A_Z_Listing::get_the_item_indices( WP_Post|WP_Term $item )
Find and return the index letter for a post
Advertisements
Description
Parameters
- $item
(WP_Post|WP_Term) (Required) The item whose index letters we want to find
Return
(Array) The post's index letters (usually matching the first character of the post title)
Source
File: partials/class-a-z-listing.php
protected function get_the_item_indices( $item ) { $terms = array(); $indices = array(); $index = ''; if ( $item instanceof WP_Term ) { $index = mb_substr( $item->name, 0, 1, 'UTF-8' ); $indices[ $index ][] = array( 'title' => $item->name, 'item' => $item, ); /** * @deprecated Use a_z_listing_item_indices * @see a_z_listing_item_indices */ $indices = apply_filters_deprecated( 'a_z_listing_term_indices', array( $indices, $item ), '1.0.0', 'a_z_listing_item_indices' ); } else { if ( ! empty( $this->index_taxonomy ) ) { $terms = array_filter( wp_get_object_terms( $item->ID, $this->index_taxonomy ) ); } $index = mb_substr( $item->post_title, 0, 1, 'UTF-8' ); $indices[ $index ][] = array( 'title' => $item->post_title, 'item' => $item, ); $term_indices = array_reduce( $terms, function( $indices, $term ) { $indices[ mb_substr( $term->name, 0, 1, 'UTF-8' ) ][] = array( 'title' => $term->name, 'item' => $term, ); return $indices; }); if ( is_array( $term_indices ) && ! empty( $term_indices ) ) { $indices = array_merge( $indices, $term_indices ); } /** * @deprecated Use a_z_listing_item_indices * @see a_z_listing_item_indices */ $indices = apply_filters_deprecated( 'a_z_listing_post_indices', array( $indices, $item ), '1.5.0', 'a_z_listing_item_indices' ); } // End if(). //$indices = array_reduce( $indices, array( $this, 'index_reduce' ) ); /** * Modify the indice(s) to group this post under * * @param array $indices The current indices * @param WP_Term|WP_Post $item The item * @param string $item_type The type of the item */ $indices = apply_filters( 'a_z_listing_item_indices', $indices, $item, $this->type ); if ( AZLISTINGLOG ) { do_action( 'log', 'Item indices', $indices ); } return $indices; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |
More Information
You are currently logged out. To view tickets you must first login.
Advertisements