Dropbox2
6 years ago
Google
6 years ago
checkout-embed
6 years ago
cloudfiles
12 years ago
handlebars
6 years ago
images
9 years ago
jquery.serializeJSON
7 years ago
jstree
6 years ago
labelauty
6 years ago
tether
6 years ago
tether-shepherd
7 years ago
updraftclone
6 years ago
S3.php
6 years ago
S3compat.php
6 years ago
cacert.pem
6 years ago
class-backup-history.php
6 years ago
class-commands.php
6 years ago
class-database-utility.php
6 years ago
class-filesystem-functions.php
6 years ago
class-job-scheduler.php
6 years ago
class-manipulation-functions.php
7 years ago
class-partialfileservlet.php
9 years ago
class-remote-send.php
6 years ago
class-semaphore.php
6 years ago
class-storage-methods-interface.php
6 years ago
class-udrpc.php
6 years ago
class-updraft-dashboard-news.php
6 years ago
class-updraftcentral-updraftplus-commands.php
8 years ago
class-updraftplus-encryption.php
6 years ago
class-wpadmin-commands.php
6 years ago
class-zip.php
6 years ago
ftp.class.php
7 years ago
get-cpanel-quota-usage.pl
12 years ago
google-extensions.php
9 years ago
jquery-ui.custom.css
7 years ago
jquery-ui.custom.min.css
7 years ago
jquery-ui.custom.min.css.map
7 years ago
jquery.blockUI.js
8 years ago
jquery.blockUI.min.js
8 years ago
updraft-admin-common.js
6 years ago
updraft-admin-common.min.js
6 years ago
updraft-notices.php
6 years ago
updraft-restorer-skin-compatibility.php
6 years ago
updraft-restorer-skin.php
6 years ago
updraftcentral.php
7 years ago
updraftplus-clone.php
6 years ago
updraftplus-login.php
7 years ago
updraftplus-notices.php
6 years ago
updraftplus-tour.php
7 years ago
updraftvault.php
6 years ago
updraftplus-tour.php
291 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 | if (isset($_REQUEST['updraftplus_tour']) && 0 === intval($_REQUEST['updraftplus_tour'])) { |
| 44 | $this->set_tour_status(array('current_step' => 'start')); |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | // if backups already exist and |
| 49 | if ($this->updraftplus_was_already_installed() && !isset($_REQUEST['updraftplus_tour'])) { |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | // if 'Take tour' link was used, reset tour |
| 54 | if (isset($_REQUEST['updraftplus_tour']) && 1 === intval($_REQUEST['updraftplus_tour'])) { |
| 55 | $this->reset_tour_status(); |
| 56 | } |
| 57 | |
| 58 | if (!UpdraftPlus_Options::get_updraft_option('updraftplus_tour_cancelled_on')) { |
| 59 | add_action('admin_enqueue_scripts', array($this, 'load_tour')); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Loads in tour assets |
| 65 | * |
| 66 | * @param string $hook - current page |
| 67 | */ |
| 68 | public function load_tour($hook) { |
| 69 | |
| 70 | $pages = array('settings_page_updraftplus', 'plugins.php'); |
| 71 | |
| 72 | if (!in_array($hook, $pages)) return; |
| 73 | if (!UpdraftPlus_Options::user_can_manage()) return; |
| 74 | |
| 75 | global $updraftplus, $updraftplus_addons2, $updraftplus_checkout_embed; |
| 76 | |
| 77 | $checkout_embed_5gb_attribute = ''; |
| 78 | if ($updraftplus_checkout_embed) { |
| 79 | $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')).'"' : ''; |
| 80 | } |
| 81 | |
| 82 | $script_suffix = $updraftplus->use_unminified_scripts() ? '' : '.min'; |
| 83 | wp_enqueue_script('updraftplus-tether-js', trailingslashit(UPDRAFTPLUS_URL).'includes/tether/tether'.$script_suffix.'.js', $updraftplus->version, true); |
| 84 | wp_enqueue_script('updraftplus-shepherd-js', trailingslashit(UPDRAFTPLUS_URL).'includes/tether-shepherd/shepherd'.$script_suffix.'.js', array('updraftplus-tether-js'), $updraftplus->version, true); |
| 85 | wp_enqueue_style('updraftplus-shepherd-css', trailingslashit(UPDRAFTPLUS_URL).'css/tether-shepherd/shepherd-theme-arrows-plain-buttons'.$script_suffix.'.css', false, $updraftplus->version); |
| 86 | wp_enqueue_style('updraftplus-tour-css', trailingslashit(UPDRAFTPLUS_URL).'css/updraftplus-tour'.$script_suffix.'.css', false, $updraftplus->version); |
| 87 | wp_register_script('updraftplus-tour-js', trailingslashit(UPDRAFTPLUS_URL).'js/tour.js', array('updraftplus-tether-js'), $updraftplus->version, true); |
| 88 | |
| 89 | $tour_data = array( |
| 90 | 'nonce' => wp_create_nonce('updraftplus-credentialtest-nonce'), |
| 91 | 'show_tab_on_load' => '#updraft-navtab-status', |
| 92 | 'next' => __('Next', 'updraftplus'), |
| 93 | 'back' => __('Back', 'updraftplus'), |
| 94 | 'skip' => __('Skip this step', 'updraftplus'), |
| 95 | 'end_tour' => __('End tour', 'updraftplus'), |
| 96 | 'close' => __('Close', 'updraftplus'), |
| 97 | 'plugins_page' => array( |
| 98 | 'title' => __("UpdraftPlus settings", 'updraftplus'), |
| 99 | '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'), |
| 100 | 'button' => array( |
| 101 | 'url' => UpdraftPlus_Options::admin_page_url().'?page=updraftplus', |
| 102 | 'text' => __('Press here to start!', 'updraftplus') |
| 103 | ) |
| 104 | ), |
| 105 | 'backup_now' => array( |
| 106 | 'title' => __('Your first backup', 'updraftplus'), |
| 107 | 'text' => sprintf(_x('To make a simple backup to your server, press this button. Or to setup regular backups and remote storage, go to %s settings %s', 'updraftplus'), '<strong><a href="#settings" class="js--go-to-settings">', '</a></strong>') |
| 108 | ), |
| 109 | 'backup_options' => array( |
| 110 | 'title' => __("Manual backup options", 'updraftplus'), |
| 111 | 'text' => __('Select what you want to backup', 'updraftplus') |
| 112 | ), |
| 113 | 'backup_now_btn' => array( |
| 114 | 'title' => __("Creating your first backup", 'updraftplus'), |
| 115 | 'text' => __("Press here to run a manual backup.", 'updraftplus').'<br>'.sprintf(_x("But to avoid server-wide threats backup regularly to remote cloud storage in %s settings %s", 'Translators: %s is a bold tag.', 'updraftplus'), '<strong><a href="#settings" class="js--go-to-settings">', '</a></strong>'), |
| 116 | 'btn_text' => __('Go to settings', 'updraftplus') |
| 117 | ), |
| 118 | 'backup_now_btn_success' => array( |
| 119 | 'title' => __('Creating your first backup', 'updraftplus'), |
| 120 | 'text' => __('Congratulations! Your first backup is running.', 'updraftplus').'<br>'.sprintf(_x('But to avoid server-wide threats backup regularly to remote cloud storage in %s settings %s', 'Translators: %s is a bold tag.', 'updraftplus'), '<strong>', '</strong>'), |
| 121 | 'btn_text' => __('Go to settings', 'updraftplus') |
| 122 | ), |
| 123 | 'settings_timing' => array( |
| 124 | 'title' => __("Choose your backup schedule", 'updraftplus'), |
| 125 | 'text' => __("Choose the schedule that you want your backups to run on.", 'updraftplus') |
| 126 | ), |
| 127 | 'settings_remote_storage' => array( |
| 128 | 'title' => __("Remote storage", 'updraftplus'), |
| 129 | 'text' => __("Now select a remote storage destination to protect against server-wide threats. If not, your backups remain on the same server as your site.", 'updraftplus') |
| 130 | .'<div class="ud-notice">' |
| 131 | .'<h3>'.__('Try UpdraftVault!').'</h3>' |
| 132 | .__("UpdraftVault is our remote storage which works seamlessly with UpdraftPlus.", 'updraftplus') |
| 133 | .' <a href="'.apply_filters('updraftplus_com_link', 'https://updraftplus.com/updraftvault/').'" target="_blank">'.__('Find out more here.', 'updraftplus').'</a>' |
| 134 | .'<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>' |
| 135 | .'</div>' |
| 136 | ), |
| 137 | 'settings_more' => array( |
| 138 | 'title' => __("More settings", 'updraftplus'), |
| 139 | 'text' => __("Look through the other settings here, making any changes you’d like.", 'updraftplus') |
| 140 | ), |
| 141 | 'settings_save' => array( |
| 142 | 'title' => __("Save", 'updraftplus'), |
| 143 | 'text' => __('Press here to save your settings.', 'updraftplus') |
| 144 | ), |
| 145 | 'settings_saved' => array( |
| 146 | 'title' => __("Save", 'updraftplus'), |
| 147 | 'text' => __('Congratulations, your settings have successfully been saved.', 'updraftplus') |
| 148 | ), |
| 149 | 'updraft_central' => array( |
| 150 | 'title' => __("UpdraftCentral", 'updraftplus'), |
| 151 | 'text' => '<div class="ud-notice">' |
| 152 | .'<h3>'.__('Control all your backups in one place', 'updraftplus').'</h3>' |
| 153 | .__('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') |
| 154 | .'</div>' |
| 155 | ), |
| 156 | 'premium' => array( |
| 157 | 'title' => 'UpdraftPlus Premium', |
| 158 | 'text' => __('Thank you for taking the tour.', 'updraftplus') |
| 159 | .'<div class="ud-notice">' |
| 160 | .'<h3>'.__('UpdraftPlus Premium and addons', 'updraftplus').'</h3>' |
| 161 | .__('UpdraftPlus Premium has many more exciting features!', 'updraftplus').' <a href="'.apply_filters('updraftplus_com_link', 'https://updraftplus.com/shop/updraftplus-premium/').'" target="_blank">'.__('Find out more here.', 'updraftplus').'</a>' |
| 162 | .'</div>', |
| 163 | 'attach_to' => '#updraft-navtab-addons top', |
| 164 | 'button' => __('Finish', 'updraftplus') |
| 165 | ), |
| 166 | 'vault_selected' => array( |
| 167 | 'title' => 'UpdraftVault', |
| 168 | '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') |
| 169 | ) |
| 170 | ); |
| 171 | |
| 172 | if (isset($_REQUEST['tab'])) { |
| 173 | $tour_data['show_tab_on_load'] = '#updraft-navtab-'.esc_attr($_REQUEST['tab']); |
| 174 | } |
| 175 | |
| 176 | // Change the data for premium users |
| 177 | if ($updraftplus_addons2 && method_exists($updraftplus_addons2, 'connection_status')) { |
| 178 | |
| 179 | $tour_data['settings_remote_storage'] = array( |
| 180 | 'title' => __("Remote storage", 'updraftplus'), |
| 181 | 'text' => __("Now select a remote storage destination to protect against server-wide threats. If not, your backups remain on the same server as your site.", 'updraftplus') |
| 182 | .'<div class="ud-notice">' |
| 183 | .'<h3>'.__('Try UpdraftVault!').'</h3>' |
| 184 | .__("UpdraftVault is our remote storage which works seamlessly with UpdraftPlus.", 'updraftplus') |
| 185 | .' <a href="'.apply_filters('updraftplus_com_link', 'https://updraftplus.com/updraftvault/').'" target="_blank">'.__('Find out more here.', 'updraftplus').'</a>' |
| 186 | .'<br>' |
| 187 | .__("If you have a valid Premium license, you get 1GB of storage included.", 'updraftplus') |
| 188 | .' <a href="'.apply_filters('updraftplus_com_link', 'https://updraftplus.com/shop/updraftplus-vault-storage-5-gb/').'" target="_blank" '.$checkout_embed_5gb_attribute.'>'.__('Otherwise, you can try UpdraftVault for 1 month for only $1!', 'updraftplus').'</a>' |
| 189 | .'</div>' |
| 190 | ); |
| 191 | |
| 192 | if ($updraftplus_addons2->connection_status() && !is_wp_error($updraftplus_addons2->connection_status())) { |
| 193 | $tour_data['premium'] = array( |
| 194 | 'title' => 'UpdraftPlus Premium', |
| 195 | 'text' => __('Thank you for taking the tour. You are now all set to use UpdraftPlus!', 'updraftplus'), |
| 196 | 'attach_to' => '#updraft-navtab-addons top', |
| 197 | 'button' => __('Finish', 'updraftplus') |
| 198 | ); |
| 199 | } else { |
| 200 | $tour_data['premium'] = array( |
| 201 | 'title' => 'UpdraftPlus Premium', |
| 202 | 'text' => __('Thank you for taking the tour.', 'updraftplus') |
| 203 | .'<div class="ud-notice">' |
| 204 | .'<h3>'.__('Connect to updraftplus.com', 'updraftplus').'</h3>' |
| 205 | .__('Log in here to enable all the features you have access to.', 'updraftplus') |
| 206 | .'</div>', |
| 207 | 'attach_to' => '#updraftplus-addons_options_email right', |
| 208 | 'button' => __('Finish', 'updraftplus') |
| 209 | ); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | wp_localize_script('updraftplus-tour-js', 'updraftplus_tour_i18n', $tour_data); |
| 214 | wp_enqueue_script('updraftplus-tour-js'); |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * Removes the tour status so the tour can be seen again |
| 219 | * |
| 220 | * @return string|WP_Error not visible by the user |
| 221 | */ |
| 222 | public function reset_tour_status() { |
| 223 | |
| 224 | // If the option isn't set, the tour hasn't been cancelled |
| 225 | if (!UpdraftPlus_Options::get_updraft_option('updraftplus_tour_cancelled_on')) { |
| 226 | // string not visible by the user |
| 227 | return 'The tour is still active. Everything should be ok.'; |
| 228 | } |
| 229 | |
| 230 | $result = UpdraftPlus_Options::delete_updraft_option('updraftplus_tour_cancelled_on'); |
| 231 | // strings not visible by the user |
| 232 | return $result ? 'The tour status was successfully reset' : new WP_Error('update_failed', 'The attempt to update the tour option failed.', array('status' => 409)); |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * Updates the stored value for which step the tour ended on |
| 237 | * |
| 238 | * @param object $request - the http $_REQUEST obj |
| 239 | * @return bool |
| 240 | */ |
| 241 | public function set_tour_status($request) { |
| 242 | if (!isset($request['current_step'])) return false; |
| 243 | return UpdraftPlus_Options::update_updraft_option('updraftplus_tour_cancelled_on', $request['current_step']); |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Adds the Tour link under the plugin on the plugin screen. |
| 248 | * |
| 249 | * @param Array $links Set of links for the plugin, before being filtered |
| 250 | * @param String $file File name (relative to the plugin directory) |
| 251 | * @return Array filtered results |
| 252 | */ |
| 253 | public function plugin_action_links($links, $file) { |
| 254 | if (is_array($links) && 'updraftplus/updraftplus.php' === $file) { |
| 255 | $links['updraftplus_tour'] = '<a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&updraftplus_tour=1" class="js-updraftplus-tour">'.__("Take Tour", "updraftplus").'</a>'; |
| 256 | } |
| 257 | return $links; |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * Checks if UDP was newly installed. |
| 262 | * |
| 263 | * Checks if there are backups, and if there are more than 1, |
| 264 | * checks if the folder is older than 1 day old |
| 265 | * |
| 266 | * @return bool |
| 267 | */ |
| 268 | public function updraftplus_was_already_installed() { |
| 269 | // If backups already exist |
| 270 | $backup_history = UpdraftPlus_Backup_History::get_history(); |
| 271 | |
| 272 | // No backup history |
| 273 | if (!$backup_history) return false; |
| 274 | if (is_array($backup_history) && 0 === count($backup_history)) { |
| 275 | return false; |
| 276 | } |
| 277 | // If there is at least 1 backup, we check if the folder is older than 1 day old |
| 278 | if (0 < count($backup_history)) { |
| 279 | $backups_timestamps = array_keys($backup_history); |
| 280 | $last_backlup_age = time() - end($backups_timestamps); |
| 281 | if (DAY_IN_SECONDS < $last_backlup_age) { |
| 282 | // 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. |
| 283 | return true; |
| 284 | } |
| 285 | } |
| 286 | return false; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | add_action('admin_init', array(UpdraftPlus_Tour::get_instance(), 'init')); |
| 291 |