'', 'display' => 'posts', 'exclude-posts' => '', 'exclude-terms' => '', 'get-all-children' => 'false', 'group-numbers' => '', 'grouping' => '', 'hide-empty-terms' => 'false', 'numbers' => 'hide', 'parent-post' => '', 'parent-term' => '', 'post-type' => 'page', 'return' => 'listing', 'target' => '', 'taxonomy' => '', 'terms' => '', ), $attributes, 'a-z-listing' ); if ( ! empty( $attributes['alphabet'] ) ) { $override = $attributes['alphabet']; add_filter( 'a-z-listing-alphabet', function( $alphabet ) use ( $override ) { return $override; } ); } $grouping = $attributes['grouping']; $group_numbers = false; if ( ! empty( $attributes['group-numbers'] ) && a_z_listing_is_truthy( $attributes['group-numbers'] ) ) { $group_numbers = true; } if ( 'numbers' === $grouping ) { $group_numbers = true; $grouping = 0; } else { $grouping = intval( $grouping ); if ( 1 < $grouping && empty( $attributes['group-numbers'] ) ) { $group_numbers = true; } } $grouping_obj = new A_Z_Listing_Grouping( $grouping ); $numbers_obj = new A_Z_Listing_Numbers( $attributes['numbers'], $group_numbers ); if ( 'terms' === $attributes['display'] && ! empty( $attributes['taxonomy'] ) ) { $taxonomy = ! empty( $attributes['taxonomy'] ) ? $attributes['taxonomy'] : 'category'; if ( isset( $attributes['hide-empty'] ) && ! empty( $attributes['hide-empty'] ) ) { $hide_empty = a_z_listing_is_truthy( $attributes['hide-empty'] ); } else { $hide_empty = a_z_listing_is_truthy( $attributes['hide-empty-terms'] ); } $taxonomies = explode( ',', $taxonomy ); $taxonomies = array_unique( array_filter( array_map( 'trim', $taxonomies ) ) ); $query = array( 'taxonomy' => $taxonomies, 'hide_empty' => $hide_empty, ); $terms_string = ''; $terms_process = 'include'; if ( ! empty( $attributes['terms'] ) ) { $terms_string = $attributes['terms']; } elseif ( ! empty( $attributes['exclude-terms'] ) ) { $terms_string = $attributes['exclude-terms']; $terms_process = 'exclude'; } if ( ! empty( $terms_string ) ) { $terms = explode( ',', $terms_string ); $terms = array_unique( array_filter( array_map( 'intval', array_map( 'trim', $terms ) ), function( $value ) { return 0 < $value; } ) ); $query = wp_parse_args( $query, array( $terms_process => $terms, ) ); } if ( ! empty( $attributes['parent-term'] ) ) { $parent_id = intval( $attributes['parent-term'] ); if ( ! empty( $attributes['get-all-children'] ) && a_z_listing_is_truthy( $attributes['get-all-children'] ) ) { $parent_selector = 'child_of'; } else { $parent_selector = 'parent'; } if ( 0 < $parent_id ) { $query = wp_parse_args( $query, array( $parent_selector => $parent_id, ) ); } } $a_z_query = new A_Z_Listing( $query, 'terms' ); } else { $post_type = explode( ',', $attributes['post-type'] ); $post_type = array_unique( array_filter( array_map( 'trim', $post_type ) ) ); $query = array( 'post_type' => $post_type, ); if ( ! empty( $attributes['exclude-posts'] ) ) { $exclude_posts = explode( ',', $attributes['exclude-posts'] ); $exclude_posts = array_unique( array_filter( array_map( 'intval', array_map( 'trim', $exclude_posts ) ), function( $value ) { return 0 < $value; } ) ); if ( ! empty( $exclude_posts ) ) { $query = wp_parse_args( $query, array( 'post__not_in' => $exclude_posts ) ); } } if ( ! empty( $attributes['parent-post'] ) ) { if ( a_z_listing_is_truthy( $attributes['get-all-children'] ) ) { $child_query = array( 'child_of' => $attributes['parent-post'] ); } else { $child_query = array( 'post_parent' => $attributes['parent-post'] ); } $query = wp_parse_args( $query, $child_query ); } $taxonomy = $attributes['taxonomy'] ? $attributes['taxonomy'] : 'category'; $tax_query = array(); if ( ! empty( $attributes['terms'] ) ) { $terms = explode( ',', $attributes['terms'] ); $terms = array_unique( array_filter( array_map( 'trim', $terms ) ) ); $tax_query[] = array( 'taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $terms, 'operator' => 'IN', ); } if ( ! empty( $attributes['exclude-terms'] ) ) { $ex_terms = explode( ',', $attributes['exclude-terms'] ); $ex_terms = array_unique( array_filter( array_map( 'trim', $ex_terms ) ) ); $tax_query[] = array( 'taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $ex_terms, 'operator' => 'NOT IN', ); } if ( ! empty( $tax_query ) ) { $query['tax_query'] = $tax_query; } $a_z_query = new A_Z_Listing( $query, 'posts' ); } $target = ''; if ( ! empty( $attributes['target'] ) ) { if ( intval( $attributes['target'] ) > 0 ) { $target = get_permalink( $attributes['target'] ); } else { $target = $attributes['target']; } } if ( 'letters' === $attributes['return'] ) { $ret = '