diff --git a/src/classes/theme-helper/class-tainacan-theme-helper.php b/src/classes/theme-helper/class-tainacan-theme-helper.php index 6c3d8e5b4..aa87c46dd 100644 --- a/src/classes/theme-helper/class-tainacan-theme-helper.php +++ b/src/classes/theme-helper/class-tainacan-theme-helper.php @@ -195,6 +195,7 @@ class Theme_Helper { } else if ( $this->is_post_a_tainacan_taxonomy_postype($post) ) { $content .= tainacan_get_taxonomies_orderby(); + $content .= tainacan_get_taxonomies_search(); $taxonomy_terms_list = tainacan_get_single_taxonomy_content($post); $content .= $taxonomy_terms_list['content']; $content .= tainacan_get_taxonomies_pagination($taxonomy_terms_list['total_terms']); @@ -598,6 +599,7 @@ class Theme_Helper { function rewrite_rules_query_vars( $public_query_vars ) { $public_query_vars[] = "tainacan_repository_archive"; $public_query_vars[] = "termspaged"; + $public_query_vars[] = "termsparent"; return $public_query_vars; } @@ -2083,13 +2085,17 @@ class Theme_Helper { $current_order = get_query_var( 'order', 'ASC' ); $current_orderby = get_query_var( 'orderby', 'name' ); $current_paged = get_query_var( 'termspaged', 1 ); - $current_perpage = get_query_var( 'perpage', 12 ); + $current_perpage = get_query_var( 'perpage', 23 ); + $current_search = get_query_var( 'search', '' ); + $current_parent = get_query_var( 'termsparent', '' ); return array( 'order' => $current_order, 'orderby' => $current_orderby, 'termspaged' => $current_paged, - 'perpage' => $current_perpage + 'perpage' => $current_perpage, + 'search' => $current_search, + 'termsparent' => $current_parent ); } } diff --git a/src/classes/theme-helper/template-tags.php b/src/classes/theme-helper/template-tags.php index 660d99b95..9226bef72 100644 --- a/src/classes/theme-helper/template-tags.php +++ b/src/classes/theme-helper/template-tags.php @@ -1210,10 +1210,15 @@ function tainacan_the_metadata_sections($args = array()) { * @param object $post The original tainacan-taxonomy post object. It contains the $post->ID, which can be used to query the taxonomy of slug tnc_tax_<$post-id> * @param array|string $args { * Optional. Array or string of arguments. - * + * @type bool $hide_hierarchy_header Do not display the Term hiearachy header before the list. Default false + * @type bool $hide_term_thumbnail Do not display the Term thumbnail. Default false + * @type bool $hide_term_hierarchy_path Do not display the Term hierarchy path. Default true * @type bool $hide_term_name Do not display the Term name. Default false * @type bool $hide_term_description Do not display the Term description. Default true + * @type bool $hide_term_children_link Do not display the Term children link. Default false + * @type bool $hide_term_items_link Do not display the Term items list link. Default false + * * @type string $before_terms_list String to be added before the taxonomy terms list * Default '' * @type string $after_terms_list String to be added after the taxonomy terms list @@ -1226,6 +1231,10 @@ function tainacan_the_metadata_sections($args = array()) { * Default '
' * @type string $after_term_description String to be added after each term description * Default '
' + * @type string $before_term_children_link String to be added before each term children link + * Default '' + * @type string $after_term_children_link String to be added after each term children link + * Default '' + * @type string $before_term_items_link String to be added before each term items link + * Default '' + * @type string $after_term_items_link String to be added after each term items link + * Default '' * } * * @return string The HTML output @@ -1241,19 +1258,29 @@ function tainacan_the_metadata_sections($args = array()) { function tainacan_get_single_taxonomy_content($post, $args = []) { $args = array_merge(array( + 'hide_hierarchy_header' => false, 'hide_term_thumbnail' => false, + 'hide_term_hierarchy_path' => false, 'hide_term_name' => false, 'hide_term_description' => true, + 'hide_term_children_link' => false, + 'hide_term_items_link' => false, 'before_terms_list' => '', 'after_terms_list' => '', 'before_term' => '', 'after_term_description' => '
', + 'before_term_children_link' => '', + 'after_term_children_link' => '', + 'before_term_items_link' => '', + 'after_term_items_link' => '', ), $args); /* Gets query arguments to build fetch params */ @@ -1265,61 +1292,87 @@ function tainacan_get_single_taxonomy_content($post, $args = []) { 'orderby' => $current_args['orderby'], 'hide_empty' => false, 'offset' => ($current_args['termspaged'] - 1) * $current_args['perpage'], - 'number' => $current_args['perpage'] + 'number' => $current_args['perpage'], + 'search' => $current_args['search'], + 'parent' => $current_args['termsparent'] ); - $terms_query_args = apply_filters('tainacan_single_taxonomy_terms_query', $terms_query_args, $post); $terms = get_terms( $terms_query_args ); - unset( $terms_query_args['number'], $terms_query_args['offset'] ); + unset( $terms_query_args['number'], $terms_query_args['offset'] ); // necessary so wp_count_terms can work $total_terms = wp_count_terms( 'tnc_tax_' . $post->ID, $terms_query_args ); $content = ''; if ( !empty( $terms ) && !is_wp_error( $terms ) ) { + $separator = strip_tags(apply_filters('tainacan-terms-hierarchy-html-separator', '>')); + $content = $args['before_terms_list'] . $content; + if ( !$args['hide_hierarchy_header'] && isset($current_args['termsparent']) && $current_args['termsparent'] ) + $content .= '' . __('Showing terms children of: ', 'tainacan') . ' ' . get_term_parents_list($current_args['termsparent'], 'tnc_tax_' . $post->ID, [ 'format' => 'name', 'separator' => $separator, 'link' => true, 'inclusive' => true ]) . '
'; + + foreach ( $terms as $term ) { $tainacan_term = new Entities\Term( $term ); + $total_children = get_term_children( $tainacan_term->get_id(), 'tnc_tax_' . $post->ID ); + $total_children = is_array($total_children) && count($total_children) ? count($total_children) : 0; + ob_start(); $before_term = $args['before_term']; $before_term = str_replace('$id', $tainacan_term->get_id(), $before_term); - ?> - - - -' . __('No term was found.', 'tainacan') . '
'; + $content .= $args['after_terms_list']; } @@ -1331,10 +1384,17 @@ function tainacan_get_taxonomies_orderby() { ob_start(); ?> -