Yoast\WP\SEO\Builders
Indexable_Post_Type_Archive_Builder::get_object_timestamps()
Returns the timestamps for a given post type.
Метод класса: Indexable_Post_Type_Archive_Builder{}
Хуков нет.
Возвращает
Объект
. An object with last_modified and published_at timestamps.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_object_timestamps( $post_type );
- $post_type(строка) (обязательный)
- The post type.
Код Indexable_Post_Type_Archive_Builder::get_object_timestamps() Indexable Post Type Archive Builder::get object timestamps Yoast 24.1
protected function get_object_timestamps( $post_type ) { 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'; $replacements[] = $post_type; //phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized. //phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- We need to use a direct query here. //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 = %s ", $replacements ) ); //phpcs:enable }