$attributes Provided by WordPress core. Contains the shortcode attributes. * @return string The AlphaListing HTML. * @suppress PhanPluginPossiblyStaticPublicMethod */ public function handle( $attributes = array() ): string { /** * Run extensions. */ do_action( 'alphalisting_shortcode_start', $attributes ); // Every attribute is contributed by a Query Part -- see alphalisting_init(). $defaults = apply_filters( 'alphalisting_get_shortcode_attributes', array() ); $attributes = shortcode_atts( $defaults, $attributes, 'alphalisting' ); foreach ( $attributes as $attribute => &$value ) { $value = apply_filters( "alphalisting_sanitize_shortcode_attribute__$attribute", $value, $attributes ); } $attributes = apply_filters( 'alphalisting_sanitize_shortcode_attributes', $attributes ); // The `??` fallbacks here and below mirror the Query Part defaults, and only // apply if a part failed to register and shortcode_atts() dropped the key. $grouping = $attributes['grouping'] ?? ''; $group_numbers = false; if ( ! empty( $attributes['group-numbers'] ) && alphalisting_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'] ?? 'hide', $group_numbers ); $a_z_query = new Query( null, '', true, $attributes ); $target = ''; if ( ! empty( $attributes['target'] ) ) { if ( intval( $attributes['target'] ) > 0 ) { // get_permalink() returns false for a post ID that no longer exists; // $target feeds get_the_letters( string $target ), which would fatal. $permalink = get_permalink( $attributes['target'] ); $target = is_string( $permalink ) ? $permalink : ''; } else { $target = $attributes['target']; } } if ( 'letters' === ( $attributes['return'] ?? 'listing' ) ) { $ret = '