Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../central
File: updraftplus.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if (!interface_exists('UpdraftCentral_Host_Interface')) require_once('interface.php');
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* This class is the basic bridge between the UpdraftCentral and UpdraftPlus.
[5] Fix | Delete
*/
[6] Fix | Delete
class UpdraftPlus_Host implements UpdraftCentral_Host_Interface {
[7] Fix | Delete
[8] Fix | Delete
const PLUGIN_NAME = 'updraftplus';
[9] Fix | Delete
[10] Fix | Delete
private $translations;
[11] Fix | Delete
[12] Fix | Delete
protected static $_instance = null;
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Creates an instance of this class. Singleton Pattern
[16] Fix | Delete
*
[17] Fix | Delete
* @return object Instance of this class
[18] Fix | Delete
*/
[19] Fix | Delete
public static function instance() {
[20] Fix | Delete
if (empty(self::$_instance)) {
[21] Fix | Delete
self::$_instance = new self();
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
return self::$_instance;
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Class constructor
[29] Fix | Delete
*/
[30] Fix | Delete
public function __construct() {
[31] Fix | Delete
add_action('updraftplus_debugtools_dashboard', array($this, 'debugtools_dashboard'), 20);
[32] Fix | Delete
[33] Fix | Delete
$this->maybe_initialize_required_objects();
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Retrieves or shows a message from the translations collection based on its identifier key
[38] Fix | Delete
*
[39] Fix | Delete
* @param string $key The ID of the the message
[40] Fix | Delete
* @param bool $echo Indicate whether the message is to be shown directly (echoed) or just for retrieval
[41] Fix | Delete
*
[42] Fix | Delete
* @return string/void
[43] Fix | Delete
*/
[44] Fix | Delete
public function retrieve_show_message($key, $echo = false) {
[45] Fix | Delete
if (empty($key) || !isset($this->translations[$key])) return '';
[46] Fix | Delete
[47] Fix | Delete
if ($echo) {
[48] Fix | Delete
echo $this->translations[$key];
[49] Fix | Delete
return;
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
return $this->translations[$key];
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* Below are interface methods' implementations that are required by UpdraftCentral to function properly. Please
[57] Fix | Delete
* see the "interface.php" to check all the required interface methods.
[58] Fix | Delete
*/
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Checks whether the plugin's DIR constant is currently define or not
[62] Fix | Delete
*
[63] Fix | Delete
* @return bool
[64] Fix | Delete
*/
[65] Fix | Delete
public function is_host_dir_set() {
[66] Fix | Delete
return defined('UPDRAFTPLUS_DIR') ? true : false;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Retrieves the filter used by UpdraftPlus to log errors or certain events
[71] Fix | Delete
*
[72] Fix | Delete
* @return string
[73] Fix | Delete
*/
[74] Fix | Delete
public function get_logline_filter() {
[75] Fix | Delete
return 'updraftplus_logline';
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Checks whether debug mod is set
[80] Fix | Delete
*
[81] Fix | Delete
* @return bool
[82] Fix | Delete
*/
[83] Fix | Delete
public function get_debug_mode() {
[84] Fix | Delete
return $this->get_option('updraft_debug_mode');
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Gets an RPC object, and sets some defaults on it that we always want
[89] Fix | Delete
*
[90] Fix | Delete
* @param string $indicator_name indicator name
[91] Fix | Delete
* @return array|bool
[92] Fix | Delete
*/
[93] Fix | Delete
public function get_udrpc($indicator_name) {
[94] Fix | Delete
global $updraftplus;
[95] Fix | Delete
[96] Fix | Delete
if ($updraftplus) {
[97] Fix | Delete
return $updraftplus->get_udrpc($indicator_name);
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
return false;
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Used as a central location (to avoid repetition) to register or de-register hooks into the WP HTTP API
[105] Fix | Delete
*
[106] Fix | Delete
* @param bool $register True to register, false to de-register
[107] Fix | Delete
* @return void
[108] Fix | Delete
*/
[109] Fix | Delete
public function register_wp_http_option_hooks($register = true) {
[110] Fix | Delete
global $updraftplus;
[111] Fix | Delete
[112] Fix | Delete
if ($updraftplus) {
[113] Fix | Delete
$updraftplus->register_wp_http_option_hooks($register);
[114] Fix | Delete
}
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
/**
[118] Fix | Delete
* Retrieves the class name of the host plugin
[119] Fix | Delete
*
[120] Fix | Delete
* @return string|bool
[121] Fix | Delete
*/
[122] Fix | Delete
public function get_class_name() {
[123] Fix | Delete
global $updraftplus;
[124] Fix | Delete
[125] Fix | Delete
if ($updraftplus) {
[126] Fix | Delete
return get_class($updraftplus);
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
return false;
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* Returns the instance of the host plugin
[134] Fix | Delete
*
[135] Fix | Delete
* @return object|bool
[136] Fix | Delete
*/
[137] Fix | Delete
public function get_instance() {
[138] Fix | Delete
global $updraftplus;
[139] Fix | Delete
[140] Fix | Delete
if ($updraftplus) {
[141] Fix | Delete
return $updraftplus;
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
return false;
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
/**
[148] Fix | Delete
* Returns the admin instance of the host plugin
[149] Fix | Delete
*
[150] Fix | Delete
* @return object|bool
[151] Fix | Delete
*/
[152] Fix | Delete
public function get_admin_instance() {
[153] Fix | Delete
global $updraftplus_admin;
[154] Fix | Delete
[155] Fix | Delete
if ($updraftplus_admin) {
[156] Fix | Delete
return $updraftplus_admin;
[157] Fix | Delete
} else {
[158] Fix | Delete
if (defined('UPDRAFTPLUS_DIR') && file_exists(UPDRAFTPLUS_DIR.'/admin.php')) {
[159] Fix | Delete
include_once(UPDRAFTPLUS_DIR.'/admin.php');
[160] Fix | Delete
$updraftplus_admin = new UpdraftPlus_Admin();
[161] Fix | Delete
return $updraftplus_admin;
[162] Fix | Delete
}
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
return false;
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
/**
[169] Fix | Delete
* Retrieves the host plugin's Options class
[170] Fix | Delete
*
[171] Fix | Delete
* @return class|bool
[172] Fix | Delete
*/
[173] Fix | Delete
public function get_option_class() {
[174] Fix | Delete
if ($this->has_options()) {
[175] Fix | Delete
return UpdraftPlus_Options;
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
return false;
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
/**
[182] Fix | Delete
* Checks whether the host plugin's Options class exists
[183] Fix | Delete
*
[184] Fix | Delete
* @return bool
[185] Fix | Delete
*/
[186] Fix | Delete
public function has_options() {
[187] Fix | Delete
return class_exists('UpdraftPlus_Options');
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
/**
[191] Fix | Delete
* Updates a specific option's value
[192] Fix | Delete
*
[193] Fix | Delete
* @param string $option Specify option name
[194] Fix | Delete
* @param string $value Specify option value
[195] Fix | Delete
* @param bool $use_cache Whether or not to use the WP options cache
[196] Fix | Delete
* @param string $autoload Whether to autoload (only takes effect on a change of value)
[197] Fix | Delete
*
[198] Fix | Delete
* @return bool
[199] Fix | Delete
*/
[200] Fix | Delete
public function update_option($option, $value, $use_cache = true, $autoload = 'yes') {
[201] Fix | Delete
if ($this->has_options()) {
[202] Fix | Delete
return UpdraftPlus_Options::update_updraft_option($option, $value, $use_cache, $autoload);
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
return false;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
/**
[209] Fix | Delete
* Retrieves a specific option's value
[210] Fix | Delete
*
[211] Fix | Delete
* @param string $option Specify option name
[212] Fix | Delete
* @param mixed $default Optional. The default value to return when option is not found
[213] Fix | Delete
*
[214] Fix | Delete
* @return mixed|bool
[215] Fix | Delete
*/
[216] Fix | Delete
public function get_option($option, $default = null) {
[217] Fix | Delete
if ($this->has_options()) {
[218] Fix | Delete
return UpdraftPlus_Options::get_updraft_option($option, $default);
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
return false;
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
/**
[225] Fix | Delete
* Returns the current version of the host plugin
[226] Fix | Delete
*
[227] Fix | Delete
* @return string|bool
[228] Fix | Delete
*/
[229] Fix | Delete
public function get_version() {
[230] Fix | Delete
global $updraftplus;
[231] Fix | Delete
[232] Fix | Delete
if ($updraftplus) {
[233] Fix | Delete
return $updraftplus->version;
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
return false;
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
/**
[240] Fix | Delete
* Returns the filesystem class of the host's plugin
[241] Fix | Delete
*
[242] Fix | Delete
* @return class|bool
[243] Fix | Delete
*/
[244] Fix | Delete
public function get_filesystem_functions() {
[245] Fix | Delete
if ($this->has_filesystem_functions()) {
[246] Fix | Delete
return UpdraftPlus_Filesystem_Functions;
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
return false;
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
/**
[253] Fix | Delete
* Checks whether the filesystem class of the host plugin exists
[254] Fix | Delete
*
[255] Fix | Delete
* @return bool
[256] Fix | Delete
*/
[257] Fix | Delete
public function has_filesystem_functions() {
[258] Fix | Delete
return class_exists('UpdraftPlus_Filesystem_Functions');
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
/**
[262] Fix | Delete
* Checks whether force debugging is set
[263] Fix | Delete
*
[264] Fix | Delete
* @return bool
[265] Fix | Delete
*/
[266] Fix | Delete
public function is_force_debug() {
[267] Fix | Delete
return (defined('UPDRAFTPLUS_UDRPC_FORCE_DEBUG') && UPDRAFTPLUS_UDRPC_FORCE_DEBUG) ? true : false;
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
/**
[271] Fix | Delete
* Adds a section to the 'advanced tools' page for generating UpdraftCentral keys. Called by a filter
[272] Fix | Delete
* inside the constructor method of this class.
[273] Fix | Delete
*
[274] Fix | Delete
* @return void
[275] Fix | Delete
*/
[276] Fix | Delete
public function debugtools_dashboard() {
[277] Fix | Delete
global $updraftcentral_main;
[278] Fix | Delete
[279] Fix | Delete
if (!class_exists('UpdraftCentral_Main')) {
[280] Fix | Delete
if (defined('UPDRAFTCENTRAL_CLIENT_DIR') && file_exists(UPDRAFTCENTRAL_CLIENT_DIR.'/bootstrap.php')) {
[281] Fix | Delete
include_once(UPDRAFTCENTRAL_CLIENT_DIR.'/bootstrap.php');
[282] Fix | Delete
$updraftcentral_main = new UpdraftCentral_Main();
[283] Fix | Delete
}
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
if ($updraftcentral_main) {
[287] Fix | Delete
$updraftcentral_main->debugtools_dashboard();
[288] Fix | Delete
}
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
/**
[292] Fix | Delete
* Initializes required objects (if not yet initialized) for UpdraftCentral usage
[293] Fix | Delete
*
[294] Fix | Delete
* @return void
[295] Fix | Delete
*/
[296] Fix | Delete
private function maybe_initialize_required_objects() {
[297] Fix | Delete
global $updraftplus;
[298] Fix | Delete
[299] Fix | Delete
if (!class_exists('UpdraftPlus')) {
[300] Fix | Delete
if (defined('UPDRAFTPLUS_DIR') && file_exists(UPDRAFTPLUS_DIR.'/class-updraftplus.php')) {
[301] Fix | Delete
include_once(UPDRAFTPLUS_DIR.'/class-updraftplus.php');
[302] Fix | Delete
if (empty($updraftplus) || !is_a($updraftplus, 'UpdraftPlus')) {
[303] Fix | Delete
$updraftplus = new UpdraftPlus();
[304] Fix | Delete
}
[305] Fix | Delete
}
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
if (!class_exists('UpdraftPlus_Options')) {
[309] Fix | Delete
if (defined('UPDRAFTPLUS_DIR') && file_exists(UPDRAFTPLUS_DIR.'/options.php')) {
[310] Fix | Delete
require_once(UPDRAFTPLUS_DIR.'/options.php');
[311] Fix | Delete
}
[312] Fix | Delete
}
[313] Fix | Delete
[314] Fix | Delete
if (!class_exists('UpdraftPlus_Filesystem_Functions')) {
[315] Fix | Delete
if (defined('UPDRAFTPLUS_DIR') && file_exists(UPDRAFTPLUS_DIR.'/includes/class-filesystem-functions.php')) {
[316] Fix | Delete
require_once(UPDRAFTPLUS_DIR.'/includes/class-filesystem-functions.php');
[317] Fix | Delete
}
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
// Load updraftplus translations
[321] Fix | Delete
if (defined('UPDRAFTCENTRAL_CLIENT_DIR') && file_exists(UPDRAFTCENTRAL_CLIENT_DIR.'/translations-updraftplus.php')) {
[322] Fix | Delete
$this->translations = include_once(UPDRAFTCENTRAL_CLIENT_DIR.'/translations-updraftplus.php');
[323] Fix | Delete
}
[324] Fix | Delete
}
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function