Yoast\WP\SEO\Builders

Indexable_Home_Page_Builder::get_object_timestamps()protectedYoast 1.0

Returns the timestamps for the homepage.

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

Хуков нет.

Возвращает

Объект. An object with last_modified and published_at timestamps.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_object_timestamps();

Код Indexable_Home_Page_Builder::get_object_timestamps() Yoast 22.3

protected function get_object_timestamps() {
	global $wpdb;
	$post_statuses = $this->post_helper->get_public_post_statuses();

	$replacements   = [];
	$replacements[] = 'post_modified_gmt';
	$replacements[] = 'post_date_gmt';
	$replacements[] = $wpdb->posts;
	$replacements[] = 'post_status';
	$replacements   = \array_merge( $replacements, $post_statuses );
	$replacements[] = 'post_password';
	$replacements[] = 'post_type';

	//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
	//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
	//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
	return $wpdb->get_row(
		$wpdb->prepare(
			'
		SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
		FROM %i AS p
		WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
			AND p.%i = ''
			AND p.%i = 'post'
		",
			$replacements
		)
	);
	//phpcs:enable
}