Yoast\WP\SEO\Abilities\Infrastructure\Global_Setting_Targets

Homepage_Target::ensure_available │ public │ Yoast 1.0

Ensures the homepage shows the latest posts.

Unlike disabled archives, a static homepage is refused rather than reported as disabled: its settings are hidden on the settings page too, and its live SEO data belongs to the page.

Метод класса: Homepage_Target{}

Хуков нет.

Возвращает

void. Ничего (null).

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

$Homepage_Target = new Homepage_Target();
$Homepage_Target->ensure_available(): void;

Код Homepage_Target::ensure_available() Yoast 28.9

public function ensure_available(): void {
	$front_page_id = $this->current_page_helper->get_front_page_id();
	if ( $front_page_id === 0 ) {
		return;
	}

	$message = \sprintf(
		/* translators: 1: the ID of a page, 2: the name of an ability. */
		\__( 'The homepage of this site is a static page (ID %1$d), so its SEO data is set on that page with the %2$s ability instead.', 'wordpress-seo' ),
		$front_page_id,
		'yoast-seo/update-post-seo-data',
	);

	// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- This is an exception message, not output.
	throw new Unavailable_Global_Setting_Target_Exception( 'yoast_seo_static_homepage', $message );
}