v1.0.0
This commit is contained in:
commit
a157afe625
21 changed files with 4623 additions and 0 deletions
50
uninstall.php
Normal file
50
uninstall.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* Uninstall handler for the AI Translator plugin.
|
||||
*
|
||||
* Plugin data is preserved by default. To delete every option and sitemeta entry,
|
||||
* either set the constant AI_TRANSLATOR_DELETE_DATA_ON_UNINSTALL to true in wp-config.php,
|
||||
* or define the site option 'ai_translator_delete_data_on_uninstall' as a truthy value.
|
||||
*
|
||||
* @package ROBOTSTXT\AI_Translator
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$ai_translator_should_delete = false;
|
||||
|
||||
if ( defined( 'AI_TRANSLATOR_DELETE_DATA_ON_UNINSTALL' ) && AI_TRANSLATOR_DELETE_DATA_ON_UNINSTALL ) {
|
||||
$ai_translator_should_delete = true;
|
||||
}
|
||||
|
||||
if ( ! $ai_translator_should_delete && function_exists( 'get_site_option' ) ) {
|
||||
$ai_translator_should_delete = (bool) get_site_option( 'ai_translator_delete_data_on_uninstall', false );
|
||||
}
|
||||
|
||||
if ( ! $ai_translator_should_delete ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$ai_translator_sites = get_sites(
|
||||
array(
|
||||
'fields' => 'ids',
|
||||
'number' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $ai_translator_sites as $ai_translator_site_id ) {
|
||||
switch_to_blog( (int) $ai_translator_site_id );
|
||||
delete_option( 'ai_translator_settings' );
|
||||
restore_current_blog();
|
||||
}
|
||||
|
||||
delete_site_option( 'ai_translator_settings' );
|
||||
delete_site_option( 'ai_translator_network_mode' );
|
||||
delete_site_option( 'ai_translator_delete_data_on_uninstall' );
|
||||
} else {
|
||||
delete_option( 'ai_translator_settings' );
|
||||
}
|
||||
Loading…
Reference in a new issue