Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../wp-conte.../plugins/wordpres.../src/helpers
File: attachment-cleanup-helper.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Helpers;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\Lib\Model;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* A helper object for the cleanup of attachments.
[7] Fix | Delete
*/
[8] Fix | Delete
class Attachment_Cleanup_Helper {
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Removes all indexables for attachments.
[12] Fix | Delete
*
[13] Fix | Delete
* @param bool $suppress_errors Whether to suppress db errors when running the cleanup query.
[14] Fix | Delete
*
[15] Fix | Delete
* @return void
[16] Fix | Delete
*/
[17] Fix | Delete
public function remove_attachment_indexables( $suppress_errors ) {
[18] Fix | Delete
global $wpdb;
[19] Fix | Delete
[20] Fix | Delete
if ( $suppress_errors ) {
[21] Fix | Delete
// If migrations haven't been completed successfully the following may give false errors. So suppress them.
[22] Fix | Delete
$show_errors = $wpdb->show_errors;
[23] Fix | Delete
$wpdb->show_errors = false;
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
$indexable_table = Model::get_table_name( 'Indexable' );
[27] Fix | Delete
[28] Fix | Delete
$delete_query = "DELETE FROM $indexable_table WHERE object_type = 'post' AND object_sub_type = 'attachment'";
[29] Fix | Delete
[30] Fix | Delete
// phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
[31] Fix | Delete
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
[32] Fix | Delete
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared -- Reason: Is it prepared already.
[33] Fix | Delete
$wpdb->query( $delete_query );
[34] Fix | Delete
// phpcs:enable
[35] Fix | Delete
[36] Fix | Delete
if ( $suppress_errors ) {
[37] Fix | Delete
$wpdb->show_errors = $show_errors;
[38] Fix | Delete
}
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Cleans all attachment links in the links table from target indexable ids.
[43] Fix | Delete
*
[44] Fix | Delete
* @param bool $suppress_errors Whether to suppress db errors when running the cleanup query.
[45] Fix | Delete
*
[46] Fix | Delete
* @return void
[47] Fix | Delete
*/
[48] Fix | Delete
public function clean_attachment_links_from_target_indexable_ids( $suppress_errors ) {
[49] Fix | Delete
global $wpdb;
[50] Fix | Delete
[51] Fix | Delete
if ( $suppress_errors ) {
[52] Fix | Delete
// If migrations haven't been completed successfully the following may give false errors. So suppress them.
[53] Fix | Delete
$show_errors = $wpdb->show_errors;
[54] Fix | Delete
$wpdb->show_errors = false;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
$links_table = Model::get_table_name( 'SEO_Links' );
[58] Fix | Delete
[59] Fix | Delete
$query = "UPDATE $links_table SET target_indexable_id = NULL WHERE type = 'image-in'";
[60] Fix | Delete
[61] Fix | Delete
// phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
[62] Fix | Delete
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
[63] Fix | Delete
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared -- Reason: Is it prepared already.
[64] Fix | Delete
$wpdb->query( $query );
[65] Fix | Delete
// phpcs:enable
[66] Fix | Delete
[67] Fix | Delete
if ( $suppress_errors ) {
[68] Fix | Delete
$wpdb->show_errors = $show_errors;
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function