query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $noindex_seo_directive . '_seo_%' ) ); } // Belt-and-suspenders: clean up the consolidated option one more time in case // delete_option() above failed due to a corrupted cache. The wildcard LIKE // matches both noindex_seo_settings and any stray noindex_seo_config_* rows. $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", 'noindex_seo_%' ) ); // Clean up transients. $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", '_transient_noindex_seo_%' ) ); $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", '_transient_timeout_noindex_seo_%' ) ); // Clean up post meta (granular control). The 3.6.0 value directives store // their per-post values under the same prefix. $noindex_seo_meta_keys = array( '_noindex_seo_override', '_noindex_seo_noindex', '_noindex_seo_nofollow', '_noindex_seo_noarchive', '_noindex_seo_nosnippet', '_noindex_seo_noimageindex', '_noindex_seo_notranslate', '_noindex_seo_max-snippet', '_noindex_seo_max-image-preview', '_noindex_seo_max-video-preview', '_noindex_seo_unavailable_after', ); foreach ( $noindex_seo_meta_keys as $noindex_seo_meta_key ) { $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s", $noindex_seo_meta_key ) ); } // Clean up term meta (per-term granular control, added in 3.0.2). // delete_term_meta() cannot be used here because term IDs are not known at // uninstall time and there is no built-in "delete all term meta by key". // $wpdb->termmeta is set by WP when the table exists; older WP versions // (pre-4.4) did not have it, hence the property_exists() check. if ( property_exists( $wpdb, 'termmeta' ) && $wpdb->termmeta ) { foreach ( $noindex_seo_meta_keys as $noindex_seo_meta_key ) { $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->termmeta} WHERE meta_key = %s", $noindex_seo_meta_key ) ); } } // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching