Edit File by line
/home/barbar84/www/wp-conte.../plugins/worker/src/MMB
File: Core.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/*************************************************************
[2] Fix | Delete
* core.class.php
[3] Fix | Delete
* Upgrade Plugins
[4] Fix | Delete
* Copyright (c) 2011 Prelovac Media
[5] Fix | Delete
* www.prelovac.com
[6] Fix | Delete
**************************************************************/
[7] Fix | Delete
class MMB_Core
[8] Fix | Delete
{
[9] Fix | Delete
/** @var MMB_Comment */
[10] Fix | Delete
private $comment_instance;
[11] Fix | Delete
[12] Fix | Delete
/** @var MMB_Stats */
[13] Fix | Delete
private $stats_instance;
[14] Fix | Delete
[15] Fix | Delete
/** @var MMB_User */
[16] Fix | Delete
private $user_instance;
[17] Fix | Delete
[18] Fix | Delete
/** @var MMB_Installer */
[19] Fix | Delete
private $installer_instance;
[20] Fix | Delete
[21] Fix | Delete
protected $mmb_multisite = false;
[22] Fix | Delete
[23] Fix | Delete
protected $network_admin_install;
[24] Fix | Delete
[25] Fix | Delete
public function __construct()
[26] Fix | Delete
{
[27] Fix | Delete
global $blog_id;
[28] Fix | Delete
[29] Fix | Delete
if (is_multisite()) {
[30] Fix | Delete
$this->mmb_multisite = $blog_id;
[31] Fix | Delete
$this->network_admin_install = get_option('mmb_network_admin_install');
[32] Fix | Delete
[33] Fix | Delete
add_action('wpmu_new_blog', array(&$this, 'updateKeys'));
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
// admin notices
[37] Fix | Delete
if (!get_option('_worker_public_key')) {
[38] Fix | Delete
if ($this->mmb_multisite) {
[39] Fix | Delete
if (is_network_admin() && $this->network_admin_install == '1') {
[40] Fix | Delete
add_action('network_admin_notices', array(&$this, 'network_admin_notice'));
[41] Fix | Delete
} else {
[42] Fix | Delete
if ($this->network_admin_install != '1') {
[43] Fix | Delete
$parent_key = $this->get_parent_blog_option('_worker_public_key');
[44] Fix | Delete
if (empty($parent_key)) {
[45] Fix | Delete
add_action('admin_notices', array(&$this, 'admin_notice'));
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
}
[49] Fix | Delete
} else {
[50] Fix | Delete
add_action('admin_notices', array(&$this, 'admin_notice'));
[51] Fix | Delete
}
[52] Fix | Delete
}
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
public function network_admin_notice()
[56] Fix | Delete
{
[57] Fix | Delete
$enabledNotice = $this->isNoticeEnabled();
[58] Fix | Delete
[59] Fix | Delete
if (count(mwp_get_communication_keys()) > 0 || !$enabledNotice) {
[60] Fix | Delete
return;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
$configurationService = new MWP_Configuration_Service();
[64] Fix | Delete
$configuration = $configurationService->getConfiguration();
[65] Fix | Delete
$notice = $configuration->getNetworkNotice();
[66] Fix | Delete
[67] Fix | Delete
echo $notice;
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
public function admin_notice()
[71] Fix | Delete
{
[72] Fix | Delete
$enabledNotice = $this->isNoticeEnabled();
[73] Fix | Delete
[74] Fix | Delete
if (count(mwp_get_communication_keys()) > 0 || !$enabledNotice) {
[75] Fix | Delete
return;
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
$configurationService = new MWP_Configuration_Service();
[79] Fix | Delete
$configuration = $configurationService->getConfiguration();
[80] Fix | Delete
$notice = is_multisite() ? $configuration->getNetworkNotice() : $configuration->getNotice();
[81] Fix | Delete
[82] Fix | Delete
echo $notice;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
private function isNoticeEnabled()
[86] Fix | Delete
{
[87] Fix | Delete
return apply_filters('mwp_admin_notice_enabled', true);
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Get parent blog options
[92] Fix | Delete
*/
[93] Fix | Delete
private function get_parent_blog_option($option_name = '')
[94] Fix | Delete
{
[95] Fix | Delete
/** @var wpdb $wpdb */
[96] Fix | Delete
global $wpdb;
[97] Fix | Delete
$option = $wpdb->get_var($wpdb->prepare("SELECT `option_value` FROM {$wpdb->base_prefix}options WHERE option_name = '%s' LIMIT 1", $option_name));
[98] Fix | Delete
[99] Fix | Delete
return $option;
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* @return MMB_Comment
[104] Fix | Delete
*/
[105] Fix | Delete
public function get_comment_instance()
[106] Fix | Delete
{
[107] Fix | Delete
if (!isset($this->comment_instance)) {
[108] Fix | Delete
$this->comment_instance = new MMB_Comment();
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
return $this->comment_instance;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* @return MMB_User
[116] Fix | Delete
*/
[117] Fix | Delete
public function get_user_instance()
[118] Fix | Delete
{
[119] Fix | Delete
if (!isset($this->user_instance)) {
[120] Fix | Delete
$this->user_instance = new MMB_User();
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
return $this->user_instance;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* @return MMB_Stats
[128] Fix | Delete
*/
[129] Fix | Delete
public function get_stats_instance()
[130] Fix | Delete
{
[131] Fix | Delete
if (!isset($this->stats_instance)) {
[132] Fix | Delete
$this->stats_instance = new MMB_Stats();
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
return $this->stats_instance;
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* @return MMB_Installer
[140] Fix | Delete
*/
[141] Fix | Delete
public function get_installer_instance()
[142] Fix | Delete
{
[143] Fix | Delete
if (!isset($this->installer_instance)) {
[144] Fix | Delete
$this->installer_instance = new MMB_Installer();
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
return $this->installer_instance;
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
public function buildLoaderContent($pluginBasename)
[151] Fix | Delete
{
[152] Fix | Delete
$loader = <<<EOF
[153] Fix | Delete
<?php
[154] Fix | Delete
[155] Fix | Delete
/*
[156] Fix | Delete
Plugin Name: ManageWP - Worker Loader
[157] Fix | Delete
Plugin URI: https://managewp.com
[158] Fix | Delete
Description: This is automatically generated by the ManageWP Worker plugin to increase performance and reliability. It is automatically disabled when disabling the main plugin.
[159] Fix | Delete
Author: GoDaddy
[160] Fix | Delete
Version: 1.0.0
[161] Fix | Delete
Author URI: https://godaddy.com
[162] Fix | Delete
License: GPL2
[163] Fix | Delete
Network: true
[164] Fix | Delete
*/
[165] Fix | Delete
[166] Fix | Delete
if (!function_exists('untrailingslashit') || !defined('WP_PLUGIN_DIR')) {
[167] Fix | Delete
// WordPress is probably not bootstrapped.
[168] Fix | Delete
exit;
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
if (file_exists(untrailingslashit(WP_PLUGIN_DIR).'/$pluginBasename')) {
[172] Fix | Delete
if (in_array('$pluginBasename', (array) get_option('active_plugins')) ||
[173] Fix | Delete
(function_exists('get_site_option') && array_key_exists('worker/init.php', (array) get_site_option('active_sitewide_plugins')))) {
[174] Fix | Delete
\$GLOBALS['mwp_is_mu'] = true;
[175] Fix | Delete
include_once untrailingslashit(WP_PLUGIN_DIR).'/$pluginBasename';
[176] Fix | Delete
}
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
EOF;
[180] Fix | Delete
[181] Fix | Delete
return $loader;
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
public function registerMustUse($loaderName, $loaderContent)
[185] Fix | Delete
{
[186] Fix | Delete
$mustUsePluginDir = rtrim(WPMU_PLUGIN_DIR, '/');
[187] Fix | Delete
$loaderPath = $mustUsePluginDir.'/'.$loaderName;
[188] Fix | Delete
[189] Fix | Delete
if (file_exists($loaderPath) && md5($loaderContent) === md5_file($loaderPath)) {
[190] Fix | Delete
return;
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
if (!is_dir($mustUsePluginDir)) {
[194] Fix | Delete
$dirMade = @mkdir($mustUsePluginDir);
[195] Fix | Delete
[196] Fix | Delete
if (!$dirMade) {
[197] Fix | Delete
$error = error_get_last();
[198] Fix | Delete
throw new Exception(sprintf('Unable to create loader directory: %s', $error['message']));
[199] Fix | Delete
}
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
if (!is_writable($mustUsePluginDir)) {
[203] Fix | Delete
throw new Exception('MU-plugin directory is not writable.');
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
$loaderWritten = @file_put_contents($loaderPath, $loaderContent);
[207] Fix | Delete
[208] Fix | Delete
if (!$loaderWritten) {
[209] Fix | Delete
$error = error_get_last();
[210] Fix | Delete
throw new Exception(sprintf('Unable to write loader: %s', $error['message']));
[211] Fix | Delete
}
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
/**
[215] Fix | Delete
* Plugin install callback function
[216] Fix | Delete
* Check PHP version
[217] Fix | Delete
*/
[218] Fix | Delete
public function install()
[219] Fix | Delete
{
[220] Fix | Delete
update_option('mwp_recovering', '');
[221] Fix | Delete
update_option('mwp_incremental_update_active', '');
[222] Fix | Delete
update_option('mwp_core_autoupdate', '');
[223] Fix | Delete
update_option('mwp_container_parameters', array());
[224] Fix | Delete
update_option('mwp_container_site_parameters', array());
[225] Fix | Delete
update_option('mwp_maintenace_mode', array());
[226] Fix | Delete
mwp_container()->getMigration()->migrate();
[227] Fix | Delete
try {
[228] Fix | Delete
$this->registerMustUse('0-worker.php', $this->buildLoaderContent('worker/init.php'));
[229] Fix | Delete
} catch (Exception $e) {
[230] Fix | Delete
mwp_logger()->error('Unable to write ManageWP loader', array('exception' => $e));
[231] Fix | Delete
}
[232] Fix | Delete
[233] Fix | Delete
/** @var wpdb $wpdb */
[234] Fix | Delete
global $wpdb;
[235] Fix | Delete
[236] Fix | Delete
//delete plugin options, just in case
[237] Fix | Delete
if ($this->mmb_multisite != false) {
[238] Fix | Delete
$network_blogs = $wpdb->get_results("select `blog_id`, `site_id` from `{$wpdb->blogs}`");
[239] Fix | Delete
if (!empty($network_blogs)) {
[240] Fix | Delete
if (is_network_admin()) {
[241] Fix | Delete
update_option('mmb_network_admin_install', 1);
[242] Fix | Delete
$mainBlogId = defined('BLOG_ID_CURRENT_SITE') ? BLOG_ID_CURRENT_SITE : false;
[243] Fix | Delete
foreach ($network_blogs as $details) {
[244] Fix | Delete
if (($mainBlogId !== false && $details->blog_id == $mainBlogId) || ($mainBlogId === false && $details->site_id == $details->blog_id)) {
[245] Fix | Delete
update_blog_option($details->blog_id, 'mmb_network_admin_install', 1);
[246] Fix | Delete
} else {
[247] Fix | Delete
update_blog_option($details->blog_id, 'mmb_network_admin_install', -1);
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
update_blog_option($details->blog_id, '_worker_nossl_key', '');
[251] Fix | Delete
update_blog_option($details->blog_id, '_worker_public_key', '');
[252] Fix | Delete
delete_blog_option($details->blog_id, '_action_message_id');
[253] Fix | Delete
}
[254] Fix | Delete
} else {
[255] Fix | Delete
update_option('mmb_network_admin_install', -1);
[256] Fix | Delete
update_option('_worker_nossl_key', '');
[257] Fix | Delete
update_option('_worker_public_key', '');
[258] Fix | Delete
delete_option('_action_message_id');
[259] Fix | Delete
}
[260] Fix | Delete
}
[261] Fix | Delete
} else {
[262] Fix | Delete
update_option('_worker_nossl_key', '');
[263] Fix | Delete
update_option('_worker_public_key', '');
[264] Fix | Delete
delete_option('_action_message_id');
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
delete_option('mwp_notifications');
[268] Fix | Delete
delete_option('mwp_worker_brand');
[269] Fix | Delete
delete_option('mwp_worker_configuration');
[270] Fix | Delete
$path = realpath(dirname(__FILE__)."/../../worker.json");
[271] Fix | Delete
if (file_exists($path)) {
[272] Fix | Delete
$configuration = file_get_contents($path);
[273] Fix | Delete
$jsonConfiguration = json_decode($configuration, true);
[274] Fix | Delete
if ($jsonConfiguration !== null) {
[275] Fix | Delete
update_option("mwp_worker_configuration", $jsonConfiguration);
[276] Fix | Delete
}
[277] Fix | Delete
}
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
public function deactivate($networkDeactivation = false, $workerDeactivation = true)
[281] Fix | Delete
{
[282] Fix | Delete
if ($workerDeactivation) {
[283] Fix | Delete
mwp_uninstall();
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
/** @var wpdb $wpdb */
[287] Fix | Delete
global $current_user, $wpdb;
[288] Fix | Delete
[289] Fix | Delete
if ($this->mmb_multisite !== false) {
[290] Fix | Delete
$network_blogs = $wpdb->get_col("select `blog_id` from `{$wpdb->blogs}`");
[291] Fix | Delete
if (!empty($network_blogs)) {
[292] Fix | Delete
if (is_network_admin()) {
[293] Fix | Delete
if ($networkDeactivation) {
[294] Fix | Delete
delete_option('mmb_network_admin_install');
[295] Fix | Delete
foreach ($network_blogs as $blog_id) {
[296] Fix | Delete
delete_blog_option($blog_id, 'mmb_network_admin_install');
[297] Fix | Delete
delete_blog_option($blog_id, '_worker_nossl_key');
[298] Fix | Delete
delete_blog_option($blog_id, '_worker_public_key');
[299] Fix | Delete
delete_blog_option($blog_id, '_action_message_id');
[300] Fix | Delete
delete_blog_option($blog_id, 'mwp_notifications');
[301] Fix | Delete
[302] Fix | Delete
if ($workerDeactivation) {
[303] Fix | Delete
delete_blog_option($blog_id, 'mwp_maintenace_mode');
[304] Fix | Delete
delete_blog_option($blog_id, 'mwp_worker_brand');
[305] Fix | Delete
}
[306] Fix | Delete
}
[307] Fix | Delete
}
[308] Fix | Delete
} else {
[309] Fix | Delete
if ($networkDeactivation) {
[310] Fix | Delete
delete_option('mmb_network_admin_install');
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
delete_option('_worker_nossl_key');
[314] Fix | Delete
delete_option('_worker_public_key');
[315] Fix | Delete
delete_option('_action_message_id');
[316] Fix | Delete
}
[317] Fix | Delete
}
[318] Fix | Delete
} else {
[319] Fix | Delete
delete_option('_worker_nossl_key');
[320] Fix | Delete
delete_option('_worker_public_key');
[321] Fix | Delete
delete_option('_action_message_id');
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
//Delete options
[325] Fix | Delete
delete_option('mwp_notifications');
[326] Fix | Delete
wp_clear_scheduled_hook('mwp_notifications');
[327] Fix | Delete
wp_clear_scheduled_hook('mwp_datasend');
[328] Fix | Delete
[329] Fix | Delete
if ($workerDeactivation) {
[330] Fix | Delete
delete_option('mwp_maintenace_mode');
[331] Fix | Delete
delete_option('mwp_worker_brand');
[332] Fix | Delete
delete_option('mwp_worker_configuration');
[333] Fix | Delete
}
[334] Fix | Delete
}
[335] Fix | Delete
[336] Fix | Delete
/**
[337] Fix | Delete
* Worker update
[338] Fix | Delete
*/
[339] Fix | Delete
public function update_worker_plugin($params)
[340] Fix | Delete
{
[341] Fix | Delete
if ($params['download_url']) {
[342] Fix | Delete
@include_once ABSPATH.'wp-admin/includes/file.php';
[343] Fix | Delete
@include_once ABSPATH.'wp-admin/includes/misc.php';
[344] Fix | Delete
@include_once ABSPATH.'wp-admin/includes/template.php';
[345] Fix | Delete
@include_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
[346] Fix | Delete
@include_once ABSPATH.'wp-admin/includes/screen.php';
[347] Fix | Delete
@include_once ABSPATH.'wp-admin/includes/plugin.php';
[348] Fix | Delete
[349] Fix | Delete
if (!$this->is_server_writable()) {
[350] Fix | Delete
return array(
[351] Fix | Delete
'error' => 'Failed, please <a target="_blank" href="http://managewp.com/user-guide/faq/my-pluginsthemes-fail-to-update-or-i-receive-a-yellow-ftp-warning">add FTP details for automatic upgrades.</a>',
[352] Fix | Delete
);
[353] Fix | Delete
}
[354] Fix | Delete
[355] Fix | Delete
mwp_load_required_components();
[356] Fix | Delete
[357] Fix | Delete
ob_start();
[358] Fix | Delete
@unlink(dirname(__FILE__));
[359] Fix | Delete
/** @handled class */
[360] Fix | Delete
$upgrader = new Plugin_Upgrader(mwp_container()->getUpdaterSkin());
[361] Fix | Delete
$result = $upgrader->run(
[362] Fix | Delete
array(
[363] Fix | Delete
'package' => $params['download_url'],
[364] Fix | Delete
'destination' => WP_PLUGIN_DIR,
[365] Fix | Delete
'clear_destination' => true,
[366] Fix | Delete
'clear_working' => true,
[367] Fix | Delete
'hook_extra' => array(
[368] Fix | Delete
'plugin' => 'worker/init.php',
[369] Fix | Delete
),
[370] Fix | Delete
)
[371] Fix | Delete
);
[372] Fix | Delete
ob_end_clean();
[373] Fix | Delete
if (is_wp_error($result) || !$result) {
[374] Fix | Delete
return array(
[375] Fix | Delete
'error' => 'ManageWP Worker plugin could not be updated.',
[376] Fix | Delete
);
[377] Fix | Delete
} else {
[378] Fix | Delete
return array(
[379] Fix | Delete
'success' => 'ManageWP Worker plugin successfully updated.',
[380] Fix | Delete
);
[381] Fix | Delete
}
[382] Fix | Delete
}
[383] Fix | Delete
[384] Fix | Delete
return array(
[385] Fix | Delete
'error' => 'Bad download path for worker installation file.',
[386] Fix | Delete
);
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
public function updateKeys()
[390] Fix | Delete
{
[391] Fix | Delete
if (!$this->mmb_multisite) {
[392] Fix | Delete
return;
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
global $wpdb;
[396] Fix | Delete
[397] Fix | Delete
$publicKey = $this->get_parent_blog_option('_worker_public_key');
[398] Fix | Delete
[399] Fix | Delete
if (empty($publicKey)) {
[400] Fix | Delete
return;
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
$networkBlogs = $wpdb->get_results("select `blog_id` from `{$wpdb->blogs}`");
[404] Fix | Delete
[405] Fix | Delete
if (empty($networkBlogs)) {
[406] Fix | Delete
return;
[407] Fix | Delete
}
[408] Fix | Delete
[409] Fix | Delete
foreach ($networkBlogs as $details) {
[410] Fix | Delete
update_blog_option($details->blog_id, '_worker_public_key', $publicKey);
[411] Fix | Delete
}
[412] Fix | Delete
[413] Fix | Delete
return;
[414] Fix | Delete
}
[415] Fix | Delete
[416] Fix | Delete
public function mmb_get_user_info($user_info = false, $info = 'login')
[417] Fix | Delete
{
[418] Fix | Delete
if ($user_info === false) {
[419] Fix | Delete
return false;
[420] Fix | Delete
}
[421] Fix | Delete
[422] Fix | Delete
if (strlen(trim($user_info)) == 0) {
[423] Fix | Delete
return false;
[424] Fix | Delete
}
[425] Fix | Delete
[426] Fix | Delete
return get_user_by($info, $user_info);
[427] Fix | Delete
}
[428] Fix | Delete
[429] Fix | Delete
public function mmb_get_transient($option_name)
[430] Fix | Delete
{
[431] Fix | Delete
global $wp_version;
[432] Fix | Delete
[433] Fix | Delete
if (trim($option_name) == '') {
[434] Fix | Delete
return false;
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
if (version_compare($wp_version, '3.4', '>')) {
[438] Fix | Delete
return get_site_transient($option_name);
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
if (!empty($this->mmb_multisite)) {
[442] Fix | Delete
return $this->mmb_get_sitemeta_transient($option_name);
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
$transient = get_option('_site_transient_'.$option_name);
[446] Fix | Delete
[447] Fix | Delete
return apply_filters("site_transient_".$option_name, $transient);
[448] Fix | Delete
}
[449] Fix | Delete
[450] Fix | Delete
public function mmb_get_sitemeta_transient($option_name)
[451] Fix | Delete
{
[452] Fix | Delete
/** @var wpdb $wpdb */
[453] Fix | Delete
global $wpdb;
[454] Fix | Delete
$option_name = '_site_transient_'.$option_name;
[455] Fix | Delete
[456] Fix | Delete
$result = $wpdb->get_var($wpdb->prepare("SELECT `meta_value` FROM `{$wpdb->sitemeta}` WHERE meta_key = '%s' AND `site_id` = '%s'", $option_name, $this->mmb_multisite));
[457] Fix | Delete
$result = maybe_unserialize($result);
[458] Fix | Delete
[459] Fix | Delete
return $result;
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
public function get_master_public_key()
[463] Fix | Delete
{
[464] Fix | Delete
if (!get_option('_worker_public_key')) {
[465] Fix | Delete
return false;
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
return base64_decode(get_option('_worker_public_key'));
[469] Fix | Delete
}
[470] Fix | Delete
[471] Fix | Delete
public function mmb_get_error($error_object)
[472] Fix | Delete
{
[473] Fix | Delete
if (!is_wp_error($error_object)) {
[474] Fix | Delete
return $error_object != '' ? $error_object : '';
[475] Fix | Delete
} else {
[476] Fix | Delete
$errors = array();
[477] Fix | Delete
if (!empty($error_object->error_data)) {
[478] Fix | Delete
foreach ($error_object->error_data as $error_key => $error_string) {
[479] Fix | Delete
$errors[] = str_replace('_', ' ', ucfirst($error_key)).': '.$error_string;
[480] Fix | Delete
}
[481] Fix | Delete
} elseif (!empty($error_object->errors)) {
[482] Fix | Delete
foreach ($error_object->errors as $error_key => $err) {
[483] Fix | Delete
$errors[] = 'Error: '.str_replace('_', ' ', strtolower($error_key));
[484] Fix | Delete
}
[485] Fix | Delete
}
[486] Fix | Delete
[487] Fix | Delete
return implode('<br />', $errors);
[488] Fix | Delete
}
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
public function check_if_pantheon()
[492] Fix | Delete
{
[493] Fix | Delete
return !empty($_ENV['PANTHEON_ENVIRONMENT']) && $_ENV['PANTHEON_ENVIRONMENT'] !== 'dev';
[494] Fix | Delete
}
[495] Fix | Delete
[496] Fix | Delete
public function is_server_writable()
[497] Fix | Delete
{
[498] Fix | Delete
if ($this->check_if_pantheon()) {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function