57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Uninstall script for iDrivee2 Media Upload.
|
|
*
|
|
* Runs when the plugin is uninstalled. By default, all plugin data is
|
|
* preserved unless the administrator explicitly opted in to removal via
|
|
* the "Delete all plugin data on uninstall" setting (data preservation
|
|
* policy per AGENTS-database-roles-performance-i18n.md).
|
|
*
|
|
* @package iDrivee2Media
|
|
* @since 0.3.0
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Prevent direct access to this file.
|
|
*/
|
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Clean up plugin data.
|
|
*
|
|
* By default all plugin data (post meta, options, statistics) is preserved.
|
|
* Data is only removed when the administrator has explicitly checked the
|
|
* "Delete all plugin data on uninstall" option on the settings page.
|
|
*
|
|
* Cron events are always cleared to prevent orphaned scheduled tasks.
|
|
*/
|
|
|
|
$idrivee2_settings = get_option( 'idrivee2_media_settings', array() );
|
|
$idrivee2_delete_data = is_array( $idrivee2_settings ) && isset( $idrivee2_settings['delete_on_uninstall'] ) && '1' === $idrivee2_settings['delete_on_uninstall'];
|
|
|
|
if ( $idrivee2_delete_data ) {
|
|
// Delete all plugin post meta via the WordPress API.
|
|
delete_post_meta_by_key( '_idrivee2_last_upload' );
|
|
delete_post_meta_by_key( '_idrivee2_s3_base_url' );
|
|
|
|
// Delete plugin options.
|
|
delete_option( 'idrivee2_deletion_queue' );
|
|
delete_option( 'idrivee2_media_settings' );
|
|
delete_option( 'idrivee2_s3_operations' );
|
|
}
|
|
|
|
// Always clear cron events to prevent orphaned scheduled tasks.
|
|
wp_clear_scheduled_hook( 'idrivee2_cleanup_local_files' );
|
|
|
|
/**
|
|
* Note: Files uploaded to S3 are NOT deleted by this uninstall script.
|
|
* If you want to delete files from S3, you must do so manually using
|
|
* your S3 management console or AWS CLI.
|
|
*
|
|
* Local files in wp-content/uploads/ are also NOT deleted, as they are
|
|
* part of WordPress's standard media library structure.
|
|
*/
|