31 lines
1,006 B
PHP
31 lines
1,006 B
PHP
<?php
|
|
/**
|
|
* Fired when the plugin is uninstalled.
|
|
*
|
|
* Drops all plugin data only if the user has explicitly opted in via Settings.
|
|
* By default, data is preserved.
|
|
*
|
|
* @package MediaRightsAudit
|
|
*/
|
|
|
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|
exit;
|
|
}
|
|
|
|
$raw = get_option( 'robotstxt_mediaaudit_settings', array() );
|
|
$settings = is_array( $raw ) ? $raw : array();
|
|
$delete = ! empty( $settings['delete_on_uninstall'] );
|
|
|
|
if ( ! $delete ) {
|
|
return;
|
|
}
|
|
|
|
global $wpdb;
|
|
|
|
// Drop tables in reverse dependency order.
|
|
$wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}mra_external_results`" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
|
|
$wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}mra_media_usage`" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
|
|
$wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}mra_media_index`" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
|
|
|
|
delete_option( 'robotstxt_mediaaudit_db_version' );
|
|
delete_option( 'robotstxt_mediaaudit_settings' );
|