Yoast\WP\SEO\Repositories
Indexable_Cleanup_Repository::count_indexables_for_authors_without_archive()
Counts total amount of indexables for authors without archives.
Метод класса: Indexable_Cleanup_Repository{}
Хуков нет.
Возвращает
true|false|int|mysqli_result|resource|null
.
Использование
$Indexable_Cleanup_Repository = new Indexable_Cleanup_Repository(); $Indexable_Cleanup_Repository->count_indexables_for_authors_without_archive();
Код Indexable_Cleanup_Repository::count_indexables_for_authors_without_archive() Indexable Cleanup Repository::count indexables for authors without archive Yoast 23.5
public function count_indexables_for_authors_without_archive() { global $wpdb; $indexable_table = Model::get_table_name( 'Indexable' ); $author_archive_post_types = $this->author_archive->get_author_archive_post_types(); $viewable_post_stati = \array_filter( \get_post_stati(), 'is_post_status_viewable' ); // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: Too hard to fix. // phpcs:disable WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber -- Reason: we're passing an array instead. $count_query = $wpdb->prepare( "SELECT count(*) FROM $indexable_table WHERE object_type = 'user' AND object_id NOT IN ( SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type IN ( " . \implode( ', ', \array_fill( 0, \count( $author_archive_post_types ), '%s' ) ) . ' ) AND post_status IN ( ' . \implode( ', ', \array_fill( 0, \count( $viewable_post_stati ), '%s' ) ) . ' ) )', \array_merge( $author_archive_post_types, $viewable_post_stati ) ); // phpcs:enable // phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches. // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way. // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared -- Reason: Is it prepared already. return $wpdb->get_col( $count_query )[0]; // phpcs:enable }