WPSEO_Upgrade::remove_indexable_rows_for_disabled_authors_archive()privateYoast 1.0

Removes all user indexable rows when the author archive is disabled.

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

Хуков нет.

Возвращает

null. Ничего.

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

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

Код WPSEO_Upgrade::remove_indexable_rows_for_disabled_authors_archive() Yoast 20.0

private function remove_indexable_rows_for_disabled_authors_archive() {
	global $wpdb;

	if ( ! \YoastSEO()->helpers->author_archive->are_disabled() ) {
		return;
	}

	// If migrations haven't been completed successfully the following may give false errors. So suppress them.
	$show_errors       = $wpdb->show_errors;
	$wpdb->show_errors = false;

	$indexable_table = Model::get_table_name( 'Indexable' );

	$delete_query = "DELETE FROM $indexable_table WHERE object_type = 'user'";
	// 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.
	$wpdb->query( $delete_query );
	// phpcs:enable

	$wpdb->show_errors = $show_errors;
}