v1.1.0
This commit is contained in:
parent
5cdf7f48e5
commit
2c300652a6
9 changed files with 230 additions and 82 deletions
|
|
@ -80,26 +80,36 @@ class Robotstxt_Mlp2_Mlp5_Step_Cleanup {
|
|||
/**
|
||||
* Delete MLP2-related entries from wp_sitemeta.
|
||||
*
|
||||
* Removes all sitemeta keys whose name starts with 'mlp_' (MLP2 prefix).
|
||||
* Removes sitemeta keys matching 'mlp_*' (MLP2 prefix) and
|
||||
* 'mlp2bak_inpsyde_multilingual*' (backed-up MLP2 sitemeta).
|
||||
*
|
||||
* @return int Number of keys deleted.
|
||||
*/
|
||||
public static function remove_mlp2_sitemeta(): int {
|
||||
global $wpdb;
|
||||
|
||||
$like = $wpdb->esc_like( 'mlp_' ) . '%';
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$keys = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"SELECT meta_key FROM {$wpdb->sitemeta} WHERE meta_key LIKE %s AND site_id = %d",
|
||||
$like,
|
||||
get_current_network_id()
|
||||
)
|
||||
$patterns = array(
|
||||
$wpdb->esc_like( 'mlp_' ) . '%',
|
||||
$wpdb->esc_like( Robotstxt_Mlp2_Mlp5_Table_Preparer::SITEMETA_BACKUP_PREFIX ) . '%',
|
||||
);
|
||||
|
||||
$keys = array();
|
||||
foreach ( $patterns as $like ) {
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$found = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"SELECT meta_key FROM {$wpdb->sitemeta} WHERE meta_key LIKE %s AND site_id = %d",
|
||||
$like,
|
||||
get_current_network_id()
|
||||
)
|
||||
);
|
||||
if ( is_array( $found ) ) {
|
||||
$keys = array_merge( $keys, $found );
|
||||
}
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
foreach ( (array) $keys as $key ) {
|
||||
foreach ( array_unique( $keys ) as $key ) {
|
||||
if ( delete_site_option( $key ) ) {
|
||||
++$deleted;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue