Dropbox2
3 weeks ago
Google
3 weeks ago
blockui
3 weeks ago
checkout-embed
3 weeks ago
cloudfiles
3 weeks ago
handlebars
1 month ago
images
9 years ago
jquery-ui.dialog.extended
3 weeks ago
jquery.serializeJSON
5 years ago
jstree
1 year ago
labelauty
3 weeks ago
pcloud
3 weeks ago
select2
1 year ago
tether
6 years ago
tether-shepherd
7 years ago
updraftclone
3 weeks ago
S3.php
3 weeks ago
S3compat.php
3 weeks ago
cacert.pem
2 years ago
class-backup-history.php
1 month ago
class-commands.php
3 weeks ago
class-database-utility.php
1 month ago
class-filesystem-functions.php
1 month ago
class-http-error-descriptions.php
2 years ago
class-job-scheduler.php
3 years ago
class-manipulation-functions.php
1 month ago
class-partialfileservlet.php
3 weeks ago
class-remote-send.php
3 weeks ago
class-search-replace.php
1 month ago
class-semaphore.php
3 weeks ago
class-storage-methods-interface.php
1 month ago
class-updraft-dashboard-news.php
1 month ago
class-updraft-semaphore.php
4 years ago
class-updraftcentral-updraftplus-commands.php
3 years ago
class-updraftplus-deactivation.php
1 month ago
class-updraftplus-encryption.php
1 month ago
class-wpadmin-commands.php
1 month ago
class-zip.php
1 month ago
ftp.class.php
2 months ago
get-cpanel-quota-usage.pl
12 years ago
google-extensions.php
1 month ago
jquery-ui.custom-v1.11.4-1-26-4.min.css
3 weeks ago
jquery-ui.custom-v1.11.4-1-26-4.min.css.map
3 weeks ago
jquery-ui.custom-v1.11.4.css
3 years ago
jquery-ui.custom-v1.12.1-1-26-4.min.css
3 weeks ago
jquery-ui.custom-v1.12.1-1-26-4.min.css.map
3 weeks ago
jquery-ui.custom-v1.12.1.css
3 years ago
migrator-lite.php
1 month ago
updraft-admin-common-1-26-4.min.js
3 weeks ago
updraft-admin-common.js
3 weeks ago
updraft-restorer-skin-compatibility.php
6 years ago
updraft-restorer-skin.php
3 years ago
updraftcentral.php
1 year ago
updraftplus-clone.php
1 year ago
updraftplus-login.php
7 months ago
updraftplus-notices.php
1 month ago
updraftplus-tour.php
1 month ago
updraftvault.php
3 years ago
class-updraftplus-deactivation.php
119 lines
| 1 | <?php |
| 2 | if (!defined('UPDRAFTPLUS_DIR')) die('No direct access allowed'); |
| 3 | |
| 4 | /** |
| 5 | * Handles the UpdraftPlus deactivation popup modal. |
| 6 | */ |
| 7 | class UpdraftPlus_Deactivation { |
| 8 | |
| 9 | private static $instance = null; |
| 10 | |
| 11 | /** |
| 12 | * Get singleton instance |
| 13 | */ |
| 14 | public static function get_instance() { |
| 15 | if (null === self::$instance) { |
| 16 | self::$instance = new self(); |
| 17 | } |
| 18 | return self::$instance; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Constructor. |
| 23 | */ |
| 24 | private function __construct() { |
| 25 | add_action('init', array($this, 'init_deinstall_dialog')); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Initialize the deactivation popup on admin plugins page or for AJAX requests |
| 30 | * Sets up the hooks required for initializing the deactivation dialog |
| 31 | */ |
| 32 | public function init_deinstall_dialog() { |
| 33 | global $pagenow; |
| 34 | if ((defined('WP_AJAX') && WP_AJAX) || 'admin-ajax.php' == $pagenow) { |
| 35 | add_action('updraftplus_deinstall', array($this, 'handle_user_choice')); |
| 36 | $this->instantiate_deinstall_dialog_object(); |
| 37 | } elseif ('plugins.php' == $pagenow) { |
| 38 | add_action('admin_init', array($this, 'instantiate_deinstall_dialog_object')); |
| 39 | add_action('updraftplus_admin_enqueue_scripts', array($this, 'enqueue_dialog_scripts')); |
| 40 | if (!class_exists('UpdraftPlus_Addon_Autobackup')) { |
| 41 | add_action('admin_footer', array($this, 'enqueue_admin_common_scripts')); |
| 42 | add_action('admin_print_footer_scripts', array($this, 'add_footer_inline_script')); |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Print additional javascript in the footer part of the page |
| 49 | */ |
| 50 | public function add_footer_inline_script() { |
| 51 | if (!UpdraftPlus_Options::user_can_manage()) { |
| 52 | return; |
| 53 | } |
| 54 | echo "<script type='text/javascript'>\n"; |
| 55 | // in free version on plugins.php page, since the deinstall dialog requires admin-common-js, the updraft_credentialtest_nonce variable should be declared because it's going to be used by the updraft_send_command for background operations, if not declared it will produce JS error in the browser's console; auto-backup does this too. |
| 56 | echo "var updraft_credentialtest_nonce = updraft_credentialtest_nonce || '".esc_js(wp_create_nonce('updraftplus-credentialtest-nonce'))."';"; |
| 57 | echo "\n</script>"; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Enqueue our admin common scripts/styles |
| 62 | */ |
| 63 | public function enqueue_admin_common_scripts() { |
| 64 | global $updraftplus_admin; |
| 65 | $updraftplus_admin->admin_enqueue_scripts(); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Enqueue deactivation dialog scripts |
| 70 | */ |
| 71 | public function enqueue_dialog_scripts() { |
| 72 | global $updraftplus; |
| 73 | $enqueue_version = $updraftplus->use_unminified_scripts() ? $updraftplus->version.'.'.time() : $updraftplus->version; |
| 74 | $updraft_min_or_not = $updraftplus->get_updraftplus_file_version(); |
| 75 | wp_enqueue_style('updraft-deactivation-popup', UPDRAFTPLUS_URL.'/css/updraftplus-deactivation'.$updraft_min_or_not.'.css', array('updraft-jquery-ui'), $enqueue_version); |
| 76 | wp_enqueue_script('udp-deactivation-js', UPDRAFTPLUS_URL.'/js/updraftplus-deactivation'.$updraft_min_or_not.'.js', array('jquery'), $enqueue_version); |
| 77 | wp_localize_script('udp-deactivation-js', 'upraftplusdialog', array( |
| 78 | 'deactivate' => esc_html__('Deactivate', 'updraftplus'), |
| 79 | 'remove' => esc_html__('Remove and deactivate', 'updraftplus'), |
| 80 | )); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Instantiate a deactivation dialog object with preconfigured settings |
| 85 | */ |
| 86 | public function instantiate_deinstall_dialog_object() { |
| 87 | |
| 88 | if (!class_exists('Updraft_Deinstall_Dialog_v1')) { |
| 89 | updraft_try_include_file( |
| 90 | 'vendor/team-updraft/common-libs/src/updraft-plugin-deinstall-dialog/class-updraft-deinstall-dialog.php', |
| 91 | 'include_once' |
| 92 | ); |
| 93 | } |
| 94 | |
| 95 | if (class_exists('Updraft_Deinstall_Dialog_v1')) { |
| 96 | new Updraft_Deinstall_Dialog_v1(array( |
| 97 | 'script_handler' => 'updraftplus', |
| 98 | 'plugin_slug' => UPDRAFTPLUS_PLUGIN_SLUG, |
| 99 | 'dialog_title' => esc_html__('Before you deactivate...', 'updraftplus'), |
| 100 | 'deactivate_label' => esc_html__('Deactivate', 'updraftplus'), |
| 101 | 'cancel_label' => esc_html__('Cancel', 'updraftplus'), |
| 102 | 'template_file' => UPDRAFTPLUS_DIR . '/templates/deactivation-popup-modal.php', |
| 103 | 'show_on_network_admin' => true, |
| 104 | 'show_on_subsites' => false, |
| 105 | )); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Handle the AJAX request to save the user’s deactivation choice. |
| 111 | * The capability check is handled by the dialog library. |
| 112 | */ |
| 113 | public function handle_user_choice() { |
| 114 | |
| 115 | $choice = UpdraftPlus_Manipulation_Functions::fetch_superglobal('post', 'updraft_deinstall_option', 'no', true, null, 'sanitize_text_field'); |
| 116 | UpdraftPlus_Options::update_updraft_option('updraftplus_deinstall_option', $choice); |
| 117 | } |
| 118 | } |
| 119 |