$v) { if ($first_one) { $first_one = false; } else { $page .= '&'; } $page .= urlencode($k).'='.urlencode($v); } } if ($page) echo ' action="'.$page.'"'; if (!$allow_autocomplete) echo ' autocomplete="off"'; echo '>'; if ($settings_fields) { // This is settings_fields('updraft-options-group'), but with the referer pruned echo ""; echo ''; wp_nonce_field("updraft-options-group-options", '_wpnonce', false); $remove_query_args = array('state', 'action', 'oauth_verifier'); $referer = UpdraftPlus_Manipulation_Functions::wp_unslash(remove_query_arg($remove_query_args, $_SERVER['REQUEST_URI'])); // 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. if (substr($referer, -19, 19) == 'options-general.php' && false !== strpos($_SERVER['REQUEST_URI'], '?')) $referer .= '?page=updraftplus'; $referer_field = ''; echo $referer_field; } } /** * Runs upon the WordPress action admin_init */ public static function admin_init() { static $already_inited = false; if ($already_inited) return; $already_inited = true; // If being called outside of the admin context, this may not be loaded yet if (!function_exists('register_setting')) include_once(ABSPATH.'wp-admin/includes/plugin.php'); global $updraftplus, $updraftplus_admin; register_setting('updraft-options-group', 'updraft_interval', array($updraftplus, 'schedule_backup')); register_setting('updraft-options-group', 'updraft_interval_database', array($updraftplus, 'schedule_backup_database')); register_setting('updraft-options-group', 'updraft_interval_increments', array($updraftplus, 'schedule_backup_increments')); register_setting('updraft-options-group', 'updraft_retain', array('UpdraftPlus_Manipulation_Functions', 'retain_range')); register_setting('updraft-options-group', 'updraft_retain_db', array('UpdraftPlus_Manipulation_Functions', 'retain_range')); register_setting('updraft-options-group', 'updraft_retain_extrarules'); register_setting('updraft-options-group', 'updraft_encryptionphrase'); register_setting('updraft-options-group', 'updraft_service', array($updraftplus, 'just_one')); $services_to_register = array_keys($updraftplus->backup_methods); foreach ($services_to_register as $service) { register_setting('updraft-options-group', 'updraft_'.$service); // We have to add the filter manually in order to get the second parameter passed through (register_setting() only registers with one parameter) add_filter('sanitize_option_updraft_'.$service, array($updraftplus, 'storage_options_filter'), 10, 2); } register_setting('updraft-options-group', 'updraft_auto_updates', 'absint'); register_setting('updraft-options-group', 'updraft_ssl_nossl', 'absint'); register_setting('updraft-options-group', 'updraft_log_syslog', 'absint'); register_setting('updraft-options-group', 'updraft_ssl_useservercerts', 'absint'); register_setting('updraft-options-group', 'updraft_ssl_disableverify', 'absint'); register_setting('updraft-options-group', 'updraft_split_every', array($updraftplus_admin, 'optionfilter_split_every')); register_setting('updraft-options-group', 'updraft_dir', array('UpdraftPlus_Manipulation_Functions', 'prune_updraft_dir_prefix')); register_setting('updraft-options-group', 'updraft_report_warningsonly', array($updraftplus_admin, 'return_array')); register_setting('updraft-options-group', 'updraft_report_wholebackup', array($updraftplus_admin, 'return_array')); register_setting('updraft-options-group', 'updraft_report_dbbackup', array($updraftplus_admin, 'return_array')); register_setting('updraft-options-group', 'updraft_autobackup_default', 'absint'); register_setting('updraft-options-group', 'updraft_delete_local', 'absint'); register_setting('updraft-options-group', 'updraft_debug_mode', 'absint'); register_setting('updraft-options-group', 'updraft_extradbs'); register_setting('updraft-options-group', 'updraft_backupdb_nonwp', 'absint'); register_setting('updraft-options-group', 'updraft_include_plugins', 'absint'); register_setting('updraft-options-group', 'updraft_include_themes', 'absint'); register_setting('updraft-options-group', 'updraft_include_uploads', 'absint'); register_setting('updraft-options-group', 'updraft_include_others', 'absint'); register_setting('updraft-options-group', 'updraft_include_wpcore', 'absint'); register_setting('updraft-options-group', 'updraft_include_wpcore_exclude', array('UpdraftPlus_Manipulation_Functions', 'strip_dirslash')); register_setting('updraft-options-group', 'updraft_include_more', 'absint'); register_setting('updraft-options-group', 'updraft_include_more_path', array('UpdraftPlus_Manipulation_Functions', 'remove_empties')); register_setting('updraft-options-group', 'updraft_include_uploads_exclude', array('UpdraftPlus_Manipulation_Functions', 'strip_dirslash')); register_setting('updraft-options-group', 'updraft_include_others_exclude', array('UpdraftPlus_Manipulation_Functions', 'strip_dirslash')); register_setting('updraft-options-group', 'updraft_starttime_files', array('UpdraftPlus_Options', 'hourminute')); register_setting('updraft-options-group', 'updraft_starttime_db', array('UpdraftPlus_Options', 'hourminute')); register_setting('updraft-options-group', 'updraft_startday_files', array('UpdraftPlus_Options', 'week_or_month_day')); register_setting('updraft-options-group', 'updraft_startday_db', array('UpdraftPlus_Options', 'week_or_month_day')); global $pagenow; if (is_multisite() && 'options-general.php' == $pagenow && isset($_REQUEST['page']) && 'updraftplus' == substr($_REQUEST['page'], 0, 11)) { add_action('all_admin_notices', array('UpdraftPlus_Options', 'show_admin_warning_multisite')); } } public static function hourminute($pot) { if (preg_match("/^([0-2]?[0-9]):([0-5][0-9])$/", $pot, $matches)) return sprintf("%02d:%s", $matches[1], $matches[2]); if ('' == $pot) return date('H:i', time()+300); return '00:00'; } public static function week_or_month_day($pot) { $pot = absint($pot); return ($pot>28) ? 1 : $pot; } public static function show_admin_warning_multisite() { global $updraftplus_admin; $updraftplus_admin->show_admin_warning(''.__('UpdraftPlus warning:', 'updraftplus').' '.__('This is a WordPress multi-site (a.k.a. network) installation.', 'updraftplus').' '.__('WordPress Multisite is supported, with extra features, by UpdraftPlus Premium, or the Multisite add-on.', 'updraftplus').' '.__('Without upgrading, UpdraftPlus allows every 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) the entire network.', 'updraftplus').' '.__('(This applies to all WordPress backup plugins unless they have been explicitly coded for multisite compatibility).', 'updraftplus'), 'error'); } } add_action('admin_init', array('UpdraftPlus_Options', 'admin_init')); add_action('admin_menu', array('UpdraftPlus_Options', 'add_admin_pages'));