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
updraftplus-tour.php
303 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) die('No direct access allowed'); |
| 3 | /** |
| 4 | * Class UpdraftPlus_Tour |
| 5 | * |
| 6 | * Adds the guided tour when activating the plugin for the first time. |
| 7 | */ |
| 8 | class UpdraftPlus_Tour { |
| 9 | |
| 10 | /** |
| 11 | * The class instance |
| 12 | * |
| 13 | * @var object |
| 14 | */ |
| 15 | protected static $instance; |
| 16 | |
| 17 | /** |
| 18 | * Get the instance |
| 19 | * |
| 20 | * @return object |
| 21 | */ |
| 22 | public static function get_instance() { |
| 23 | if (!self::$instance) { |
| 24 | self::$instance = new self(); |
| 25 | } |
| 26 | return self::$instance; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * __construct |
| 31 | */ |
| 32 | private function __construct() { |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Sets up the notices, security and loads assets for the admin page |
| 37 | */ |
| 38 | public function init() { |
| 39 | // Add plugin action link |
| 40 | add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2); |
| 41 | |
| 42 | // only init and load assets if the tour hasn't been canceled |
| 43 | $updraftplus_tour = UpdraftPlus_Manipulation_Functions::fetch_superglobal('request', 'updraftplus_tour'); |
| 44 | if (isset($updraftplus_tour) && 0 === (int) $updraftplus_tour) { |
| 45 | $this->set_tour_status(array('current_step' => 'start')); |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | // if backups already exist and |
| 50 | if ($this->updraftplus_was_already_installed() && !isset($updraftplus_tour)) { |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | // if 'Take tour' link was used, reset tour |
| 55 | if (isset($updraftplus_tour) && 1 === (int) $updraftplus_tour) { |
| 56 | $this->reset_tour_status(); |
| 57 | } |
| 58 | |
| 59 | if (!UpdraftPlus_Options::get_updraft_option('updraftplus_tour_cancelled_on')) { |
| 60 | add_action('admin_enqueue_scripts', array($this, 'load_tour')); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Loads in tour assets |
| 66 | * |
| 67 | * @param string $hook - current page |
| 68 | */ |
| 69 | public function load_tour($hook) { |
| 70 | |
| 71 | $pages = array('settings_page_updraftplus', 'plugins.php'); |
| 72 | |
| 73 | if (!in_array($hook, $pages)) return; |
| 74 | if (!UpdraftPlus_Options::user_can_manage()) return; |
| 75 | |
| 76 | global $updraftplus, $updraftplus_addons2, $updraftplus_checkout_embed; |
| 77 | |
| 78 | $checkout_embed_5gb_attribute = ''; |
| 79 | if ($updraftplus_checkout_embed) { |
| 80 | $checkout_embed_5gb_attribute = $updraftplus_checkout_embed->get_product('updraftplus-vault-storage-5-gb') ? 'data-embed-checkout="'.apply_filters('updraftplus_com_link', $updraftplus_checkout_embed->get_product('updraftplus-vault-storage-5-gb', UpdraftPlus_Options::admin_page_url().'?page=updraftplus&tab=settings')).'"' : ''; |
| 81 | } |
| 82 | |
| 83 | $script_suffix = $updraftplus->use_unminified_scripts() ? '' : '.min'; |
| 84 | $updraft_min_or_not = $updraftplus->get_updraftplus_file_version(); |
| 85 | wp_enqueue_script('updraftplus-tether-js', trailingslashit(UPDRAFTPLUS_URL).'includes/tether/tether'.$script_suffix.'.js', $updraftplus->version, true); |
| 86 | wp_enqueue_script('updraftplus-shepherd-js', trailingslashit(UPDRAFTPLUS_URL).'includes/tether-shepherd/shepherd'.$script_suffix.'.js', array('updraftplus-tether-js'), $updraftplus->version, true); |
| 87 | wp_enqueue_style('updraftplus-shepherd-css', trailingslashit(UPDRAFTPLUS_URL).'css/tether-shepherd/shepherd-theme-arrows-plain-buttons'.$script_suffix.'.css', false, $updraftplus->version); |
| 88 | wp_enqueue_style('updraftplus-tour-css', trailingslashit(UPDRAFTPLUS_URL).'css/updraftplus-tour'.$updraft_min_or_not.'.css', false, $updraftplus->version); |
| 89 | wp_register_script('updraftplus-tour-js', trailingslashit(UPDRAFTPLUS_URL).'js/tour.js', array('updraftplus-tether-js'), $updraftplus->version, true); |
| 90 | |
| 91 | $tour_data = array( |
| 92 | 'nonce' => wp_create_nonce('updraftplus-credentialtest-nonce'), |
| 93 | 'show_tab_on_load' => '#updraft-navtab-status', |
| 94 | 'next' => __('Next', 'updraftplus'), |
| 95 | 'back' => __('Back', 'updraftplus'), |
| 96 | 'skip' => __('Skip this step', 'updraftplus'), |
| 97 | 'end_tour' => __('End tour', 'updraftplus'), |
| 98 | 'close' => __('Close', 'updraftplus'), |
| 99 | 'plugins_page' => array( |
| 100 | 'title' => __("UpdraftPlus settings", 'updraftplus'), |
| 101 | 'text' => '<div class="updraftplus-welcome-logo"><img src="'.trailingslashit(UPDRAFTPLUS_URL).'images/ud-logo.png" alt="" /></div><strong>'.__('Welcome to UpdraftPlus', 'updraftplus').'</strong>, '.__("the world’s most trusted backup plugin!", 'updraftplus'), |
| 102 | 'button' => array( |
| 103 | 'url' => UpdraftPlus_Options::admin_page_url().'?page=updraftplus', |
| 104 | 'text' => __('Press here to start!', 'updraftplus') |
| 105 | ) |
| 106 | ), |
| 107 | 'backup_now' => array( |
| 108 | 'title' => __('Your first backup', 'updraftplus'), |
| 109 | 'text' => sprintf( |
| 110 | __('To make a simple backup to your server, press this button.', 'updraftplus').' '. |
| 111 | /* translators: 1: HTML <a> and <strong> opening tag 2: HTML </a> and </strong> closing tag*/ |
| 112 | __('Or to setup regular backups and remote storage, go to %1$s settings %2$s', 'updraftplus'), |
| 113 | '<strong><a href="#settings" class="js--go-to-settings">', |
| 114 | '</a></strong>' |
| 115 | ) |
| 116 | ), |
| 117 | 'backup_options' => array( |
| 118 | 'title' => __("Manual backup options", 'updraftplus'), |
| 119 | 'text' => __('Select what you want to backup', 'updraftplus') |
| 120 | ), |
| 121 | 'backup_now_btn' => array( |
| 122 | 'title' => __("Creating your first backup", 'updraftplus'), |
| 123 | 'text' => __("Press here to run a manual backup.", 'updraftplus').'<br>'. |
| 124 | /* translators: 1: Opening anchor tag, 2: Closing anchor tag */ |
| 125 | sprintf(_x('But to avoid server-wide threats backup regularly to remote cloud storage in %1$s settings %2$s', 'Backup warning with link', 'updraftplus'), '<strong><a href="#settings" class="js--go-to-settings">', '</a></strong>'), |
| 126 | 'btn_text' => __('Go to settings', 'updraftplus') |
| 127 | ), |
| 128 | 'backup_now_btn_success' => array( |
| 129 | 'title' => __('Creating your first backup', 'updraftplus'), |
| 130 | 'text' => __('Congratulations! Your first backup is running.', 'updraftplus').'<br>'. |
| 131 | /* translators: 1: Opening strong tag, 2: Closing strong tag */ |
| 132 | sprintf(_x('But to avoid server-wide threats backup regularly to remote cloud storage in %1$s settings %2$s', 'Backup recommendation', 'updraftplus'), '<strong>', '</strong>'), |
| 133 | 'btn_text' => __('Go to settings', 'updraftplus') |
| 134 | ), |
| 135 | 'settings_timing' => array( |
| 136 | 'title' => __("Choose your backup schedule", 'updraftplus'), |
| 137 | 'text' => __("Choose the schedule that you want your backups to run on.", 'updraftplus') |
| 138 | ), |
| 139 | 'settings_remote_storage' => array( |
| 140 | 'title' => __("Remote storage", 'updraftplus'), |
| 141 | 'text' => __('Now select a remote storage destination to protect against server-wide threats.', 'updraftplus').' '.__('If not, your backups remain on the same server as your site.', 'updraftplus') |
| 142 | .'<div class="ud-notice">' |
| 143 | .'<h3>'.__('Try UpdraftVault!', 'updraftplus').'</h3>' |
| 144 | .__("UpdraftVault is our remote storage which works seamlessly with UpdraftPlus.", 'updraftplus') |
| 145 | .' <a href="'.apply_filters('updraftplus_com_link', 'https://teamupdraft.com/updraftplus/updraftvault/').'" target="_blank">'.__('Find out more here.', 'updraftplus').'</a>' |
| 146 | .'<p><a href="'.apply_filters('updraftplus_com_link', $updraftplus->get_url('shop_vault_5')).'" target="_blank" '.$checkout_embed_5gb_attribute.' class="button button-primary">'.__('Try UpdraftVault for 1 month for only $1!', 'updraftplus').'</a></p>' |
| 147 | .'</div>' |
| 148 | ), |
| 149 | 'settings_more' => array( |
| 150 | 'title' => __("More settings", 'updraftplus'), |
| 151 | 'text' => __("Look through the other settings here, making any changes you’d like.", 'updraftplus') |
| 152 | ), |
| 153 | 'settings_save' => array( |
| 154 | 'title' => __("Save", 'updraftplus'), |
| 155 | 'text' => __('Press here to save your settings.', 'updraftplus') |
| 156 | ), |
| 157 | 'settings_saved' => array( |
| 158 | 'title' => __("Save", 'updraftplus'), |
| 159 | 'text' => __('Congratulations, your settings have successfully been saved.', 'updraftplus') |
| 160 | ), |
| 161 | 'updraft_central' => array( |
| 162 | 'title' => __("UpdraftCentral", 'updraftplus'), |
| 163 | 'text' => '<div class="ud-notice">' |
| 164 | .'<h3>'.__('Control all your backups in one place', 'updraftplus').'</h3>' |
| 165 | .__('Do you have a few more WordPress sites you want to backup? If yes you can save hours by controlling all your backups in one place from UpdraftCentral.', 'updraftplus') |
| 166 | .'</div>' |
| 167 | ), |
| 168 | 'premium' => array( |
| 169 | 'title' => 'UpdraftPlus Premium', |
| 170 | 'text' => __('Thank you for taking the tour.', 'updraftplus') |
| 171 | .'<div class="ud-notice">' |
| 172 | .'<h3>'.__('UpdraftPlus Premium and addons', 'updraftplus').'</h3>' |
| 173 | .__('UpdraftPlus Premium has many more exciting features!', 'updraftplus').' <a href="'.$updraftplus->get_url('premium').'" target="_blank">'.__('Find out more here.', 'updraftplus').'</a>' |
| 174 | .'</div>', |
| 175 | 'attach_to' => '#updraft-navtab-addons top', |
| 176 | 'button' => __('Finish', 'updraftplus') |
| 177 | ), |
| 178 | 'vault_selected' => array( |
| 179 | 'title' => 'UpdraftVault', |
| 180 | 'text' => _x('To get started with UpdraftVault, select one of the options below:', 'Translators: UpdraftVault is a product name and should not be translated.', 'updraftplus') |
| 181 | ) |
| 182 | ); |
| 183 | $tab = UpdraftPlus_Manipulation_Functions::fetch_superglobal('request', 'tab'); |
| 184 | if (isset($tab)) { |
| 185 | $tour_data['show_tab_on_load'] = '#updraft-navtab-'.esc_attr(sanitize_text_field($tab)); |
| 186 | } |
| 187 | |
| 188 | // Change the data for premium users |
| 189 | if ($updraftplus_addons2 && method_exists($updraftplus_addons2, 'connection_status')) { |
| 190 | |
| 191 | $tour_data['settings_remote_storage'] = array( |
| 192 | 'title' => __("Remote storage", 'updraftplus'), |
| 193 | 'text' => __('Now select a remote storage destination to protect against server-wide threats.', 'updraftplus').' '.__('If not, your backups remain on the same server as your site.', 'updraftplus') |
| 194 | .'<div class="ud-notice">' |
| 195 | .'<h3>'.__('Try UpdraftVault!', 'updraftplus').'</h3>' |
| 196 | .__("UpdraftVault is our remote storage which works seamlessly with UpdraftPlus.", 'updraftplus') |
| 197 | .' <a href="'.apply_filters('updraftplus_com_link', 'https://teamupdraft.com/updraftplus/updraftvault/').'" target="_blank">'.__('Find out more here.', 'updraftplus').'</a>' |
| 198 | .'<br>' |
| 199 | .__("If you have a valid Premium license, you get 1GB of storage included.", 'updraftplus') |
| 200 | .' <a href="'.apply_filters('updraftplus_com_link', $updraftplus->get_url('shop_vault_5')).'" target="_blank" '.$checkout_embed_5gb_attribute.'>'.__('Otherwise, you can try UpdraftVault for 1 month for only $1!', 'updraftplus').'</a>' |
| 201 | .'</div>' |
| 202 | ); |
| 203 | |
| 204 | if ($updraftplus_addons2->connection_status() && !is_wp_error($updraftplus_addons2->connection_status())) { |
| 205 | $tour_data['premium'] = array( |
| 206 | 'title' => 'UpdraftPlus Premium', |
| 207 | 'text' => __('Thank you for taking the tour.', 'updraftplus').' '.__('You are now all set to use UpdraftPlus!', 'updraftplus'), |
| 208 | 'attach_to' => '#updraft-navtab-addons top', |
| 209 | 'button' => __('Finish', 'updraftplus') |
| 210 | ); |
| 211 | } else { |
| 212 | $tour_data['premium'] = array( |
| 213 | 'title' => 'UpdraftPlus Premium', |
| 214 | 'text' => __('Thank you for taking the tour.', 'updraftplus') |
| 215 | .'<div class="ud-notice">' |
| 216 | .'<h3>'.__('Connect to updraftplus.com', 'updraftplus').'</h3>' |
| 217 | .__('Log in here to enable all the features you have access to.', 'updraftplus') |
| 218 | .'</div>', |
| 219 | 'attach_to' => '#updraftplus-addons_options_email right', |
| 220 | 'button' => __('Finish', 'updraftplus') |
| 221 | ); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | wp_localize_script('updraftplus-tour-js', 'updraftplus_tour_i18n', $tour_data); |
| 226 | wp_enqueue_script('updraftplus-tour-js'); |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * Removes the tour status so the tour can be seen again |
| 231 | * |
| 232 | * @return string|WP_Error not visible by the user |
| 233 | */ |
| 234 | public function reset_tour_status() { |
| 235 | |
| 236 | // If the option isn't set, the tour hasn't been cancelled |
| 237 | if (!UpdraftPlus_Options::get_updraft_option('updraftplus_tour_cancelled_on')) { |
| 238 | // string not visible by the user |
| 239 | return 'The tour is still active. Everything should be ok.'; |
| 240 | } |
| 241 | |
| 242 | $result = UpdraftPlus_Options::delete_updraft_option('updraftplus_tour_cancelled_on'); |
| 243 | // strings not visible by the user |
| 244 | return $result ? 'The tour status was successfully reset' : new WP_Error('update_failed', 'The attempt to update the tour option failed.', array('status' => 409)); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * Updates the stored value for which step the tour ended on |
| 249 | * |
| 250 | * @param object $request - the http $_REQUEST obj |
| 251 | * @return bool |
| 252 | */ |
| 253 | public function set_tour_status($request) { |
| 254 | if (!isset($request['current_step'])) return false; |
| 255 | return UpdraftPlus_Options::update_updraft_option('updraftplus_tour_cancelled_on', $request['current_step']); |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Adds the Tour link under the plugin on the plugin screen. |
| 260 | * |
| 261 | * @param Array $links Set of links for the plugin, before being filtered |
| 262 | * @param String $file File name (relative to the plugin directory) |
| 263 | * @return Array filtered results |
| 264 | */ |
| 265 | public function plugin_action_links($links, $file) { |
| 266 | if (is_array($links) && 'updraftplus/updraftplus.php' === $file) { |
| 267 | $links['updraftplus_tour'] = '<a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&updraftplus_tour=1" class="js-updraftplus-tour">'.__("Take Tour", "updraftplus").'</a>'; |
| 268 | } |
| 269 | return $links; |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * Checks if UDP was newly installed. |
| 274 | * |
| 275 | * Checks if there are backups, and if there are more than 1, |
| 276 | * checks if the folder is older than 1 day old |
| 277 | * |
| 278 | * @return bool |
| 279 | */ |
| 280 | public function updraftplus_was_already_installed() { |
| 281 | // If backups already exist |
| 282 | $backup_history = UpdraftPlus_Backup_History::get_history(); |
| 283 | |
| 284 | // No backup history |
| 285 | if (!$backup_history) return false; |
| 286 | if (is_array($backup_history) && 0 === count($backup_history)) { |
| 287 | return false; |
| 288 | } |
| 289 | // If there is at least 1 backup, we check if the folder is older than 1 day old |
| 290 | if (0 < count($backup_history)) { |
| 291 | $backups_timestamps = array_keys($backup_history); |
| 292 | $last_backlup_age = time() - end($backups_timestamps); |
| 293 | if (DAY_IN_SECONDS < $last_backlup_age) { |
| 294 | // the oldest backup is older than 1 day old, so it's likely that UDP was already installed, and the backups aren't a product of the user testing while doing the tour. |
| 295 | return true; |
| 296 | } |
| 297 | } |
| 298 | return false; |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | add_action('admin_init', array(UpdraftPlus_Tour::get_instance(), 'init')); |
| 303 |