$attributes Provided by WordPress core. Contains the shortcode attributes. * @return string The A-Z Listing HTML. * @suppress PhanPluginPossiblyStaticPublicMethod */ public function handle( $attributes = array() ): string { /** * Run extensions. */ do_action( 'a_z_listing_shortcode_start', $attributes ); $defaults = apply_filters( 'a_z_listing_get_shortcode_attributes', array( 'display' => 'posts', 'get-all-children' => 'false', 'group-numbers' => '', 'grouping' => '', 'numbers' => 'hide', 'return' => 'listing', 'target' => '', ) ); $attributes = shortcode_atts( $defaults, $attributes, 'a-z-listing' ); foreach ( $attributes as $attribute => &$value ) { $value = apply_filters( "a_z_listing_sanitize_shortcode_attribute__$attribute", $value, $attributes ); } $attributes = apply_filters( 'a_z_listing_sanitize_shortcode_attributes', $attributes ); $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 Grouping( $grouping ); $numbers_obj = new Numbers( $attributes['numbers'], $group_numbers ); $a_z_query = new Query( null, '', true, $attributes ); $target = ''; if ( ! empty( $attributes['target'] ) ) { if ( intval( $attributes['target'] ) > 0 ) { $target = get_permalink( $attributes['target'] ); } else { $target = $attributes['target']; } } if ( 'letters' === $attributes['return'] ) { $ret = '
' . $a_z_query->get_the_letters( $target ) . '
'; } else { $ret = $a_z_query->get_the_listing(); } $grouping_obj->teardown(); $numbers_obj->teardown(); do_action( 'a_z_listing_shortcode_end', $attributes ); return $ret; } }