Yoast\WP\SEO\Editors\Application\Seo

Term_Seo_Information_Repository{}Yoast 1.0

The repository to get term related SEO data.

Хуков нет.

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

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

Методы

  1. public __construct( Abstract_Term_Seo_Data_Provider ...$seo_data_providers )
  2. public get_seo_data()
  3. public set_term( WP_Term $term )

Код Term_Seo_Information_Repository{} Yoast 25.1

class Term_Seo_Information_Repository {

	/**
	 * The term.
	 *
	 * @var WP_Term
	 */
	private $term;

	/**
	 * The data providers.
	 *
	 * @var Abstract_Term_Seo_Data_Provider
	 */
	private $seo_data_providers;

	/**
	 * The constructor.
	 *
	 * @param Abstract_Term_Seo_Data_Provider ...$seo_data_providers The providers.
	 */
	public function __construct( Abstract_Term_Seo_Data_Provider ...$seo_data_providers ) {
		$this->seo_data_providers = $seo_data_providers;
	}

	/**
	 * The term.
	 *
	 * @param WP_Term $term The term.
	 *
	 * @return void
	 */
	public function set_term( WP_Term $term ): void {
		$this->term = $term;
	}

	/**
	 * Method to return the compiled SEO data.
	 *
	 * @return array<string> The specific seo data.
	 */
	public function get_seo_data(): array {
		$array = [];
		foreach ( $this->seo_data_providers as $data_provider ) {
			$data_provider->set_term( $this->term );
			$array = \array_merge( $array, $data_provider->get_data()->to_legacy_array() );
		}

		return $array;
	}
}