| 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 get_updraft_option($option, $default = null) { |
| 13 |
return get_option($option, $default); |
| 14 |
} |
| 15 |
|
| 16 |
public static function update_updraft_option($option, $value) { |
| 17 |
update_option($option, $value); |
| 18 |
} |
| 19 |
|
| 20 |
public static function delete_updraft_option($option) { |
| 21 |
delete_option($option, $value); |
| 22 |
} |
| 23 |
|
| 24 |
public static function add_admin_pages() { |
| 25 |
global $updraftplus; |
| 26 |
add_submenu_page('options-general.php', "UpdraftPlus", "UpdraftPlus", "manage_options", "updraftplus", array($updraftplus, "settings_output")); |
| 27 |
} |
| 28 |
|
| 29 |
public static function options_form_begin() { |
| 30 |
echo '<form method="post" action="options.php">'; |
| 31 |
settings_fields('updraft-options-group'); |
| 32 |
} |
| 33 |
|
| 34 |
public static function admin_init() { |
| 35 |
|
| 36 |
global $updraftplus; |
| 37 |
register_setting('updraft-options-group', 'updraft_interval', array($updraftplus, 'schedule_backup') ); |
| 38 |
register_setting('updraft-options-group', 'updraft_interval_database', array($updraftplus, 'schedule_backup_database') ); |
| 39 |
register_setting('updraft-options-group', 'updraft_retain', array($updraftplus, 'retain_range') ); |
| 40 |
register_setting('updraft-options-group', 'updraft_retain_db', array($updraftplus, 'retain_range') ); |
| 41 |
register_setting('updraft-options-group', 'updraft_encryptionphrase'); |
| 42 |
register_setting('updraft-options-group', 'updraft_service' ); |
| 43 |
|
| 44 |
register_setting('updraft-options-group', 'updraft_s3_login' ); |
| 45 |
register_setting('updraft-options-group', 'updraft_s3_pass' ); |
| 46 |
register_setting('updraft-options-group', 'updraft_s3_remote_path' ); |
| 47 |
|
| 48 |
register_setting('updraft-options-group', 'updraft_dropbox_appkey' ); |
| 49 |
register_setting('updraft-options-group', 'updraft_dropbox_secret' ); |
| 50 |
register_setting('updraft-options-group', 'updraft_dropbox_folder' ); |
| 51 |
|
| 52 |
register_setting('updraft-options-group', 'updraft_googledrive_clientid', array($updraftplus, 'googledrive_clientid_checkchange') ); |
| 53 |
register_setting('updraft-options-group', 'updraft_googledrive_secret' ); |
| 54 |
register_setting('updraft-options-group', 'updraft_googledrive_remotepath' ); |
| 55 |
register_setting('updraft-options-group', 'updraft_ftp_login' ); |
| 56 |
register_setting('updraft-options-group', 'updraft_ftp_pass' ); |
| 57 |
register_setting('updraft-options-group', 'updraft_ftp_remote_path' ); |
| 58 |
register_setting('updraft-options-group', 'updraft_server_address' ); |
| 59 |
register_setting('updraft-options-group', 'updraft_dir' ); |
| 60 |
register_setting('updraft-options-group', 'updraft_email'); |
| 61 |
register_setting('updraft-options-group', 'updraft_delete_local', 'absint' ); |
| 62 |
register_setting('updraft-options-group', 'updraft_debug_mode', 'absint' ); |
| 63 |
register_setting('updraft-options-group', 'updraft_include_plugins', 'absint' ); |
| 64 |
register_setting('updraft-options-group', 'updraft_include_themes', 'absint' ); |
| 65 |
register_setting('updraft-options-group', 'updraft_include_uploads', 'absint' ); |
| 66 |
register_setting('updraft-options-group', 'updraft_include_others', 'absint' ); |
| 67 |
register_setting('updraft-options-group', 'updraft_include_others_exclude' ); |
| 68 |
|
| 69 |
if (is_multisite()) { |
| 70 |
add_action('admin_notices', array('UpdraftPlus_Options', 'show_admin_warning_multisite') ); |
| 71 |
} |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
public static function show_admin_warning_multisite() { |
| 76 |
|
| 77 |
global $updraftplus; |
| 78 |
|
| 79 |
$updraftplus->show_admin_warning('<strong>UpdraftPlus warning:</strong> This is a WordPress multi-site (a.k.a. network) installation. <a href="http://updraftplus.com">WordPress Multisite is supported by UpdraftPlus Premium</a>. Non-premium UpdraftPlus does not support multi-site installations securely. <strong>Every</strong> blog admin can both 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>. Unless you are the only blog admin user across the entire network, you should immediately de-active UpdraftPlus. (This applies to all WordPress backup plugins unless they have been explicitly coded for multisite compatibility).', "error"); |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
} |
| 85 |
|
| 86 |
add_action('admin_init', array('UpdraftPlus_Options', 'admin_init')); |
| 87 |
add_action('admin_menu', array('UpdraftPlus_Options', 'add_admin_pages')); |
| 88 |
|
| 89 |
?> |