Edit File by line
/home/barbar84/www/wp-conte.../plugins/worker/src/MWP/Progress
File: Abstract.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
abstract class MWP_Progress_Abstract implements MWP_Progress_CurlCallbackInterface
[10] Fix | Delete
{
[11] Fix | Delete
private $threshold;
[12] Fix | Delete
[13] Fix | Delete
private $lastYield;
[14] Fix | Delete
[15] Fix | Delete
protected function getThreshold()
[16] Fix | Delete
{
[17] Fix | Delete
return $this->threshold;
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
protected function setThreshold($threshold)
[21] Fix | Delete
{
[22] Fix | Delete
$this->threshold = $threshold;
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
protected function yieldCallback()
[26] Fix | Delete
{
[27] Fix | Delete
if (time() - $this->lastYield >= $this->threshold) {
[28] Fix | Delete
$this->lastYield = time();
[29] Fix | Delete
[30] Fix | Delete
return true;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
return false;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
protected function formatBytes($bytes)
[37] Fix | Delete
{
[38] Fix | Delete
$bytes = (int) $bytes;
[39] Fix | Delete
[40] Fix | Delete
if ($bytes > 1024 * 1024 * 1024) {
[41] Fix | Delete
return round($bytes / 1024 / 1024 / 1024, 2).' GB';
[42] Fix | Delete
} elseif ($bytes > 1024 * 1024) {
[43] Fix | Delete
return round($bytes / 1024 / 1024, 2).' MB';
[44] Fix | Delete
} elseif ($bytes > 1024) {
[45] Fix | Delete
return round($bytes / 1024, 2).' KB';
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
return $bytes.' B';
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
protected function calculateOffset($curl)
[52] Fix | Delete
{
[53] Fix | Delete
/** @handled function */
[54] Fix | Delete
$info = curl_getinfo($curl);
[55] Fix | Delete
[56] Fix | Delete
$url = parse_url($info['url']);
[57] Fix | Delete
[58] Fix | Delete
if (!isset($url['query'])) {
[59] Fix | Delete
return 0;
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
parse_str($url['query'], $query);
[63] Fix | Delete
[64] Fix | Delete
if (!isset($query['offset'])) {
[65] Fix | Delete
return 0;
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
return (int) $query['offset'];
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
public function getCallback()
[72] Fix | Delete
{
[73] Fix | Delete
return array($this, 'callback');
[74] Fix | Delete
}
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function