Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../methods
File: backup-module.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if (!defined('UPDRAFTPLUS_DIR')) die('No direct access allowed.');
[2] Fix | Delete
[3] Fix | Delete
abstract class UpdraftPlus_BackupModule {
[4] Fix | Delete
[5] Fix | Delete
private $_options;
[6] Fix | Delete
[7] Fix | Delete
private $_instance_id;
[8] Fix | Delete
[9] Fix | Delete
private $_storage;
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Store options (within this class) for this remote storage module. There is also a parameter for saving to the permanent storage (i.e. database).
[13] Fix | Delete
*
[14] Fix | Delete
* @param array $options array of options to store
[15] Fix | Delete
* @param Boolean $save whether or not to also save the options to the database
[16] Fix | Delete
* @param null|String $instance_id optionally set the instance ID for this instance at the same time. This is required if you have not already set an instance ID with set_instance_id()
[17] Fix | Delete
* @return void|Boolean If saving to DB, then the result of the DB save operation is returned.
[18] Fix | Delete
*/
[19] Fix | Delete
public function set_options($options, $save = false, $instance_id = null) {
[20] Fix | Delete
[21] Fix | Delete
$this->_options = $options;
[22] Fix | Delete
[23] Fix | Delete
// Remove any previously-stored storage object, because this is usually tied to the options
[24] Fix | Delete
if (!empty($this->_storage)) unset($this->_storage);
[25] Fix | Delete
[26] Fix | Delete
if ($instance_id) $this->set_instance_id($instance_id);
[27] Fix | Delete
[28] Fix | Delete
if ($save) return $this->save_options();
[29] Fix | Delete
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Saves the current options to the database. This is a private function; external callers should use set_options().
[34] Fix | Delete
*
[35] Fix | Delete
* @throws Exception if trying to save options without indicating an instance_id, or if the remote storage module does not have the multi-option capability
[36] Fix | Delete
*/
[37] Fix | Delete
private function save_options() {
[38] Fix | Delete
[39] Fix | Delete
if (!$this->supports_feature('multi_options')) {
[40] Fix | Delete
throw new Exception('save_options() can only be called on a storage method which supports multi_options (this module, '.$this->get_id().', does not)');
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
if (!$this->_instance_id) {
[44] Fix | Delete
throw new Exception('save_options() requires an instance ID, but was called without setting one (either directly or via set_instance_id())');
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
$current_db_options = UpdraftPlus_Storage_Methods_Interface::update_remote_storage_options_format($this->get_id());
[48] Fix | Delete
[49] Fix | Delete
if (is_wp_error($current_db_options)) {
[50] Fix | Delete
throw new Exception('save_options(): options fetch/update failed ('.$current_db_options->get_error_code().': '.$current_db_options->get_error_message().')');
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
$current_db_options['settings'][$this->_instance_id] = $this->_options;
[54] Fix | Delete
[55] Fix | Delete
return UpdraftPlus_Options::update_updraft_option('updraft_'.$this->get_id(), $current_db_options);
[56] Fix | Delete
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Retrieve default options for this remote storage module.
[61] Fix | Delete
* This method would normally be over-ridden by the child.
[62] Fix | Delete
*
[63] Fix | Delete
* @return Array - an array of options
[64] Fix | Delete
*/
[65] Fix | Delete
public function get_default_options() {
[66] Fix | Delete
return array();
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Check whether options have been set up by the user, or not
[71] Fix | Delete
* This method would normally be over-ridden by the child.
[72] Fix | Delete
*
[73] Fix | Delete
* @param Array $opts - the potential options
[74] Fix | Delete
*
[75] Fix | Delete
* @return Boolean
[76] Fix | Delete
*/
[77] Fix | Delete
public function options_exist($opts) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
[78] Fix | Delete
return false;
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Retrieve a list of supported features for this storage method
[83] Fix | Delete
* This method should be over-ridden by methods supporting new
[84] Fix | Delete
* features.
[85] Fix | Delete
*
[86] Fix | Delete
* Keys are strings, and values are booleans.
[87] Fix | Delete
*
[88] Fix | Delete
* Currently known features:
[89] Fix | Delete
*
[90] Fix | Delete
* - multi_options : indicates that the remote storage module
[91] Fix | Delete
* can handle its options being in the Feb-2017 multi-options
[92] Fix | Delete
* format. N.B. This only indicates options handling, not any
[93] Fix | Delete
* other multi-destination options.
[94] Fix | Delete
*
[95] Fix | Delete
* - multi_servers : not implemented yet: indicates that the
[96] Fix | Delete
* remote storage module can handle multiple servers at backup
[97] Fix | Delete
* time. This should not be specified without multi_options.
[98] Fix | Delete
* multi_options without multi_servers is fine - it will just
[99] Fix | Delete
* cause only the first entry in the options array to be used.
[100] Fix | Delete
*
[101] Fix | Delete
* - config_templates : not implemented yet: indicates that
[102] Fix | Delete
* the remote storage module can output its configuration in
[103] Fix | Delete
* Handlebars format via the get_configuration_template() method.
[104] Fix | Delete
*
[105] Fix | Delete
* - conditional_logic : indicates that the remote storage module
[106] Fix | Delete
* can handle predefined logics regarding how backups should be
[107] Fix | Delete
* sent to the remote storage
[108] Fix | Delete
*
[109] Fix | Delete
* @return Array - an array of supported features (any features not
[110] Fix | Delete
* mentioned are assumed to not be supported)
[111] Fix | Delete
*/
[112] Fix | Delete
public function get_supported_features() {
[113] Fix | Delete
return array();
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* This method should only be called if the feature 'multi storage' is supported. In that case, it returns a template with information about the remote storage. The code below is a placeholder, and methods supporting the feature should always over-ride it.
[118] Fix | Delete
*
[119] Fix | Delete
* @return String - HTML template
[120] Fix | Delete
*/
[121] Fix | Delete
public function get_pre_configuration_template() {
[122] Fix | Delete
return $this->get_id().": called, but not implemented in the child class (coding error)";
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* This method should only be called if the feature 'config templates' is supported. In that case, it returns a template with appropriate placeholders for specific settings. The code below is a placeholder, and methods supporting the feature should always over-ride it.
[127] Fix | Delete
*
[128] Fix | Delete
* @return String - HTML template
[129] Fix | Delete
*/
[130] Fix | Delete
public function get_configuration_template() {
[131] Fix | Delete
return $this->get_id().": called, but not implemented in the child class (coding error)";
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
/**
[135] Fix | Delete
* This method will set the stored storage object to that indicated
[136] Fix | Delete
*
[137] Fix | Delete
* @param Object $storage - the storage client
[138] Fix | Delete
*/
[139] Fix | Delete
public function set_storage($storage) {
[140] Fix | Delete
$this->_storage = $storage;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
* This method will return the stored storage client
[145] Fix | Delete
*
[146] Fix | Delete
* @return Object - the stored remote storage client
[147] Fix | Delete
*/
[148] Fix | Delete
public function get_storage() {
[149] Fix | Delete
if (!empty($this->_storage)) return $this->_storage;
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
/**
[153] Fix | Delete
* Outputs id and name fields, as if currently within an input tag
[154] Fix | Delete
*
[155] Fix | Delete
* This assumes standardised options handling (i.e. that the options array is updraft_(method-id))
[156] Fix | Delete
*
[157] Fix | Delete
* @param Array|String $field - the field identifiers
[158] Fix | Delete
* @param Boolean $return_instead_of_echo - tells the method if it should return the output or echo it to page
[159] Fix | Delete
*/
[160] Fix | Delete
public function output_settings_field_name_and_id($field, $return_instead_of_echo = false) {
[161] Fix | Delete
[162] Fix | Delete
$method_id = $this->get_id();
[163] Fix | Delete
[164] Fix | Delete
$instance_id = $this->supports_feature('config_templates') ? '{{instance_id}}' : $this->_instance_id;
[165] Fix | Delete
[166] Fix | Delete
$id = '';
[167] Fix | Delete
$name = '';
[168] Fix | Delete
[169] Fix | Delete
if (is_array($field)) {
[170] Fix | Delete
foreach ($field as $value) {
[171] Fix | Delete
$id .= '_'.$value;
[172] Fix | Delete
$name .= '['.$value.']';
[173] Fix | Delete
}
[174] Fix | Delete
} else {
[175] Fix | Delete
$id = '_'.$field;
[176] Fix | Delete
$name = '['.$field.']';
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
$output = "id=\"updraft_${method_id}${id}_${instance_id}\" name=\"updraft_${method_id}[settings][${instance_id}]${name}\" ";
[180] Fix | Delete
[181] Fix | Delete
if ($return_instead_of_echo) {
[182] Fix | Delete
return $output;
[183] Fix | Delete
} else {
[184] Fix | Delete
echo $output;
[185] Fix | Delete
}
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
/**
[189] Fix | Delete
* Get the CSS ID
[190] Fix | Delete
*
[191] Fix | Delete
* @param String $field - the field identifier to return a CSS ID for
[192] Fix | Delete
*
[193] Fix | Delete
* @return String
[194] Fix | Delete
*/
[195] Fix | Delete
public function get_css_id($field) {
[196] Fix | Delete
$method_id = $this->get_id();
[197] Fix | Delete
$instance_id = $this->supports_feature('config_templates') ? '{{instance_id}}' : $this->_instance_id;
[198] Fix | Delete
return "updraft_${method_id}_${field}_${instance_id}";
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
/**
[202] Fix | Delete
* Get handlebarsjs template
[203] Fix | Delete
* This deals with any boiler-plate, prior to calling config_print()
[204] Fix | Delete
*
[205] Fix | Delete
* @uses self::config_print()
[206] Fix | Delete
* @uses self::get_configuration_template()
[207] Fix | Delete
*
[208] Fix | Delete
* return handlebarsjs template or html
[209] Fix | Delete
*/
[210] Fix | Delete
public function get_template() {
[211] Fix | Delete
ob_start();
[212] Fix | Delete
// Allow methods to not use this hidden field, if they do not output any settings (to prevent their saved settings being over-written by just this hidden field)
[213] Fix | Delete
if ($this->print_shared_settings_fields()) {
[214] Fix | Delete
?><tr class="<?php echo $this->get_css_classes(); ?>"><input type="hidden" name="updraft_<?php echo $this->get_id();?>[version]" value="1"></tr><?php
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
if ($this->supports_feature('config_templates')) {
[218] Fix | Delete
?>
[219] Fix | Delete
{{#if first_instance}}
[220] Fix | Delete
<?php
[221] Fix | Delete
[222] Fix | Delete
$this->get_pre_configuration_template();
[223] Fix | Delete
[224] Fix | Delete
if ($this->supports_feature('multi_storage')) {
[225] Fix | Delete
do_action('updraftplus_config_print_add_multi_storage', $this->get_id(), $this);
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
?>
[229] Fix | Delete
{{/if}}
[230] Fix | Delete
<?php
[231] Fix | Delete
do_action('updraftplus_config_print_before_storage', $this->get_id(), $this);
[232] Fix | Delete
if ('updraftvault' !== $this->get_id()) do_action('updraftplus_config_print_add_conditional_logic', $this->get_id(), $this);
[233] Fix | Delete
if ($this->supports_feature('multi_storage')) {
[234] Fix | Delete
do_action('updraftplus_config_print_add_instance_label', $this->get_id(), $this);
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
$template = ob_get_clean();
[238] Fix | Delete
$template .= $this->get_configuration_template();
[239] Fix | Delete
if ('updraftvault' === $this->get_id()) {
[240] Fix | Delete
ob_start();
[241] Fix | Delete
do_action('updraftplus_config_print_add_conditional_logic', $this->get_id(), $this);
[242] Fix | Delete
$template .= ob_get_clean();
[243] Fix | Delete
}
[244] Fix | Delete
} else {
[245] Fix | Delete
do_action('updraftplus_config_print_before_storage', $this->get_id(), $this);
[246] Fix | Delete
do_action('updraftplus_config_print_add_conditional_logic', $this->get_id(), $this);
[247] Fix | Delete
// N.B. These are mutually exclusive: config_print() is not used if config_templates is supported. So, even during transition, the UpdraftPlus_BackupModule instance only needs to support one of the two, not both.
[248] Fix | Delete
$this->config_print();
[249] Fix | Delete
$template = ob_get_clean();
[250] Fix | Delete
}
[251] Fix | Delete
return $template;
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
/**
[255] Fix | Delete
* Modifies handerbar template options. Other child class can extend it.
[256] Fix | Delete
*
[257] Fix | Delete
* @param array $opts
[258] Fix | Delete
* @return Array - Modified handerbar template options
[259] Fix | Delete
*/
[260] Fix | Delete
public function transform_options_for_template($opts) {
[261] Fix | Delete
return $opts;
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
/**
[265] Fix | Delete
* Gives settings keys which values should not passed to handlebarsjs context.
[266] Fix | Delete
* The settings stored in UD in the database sometimes also include internal information that it would be best not to send to the front-end (so that it can't be stolen by a man-in-the-middle attacker)
[267] Fix | Delete
*
[268] Fix | Delete
* @return Array - Settings array keys which should be filtered
[269] Fix | Delete
*/
[270] Fix | Delete
public function filter_frontend_settings_keys() {
[271] Fix | Delete
return array();
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
/**
[275] Fix | Delete
* Over-ride this to allow methods to not use the hidden version field, if they do not output any settings (to prevent their saved settings being over-written by just this hidden field
[276] Fix | Delete
*
[277] Fix | Delete
* @return [boolean] - return true to output the version field or false to not output the field
[278] Fix | Delete
*/
[279] Fix | Delete
public function print_shared_settings_fields() {
[280] Fix | Delete
return true;
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
/**
[284] Fix | Delete
* Prints out the configuration section for a particular module. This is now (Sep 2017) considered deprecated; things are being ported over to get_configuration_template(), indicated via the feature 'config_templates'.
[285] Fix | Delete
*/
[286] Fix | Delete
public function config_print() {
[287] Fix | Delete
echo $this->get_id().": module neither declares config_templates support, nor has a config_print() method (coding bug)";
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
/**
[291] Fix | Delete
* Supplies the list of keys for options to be saved in the backup job.
[292] Fix | Delete
*
[293] Fix | Delete
* @return Array
[294] Fix | Delete
*/
[295] Fix | Delete
public function get_credentials() {
[296] Fix | Delete
$keys = array('updraft_ssl_disableverify', 'updraft_ssl_nossl', 'updraft_ssl_useservercerts');
[297] Fix | Delete
if (!$this->supports_feature('multi_servers')) $keys[] = 'updraft_'.$this->get_id();
[298] Fix | Delete
return $keys;
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
/**
[302] Fix | Delete
* Returns a space-separated list of CSS classes suitable for rows in the configuration section
[303] Fix | Delete
*
[304] Fix | Delete
* @param Boolean $include_instance - a boolean value to indicate if we want to include the instance_id in the css class, we may not want to include the instance if it's for a UI element that we don't want to be removed along with other UI elements that do include a instance id.
[305] Fix | Delete
*
[306] Fix | Delete
* @returns String - the list of CSS classes
[307] Fix | Delete
*/
[308] Fix | Delete
public function get_css_classes($include_instance = true) {
[309] Fix | Delete
$classes = 'updraftplusmethod '.$this->get_id();
[310] Fix | Delete
if (!$include_instance) return $classes;
[311] Fix | Delete
if ($this->supports_feature('multi_options')) {
[312] Fix | Delete
if ($this->supports_feature('config_templates')) {
[313] Fix | Delete
$classes .= ' '.$this->get_id().'-{{instance_id}}';
[314] Fix | Delete
} else {
[315] Fix | Delete
$classes .= ' '.$this->get_id().'-'.$this->_instance_id;
[316] Fix | Delete
}
[317] Fix | Delete
}
[318] Fix | Delete
return $classes;
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
/**
[322] Fix | Delete
*
[323] Fix | Delete
* Returns HTML for a row for a test button
[324] Fix | Delete
*
[325] Fix | Delete
* @param String $title - The text to be used in the button
[326] Fix | Delete
*
[327] Fix | Delete
* @returns String - The HTML to be inserted into the settings page
[328] Fix | Delete
*/
[329] Fix | Delete
protected function get_test_button_html($title) {
[330] Fix | Delete
ob_start();
[331] Fix | Delete
$instance_id = $this->supports_feature('config_templates') ? '{{instance_id}}' : $this->_instance_id;
[332] Fix | Delete
?>
[333] Fix | Delete
<tr class="<?php echo $this->get_css_classes(); ?>">
[334] Fix | Delete
<th></th>
[335] Fix | Delete
<td><p><button id="updraft-<?php echo $this->get_id();?>-test-<?php echo $instance_id;?>" type="button" class="button-primary updraft-test-button updraft-<?php echo $this->get_id();?>-test" data-instance_id="<?php echo $instance_id;?>" data-method="<?php echo $this->get_id();?>" data-method_label="<?php echo esc_attr($title);?>"><?php printf(__('Test %s Settings', 'updraftplus'), $title);?></button></p></td>
[336] Fix | Delete
</tr>
[337] Fix | Delete
<?php
[338] Fix | Delete
return ob_get_clean();
[339] Fix | Delete
}
[340] Fix | Delete
[341] Fix | Delete
/**
[342] Fix | Delete
* Get the backup method identifier for this class
[343] Fix | Delete
*
[344] Fix | Delete
* @return String - the identifier
[345] Fix | Delete
*/
[346] Fix | Delete
public function get_id() {
[347] Fix | Delete
$class = get_class($this);
[348] Fix | Delete
// UpdraftPlus_BackupModule_
[349] Fix | Delete
return substr($class, 25);
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
/**
[353] Fix | Delete
* Get the backup method description for this class
[354] Fix | Delete
*
[355] Fix | Delete
* @return String - the identifier
[356] Fix | Delete
*/
[357] Fix | Delete
public function get_description() {
[358] Fix | Delete
global $updraftplus;
[359] Fix | Delete
[360] Fix | Delete
$methods = $updraftplus->backup_methods;
[361] Fix | Delete
[362] Fix | Delete
$id = $this->get_id();
[363] Fix | Delete
[364] Fix | Delete
return isset($methods[$id]) ? $methods[$id] : $id;
[365] Fix | Delete
}
[366] Fix | Delete
[367] Fix | Delete
/**
[368] Fix | Delete
* Sets the instance ID - for supporting multi_options
[369] Fix | Delete
*
[370] Fix | Delete
* @param String $instance_id - the instance ID
[371] Fix | Delete
*/
[372] Fix | Delete
public function set_instance_id($instance_id) {
[373] Fix | Delete
$this->_instance_id = $instance_id;
[374] Fix | Delete
}
[375] Fix | Delete
[376] Fix | Delete
/**
[377] Fix | Delete
* Sets the instance ID - for supporting multi_options
[378] Fix | Delete
*
[379] Fix | Delete
* @returns String the instance ID
[380] Fix | Delete
*/
[381] Fix | Delete
public function get_instance_id() {
[382] Fix | Delete
return $this->_instance_id;
[383] Fix | Delete
}
[384] Fix | Delete
[385] Fix | Delete
/**
[386] Fix | Delete
* Check whether this storage module supports a mentioned feature
[387] Fix | Delete
*
[388] Fix | Delete
* @param String $feature - the feature concerned
[389] Fix | Delete
*
[390] Fix | Delete
* @returns Boolean
[391] Fix | Delete
*/
[392] Fix | Delete
public function supports_feature($feature) {
[393] Fix | Delete
return in_array($feature, $this->get_supported_features());
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
/**
[397] Fix | Delete
* Retrieve options for this remote storage module.
[398] Fix | Delete
* N.B. The option name instance_id is reserved and should not be used.
[399] Fix | Delete
*
[400] Fix | Delete
* @uses get_default_options
[401] Fix | Delete
*
[402] Fix | Delete
* @return Array - array of options. This will include default values for any options not set.
[403] Fix | Delete
*/
[404] Fix | Delete
public function get_options() {
[405] Fix | Delete
[406] Fix | Delete
global $updraftplus;
[407] Fix | Delete
[408] Fix | Delete
$supports_multi_options = $this->supports_feature('multi_options');
[409] Fix | Delete
[410] Fix | Delete
if (is_array($this->_options)) {
[411] Fix | Delete
// First, prioritise any options that were explicitly set. This is the eventual goal for all storage modules.
[412] Fix | Delete
$options = $this->_options;
[413] Fix | Delete
[414] Fix | Delete
} elseif (is_callable(array($this, 'get_opts'))) {
[415] Fix | Delete
// Next, get any options available via a legacy / over-ride method.
[416] Fix | Delete
[417] Fix | Delete
if ($supports_multi_options) {
[418] Fix | Delete
// This is forbidden, because get_opts() is legacy and is for methods that do not support multi-options. Supporting multi-options leads to the array format being updated, which will then break get_opts().
[419] Fix | Delete
die('Fatal error: method '.$this->get_id().' both supports multi_options and provides a get_opts method');
[420] Fix | Delete
}
[421] Fix | Delete
[422] Fix | Delete
$options = $this->get_opts();
[423] Fix | Delete
[424] Fix | Delete
} else {
[425] Fix | Delete
[426] Fix | Delete
// Next, look for job options (which in turn, falls back to saved settings if no job options were set)
[427] Fix | Delete
[428] Fix | Delete
$options = $updraftplus->get_job_option('updraft_'.$this->get_id());
[429] Fix | Delete
if (!is_array($options)) $options = array();
[430] Fix | Delete
[431] Fix | Delete
if ($supports_multi_options) {
[432] Fix | Delete
[433] Fix | Delete
if (!isset($options['version'])) {
[434] Fix | Delete
$options_full = UpdraftPlus_Storage_Methods_Interface::update_remote_storage_options_format($this->get_id());
[435] Fix | Delete
[436] Fix | Delete
if (is_wp_error($options_full)) {
[437] Fix | Delete
$updraftplus->log("Options retrieval failure: ".$options_full->get_error_code().": ".$options_full->get_error_message()." (".json_encode($options_full->get_error_data()).")");
[438] Fix | Delete
return array();
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
} else {
[442] Fix | Delete
$options_full = $options;
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
// UpdraftPlus_BackupModule::get_options() is for getting the current instance's options. So, this branch (going via the job option) is a legacy route, and hence we just give back the first one. The non-legacy route is to call the set_options() method externally.
[446] Fix | Delete
$options = reset($options_full['settings']);
[447] Fix | Delete
[448] Fix | Delete
if (false === $options) {
[449] Fix | Delete
$updraftplus->log("Options retrieval failure (no options set)");
[450] Fix | Delete
return array();
[451] Fix | Delete
}
[452] Fix | Delete
$instance_id = key($options_full['settings']);
[453] Fix | Delete
$this->set_options($options, false, $instance_id);
[454] Fix | Delete
[455] Fix | Delete
}
[456] Fix | Delete
[457] Fix | Delete
}
[458] Fix | Delete
[459] Fix | Delete
$options = apply_filters(
[460] Fix | Delete
'updraftplus_backupmodule_get_options',
[461] Fix | Delete
wp_parse_args($options, $this->get_default_options()),
[462] Fix | Delete
$this
[463] Fix | Delete
);
[464] Fix | Delete
[465] Fix | Delete
return $options;
[466] Fix | Delete
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
/**
[470] Fix | Delete
* Set job data that is local to this storage instance
[471] Fix | Delete
* (i.e. the key does not need to be unique across instances)
[472] Fix | Delete
*
[473] Fix | Delete
* @uses UpdraftPlus::jobdata_set()
[474] Fix | Delete
*
[475] Fix | Delete
* @param String $key - the key for the job data
[476] Fix | Delete
* @param Mixed $value - the data to be stored
[477] Fix | Delete
*/
[478] Fix | Delete
public function jobdata_set($key, $value) {
[479] Fix | Delete
[480] Fix | Delete
$instance_key = $this->get_id().'-'.($this->_instance_id ? $this->_instance_id : 'no_instance');
[481] Fix | Delete
[482] Fix | Delete
global $updraftplus;
[483] Fix | Delete
[484] Fix | Delete
$instance_data = $updraftplus->jobdata_get($instance_key);
[485] Fix | Delete
[486] Fix | Delete
if (!is_array($instance_data)) $instance_data = array();
[487] Fix | Delete
[488] Fix | Delete
$instance_data[$key] = $value;
[489] Fix | Delete
[490] Fix | Delete
$updraftplus->jobdata_set($instance_key, $instance_data);
[491] Fix | Delete
[492] Fix | Delete
}
[493] Fix | Delete
[494] Fix | Delete
/**
[495] Fix | Delete
* Get job data that is local to this storage instance
[496] Fix | Delete
* (i.e. the key does not need to be unique across instances)
[497] Fix | Delete
*
[498] Fix | Delete
* @uses UpdraftPlus::jobdata_get()
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function