| 1 |
<?php |
| 2 |
|
| 3 |
// Options handling |
| 4 |
if (!defined('ABSPATH')) die ('No direct access allowed'); |
| 5 |
|
| 6 |
class UpdraftPlus_Options { |
| 7 |
|
| 8 |
public static function user_can_manage() { |
| 9 |
return current_user_can('manage_options'); |
| 10 |
} |
| 11 |
|
| 12 |
public static function admin_page_url() { |
| 13 |
return admin_url('options-general.php'); |
| 14 |
} |
| 15 |
|
| 16 |
public static function admin_page() { |
| 17 |
return 'options-general.php'; |
| 18 |
} |
| 19 |
|
| 20 |
public static function get_updraft_option($option, $default = null) { |
| 21 |
return get_option($option, $default); |
| 22 |
} |
| 23 |
|
| 24 |
public static function update_updraft_option($option, $value, $use_cache = true) { |
| 25 |
update_option($option, $value); |
| 26 |
} |
| 27 |
|
| 28 |
public static function delete_updraft_option($option) { |
| 29 |
delete_option($option); |
| 30 |
} |
| 31 |
|
| 32 |
public static function add_admin_pages() { |
| 33 |
global $updraftplus_admin; |
| 34 |
add_submenu_page('options-general.php', 'UpdraftPlus', __('UpdraftPlus Backups','updraftplus'), "manage_options", "updraftplus", array($updraftplus_admin, "settings_output")); |
| 35 |
} |
| 36 |
|
| 37 |
public static function options_form_begin($settings_fields = 'updraft-options-group', $allow_autocomplete = true) { |
| 38 |
global $pagenow; |
| 39 |
echo '<form method="post" '; |
| 40 |
if ($pagenow == 'options-general.php') echo 'action="options.php"'; |
| 41 |
if (!$allow_autocomplete) echo ' autocomplete="off"'; |
| 42 |
echo '>'; |
| 43 |
if ($settings_fields) settings_fields('updraft-options-group'); |
| 44 |
} |
| 45 |
|
| 46 |
public static function admin_init() { |
| 47 |
|
| 48 |
global $updraftplus, $updraftplus_admin; |
| 49 |
register_setting('updraft-options-group', 'updraft_interval', array($updraftplus, 'schedule_backup') ); |
| 50 |
register_setting('updraft-options-group', 'updraft_interval_database', array($updraftplus, 'schedule_backup_database') ); |
| 51 |
register_setting('updraft-options-group', 'updraft_retain', array($updraftplus, 'retain_range') ); |
| 52 |
register_setting('updraft-options-group', 'updraft_retain_db', array($updraftplus, 'retain_range') ); |
| 53 |
register_setting('updraft-options-group', 'updraft_encryptionphrase'); |
| 54 |
register_setting('updraft-options-group', 'updraft_service', array($updraftplus, 'just_one')); |
| 55 |
|
| 56 |
register_setting('updraft-options-group', 'updraft_s3'); |
| 57 |
register_setting('updraft-options-group', 'updraft_dreamobjects'); |
| 58 |
register_setting('updraft-options-group', 'updraft_s3generic'); |
| 59 |
register_setting('updraft-options-group', 'updraft_cloudfiles'); |
| 60 |
|
| 61 |
register_setting('updraft-options-group', 'updraft_sftp_settings'); |
| 62 |
register_setting('updraft-options-group', 'updraft_webdav_settings', array($updraftplus, 'replace_http_with_webdav')); |
| 63 |
|
| 64 |
register_setting('updraft-options-group', 'updraft_dropbox_appkey'); |
| 65 |
register_setting('updraft-options-group', 'updraft_dropbox_secret'); |
| 66 |
register_setting('updraft-options-group', 'updraft_dropbox_folder'); |
| 67 |
|
| 68 |
register_setting('updraft-options-group', 'updraft_ssl_nossl', 'absint'); |
| 69 |
register_setting('updraft-options-group', 'updraft_log_syslog', 'absint'); |
| 70 |
register_setting('updraft-options-group', 'updraft_ssl_useservercerts', 'absint'); |
| 71 |
register_setting('updraft-options-group', 'updraft_ssl_disableverify', 'absint'); |
| 72 |
|
| 73 |
register_setting('updraft-options-group', 'updraft_googledrive_clientid', array($updraftplus, 'googledrive_clientid_checkchange') ); |
| 74 |
register_setting('updraft-options-group', 'updraft_googledrive_secret'); |
| 75 |
register_setting('updraft-options-group', 'updraft_googledrive_remotepath', array($updraftplus_admin, 'googledrive_remove_folderurlprefix') ); |
| 76 |
|
| 77 |
register_setting('updraft-options-group', 'updraft_split_every', array($updraftplus_admin, 'optionfilter_split_every') ); |
| 78 |
|
| 79 |
register_setting('updraft-options-group', 'updraft_ftp_login' ); |
| 80 |
register_setting('updraft-options-group', 'updraft_ftp_pass' ); |
| 81 |
register_setting('updraft-options-group', 'updraft_ftp_remote_path' ); |
| 82 |
|
| 83 |
register_setting('updraft-options-group', 'updraft_server_address' ); |
| 84 |
register_setting('updraft-options-group', 'updraft_dir', array($updraftplus_admin, 'prune_updraft_dir_prefix') ); |
| 85 |
register_setting('updraft-options-group', 'updraft_email', array($updraftplus, 'just_one_email')); |
| 86 |
|
| 87 |
register_setting('updraft-options-group', 'updraft_report_warningsonly', array($updraftplus_admin, 'return_array')); |
| 88 |
register_setting('updraft-options-group', 'updraft_report_wholebackup', array($updraftplus_admin, 'return_array')); |
| 89 |
|
| 90 |
register_setting('updraft-options-group', 'updraft_delete_local', 'absint' ); |
| 91 |
register_setting('updraft-options-group', 'updraft_debug_mode', 'absint' ); |
| 92 |
|
| 93 |
register_setting('updraft-options-group', 'updraft_include_plugins', 'absint' ); |
| 94 |
register_setting('updraft-options-group', 'updraft_include_themes', 'absint' ); |
| 95 |
register_setting('updraft-options-group', 'updraft_include_uploads', 'absint' ); |
| 96 |
register_setting('updraft-options-group', 'updraft_include_others', 'absint' ); |
| 97 |
register_setting('updraft-options-group', 'updraft_include_wpcore', 'absint' ); |
| 98 |
register_setting('updraft-options-group', 'updraft_include_wpcore_exclude', array($updraftplus, 'strip_dirslash')); |
| 99 |
register_setting('updraft-options-group', 'updraft_include_more', 'absint' ); |
| 100 |
register_setting('updraft-options-group', 'updraft_include_more_path', array($updraftplus, 'remove_empties')); |
| 101 |
register_setting('updraft-options-group', 'updraft_include_uploads_exclude', array($updraftplus, 'strip_dirslash')); |
| 102 |
register_setting('updraft-options-group', 'updraft_include_others_exclude', array($updraftplus, 'strip_dirslash')); |
| 103 |
|
| 104 |
register_setting('updraft-options-group', 'updraft_starttime_files', array('UpdraftPlus_Options', 'hourminute') ); |
| 105 |
register_setting('updraft-options-group', 'updraft_starttime_db', array('UpdraftPlus_Options', 'hourminute') ); |
| 106 |
|
| 107 |
register_setting('updraft-options-group', 'updraft_startday_files', array('UpdraftPlus_Options', 'weekday') ); |
| 108 |
register_setting('updraft-options-group', 'updraft_startday_db', array('UpdraftPlus_Options', 'weekday') ); |
| 109 |
|
| 110 |
global $pagenow; |
| 111 |
if (is_multisite() && $pagenow == 'options-general.php' && isset($_REQUEST['page']) && 'updraftplus' == substr($_REQUEST['page'], 0, 11)) { |
| 112 |
add_action('all_admin_notices', array('UpdraftPlus_Options', 'show_admin_warning_multisite') ); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
public static function hourminute($pot) { |
| 117 |
if (preg_match("/^[0-2][0-9]:[0-5][0-9]$/", $pot)) return $pot; |
| 118 |
if ('' == $pot) return date('H:i', time()+300); |
| 119 |
return '00:00'; |
| 120 |
} |
| 121 |
|
| 122 |
public static function weekday($pot) { |
| 123 |
$pot = absint($pot); |
| 124 |
return ($pot>6) ? 0 : $pot; |
| 125 |
} |
| 126 |
|
| 127 |
public static function show_admin_warning_multisite() { |
| 128 |
global $updraftplus_admin; |
| 129 |
$updraftplus_admin->show_admin_warning('<strong>'.__('UpdraftPlus warning:', 'updraftplus').'</strong> '.__('This is a WordPress multi-site (a.k.a. network) installation.', 'updraftplus').' <a href="http://updraftplus.com">'.__('WordPress Multisite is supported, with extra features, by UpdraftPlus Premium, or the Multisite add-on.', 'updraftplus').'</a> '.__('Without upgrading, UpdraftPlus allows <strong>every</strong> blog admin who can modify plugin settings to back up (and hence access the data, including passwords, from) and restore (including with customised 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'); |
| 130 |
} |
| 131 |
|
| 132 |
} |
| 133 |
|
| 134 |
add_action('admin_init', array('UpdraftPlus_Options', 'admin_init')); |
| 135 |
add_action('admin_menu', array('UpdraftPlus_Options', 'add_admin_pages')); |
| 136 |
|
| 137 |
?> |
| 138 |
|