set_tour_status(array('current_step' => 'start')); return; } // if backups already exist and if ($this->updraftplus_was_already_installed() && !isset($_REQUEST['updraftplus_tour'])) { return; } // if 'Take tour' link was used, reset tour if (isset($_REQUEST['updraftplus_tour']) && 1 === intval($_REQUEST['updraftplus_tour'])) { $this->reset_tour_status(); } if (!UpdraftPlus_Options::get_updraft_option('updraftplus_tour_cancelled_on')) { add_action('admin_enqueue_scripts', array($this, 'load_tour')); } } /** * Loads in tour assets * * @param string $hook - current page */ public function load_tour($hook) { $pages = array('settings_page_updraftplus', 'plugins.php'); if (!in_array($hook, $pages)) return; if (!UpdraftPlus_Options::user_can_manage()) return; global $updraftplus, $updraftplus_addons2; $script_suffix = $updraftplus->use_unminified_scripts() ? '' : '.min'; wp_enqueue_script('updraftplus-tether-js', trailingslashit(UPDRAFTPLUS_URL).'includes/tether/tether'.$script_suffix.'.js', $updraftplus->version, true); wp_enqueue_script('updraftplus-shepherd-js', trailingslashit(UPDRAFTPLUS_URL).'includes/tether-shepherd/shepherd'.$script_suffix.'.js', array('updraftplus-tether-js'), $updraftplus->version, true); wp_enqueue_style('updraftplus-shepherd-css', trailingslashit(UPDRAFTPLUS_URL).'css/tether-shepherd/shepherd-theme-arrows-plain-buttons'.$script_suffix.'.css', false, $updraftplus->version); wp_enqueue_style('updraftplus-tour-css', trailingslashit(UPDRAFTPLUS_URL).'css/updraftplus-tour'.$script_suffix.'.css', false, $updraftplus->version); wp_register_script('updraftplus-tour-js', trailingslashit(UPDRAFTPLUS_URL).'js/tour.js', array('updraftplus-tether-js'), $updraftplus->version, true); $tour_data = array( 'nonce' => wp_create_nonce('updraftplus-credentialtest-nonce'), 'show_tab_on_load' => '#updraft-navtab-status', 'next' => __('Next', 'updraftplus'), 'back' => __('Back', 'updraftplus'), 'skip' => __('Skip this step', 'updraftplus'), 'end_tour' => __('End tour', 'updraftplus'), 'close' => __('Close', 'updraftplus'), 'plugins_page' => array( 'title' => __("UpdraftPlus settings", 'updraftplus'), 'text' => ''.__('Welcome to UpdraftPlus', 'updraftplus').', '.__("the world’s most trusted backup plugin!", 'updraftplus'), 'button' => array( 'url' => UpdraftPlus_Options::admin_page_url().'?page=updraftplus', 'text' => __('Press here to start!', 'updraftplus') ) ), 'backup_now' => array( 'title' => __('Your first backup', 'updraftplus'), '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'), '', '') ), 'backup_options' => array( 'title' => __("Manual backup options", 'updraftplus'), 'text' => __('Select what you want to backup', 'updraftplus') ), 'backup_now_btn' => array( 'title' => __("Creating your first backup", 'updraftplus'), 'text' => __("Press here to run a manual backup.", 'updraftplus').'
'.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'), '', ''), 'btn_text' => __('Go to settings', 'updraftplus') ), 'backup_now_btn_success' => array( 'title' => __('Creating your first backup', 'updraftplus'), 'text' => __('Congratulations! Your first backup is running.', 'updraftplus').'
'.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'), '', ''), 'btn_text' => __('Go to settings', 'updraftplus') ), 'settings_timing' => array( 'title' => __("Choose your backup schedule", 'updraftplus'), 'text' => __("Choose the schedule that you want your backups to run on.", 'updraftplus') ), 'settings_remote_storage' => array( 'title' => __("Remote storage", 'updraftplus'), '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') .'
' .'

'.__('Try UpdraftVault!').'

' .__("UpdraftVault is our remote storage which works seamlessly with UpdraftPlus.", 'updraftplus') .' '.__('Find out more here.', 'updraftplus').'' .'
' ), 'settings_more' => array( 'title' => __("More settings", 'updraftplus'), 'text' => __("Look through the other settings here, making any changes you’d like.", 'updraftplus') ), 'settings_save' => array( 'title' => __("Save", 'updraftplus'), 'text' => __('Press here to save your settings.', 'updraftplus') ), 'settings_saved' => array( 'title' => __("Save", 'updraftplus'), 'text' => __('Congratulations, your settings have successfully been saved.', 'updraftplus') ), 'updraft_central' => array( 'title' => __("UpdraftCentral", 'updraftplus'), 'text' => '
' .'

'.__('Control all your backups in one place', 'updraftplus').'

' .__('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') .'
' ), 'premium' => array( 'title' => 'UpdraftPlus Premium', 'text' => __('Thank you for taking the tour.', 'updraftplus') .'
' .'

'.__('UpdraftPlus Premium and addons', 'updraftplus').'

' .__('UpdraftPlus Premium has many more exciting features!', 'updraftplus').' '.__('Find out more here.', 'updraftplus').'' .'
', 'attach_to' => '#updraft-navtab-addons top', 'button' => __('Finish', 'updraftplus') ), 'vault_selected' => array( 'title' => 'UpdraftVault', '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') ) ); if (isset($_REQUEST['tab']) && 'addons' === $_REQUEST['tab']) { $tour_data['show_tab_on_load'] = '#updraft-navtab-addons'; } if ($updraftplus_addons2 && method_exists($updraftplus_addons2, 'connection_status')) { if ($updraftplus_addons2->connection_status() && !is_wp_error($updraftplus_addons2->connection_status())) { $tour_data['premium'] = array( 'title' => 'UpdraftPlus Premium', 'text' => __('Thank you for taking the tour. You are now all set to use UpdraftPlus!', 'updraftplus'), 'attach_to' => '#updraft-navtab-addons top', 'button' => __('Finish', 'updraftplus') ); } else { $tour_data['premium'] = array( 'title' => 'UpdraftPlus Premium', 'text' => __('Thank you for taking the tour.', 'updraftplus') .'
' .'

'.__('Connect to updraftplus.com', 'updraftplus').'

' .__('Log in here to enable all the features you have access to.', 'updraftplus') .'
', 'attach_to' => '#updraftplus-addons_options_email right', 'button' => __('Finish', 'updraftplus') ); } } wp_localize_script('updraftplus-tour-js', 'updraftplus_tour_i18n', $tour_data); wp_enqueue_script('updraftplus-tour-js'); } /** * Removes the tour status so the tour can be seen again * * @return string|WP_Error not visible by the user */ public function reset_tour_status() { // If the option isn't set, the tour hasn't been cancelled if (!UpdraftPlus_Options::get_updraft_option('updraftplus_tour_cancelled_on')) { // string not visible by the user return 'The tour is still active. Everything should be ok.'; } $result = UpdraftPlus_Options::delete_updraft_option('updraftplus_tour_cancelled_on'); // strings not visible by the user return $result ? 'The tour status was successfully reset' : new WP_Error('update_failed', 'The attempt to update the tour option failed.', array('status' => 409)); } /** * Updates the stored value for which step the tour ended on * * @param object $request - the http $_REQUEST obj * @return bool */ public function set_tour_status($request) { if (!isset($request['current_step'])) return false; return UpdraftPlus_Options::update_updraft_option('updraftplus_tour_cancelled_on', $request['current_step']); } /** * Adds the Tour link under the plugin on the plugin screen. * * @param Array $links Set of links for the plugin, before being filtered * @param String $file File name (relative to the plugin directory) * @return Array filtered results */ public function plugin_action_links($links, $file) { if (is_array($links) && 'updraftplus/updraftplus.php' === $file) { $links['updraftplus_tour'] = ''.__("Take Tour", "updraftplus").''; } return $links; } /** * Checks if UDP was newly installed. * * Checks if there are backups, and if there are more than 1, * checks if the folder is older than 1 day old * * @return bool */ public function updraftplus_was_already_installed() { // If backups already exist $backup_history = UpdraftPlus_Backup_History::get_history(); // No backup history if (!$backup_history) return false; if (is_array($backup_history) && 0 === count($backup_history)) { return false; } // If there is at least 1 backup, we check if the folder is older than 1 day old if (0 < count($backup_history)) { $backups_timestamps = array_keys($backup_history); $last_backlup_age = time() - end($backups_timestamps); if (DAY_IN_SECONDS < $last_backlup_age) { // 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. return true; } } return false; } } add_action('admin_init', array(UpdraftPlus_Tour::get_instance(), 'init'));