Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/MWP/Updater
File: TraceableUpdaterSkin.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* This file is part of the ManageWP Worker plugin.
[2] Fix | Delete
*
[3] Fix | Delete
* (c) ManageWP LLC <contact@managewp.com>
[4] Fix | Delete
*
[5] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[6] Fix | Delete
* file that was distributed with this source code.
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Taken from WordPress's automatic updater skin, which was added in version 3.7.
[11] Fix | Delete
*
[12] Fix | Delete
* @see Automatic_Upgrader_Skin
[13] Fix | Delete
*/
[14] Fix | Delete
class MWP_Updater_TraceableUpdaterSkin
[15] Fix | Delete
{
[16] Fix | Delete
[17] Fix | Delete
public $options = array(
[18] Fix | Delete
'url' => '',
[19] Fix | Delete
'nonce' => '',
[20] Fix | Delete
'title' => '',
[21] Fix | Delete
'context' => false,
[22] Fix | Delete
);
[23] Fix | Delete
[24] Fix | Delete
public $upgrader;
[25] Fix | Delete
[26] Fix | Delete
public $result;
[27] Fix | Delete
[28] Fix | Delete
public $done_header = false;
[29] Fix | Delete
[30] Fix | Delete
protected $messages = array();
[31] Fix | Delete
[32] Fix | Delete
private $startedImplicit = false;
[33] Fix | Delete
[34] Fix | Delete
public function request_filesystem_credentials($error = false, $context = '', $allow_relaxed_file_ownership = false)
[35] Fix | Delete
{
[36] Fix | Delete
if ($error instanceof WP_Error) {
[37] Fix | Delete
throw new MWP_Worker_Exception(MWP_Worker_Exception::FILESYSTEM_CREDENTIALS_ERROR, $error->get_error_message());
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
if ($context) {
[41] Fix | Delete
$this->options['context'] = $context;
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
// file.php and template.php are documented to be required; the rest are there to match
[45] Fix | Delete
// the list in the MMB_Installer class.
[46] Fix | Delete
require_once ABSPATH.'wp-admin/includes/file.php';
[47] Fix | Delete
require_once ABSPATH.'wp-admin/includes/plugin.php';
[48] Fix | Delete
require_once ABSPATH.'wp-admin/includes/theme.php';
[49] Fix | Delete
require_once ABSPATH.'wp-admin/includes/misc.php';
[50] Fix | Delete
require_once ABSPATH.'wp-admin/includes/template.php';
[51] Fix | Delete
require_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
[52] Fix | Delete
// This will output a credentials form in event of failure; we don't want that, so just hide with a buffer.
[53] Fix | Delete
ob_start();
[54] Fix | Delete
/** @handled function */
[55] Fix | Delete
$result = request_filesystem_credentials('', '', $error, $context, null, $allow_relaxed_file_ownership);
[56] Fix | Delete
ob_end_clean();
[57] Fix | Delete
[58] Fix | Delete
return $result;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
public function get_upgrade_messages()
[62] Fix | Delete
{
[63] Fix | Delete
return $this->messages;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* @param string|array|WP_Error $data
[68] Fix | Delete
*/
[69] Fix | Delete
public function feedback($data)
[70] Fix | Delete
{
[71] Fix | Delete
if (!$this->startedImplicit) {
[72] Fix | Delete
$this->startedImplicit = true;
[73] Fix | Delete
@ob_implicit_flush(true);
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
echo ' ';
[77] Fix | Delete
@ob_flush();
[78] Fix | Delete
[79] Fix | Delete
if (is_wp_error($data)) {
[80] Fix | Delete
$string = $data->get_error_message();
[81] Fix | Delete
} else {
[82] Fix | Delete
if (is_array($data)) {
[83] Fix | Delete
return;
[84] Fix | Delete
} else {
[85] Fix | Delete
$string = $data;
[86] Fix | Delete
}
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
if (!empty($this->upgrader->strings[$string])) {
[90] Fix | Delete
$string = $this->upgrader->strings[$string];
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
if (strpos($string, '%') !== false) {
[94] Fix | Delete
$args = func_get_args();
[95] Fix | Delete
$args = array_splice($args, 1);
[96] Fix | Delete
if (!empty($args)) {
[97] Fix | Delete
$string = vsprintf($string, $args);
[98] Fix | Delete
}
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
$string = trim($string);
[102] Fix | Delete
[103] Fix | Delete
/** @handled function */
[104] Fix | Delete
// Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
[105] Fix | Delete
$string = wp_kses($string, array(
[106] Fix | Delete
'a' => array(
[107] Fix | Delete
'href' => true
[108] Fix | Delete
),
[109] Fix | Delete
'br' => true,
[110] Fix | Delete
'em' => true,
[111] Fix | Delete
'strong' => true,
[112] Fix | Delete
));
[113] Fix | Delete
[114] Fix | Delete
if (empty($string)) {
[115] Fix | Delete
return;
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
$this->messages[] = array(
[119] Fix | Delete
'message' => $string,
[120] Fix | Delete
'key' => $data,
[121] Fix | Delete
'args' => isset($args) ? $args : array(),
[122] Fix | Delete
);
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
public function header()
[126] Fix | Delete
{
[127] Fix | Delete
ob_start();
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
public function footer()
[131] Fix | Delete
{
[132] Fix | Delete
$output = ob_get_contents();
[133] Fix | Delete
if (!empty($output)) {
[134] Fix | Delete
$this->feedback($output);
[135] Fix | Delete
}
[136] Fix | Delete
ob_end_clean();
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
public function bulk_header()
[140] Fix | Delete
{
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
public function bulk_footer()
[144] Fix | Delete
{
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
public function before()
[148] Fix | Delete
{
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
public function after()
[152] Fix | Delete
{
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
// Below was taken from WP_Upgrader_Skin, so we don't autoload it and cause trouble.
[156] Fix | Delete
public function decrement_update_count()
[157] Fix | Delete
{
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
public function error($errors)
[161] Fix | Delete
{
[162] Fix | Delete
if (is_string($errors)) {
[163] Fix | Delete
$this->feedback($errors);
[164] Fix | Delete
[165] Fix | Delete
return;
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
if (!$errors instanceof WP_Error || !$errors->get_error_code()) {
[169] Fix | Delete
return;
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
foreach ($errors->get_error_messages() as $message) {
[173] Fix | Delete
if ($errors->get_error_data() && is_string($errors->get_error_data())) {
[174] Fix | Delete
$this->feedback($message.' '.esc_html(strip_tags($errors->get_error_data())));
[175] Fix | Delete
} else {
[176] Fix | Delete
$this->feedback($message);
[177] Fix | Delete
}
[178] Fix | Delete
}
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
/**
[182] Fix | Delete
* @param WP_Upgrader $upgrader
[183] Fix | Delete
*/
[184] Fix | Delete
public function set_upgrader($upgrader)
[185] Fix | Delete
{
[186] Fix | Delete
if (is_object($upgrader)) {
[187] Fix | Delete
$this->upgrader = $upgrader;
[188] Fix | Delete
}
[189] Fix | Delete
$this->add_strings();
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
public function add_strings()
[193] Fix | Delete
{
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
public function set_result($result)
[197] Fix | Delete
{
[198] Fix | Delete
$this->result = $result;
[199] Fix | Delete
}
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function