Yoast\WP\SEO\Helpers
Attachment_Cleanup_Helper::remove_attachment_indexables
Removes all indexables for attachments.
Метод класса: Attachment_Cleanup_Helper{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$Attachment_Cleanup_Helper = new Attachment_Cleanup_Helper(); $Attachment_Cleanup_Helper->remove_attachment_indexables( $suppress_errors );
- $suppress_errors(true|false) (обязательный)
- Whether to suppress db errors when running the cleanup query.
Код Attachment_Cleanup_Helper::remove_attachment_indexables() Attachment Cleanup Helper::remove attachment indexables Yoast 28.9
public function remove_attachment_indexables( $suppress_errors ) {
global $wpdb;
if ( $suppress_errors ) {
// 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 = 'post' AND object_sub_type = 'attachment'";
// 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
if ( $suppress_errors ) {
$wpdb->show_errors = $show_errors;
}
}