Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../central/modules
File: updates.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if (!defined('UPDRAFTCENTRAL_CLIENT_DIR')) die('No access.');
[2] Fix | Delete
[3] Fix | Delete
class UpdraftCentral_Updates_Commands extends UpdraftCentral_Commands {
[4] Fix | Delete
[5] Fix | Delete
public function do_updates($updates) {
[6] Fix | Delete
[7] Fix | Delete
if (!is_array($updates)) $this->_generic_error_response('invalid_data');
[8] Fix | Delete
[9] Fix | Delete
if (!empty($updates['plugins']) && !current_user_can('update_plugins')) return $this->_generic_error_response('updates_permission_denied', 'update_plugins');
[10] Fix | Delete
[11] Fix | Delete
if (!empty($updates['themes']) && !current_user_can('update_themes')) return $this->_generic_error_response('updates_permission_denied', 'update_themes');
[12] Fix | Delete
[13] Fix | Delete
if (!empty($updates['core']) && !current_user_can('update_core')) return $this->_generic_error_response('updates_permission_denied', 'update_core');
[14] Fix | Delete
[15] Fix | Delete
if (!empty($updates['translations']) && !$this->user_can_update_translations()) return $this->_generic_error_response('updates_permission_denied', 'update_translations');
[16] Fix | Delete
[17] Fix | Delete
$this->_admin_include('plugin.php', 'update.php', 'file.php', 'template.php');
[18] Fix | Delete
$this->_frontend_include('update.php');
[19] Fix | Delete
[20] Fix | Delete
if (!empty($updates['meta']) && isset($updates['meta']['filesystem_credentials'])) {
[21] Fix | Delete
parse_str($updates['meta']['filesystem_credentials'], $filesystem_credentials);
[22] Fix | Delete
if (is_array($filesystem_credentials)) {
[23] Fix | Delete
foreach ($filesystem_credentials as $key => $value) {
[24] Fix | Delete
// Put them into $_POST, which is where request_filesystem_credentials() checks for them.
[25] Fix | Delete
$_POST[$key] = $value;
[26] Fix | Delete
}
[27] Fix | Delete
}
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
$plugins = empty($updates['plugins']) ? array() : $updates['plugins'];
[31] Fix | Delete
$plugin_updates = array();
[32] Fix | Delete
foreach ($plugins as $plugin_info) {
[33] Fix | Delete
$plugin_updates[] = $this->_update_plugin($plugin_info['plugin'], $plugin_info['slug']);
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
$themes = empty($updates['themes']) ? array() : $updates['themes'];
[37] Fix | Delete
$theme_updates = array();
[38] Fix | Delete
foreach ($themes as $theme_info) {
[39] Fix | Delete
$theme = $theme_info['theme'];
[40] Fix | Delete
$theme_updates[] = $this->_update_theme($theme);
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
$cores = empty($updates['core']) ? array() : $updates['core'];
[44] Fix | Delete
$core_updates = array();
[45] Fix | Delete
foreach ($cores as $core) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- We dont use $core but we need the AS in the foreach so it needs to stay
[46] Fix | Delete
$core_updates[] = $this->_update_core(null);
[47] Fix | Delete
// Only one (and always we go to the latest version) - i.e. we ignore the passed parameters
[48] Fix | Delete
break;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
$translation_updates = array();
[52] Fix | Delete
if (!empty($updates['translations'])) {
[53] Fix | Delete
$translation_updates[] = $this->_update_translation();
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
return $this->_response(array(
[57] Fix | Delete
'plugins' => $plugin_updates,
[58] Fix | Delete
'themes' => $theme_updates,
[59] Fix | Delete
'core' => $core_updates,
[60] Fix | Delete
'translations' => $translation_updates,
[61] Fix | Delete
));
[62] Fix | Delete
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Updates a plugin. A facade method that exposes a private updates
[67] Fix | Delete
* feature for other modules to consume.
[68] Fix | Delete
*
[69] Fix | Delete
* @param string $plugin Specific plugin to be updated
[70] Fix | Delete
* @param string $slug Unique key passed for updates
[71] Fix | Delete
*
[72] Fix | Delete
* @return array
[73] Fix | Delete
*/
[74] Fix | Delete
public function update_plugin($plugin, $slug) {
[75] Fix | Delete
return $this->_update_plugin($plugin, $slug);
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Updates a theme. A facade method that exposes a private updates
[80] Fix | Delete
* feature for other modules to consume.
[81] Fix | Delete
*
[82] Fix | Delete
* @param string $theme Specific theme to be updated
[83] Fix | Delete
*
[84] Fix | Delete
* @return array
[85] Fix | Delete
*/
[86] Fix | Delete
public function update_theme($theme) {
[87] Fix | Delete
return $this->_update_theme($theme);
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Gets available updates for a certain entity (e.g. plugin or theme). A facade method that
[92] Fix | Delete
* exposes a private updates feature for other modules to consume.
[93] Fix | Delete
*
[94] Fix | Delete
* @param string $entity The name of the entity that this request is intended for (e.g. themes or plugins)
[95] Fix | Delete
*
[96] Fix | Delete
* @return array
[97] Fix | Delete
*/
[98] Fix | Delete
public function get_item_updates($entity) {
[99] Fix | Delete
$updates = array();
[100] Fix | Delete
switch ($entity) {
[101] Fix | Delete
case 'themes':
[102] Fix | Delete
wp_update_themes();
[103] Fix | Delete
$updates = $this->maybe_add_third_party_items(get_theme_updates(), 'theme');
[104] Fix | Delete
break;
[105] Fix | Delete
case 'plugins':
[106] Fix | Delete
wp_update_plugins();
[107] Fix | Delete
$updates = $this->maybe_add_third_party_items(get_plugin_updates(), 'plugin');
[108] Fix | Delete
break;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
return $updates;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Mostly from wp_ajax_update_plugin() in wp-admin/includes/ajax-actions.php (WP 4.5.2)
[116] Fix | Delete
* Code-formatting style has been retained from the original, for ease of comparison/updating
[117] Fix | Delete
*
[118] Fix | Delete
* @param string $plugin Specific plugin to be updated
[119] Fix | Delete
* @param string $slug Unique key passed for updates
[120] Fix | Delete
* @return array
[121] Fix | Delete
*/
[122] Fix | Delete
private function _update_plugin($plugin, $slug) {
[123] Fix | Delete
[124] Fix | Delete
$status = array(
[125] Fix | Delete
'update' => 'plugin',
[126] Fix | Delete
'plugin' => $plugin,
[127] Fix | Delete
'slug' => sanitize_key($slug),
[128] Fix | Delete
'oldVersion' => '',
[129] Fix | Delete
'newVersion' => '',
[130] Fix | Delete
);
[131] Fix | Delete
[132] Fix | Delete
if (false !== strpos($plugin, '..') || false !== strpos($plugin, ':') || !preg_match('#^[^\/]#i', $plugin)) {
[133] Fix | Delete
$status['error'] = 'not_found';
[134] Fix | Delete
return $status;
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
$plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
[138] Fix | Delete
if (!isset($plugin_data['Name']) || !isset($plugin_data['Author']) || ('' == $plugin_data['Name'] && '' == $plugin_data['Author'])) {
[139] Fix | Delete
$status['error'] = 'not_found';
[140] Fix | Delete
return $status;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
if ($plugin_data['Version']) {
[144] Fix | Delete
$status['oldVersion'] = $plugin_data['Version'];
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
if (!current_user_can('update_plugins')) {
[148] Fix | Delete
$status['error'] = 'updates_permission_denied';
[149] Fix | Delete
return $status;
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
[153] Fix | Delete
[154] Fix | Delete
wp_update_plugins();
[155] Fix | Delete
[156] Fix | Delete
// WP < 3.7
[157] Fix | Delete
if (!class_exists('Automatic_Upgrader_Skin')) include_once(UPDRAFTCENTRAL_CLIENT_DIR.'/classes/class-automatic-upgrader-skin.php');
[158] Fix | Delete
[159] Fix | Delete
$skin = new Automatic_Upgrader_Skin();
[160] Fix | Delete
$upgrader = new Plugin_Upgrader($skin);
[161] Fix | Delete
$result = $upgrader->bulk_upgrade(array($plugin));
[162] Fix | Delete
[163] Fix | Delete
if (is_array($result) && empty($result[$plugin]) && is_wp_error($skin->result)) {
[164] Fix | Delete
$result = $skin->result;
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
$status['messages'] = $upgrader->skin->get_upgrade_messages();
[168] Fix | Delete
[169] Fix | Delete
if (is_array($result) && !empty($result[$plugin])) {
[170] Fix | Delete
$plugin_update_data = current($result);
[171] Fix | Delete
[172] Fix | Delete
/*
[173] Fix | Delete
* If the `update_plugins` site transient is empty (e.g. when you update
[174] Fix | Delete
* two plugins in quick succession before the transient repopulates),
[175] Fix | Delete
* this may be the return.
[176] Fix | Delete
*
[177] Fix | Delete
* Preferably something can be done to ensure `update_plugins` isn't empty.
[178] Fix | Delete
* For now, surface some sort of error here.
[179] Fix | Delete
*/
[180] Fix | Delete
if (true === $plugin_update_data) {
[181] Fix | Delete
$status['error'] = 'update_failed';
[182] Fix | Delete
return $status;
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
if (is_wp_error($result[$plugin])) {
[186] Fix | Delete
$status['error'] = $result[$plugin]->get_error_code();
[187] Fix | Delete
$status['error_message'] = $result[$plugin]->get_error_message();
[188] Fix | Delete
return $status;
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
$plugin_data = get_plugins('/' . $result[$plugin]['destination_name']);
[192] Fix | Delete
$plugin_data = reset($plugin_data);
[193] Fix | Delete
[194] Fix | Delete
if ($plugin_data['Version']) {
[195] Fix | Delete
$status['newVersion'] = $plugin_data['Version'];
[196] Fix | Delete
}
[197] Fix | Delete
return $status;
[198] Fix | Delete
[199] Fix | Delete
} elseif (is_wp_error($result)) {
[200] Fix | Delete
$status['error'] = $result->get_error_code();
[201] Fix | Delete
$status['error_message'] = $result->get_error_message();
[202] Fix | Delete
return $status;
[203] Fix | Delete
[204] Fix | Delete
} elseif (is_bool($result) && !$result) {
[205] Fix | Delete
$status['error'] = 'unable_to_connect_to_filesystem';
[206] Fix | Delete
[207] Fix | Delete
global $wp_filesystem;
[208] Fix | Delete
[209] Fix | Delete
// Pass through the error from WP_Filesystem if one was raised
[210] Fix | Delete
if (isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
[211] Fix | Delete
$status['error'] = $wp_filesystem->errors->get_error_code();
[212] Fix | Delete
$status['error_message'] = $wp_filesystem->errors->get_error_message();
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
return $status;
[216] Fix | Delete
[217] Fix | Delete
} else {
[218] Fix | Delete
// An unhandled error occured
[219] Fix | Delete
$status['error'] = 'update_failed';
[220] Fix | Delete
return $status;
[221] Fix | Delete
}
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
/**
[225] Fix | Delete
* Adapted from _update_theme (above)
[226] Fix | Delete
*
[227] Fix | Delete
* @param string $core
[228] Fix | Delete
* @return array
[229] Fix | Delete
*/
[230] Fix | Delete
private function _update_core($core) {
[231] Fix | Delete
[232] Fix | Delete
global $wp_filesystem;
[233] Fix | Delete
[234] Fix | Delete
$status = array(
[235] Fix | Delete
'update' => 'core',
[236] Fix | Delete
'core' => $core,
[237] Fix | Delete
'oldVersion' => '',
[238] Fix | Delete
'newVersion' => '',
[239] Fix | Delete
);
[240] Fix | Delete
[241] Fix | Delete
// THis is included so we can get $wp_version
[242] Fix | Delete
include(ABSPATH.WPINC.'/version.php');
[243] Fix | Delete
[244] Fix | Delete
$status['oldVersion'] = $wp_version;// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
[245] Fix | Delete
[246] Fix | Delete
if (!current_user_can('update_core')) {
[247] Fix | Delete
$status['error'] = 'updates_permission_denied';
[248] Fix | Delete
return $status;
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
[252] Fix | Delete
[253] Fix | Delete
wp_version_check();
[254] Fix | Delete
[255] Fix | Delete
$locale = get_locale();// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
[256] Fix | Delete
[257] Fix | Delete
$core_update_key = false;
[258] Fix | Delete
$core_update_latest_version = false;
[259] Fix | Delete
[260] Fix | Delete
$get_core_updates = get_core_updates();
[261] Fix | Delete
[262] Fix | Delete
// THis is included so we can get $wp_version
[263] Fix | Delete
@include(ABSPATH.WPINC.'/version.php');// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
[264] Fix | Delete
[265] Fix | Delete
foreach ($get_core_updates as $k => $core_update) {
[266] Fix | Delete
if (isset($core_update->version) && version_compare($core_update->version, $wp_version, '>') && version_compare($core_update->version, $core_update_latest_version, '>')) {// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
[267] Fix | Delete
$core_update_latest_version = $core_update->version;
[268] Fix | Delete
$core_update_key = $k;
[269] Fix | Delete
}
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
if (false === $core_update_key) {
[273] Fix | Delete
$status['error'] = 'no_update_found';
[274] Fix | Delete
return $status;
[275] Fix | Delete
}
[276] Fix | Delete
[277] Fix | Delete
$update = $get_core_updates[$core_update_key];
[278] Fix | Delete
[279] Fix | Delete
// WP < 3.7
[280] Fix | Delete
if (!class_exists('Automatic_Upgrader_Skin')) include_once(UPDRAFTCENTRAL_CLIENT_DIR.'/classes/class-automatic-upgrader-skin.php');
[281] Fix | Delete
[282] Fix | Delete
$skin = new Automatic_Upgrader_Skin();
[283] Fix | Delete
$upgrader = new Core_Upgrader($skin);
[284] Fix | Delete
[285] Fix | Delete
$result = $upgrader->upgrade($update);
[286] Fix | Delete
[287] Fix | Delete
$status['messages'] = $upgrader->skin->get_upgrade_messages();
[288] Fix | Delete
[289] Fix | Delete
if (is_wp_error($result)) {
[290] Fix | Delete
$status['error'] = $result->get_error_code();
[291] Fix | Delete
$status['error_message'] = $result->get_error_message();
[292] Fix | Delete
return $status;
[293] Fix | Delete
[294] Fix | Delete
} elseif (is_bool($result) && !$result) {
[295] Fix | Delete
$status['error'] = 'unable_to_connect_to_filesystem';
[296] Fix | Delete
[297] Fix | Delete
// Pass through the error from WP_Filesystem if one was raised
[298] Fix | Delete
if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
[299] Fix | Delete
$status['error'] = $wp_filesystem->errors->get_error_code();
[300] Fix | Delete
$status['error_message'] = $wp_filesystem->errors->get_error_message();
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
return $status;
[304] Fix | Delete
[305] Fix | Delete
[306] Fix | Delete
} elseif (preg_match('/^[0-9]/', $result)) {
[307] Fix | Delete
[308] Fix | Delete
$status['newVersion'] = $result;
[309] Fix | Delete
[310] Fix | Delete
return $status;
[311] Fix | Delete
[312] Fix | Delete
} else {
[313] Fix | Delete
// An unhandled error occured
[314] Fix | Delete
$status['error'] = 'update_failed';
[315] Fix | Delete
return $status;
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
private function _update_theme($theme) {
[321] Fix | Delete
[322] Fix | Delete
global $wp_filesystem;
[323] Fix | Delete
[324] Fix | Delete
$status = array(
[325] Fix | Delete
'update' => 'theme',
[326] Fix | Delete
'theme' => $theme,
[327] Fix | Delete
'oldVersion' => '',
[328] Fix | Delete
'newVersion' => '',
[329] Fix | Delete
);
[330] Fix | Delete
[331] Fix | Delete
if (false !== strpos($theme, '/') || false !== strpos($theme, '\\')) {
[332] Fix | Delete
$status['error'] = 'not_found';
[333] Fix | Delete
return $status;
[334] Fix | Delete
}
[335] Fix | Delete
[336] Fix | Delete
$theme_version = $this->get_theme_version($theme);
[337] Fix | Delete
if (false === $theme_version) {
[338] Fix | Delete
$status['error'] = 'not_found';
[339] Fix | Delete
return $status;
[340] Fix | Delete
}
[341] Fix | Delete
$status['oldVersion'] = $theme_version;
[342] Fix | Delete
[343] Fix | Delete
if (!current_user_can('update_themes')) {
[344] Fix | Delete
$status['error'] = 'updates_permission_denied';
[345] Fix | Delete
return $status;
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
[349] Fix | Delete
[350] Fix | Delete
wp_update_themes();
[351] Fix | Delete
[352] Fix | Delete
// WP < 3.7
[353] Fix | Delete
if (!class_exists('Automatic_Upgrader_Skin')) include_once(UPDRAFTCENTRAL_CLIENT_DIR.'/classes/class-automatic-upgrader-skin.php');
[354] Fix | Delete
[355] Fix | Delete
$skin = new Automatic_Upgrader_Skin();
[356] Fix | Delete
$upgrader = new Theme_Upgrader($skin);
[357] Fix | Delete
$upgrader->init();
[358] Fix | Delete
$result = $upgrader->bulk_upgrade(array($theme));
[359] Fix | Delete
[360] Fix | Delete
if (is_array($result) && empty($result[$theme]) && is_wp_error($skin->result)) {
[361] Fix | Delete
$result = $skin->result;
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
$status['messages'] = $upgrader->skin->get_upgrade_messages();
[365] Fix | Delete
[366] Fix | Delete
if (is_array($result) && !empty($result[$theme])) {
[367] Fix | Delete
$theme_update_data = current($result);
[368] Fix | Delete
[369] Fix | Delete
/*
[370] Fix | Delete
* If the `update_themes` site transient is empty (e.g. when you update
[371] Fix | Delete
* two plugins in quick succession before the transient repopulates),
[372] Fix | Delete
* this may be the return.
[373] Fix | Delete
*
[374] Fix | Delete
* Preferably something can be done to ensure `update_themes` isn't empty.
[375] Fix | Delete
* For now, surface some sort of error here.
[376] Fix | Delete
*/
[377] Fix | Delete
if (true === $theme_update_data) {
[378] Fix | Delete
$status['error'] = 'update_failed';
[379] Fix | Delete
return $status;
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
$new_theme_version = $this->get_theme_version($theme);
[383] Fix | Delete
if (false === $new_theme_version) {
[384] Fix | Delete
$status['error'] = 'update_failed';
[385] Fix | Delete
return $status;
[386] Fix | Delete
}
[387] Fix | Delete
[388] Fix | Delete
$status['newVersion'] = $new_theme_version;
[389] Fix | Delete
[390] Fix | Delete
return $status;
[391] Fix | Delete
[392] Fix | Delete
} elseif (is_wp_error($result)) {
[393] Fix | Delete
$status['error'] = $result->get_error_code();
[394] Fix | Delete
$status['error_message'] = $result->get_error_message();
[395] Fix | Delete
return $status;
[396] Fix | Delete
[397] Fix | Delete
} elseif (is_bool($result) && !$result) {
[398] Fix | Delete
$status['error'] = 'unable_to_connect_to_filesystem';
[399] Fix | Delete
[400] Fix | Delete
// Pass through the error from WP_Filesystem if one was raised
[401] Fix | Delete
if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
[402] Fix | Delete
$status['error'] = $wp_filesystem->errors->get_error_code();
[403] Fix | Delete
$status['error_message'] = $wp_filesystem->errors->get_error_message();
[404] Fix | Delete
}
[405] Fix | Delete
[406] Fix | Delete
return $status;
[407] Fix | Delete
[408] Fix | Delete
} else {
[409] Fix | Delete
// An unhandled error occured
[410] Fix | Delete
$status['error'] = 'update_failed';
[411] Fix | Delete
return $status;
[412] Fix | Delete
}
[413] Fix | Delete
[414] Fix | Delete
}
[415] Fix | Delete
[416] Fix | Delete
/**
[417] Fix | Delete
* Updates available translations for this website
[418] Fix | Delete
*
[419] Fix | Delete
* @return Array
[420] Fix | Delete
*/
[421] Fix | Delete
private function _update_translation() {
[422] Fix | Delete
global $wp_filesystem;
[423] Fix | Delete
[424] Fix | Delete
$status = array();
[425] Fix | Delete
[426] Fix | Delete
include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
[427] Fix | Delete
if (!class_exists('Automatic_Upgrader_Skin')) include_once(UPDRAFTCENTRAL_CLIENT_DIR.'/classes/class-automatic-upgrader-skin.php');
[428] Fix | Delete
[429] Fix | Delete
$skin = new Automatic_Upgrader_Skin();
[430] Fix | Delete
$upgrader = new Language_Pack_Upgrader($skin);
[431] Fix | Delete
$result = $upgrader->bulk_upgrade();
[432] Fix | Delete
[433] Fix | Delete
if (is_array($result) && !empty($result)) {
[434] Fix | Delete
$status['success'] = true;
[435] Fix | Delete
} elseif (is_wp_error($result)) {
[436] Fix | Delete
$status['error'] = $result->get_error_code();
[437] Fix | Delete
$status['error_message'] = $result->get_error_message();
[438] Fix | Delete
} elseif (is_bool($result) && !$result) {
[439] Fix | Delete
$status['error'] = 'unable_to_connect_to_filesystem';
[440] Fix | Delete
[441] Fix | Delete
// Pass through the error from WP_Filesystem if one was raised
[442] Fix | Delete
if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
[443] Fix | Delete
$status['error'] = $wp_filesystem->errors->get_error_code();
[444] Fix | Delete
$status['error_message'] = $wp_filesystem->errors->get_error_message();
[445] Fix | Delete
}
[446] Fix | Delete
} elseif (is_bool($result) && $result) {
[447] Fix | Delete
$status['error'] = 'up_to_date';
[448] Fix | Delete
} else {
[449] Fix | Delete
// An unhandled error occured
[450] Fix | Delete
$status['error'] = 'update_failed';
[451] Fix | Delete
}
[452] Fix | Delete
[453] Fix | Delete
return $status;
[454] Fix | Delete
}
[455] Fix | Delete
[456] Fix | Delete
private function get_theme_version($theme) {
[457] Fix | Delete
[458] Fix | Delete
if (function_exists('wp_get_theme')) {
[459] Fix | Delete
// Since WP 3.4.0
[460] Fix | Delete
$theme = wp_get_theme($theme);
[461] Fix | Delete
[462] Fix | Delete
if (is_a($theme, 'WP_Theme')) {
[463] Fix | Delete
return $theme->Version;
[464] Fix | Delete
} else {
[465] Fix | Delete
return false;
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
} else {
[469] Fix | Delete
$theme_data = get_theme_data(WP_CONTENT_DIR . '/themes/'.$theme.'/style.css');
[470] Fix | Delete
[471] Fix | Delete
if (isset($theme_data['Version'])) {
[472] Fix | Delete
return $theme_data['Version'];
[473] Fix | Delete
} else {
[474] Fix | Delete
return false;
[475] Fix | Delete
}
[476] Fix | Delete
}
[477] Fix | Delete
}
[478] Fix | Delete
[479] Fix | Delete
/**
[480] Fix | Delete
* Adding third-party plugins/theme for UDC automatic updates, for some updaters which store their information when the transient is set, instead of (like most) when it is fetched
[481] Fix | Delete
*
[482] Fix | Delete
* @param Array $items A collection of plugins or themes for updates
[483] Fix | Delete
* @param String $type A string indicating which type of collection to process (e.g. 'plugin' or 'theme')
[484] Fix | Delete
* @return Array An updated collection of plugins or themes for updates
[485] Fix | Delete
*/
[486] Fix | Delete
private function maybe_add_third_party_items($items, $type) {
[487] Fix | Delete
[488] Fix | Delete
// Here we're preparing a dummy transient object that will be pass to the filter
[489] Fix | Delete
// and gets populated by those plugins or themes that hooked into the "pre_set_site_transient_*" filter.
[490] Fix | Delete
//
[491] Fix | Delete
// We're setting some default properties so that plugins and themes won't be able to bypass populating them,
[492] Fix | Delete
// because most of the plugins and themes updater scripts checks whether or not these properties are set and
[493] Fix | Delete
// non-empty or passed the 12 hour period (where WordPress re-starts the process of checking updates for
[494] Fix | Delete
// these plugins and themes), otherwise, they bypass populating the update/upgrade info for these items.
[495] Fix | Delete
$transient = (object) array(
[496] Fix | Delete
'last_checked' => time() - (13 * 3600), /* Making sure that we passed the 12 hour period check */
[497] Fix | Delete
'checked' => array('default' => 'none'),
[498] Fix | Delete
'response' => array('default' => 'none')
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function