| 1 |
<?php |
| 2 |
/** |
| 3 |
* Uninstall script for GutSliderBlocks. |
| 4 |
* |
| 5 |
* Generated stylesheets are always removed. Stored options are only |
| 6 |
* removed when "Delete data on uninstall" is enabled in the settings. |
| 7 |
* |
| 8 |
* @package GutSliderBlocks |
| 9 |
*/ |
| 10 |
|
| 11 |
// If uninstall not called from WordPress, then exit. |
| 12 |
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
$gutslider_settings = get_option( 'gutslider_settings', array() ); |
| 17 |
$gutslider_remove_data = is_array( $gutslider_settings ) && ! empty( $gutslider_settings['remove_data'] ); |
| 18 |
|
| 19 |
// Load the main plugin file to access the cleanup method. |
| 20 |
require_once plugin_dir_path( __FILE__ ) . 'slider-blocks.php'; |
| 21 |
|
| 22 |
// Remove generated stylesheets. |
| 23 |
GutSlider\Plugin::cleanup(); |
| 24 |
|
| 25 |
if ( ! $gutslider_remove_data ) { |
| 26 |
return; |
| 27 |
} |
| 28 |
|
| 29 |
// Remove the plugin's own options. |
| 30 |
$gutslider_options = array( |
| 31 |
'gutslider_settings', |
| 32 |
'gutslider_blocks', |
| 33 |
'gutslider_blocks_version', |
| 34 |
'gutsliderblocks_do_activation_redirect', |
| 35 |
); |
| 36 |
|
| 37 |
$gutslider_blocks_file = plugin_dir_path( __FILE__ ) . 'includes/Api/blocks.php'; |
| 38 |
|
| 39 |
if ( file_exists( $gutslider_blocks_file ) ) { |
| 40 |
$gutslider_block_list = include $gutslider_blocks_file; |
| 41 |
|
| 42 |
if ( is_array( $gutslider_block_list ) ) { |
| 43 |
foreach ( $gutslider_block_list as $gutslider_block ) { |
| 44 |
if ( isset( $gutslider_block['name'] ) ) { |
| 45 |
$gutslider_options[] = 'gut_' . str_replace( '-', '_', $gutslider_block['name'] ); |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
foreach ( array_unique( $gutslider_options ) as $gutslider_option ) { |
| 52 |
delete_option( $gutslider_option ); |
| 53 |
} |
| 54 |
|