A_Z_Listing::__construct( null|WP_Query|array|string $query = null )

A_Z_Listing constructor.


Description


Parameters

$query

(null|WP_Query|array|string) (Optional)

Default value: null


Source

File: partials/class-a-z-listing.php

	public function __construct( $query = null ) {
		global $post;
		self::get_alphabet();
		$this->available_indices = array_values( array_unique( array_values( self::$alphabet ) ) );

		if ( is_string( $query ) && ! empty( $query ) ) {
			if ( AZLISTINGLOG ) {
				do_action( 'log', 'A-Z Listing: Setting taxonomy mode', $query );
			}
			$this->type = 'taxonomy';
			$this->taxonomy = $query;
			$this->items = get_terms( $query, array(
				'hide_empty' => false,
			) );
			if ( AZLISTINGLOG ) {
				do_action( 'log', 'A-Z Listing: Terms', '!slug', $this->items );
			}
		} else {
			if ( AZLISTINGLOG ) {
				do_action( 'log', 'A-Z Listing: Setting posts mode', $query );
			}
			/**
			 * @deprecated Use a_z_listing_additional_titles_taxonomy
			 * @see a_z_listing_additional_titles_taxonomy
			 */
			$index_taxonomy = apply_filters_deprecated( 'az_additional_titles_taxonomy', array( '' ), '1.0.0', 'a_z_listing_additional_titles_taxonomy' );
			/**
			 * Taxonomy containing terms which are used as the title for associated posts
			 *
			 * @param string $taxonomy The taxonomy mapping alternative titles to posts
			 */
			$this->index_taxonomy = apply_filters( 'a_z_listing_additional_titles_taxonomy', $index_taxonomy );

			$this->query = (array) $query;

			$section = self::get_section();

			if ( ( isset( $this->query->post_type ) && 'page' !== $this->query->post_type )
				|| ( isset( $post ) && 'page' !== $post->post_type ) ) {
				$section = null;
			}

			if ( $section ) {
				$this->query->child_of = $section->ID;
			}

			if ( isset( $this->query->child_of ) ) {
				$this->items = get_pages( $this->query );
			} else {
				$this->construct_query();
				$this->items = $this->query->get_posts();
			}
		} // End if().
		$this->matched_item_indices = $this->get_all_indices();
	}

Changelog

Changelog
Version Description
0.1 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.