This commit is contained in:
Javier Casares 2026-08-10 14:03:36 +00:00
commit 3bb9ed33e1
12 changed files with 1762 additions and 409 deletions

View file

@ -24,40 +24,56 @@ function robotstxt_og_uninstall_cleanup(): void {
return;
}
// Delete all plugin options.
delete_option( 'robotstxt_og_fallback_image' );
delete_option( 'robotstxt_og_homepage_image' );
delete_option( 'robotstxt_og_enable_facebook' );
delete_option( 'robotstxt_og_enable_twitter' );
delete_option( 'robotstxt_og_twitter_card_type' );
delete_option( 'robotstxt_og_twitter_site' );
delete_option( 'robotstxt_og_delete_data_on_uninstall' );
// All plugin options (general, social, platform integration, mobile/web-app).
$options = array(
'robotstxt_og_fallback_image',
'robotstxt_og_homepage_image',
'robotstxt_og_enable_facebook',
'robotstxt_og_enable_twitter',
'robotstxt_og_twitter_card_type',
'robotstxt_og_twitter_site',
'robotstxt_og_fb_app_id',
'robotstxt_og_fb_admins',
'robotstxt_og_fb_pages',
'robotstxt_og_pinterest_verify',
'robotstxt_og_pinterest_nopin',
'robotstxt_og_telegram_channel',
'robotstxt_og_slack_app_id',
'robotstxt_og_theme_color',
'robotstxt_og_app_name',
'robotstxt_og_web_app_capable',
'robotstxt_og_app_status_bar_style',
'robotstxt_og_format_detection',
'robotstxt_og_delete_data_on_uninstall',
);
foreach ( $options as $option_name ) {
delete_option( $option_name );
}
// Delete all cached postmeta (fallback URLs and per-post OG overrides).
global $wpdb;
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
// Bulk delete during uninstall — no WP API exists to delete all postmeta rows by key at once.
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s",
'_og_image_fallback_url'
)
);
foreach ( array( '_og_image_fallback_url', '_og_title', '_og_description', '_og_image_alt', '_og_type', '_twitter_creator' ) as $post_meta_key ) {
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s",
$post_meta_key
)
);
}
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s",
'_og_title'
)
);
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s",
'_og_description'
)
);
// Delete all term-level OG meta (per-term overrides + cached taxonomy fallback).
foreach ( array( '_og_title', '_og_image', '_og_description', '_og_image_alt', '_og_image_fallback_url' ) as $term_meta_key ) {
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->termmeta} WHERE meta_key = %s",
$term_meta_key
)
);
}
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
// Clear related transients.
@ -75,37 +91,31 @@ function robotstxt_og_uninstall_cleanup(): void {
switch_to_blog( (int) $site->blog_id );
// Delete site-specific options.
delete_option( 'robotstxt_og_fallback_image' );
delete_option( 'robotstxt_og_homepage_image' );
delete_option( 'robotstxt_og_enable_facebook' );
delete_option( 'robotstxt_og_enable_twitter' );
delete_option( 'robotstxt_og_twitter_card_type' );
delete_option( 'robotstxt_og_twitter_site' );
delete_option( 'robotstxt_og_delete_data_on_uninstall' );
foreach ( $options as $option_name ) {
delete_option( $option_name );
}
// Delete site-specific postmeta.
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
// Bulk delete during uninstall — no WP API exists to delete all postmeta rows by key at once.
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s",
'_og_image_fallback_url'
)
);
foreach ( array( '_og_image_fallback_url', '_og_title', '_og_description', '_og_image_alt', '_og_type', '_twitter_creator' ) as $post_meta_key ) {
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s",
$post_meta_key
)
);
}
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s",
'_og_title'
)
);
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s",
'_og_description'
)
);
// Delete all term-level OG meta (per-term overrides + cached taxonomy fallback).
foreach ( array( '_og_title', '_og_image', '_og_description', '_og_image_alt', '_og_image_fallback_url' ) as $term_meta_key ) {
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->termmeta} WHERE meta_key = %s",
$term_meta_key
)
);
}
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
// Clear site-specific transients.