Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/MWP/Configur...
File: Service.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
* Class MWP_Configuration_Service
[11] Fix | Delete
* This class is service provider for configuration object.
[12] Fix | Delete
* It include get/save operations, with singleton to lower database hits.
[13] Fix | Delete
*
[14] Fix | Delete
* @package src\MWP\Configuration
[15] Fix | Delete
*/
[16] Fix | Delete
class MWP_Configuration_Service
[17] Fix | Delete
{
[18] Fix | Delete
/**
[19] Fix | Delete
* @var MWP_Configuration_Conf
[20] Fix | Delete
*/
[21] Fix | Delete
public static $configuration;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Returns configuration instance. This is singleton
[25] Fix | Delete
*
[26] Fix | Delete
* @return MWP_Configuration_Conf
[27] Fix | Delete
*/
[28] Fix | Delete
public function getConfiguration()
[29] Fix | Delete
{
[30] Fix | Delete
if (!self::$configuration) {
[31] Fix | Delete
/** @handled function fix */
[32] Fix | Delete
$configuration = get_option("mwp_worker_configuration");
[33] Fix | Delete
$path = realpath(dirname(__FILE__)."/../../../worker.json");
[34] Fix | Delete
if (empty($configuration) && file_exists($path)) {
[35] Fix | Delete
$json = file_get_contents($path);
[36] Fix | Delete
$configuration = json_decode($json, true);
[37] Fix | Delete
/** @handled function fix */
[38] Fix | Delete
update_option("mwp_worker_configuration", $configuration);
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
self::$configuration = new MWP_Configuration_Conf($configuration);
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
return self::$configuration;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Reloads configuration from database, update internal singleton and returns reload object
[49] Fix | Delete
*
[50] Fix | Delete
* @return MWP_Configuration_Conf
[51] Fix | Delete
*/
[52] Fix | Delete
public function reloadConfiguration()
[53] Fix | Delete
{
[54] Fix | Delete
/** @handled function fix */
[55] Fix | Delete
self::$configuration = new MWP_Configuration_Conf(get_option("mwp_worker_configuration"));
[56] Fix | Delete
[57] Fix | Delete
return self::$configuration;
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Save to database configuration instance
[62] Fix | Delete
*
[63] Fix | Delete
* @param MWP_Configuration_Conf $configuration
[64] Fix | Delete
*/
[65] Fix | Delete
public function saveConfiguration(MWP_Configuration_Conf $configuration)
[66] Fix | Delete
{
[67] Fix | Delete
self::$configuration = $configuration;
[68] Fix | Delete
$data = $configuration->toArray();
[69] Fix | Delete
if (array_key_exists("master_cron_url", $data) && !empty($data['master_cron_url'])) {
[70] Fix | Delete
/** @handled function fix */
[71] Fix | Delete
update_option("mwp_worker_configuration", $data);
[72] Fix | Delete
}
[73] Fix | Delete
}
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function