WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
класс не описан

Yoast\WP\SEO\Actions\Indexables

Indexable_Head_Action{} Yoast 1.0

Get head action for indexables.

Хуков нет.

Возвращает

null. Ничего.

Использование

$Indexable_Head_Action = new Indexable_Head_Action();
// use class methods

Методы

  1. __construct( Meta_Surface $meta_surface )
  2. for_404()
  3. for_author( $id )
  4. for_post( $id )
  5. for_post_type_archive( $type )
  6. for_posts_page()
  7. for_term( $id )
  8. for_url( $url )

Код Indexable_Head_Action{} Yoast 16.5

<?php
class Indexable_Head_Action {

	/**
	 * The meta surface.
	 *
	 * @var Meta_Surface
	 */
	private $meta_surface;

	/**
	 * Indexable_Head_Action constructor.
	 *
	 * @param Meta_Surface $meta_surface The meta surface.
	 */
	public function __construct( Meta_Surface $meta_surface ) {
		$this->meta_surface = $meta_surface;
	}

	/**
	 * Retrieves the head for a url.
	 *
	 * @param string $url The url to get the head for.
	 *
	 * @return object Object with head and status properties.
	 */
	public function for_url( $url ) {
		$meta = $this->meta_surface->for_url( $url );

		if ( $meta === false ) {
			return $this->for_404();
		}

		return (object) [
			'head'   => $meta->get_head(),
			'status' => 200,
		];
	}

	/**
	 * Retrieves the head for a post.
	 *
	 * @param int $id The id.
	 *
	 * @return object Object with head and status properties.
	 */
	public function for_post( $id ) {
		$meta = $this->meta_surface->for_post( $id );

		if ( $meta === false ) {
			return $this->for_404();
		}

		return (object) [
			'head'   => $meta->get_head(),
			'status' => 200,
		];
	}

	/**
	 * Retrieves the head for a term.
	 *
	 * @param int $id The id.
	 *
	 * @return object Object with head and status properties.
	 */
	public function for_term( $id ) {
		$meta = $this->meta_surface->for_term( $id );

		if ( $meta === false ) {
			return $this->for_404();
		}

		return (object) [
			'head'   => $meta->get_head(),
			'status' => 200,
		];
	}

	/**
	 * Retrieves the head for an author.
	 *
	 * @param int $id The id.
	 *
	 * @return object Object with head and status properties.
	 */
	public function for_author( $id ) {
		$meta = $this->meta_surface->for_author( $id );

		if ( $meta === false ) {
			return $this->for_404();
		}

		return (object) [
			'head'   => $meta->get_head(),
			'status' => 200,
		];
	}

	/**
	 * Retrieves the head for a post type archive.
	 *
	 * @param int $type The id.
	 *
	 * @return object Object with head and status properties.
	 */
	public function for_post_type_archive( $type ) {
		$meta = $this->meta_surface->for_post_type_archive( $type );

		if ( $meta === false ) {
			return $this->for_404();
		}

		return (object) [
			'head'   => $meta->get_head(),
			'status' => 200,
		];
	}

	/**
	 * Retrieves the head for the posts page.
	 *
	 * @return object Object with head and status properties.
	 */
	public function for_posts_page() {
		$meta = $this->meta_surface->for_posts_page();

		if ( $meta === false ) {
			return $this->for_404();
		}

		return (object) [
			'head'   => $meta->get_head(),
			'status' => 200,
		];
	}

	/**
	 * Retrieves the head for the 404 page. Always sets the status to 404.
	 *
	 * @return object Object with head and status properties.
	 */
	public function for_404() {
		$meta = $this->meta_surface->for_404();
		return (object) [
			'head'   => $meta->get_head(),
			'status' => 404,
		];
	}
}