Yoast\WP\SEO\Builders
Indexable_Author_Builder::get_object_timestamps()
Returns the timestamps for a given author.
Метод класса: Indexable_Author_Builder{}
Хуков нет.
Возвращает
Объект
. An object with last_modified and published_at timestamps.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_object_timestamps( $author_id );
- $author_id(int) (обязательный)
- The author ID.
Код Indexable_Author_Builder::get_object_timestamps() Indexable Author Builder::get object timestamps Yoast 24.4
protected function get_object_timestamps( $author_id ) { 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_author'; $replacements[] = $author_id; //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 = %d ", $replacements ) ); //phpcs:enable }