Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp...
File: options.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Options handling
[2] Fix | Delete
*/
[3] Fix | Delete
if (!defined('ABSPATH')) die('No direct access allowed');
[4] Fix | Delete
[5] Fix | Delete
class UpdraftPlus_Options {
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Whether or not the current user has permission to manage UpdraftPlus
[9] Fix | Delete
*
[10] Fix | Delete
* @return Boolean
[11] Fix | Delete
*/
[12] Fix | Delete
public static function user_can_manage() {
[13] Fix | Delete
$user_can_manage = current_user_can(apply_filters('option_page_capability_updraft-options-group', 'manage_options'));
[14] Fix | Delete
// false: allows the filter to know that the request is not coming from the multisite add-on
[15] Fix | Delete
return apply_filters('updraft_user_can_manage', $user_can_manage, false);
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
public static function options_table() {
[19] Fix | Delete
return 'options';
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Get the URL to the dashboard admin page
[24] Fix | Delete
*
[25] Fix | Delete
* @return String
[26] Fix | Delete
*/
[27] Fix | Delete
public static function admin_page_url() {
[28] Fix | Delete
return admin_url('options-general.php');
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* Get the base-name for the dashboard admin page
[33] Fix | Delete
*
[34] Fix | Delete
* @return String
[35] Fix | Delete
*/
[36] Fix | Delete
public static function admin_page() {
[37] Fix | Delete
return 'options-general.php';
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* Extracts the last logged message from updraftplus last process
[42] Fix | Delete
*
[43] Fix | Delete
* @return Mixed - Value set for the option or the default message
[44] Fix | Delete
*/
[45] Fix | Delete
public static function get_updraft_lastmessage() {
[46] Fix | Delete
return UpdraftPlus_Options::get_updraft_option('updraft_lastmessage', __('(Nothing has been logged yet)', 'updraftplus'));
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Get the value for a specified option
[51] Fix | Delete
*
[52] Fix | Delete
* @param String option
[53] Fix | Delete
* @param Mixed $default
[54] Fix | Delete
*
[55] Fix | Delete
* @return Mixed
[56] Fix | Delete
*/
[57] Fix | Delete
public static function get_updraft_option($option, $default = null) {
[58] Fix | Delete
$ret = get_option($option, $default);
[59] Fix | Delete
return apply_filters('updraftplus_get_option', $ret, $option, $default);
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* The apparently unused parameter is used in the alternative class in the Multisite add-on
[64] Fix | Delete
*
[65] Fix | Delete
* @param String $option specify option name
[66] Fix | Delete
* @param String $value specify option value
[67] Fix | Delete
* @param Boolean $use_cache whether or not to use the WP options cache
[68] Fix | Delete
* @param String $autoload whether to autoload (only takes effect on a change of value)
[69] Fix | Delete
*
[70] Fix | Delete
* @return Boolean - as from update_option()
[71] Fix | Delete
*/
[72] Fix | Delete
public static function update_updraft_option($option, $value, $use_cache = true, $autoload = 'yes') {
[73] Fix | Delete
return update_option($option, apply_filters('updraftplus_update_option', $value, $option, $use_cache), $autoload);
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Delete an option
[78] Fix | Delete
*
[79] Fix | Delete
* @param String $option - the option name
[80] Fix | Delete
*/
[81] Fix | Delete
public static function delete_updraft_option($option) {
[82] Fix | Delete
delete_option($option);
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
/**
[86] Fix | Delete
* Register the UpdraftPlus admin menu entry
[87] Fix | Delete
*/
[88] Fix | Delete
public static function add_admin_pages() {
[89] Fix | Delete
global $updraftplus_admin;
[90] Fix | Delete
add_submenu_page('options-general.php', 'UpdraftPlus', __('UpdraftPlus Backups', 'updraftplus'), apply_filters('option_page_capability_updraft-options-group', 'manage_options'), 'updraftplus', array($updraftplus_admin, 'settings_output'));
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
public static function options_form_begin($settings_fields = 'updraft-options-group', $allow_autocomplete = true, $get_params = array(), $classes = '') {
[94] Fix | Delete
global $pagenow;
[95] Fix | Delete
echo '<form method="post"';
[96] Fix | Delete
[97] Fix | Delete
if ('' != $classes) echo ' class="'.$classes.'"';
[98] Fix | Delete
[99] Fix | Delete
$page = '';
[100] Fix | Delete
if ('options-general.php' == $pagenow) $page = "options.php";
[101] Fix | Delete
[102] Fix | Delete
if (!empty($get_params)) {
[103] Fix | Delete
$page .= '?';
[104] Fix | Delete
$first_one = true;
[105] Fix | Delete
foreach ($get_params as $k => $v) {
[106] Fix | Delete
if ($first_one) {
[107] Fix | Delete
$first_one = false;
[108] Fix | Delete
} else {
[109] Fix | Delete
$page .= '&';
[110] Fix | Delete
}
[111] Fix | Delete
$page .= urlencode($k).'='.urlencode($v);
[112] Fix | Delete
}
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
if ($page) echo ' action="'.$page.'"';
[116] Fix | Delete
[117] Fix | Delete
if (!$allow_autocomplete) echo ' autocomplete="off"';
[118] Fix | Delete
echo '>';
[119] Fix | Delete
if ($settings_fields) {
[120] Fix | Delete
// This is settings_fields('updraft-options-group'), but with the referer pruned
[121] Fix | Delete
echo "<input type='hidden' name='option_page' value='" . esc_attr('updraft-options-group') . "' />";
[122] Fix | Delete
echo '<input type="hidden" name="action" value="update" />';
[123] Fix | Delete
wp_nonce_field("updraft-options-group-options", '_wpnonce', false);
[124] Fix | Delete
[125] Fix | Delete
$remove_query_args = array('state', 'action', 'oauth_verifier');
[126] Fix | Delete
[127] Fix | Delete
$referer = UpdraftPlus_Manipulation_Functions::wp_unslash(remove_query_arg($remove_query_args, $_SERVER['REQUEST_URI']));
[128] Fix | Delete
[129] Fix | Delete
// Add back the page parameter if it looks like we were on the settings page via an OAuth callback that has now had all parameters removed. This is likely unnecessarily conservative, but there's nothing requiring more than this at the current time.
[130] Fix | Delete
if (substr($referer, -19, 19) == 'options-general.php' && false !== strpos($_SERVER['REQUEST_URI'], '?')) $referer .= '?page=updraftplus';
[131] Fix | Delete
[132] Fix | Delete
$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr($referer) . '" />';
[133] Fix | Delete
echo $referer_field;
[134] Fix | Delete
}
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* Runs upon the WordPress action admin_init
[139] Fix | Delete
*/
[140] Fix | Delete
public static function admin_init() {
[141] Fix | Delete
[142] Fix | Delete
static $already_inited = false;
[143] Fix | Delete
if ($already_inited) return;
[144] Fix | Delete
[145] Fix | Delete
$already_inited = true;
[146] Fix | Delete
[147] Fix | Delete
// If being called outside of the admin context, this may not be loaded yet
[148] Fix | Delete
if (!function_exists('register_setting')) include_once(ABSPATH.'wp-admin/includes/plugin.php');
[149] Fix | Delete
[150] Fix | Delete
global $updraftplus, $updraftplus_admin;
[151] Fix | Delete
register_setting('updraft-options-group', 'updraft_interval', array($updraftplus, 'schedule_backup'));
[152] Fix | Delete
register_setting('updraft-options-group', 'updraft_interval_database', array($updraftplus, 'schedule_backup_database'));
[153] Fix | Delete
register_setting('updraft-options-group', 'updraft_interval_increments', array($updraftplus, 'schedule_backup_increments'));
[154] Fix | Delete
register_setting('updraft-options-group', 'updraft_retain', array('UpdraftPlus_Manipulation_Functions', 'retain_range'));
[155] Fix | Delete
register_setting('updraft-options-group', 'updraft_retain_db', array('UpdraftPlus_Manipulation_Functions', 'retain_range'));
[156] Fix | Delete
register_setting('updraft-options-group', 'updraft_retain_extrarules');
[157] Fix | Delete
[158] Fix | Delete
register_setting('updraft-options-group', 'updraft_encryptionphrase');
[159] Fix | Delete
register_setting('updraft-options-group', 'updraft_service', array($updraftplus, 'just_one'));
[160] Fix | Delete
[161] Fix | Delete
$services_to_register = array_keys($updraftplus->backup_methods);
[162] Fix | Delete
foreach ($services_to_register as $service) {
[163] Fix | Delete
register_setting('updraft-options-group', 'updraft_'.$service);
[164] Fix | Delete
// We have to add the filter manually in order to get the second parameter passed through (register_setting() only registers with one parameter)
[165] Fix | Delete
add_filter('sanitize_option_updraft_'.$service, array($updraftplus, 'storage_options_filter'), 10, 2);
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
register_setting('updraft-options-group', 'updraft_auto_updates', 'absint');
[169] Fix | Delete
register_setting('updraft-options-group', 'updraft_ssl_nossl', 'absint');
[170] Fix | Delete
register_setting('updraft-options-group', 'updraft_log_syslog', 'absint');
[171] Fix | Delete
register_setting('updraft-options-group', 'updraft_ssl_useservercerts', 'absint');
[172] Fix | Delete
register_setting('updraft-options-group', 'updraft_ssl_disableverify', 'absint');
[173] Fix | Delete
[174] Fix | Delete
register_setting('updraft-options-group', 'updraft_split_every', array($updraftplus_admin, 'optionfilter_split_every'));
[175] Fix | Delete
[176] Fix | Delete
register_setting('updraft-options-group', 'updraft_dir', array('UpdraftPlus_Manipulation_Functions', 'prune_updraft_dir_prefix'));
[177] Fix | Delete
[178] Fix | Delete
register_setting('updraft-options-group', 'updraft_report_warningsonly', array($updraftplus_admin, 'return_array'));
[179] Fix | Delete
register_setting('updraft-options-group', 'updraft_report_wholebackup', array($updraftplus_admin, 'return_array'));
[180] Fix | Delete
register_setting('updraft-options-group', 'updraft_report_dbbackup', array($updraftplus_admin, 'return_array'));
[181] Fix | Delete
[182] Fix | Delete
register_setting('updraft-options-group', 'updraft_autobackup_default', 'absint');
[183] Fix | Delete
register_setting('updraft-options-group', 'updraft_delete_local', 'absint');
[184] Fix | Delete
register_setting('updraft-options-group', 'updraft_debug_mode', 'absint');
[185] Fix | Delete
register_setting('updraft-options-group', 'updraft_extradbs');
[186] Fix | Delete
register_setting('updraft-options-group', 'updraft_backupdb_nonwp', 'absint');
[187] Fix | Delete
[188] Fix | Delete
register_setting('updraft-options-group', 'updraft_include_plugins', 'absint');
[189] Fix | Delete
register_setting('updraft-options-group', 'updraft_include_themes', 'absint');
[190] Fix | Delete
register_setting('updraft-options-group', 'updraft_include_uploads', 'absint');
[191] Fix | Delete
register_setting('updraft-options-group', 'updraft_include_others', 'absint');
[192] Fix | Delete
register_setting('updraft-options-group', 'updraft_include_wpcore', 'absint');
[193] Fix | Delete
register_setting('updraft-options-group', 'updraft_include_wpcore_exclude', array('UpdraftPlus_Manipulation_Functions', 'strip_dirslash'));
[194] Fix | Delete
register_setting('updraft-options-group', 'updraft_include_more', 'absint');
[195] Fix | Delete
register_setting('updraft-options-group', 'updraft_include_more_path', array('UpdraftPlus_Manipulation_Functions', 'remove_empties'));
[196] Fix | Delete
register_setting('updraft-options-group', 'updraft_include_uploads_exclude', array('UpdraftPlus_Manipulation_Functions', 'strip_dirslash'));
[197] Fix | Delete
register_setting('updraft-options-group', 'updraft_include_others_exclude', array('UpdraftPlus_Manipulation_Functions', 'strip_dirslash'));
[198] Fix | Delete
[199] Fix | Delete
register_setting('updraft-options-group', 'updraft_starttime_files', array('UpdraftPlus_Options', 'hourminute'));
[200] Fix | Delete
register_setting('updraft-options-group', 'updraft_starttime_db', array('UpdraftPlus_Options', 'hourminute'));
[201] Fix | Delete
[202] Fix | Delete
register_setting('updraft-options-group', 'updraft_startday_files', array('UpdraftPlus_Options', 'week_or_month_day'));
[203] Fix | Delete
register_setting('updraft-options-group', 'updraft_startday_db', array('UpdraftPlus_Options', 'week_or_month_day'));
[204] Fix | Delete
[205] Fix | Delete
global $pagenow;
[206] Fix | Delete
if (is_multisite() && 'options-general.php' == $pagenow && isset($_REQUEST['page']) && 'updraftplus' == substr($_REQUEST['page'], 0, 11)) {
[207] Fix | Delete
add_action('all_admin_notices', array('UpdraftPlus_Options', 'show_admin_warning_multisite'));
[208] Fix | Delete
}
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
public static function hourminute($pot) {
[212] Fix | Delete
if (preg_match("/^([0-2]?[0-9]):([0-5][0-9])$/", $pot, $matches)) return sprintf("%02d:%s", $matches[1], $matches[2]);
[213] Fix | Delete
if ('' == $pot) return date('H:i', time()+300);
[214] Fix | Delete
return '00:00';
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
public static function week_or_month_day($pot) {
[218] Fix | Delete
$pot = absint($pot);
[219] Fix | Delete
return ($pot>28) ? 1 : $pot;
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
/**
[223] Fix | Delete
* Output information about the multisite add-on when relevant
[224] Fix | Delete
*/
[225] Fix | Delete
public static function show_admin_warning_multisite() {
[226] Fix | Delete
global $updraftplus_admin;
[227] Fix | Delete
$updraftplus_admin->show_admin_warning('<strong>'.__('UpdraftPlus warning:', 'updraftplus').'</strong> '.__('This is a WordPress multi-site (a.k.a. network) installation.', 'updraftplus').' <a href="https://updraftplus.com/shop/" target="_blank">'.__('WordPress Multisite is supported, with extra features, by UpdraftPlus Premium.', 'updraftplus').'</a> '.__('Without upgrading, UpdraftPlus allows <strong>every</strong> blog admin who can modify plugin settings to backup (and hence access the data, including passwords, from) and restore (including with customized modifications, e.g. changed passwords) <strong>the entire network</strong>.', 'updraftplus').' '.__('(This applies to all WordPress backup plugins unless they have been explicitly coded for multisite compatibility).', 'updraftplus'), 'error');
[228] Fix | Delete
}
[229] Fix | Delete
}
[230] Fix | Delete
[231] Fix | Delete
add_action('admin_init', array('UpdraftPlus_Options', 'admin_init'));
[232] Fix | Delete
add_action('admin_menu', array('UpdraftPlus_Options', 'add_admin_pages'));
[233] Fix | Delete
[234] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function