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