Yoast\WP\SEO\Helpers
Attachment_Cleanup_Helper::clean_attachment_links_from_target_indexable_ids()
Cleans all attachment links in the links table from target indexable ids.
Метод класса: Attachment_Cleanup_Helper{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$Attachment_Cleanup_Helper = new Attachment_Cleanup_Helper(); $Attachment_Cleanup_Helper->clean_attachment_links_from_target_indexable_ids( $suppress_errors );
- $suppress_errors(true|false) (обязательный)
- Whether to suppress db errors when running the cleanup query.
Код Attachment_Cleanup_Helper::clean_attachment_links_from_target_indexable_ids() Attachment Cleanup Helper::clean attachment links from target indexable ids Yoast 24.4
public function clean_attachment_links_from_target_indexable_ids( $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; } $links_table = Model::get_table_name( 'SEO_Links' ); $query = "UPDATE $links_table SET target_indexable_id = NULL WHERE type = 'image-in'"; // 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( $query ); // phpcs:enable if ( $suppress_errors ) { $wpdb->show_errors = $show_errors; } }