Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../lib
File: menu_wordfence_central.php
<?php
[0] Fix | Delete
if (!defined('WORDFENCE_VERSION')) {
[1] Fix | Delete
exit;
[2] Fix | Delete
}
[3] Fix | Delete
/**
[4] Fix | Delete
* @var string $subpage
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
$stepContent = array(
[8] Fix | Delete
1 => __('Testing initial communication with Wordfence Central.', 'wordfence'),
[9] Fix | Delete
2 => __('Passing public key to Wordfence Central.', 'wordfence'),
[10] Fix | Delete
3 => __('Testing public key authentication with Wordfence Central.', 'wordfence'),
[11] Fix | Delete
4 => __('Testing that Wordfence Central is able to communicate with this site.', 'wordfence'),
[12] Fix | Delete
5 => __('Retrieving access token using authorization grant.', 'wordfence'),
[13] Fix | Delete
6 => __('Redirecting back to Wordfence Central.', 'wordfence'),
[14] Fix | Delete
);
[15] Fix | Delete
$connected = wfCentral::isConnected();
[16] Fix | Delete
$partialConnection = wfCentral::isPartialConnection();
[17] Fix | Delete
[18] Fix | Delete
?>
[19] Fix | Delete
<?php
[20] Fix | Delete
if (!wfOnboardingController::shouldShowAttempt3() && wfConfig::get('touppPromptNeeded')) {
[21] Fix | Delete
echo wfView::create('gdpr/disabled-overlay')->render();
[22] Fix | Delete
echo wfView::create('gdpr/banner')->render();
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
if (function_exists('network_admin_url') && is_multisite()) {
[26] Fix | Delete
$wordfenceURL = network_admin_url('admin.php?page=Wordfence');
[27] Fix | Delete
}
[28] Fix | Delete
else {
[29] Fix | Delete
$wordfenceURL = admin_url('admin.php?page=Wordfence');
[30] Fix | Delete
}
[31] Fix | Delete
?>
[32] Fix | Delete
<div class="wrap wordfence">
[33] Fix | Delete
<div class="wf-container-fluid">
[34] Fix | Delete
<div class="wf-row">
[35] Fix | Delete
<div class="wf-col-xs-12">
[36] Fix | Delete
<div class="wp-header-end"></div>
[37] Fix | Delete
<?php
[38] Fix | Delete
echo wfView::create('common/section-title', array(
[39] Fix | Delete
'title' => __('Wordfence Central', 'wordfence'),
[40] Fix | Delete
'showIcon' => true,
[41] Fix | Delete
))->render();
[42] Fix | Delete
?>
[43] Fix | Delete
</div>
[44] Fix | Delete
[45] Fix | Delete
<?php if ($connected): ?>
[46] Fix | Delete
<div class="wf-col-xs-12 wf-central-connected">
[47] Fix | Delete
<div class="wf-flex-row wf-flex-grow-all">
[48] Fix | Delete
<div class="wf-flex-row-1 wf-block wf-active">
[49] Fix | Delete
<div class="wf-central-dashboard">
[50] Fix | Delete
<img class="wf-central-dashboard-logo" src="<?php echo wfUtils::getBaseURL() ?>images/wf-central-logo.svg" alt="Wordfence Central">
[51] Fix | Delete
<div class="wf-central-dashboard-copy">
[52] Fix | Delete
<p><strong><?php esc_html_e('Wordfence Central', 'wordfence') ?></strong></p>
[53] Fix | Delete
<p><?php esc_html_e('Wordfence Central allows you to manage Wordfence on multiple sites from one location. It makes security monitoring and configuring Wordfence easier.', 'wordfence') ?></p>
[54] Fix | Delete
<p class="wf-right-lg"><a href="https://www.wordfence.com/central" target="_blank" rel="noopener noreferrer"><strong><?php esc_html_e('Visit Wordfence Central', 'wordfence') ?></strong><span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a></p>
[55] Fix | Delete
</div>
[56] Fix | Delete
</div>
[57] Fix | Delete
</div>
[58] Fix | Delete
<div class="wf-flex-row-1 wf-block wf-active">
[59] Fix | Delete
<p><strong><?php esc_html_e('Wordfence Central Status', 'wordfence') ?></strong></p>
[60] Fix | Delete
<p><?php echo esc_html(sprintf(
[61] Fix | Delete
/* translators: 1. Email address. 2. Localized date. */
[62] Fix | Delete
__('Activated - connected by %1$s on %2$s', 'wordfence'), wfConfig::get('wordfenceCentralConnectEmail'), date_i18n('F j, Y', (int) wfConfig::get('wordfenceCentralConnectTime')))) ?></p>
[63] Fix | Delete
<p class="wf-right-lg"><a href="<?php echo esc_url($wordfenceURL); ?>"><strong><?php esc_html_e('Disconnect This Site', 'wordfence') ?></strong></a></p>
[64] Fix | Delete
</div>
[65] Fix | Delete
</div>
[66] Fix | Delete
</div>
[67] Fix | Delete
<?php elseif (isset($_GET['grant'])): ?>
[68] Fix | Delete
<div class="wf-col-xs-12">
[69] Fix | Delete
<div class="wf-block wf-active">
[70] Fix | Delete
<div class="wf-block-header">
[71] Fix | Delete
<div class="wf-block-header-content">
[72] Fix | Delete
<strong><?php esc_html_e('Wordfence Central Installation Process', 'wordfence') ?></strong>
[73] Fix | Delete
</div>
[74] Fix | Delete
</div>
[75] Fix | Delete
<div class="wf-block-content">
[76] Fix | Delete
<ul class="wf-block-list" id="wf-central-progress">
[77] Fix | Delete
<?php for ($i = 1; $i <= 6; $i++): ?>
[78] Fix | Delete
<li id="wf-central-progress-step<?php echo $i ?>" class="pending">
[79] Fix | Delete
<div class="wf-central-progress-icon">
[80] Fix | Delete
<div class="wf-step-pending"></div>
[81] Fix | Delete
<div class="wf-step-running">
[82] Fix | Delete
<?php
[83] Fix | Delete
echo wfView::create('common/indeterminate-progress', array(
[84] Fix | Delete
'size' => 50,
[85] Fix | Delete
))->render();
[86] Fix | Delete
?>
[87] Fix | Delete
</div>
[88] Fix | Delete
<div class="wf-step-complete-success"></div>
[89] Fix | Delete
<div class="wf-step-complete-warning"></div>
[90] Fix | Delete
</div>
[91] Fix | Delete
<div class="wf-central-progress-content">
[92] Fix | Delete
<p><?php echo esc_html($stepContent[$i]) ?></p>
[93] Fix | Delete
</div>
[94] Fix | Delete
</li>
[95] Fix | Delete
<?php endfor ?>
[96] Fix | Delete
</ul>
[97] Fix | Delete
</div>
[98] Fix | Delete
</div>
[99] Fix | Delete
</div>
[100] Fix | Delete
<?php elseif ($partialConnection): ?>
[101] Fix | Delete
<div class="wf-center-lg">
[102] Fix | Delete
<p><?php esc_html_e('It looks like you\'ve tried to connect this site to Wordfence Central, but the installation did not finish.', 'wordfence') ?></p>
[103] Fix | Delete
<p>
[104] Fix | Delete
<a href="<?php echo WORDFENCE_CENTRAL_URL_SEC ?>/sites/connection-issues?complete-setup=<?php echo esc_attr(wfConfig::get('wordfenceCentralSiteID')) ?>"
[105] Fix | Delete
class="wf-btn wf-btn-primary"
[106] Fix | Delete
><?php esc_html_e('Resume Installation', 'wordfence') ?></a>
[107] Fix | Delete
<a href="<?php echo esc_url($wordfenceURL); ?>" class="wf-btn wf-btn-warning"><?php esc_html_e('Disconnect Site', 'wordfence') ?></a>
[108] Fix | Delete
</p>
[109] Fix | Delete
</div>
[110] Fix | Delete
<?php else: ?>
[111] Fix | Delete
<div class="wf-center-lg">
[112] Fix | Delete
<p><?php esc_html_e('Wordfence Central allows you to manage Wordfence on multiple sites from one location. It makes security monitoring and configuring Wordfence easier.', 'wordfence') ?></p>
[113] Fix | Delete
<p><?php esc_html_e('To connect your site your site to Wordfence Central, use the link below:', 'wordfence') ?></p>
[114] Fix | Delete
<p class="wf-center">
[115] Fix | Delete
<a href="<?php echo WORDFENCE_CENTRAL_URL_SEC ?>?newsite=<?php echo esc_attr(home_url()) ?>" class="wf-btn wf-btn-primary"><?php esc_html_e('Connect Site', 'wordfence') ?></a>
[116] Fix | Delete
</p>
[117] Fix | Delete
</div>
[118] Fix | Delete
<?php endif ?>
[119] Fix | Delete
</div>
[120] Fix | Delete
</div>
[121] Fix | Delete
</div>
[122] Fix | Delete
[123] Fix | Delete
<script>
[124] Fix | Delete
(function($) {
[125] Fix | Delete
var authGrant = '<?php echo esc_js(isset($_GET['grant']) ? $_GET['grant'] : '') ?>';
[126] Fix | Delete
var currentStep = <?php echo json_encode(wfConfig::getInt('wordfenceCentralCurrentStep', 1)) ?>;
[127] Fix | Delete
var connected = <?php echo json_encode($connected) ?>;
[128] Fix | Delete
[129] Fix | Delete
function wfConnectError(error) {
[130] Fix | Delete
WFAD.colorboxError(error);
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
function wfCentralStepAjax(step, action, data, cb, cbErr, noLoading) {
[134] Fix | Delete
var el = $('#wf-central-progress-' + step);
[135] Fix | Delete
el.removeClass('pending')
[136] Fix | Delete
.addClass('running');
[137] Fix | Delete
[138] Fix | Delete
WFAD.ajax(action, data, function(response) {
[139] Fix | Delete
if (response && response.success) {
[140] Fix | Delete
el.removeClass('running')
[141] Fix | Delete
.addClass('complete-success');
[142] Fix | Delete
cb && cb(response);
[143] Fix | Delete
} else if (response && response.err) {
[144] Fix | Delete
el.removeClass('running')
[145] Fix | Delete
.addClass('complete-warning');
[146] Fix | Delete
}
[147] Fix | Delete
}, function(response) {
[148] Fix | Delete
el.removeClass('running')
[149] Fix | Delete
.addClass('complete-warning');
[150] Fix | Delete
cbErr && cbErr(response);
[151] Fix | Delete
}, noLoading);
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
var WFCentralInstaller = {};
[155] Fix | Delete
window.WFCentralInstaller = WFCentralInstaller;
[156] Fix | Delete
[157] Fix | Delete
// Step 1: Makes GET request to `/central/api/site/access-token` endpoint authenticated with the auth grant supplied by the user.
[158] Fix | Delete
// - Receives site GUID, public key, short lived JWT.
[159] Fix | Delete
[160] Fix | Delete
WFCentralInstaller.step1 = function() {
[161] Fix | Delete
wfCentralStepAjax('step1', 'wordfence_wfcentral_step1', {
[162] Fix | Delete
'auth-grant': authGrant
[163] Fix | Delete
}, function(response) {
[164] Fix | Delete
$(window).trigger('step2', response);
[165] Fix | Delete
}, wfConnectError);
[166] Fix | Delete
};
[167] Fix | Delete
[168] Fix | Delete
// Step 2: Makes PATCH request to `/central/api/wf/site/<guid>` endpoint passing in the new public key.
[169] Fix | Delete
// Uses JWT from auth grant endpoint as auth.
[170] Fix | Delete
WFCentralInstaller.step2 = function() {
[171] Fix | Delete
wfCentralStepAjax('step2', 'wordfence_wfcentral_step2', {}, function(response) {
[172] Fix | Delete
$(window).trigger('step3', response);
[173] Fix | Delete
}, wfConnectError);
[174] Fix | Delete
};
[175] Fix | Delete
[176] Fix | Delete
$(window).on('step2', WFCentralInstaller.step2);
[177] Fix | Delete
[178] Fix | Delete
// Step 3: Makes GET request to `/central/api/wf/site/<guid>` endpoint signed using Wordfence plugin private key.
[179] Fix | Delete
// - Expects 200 response with site data.
[180] Fix | Delete
WFCentralInstaller.step3 = function() {
[181] Fix | Delete
wfCentralStepAjax('step3', 'wordfence_wfcentral_step3', {}, function(response) {
[182] Fix | Delete
var callback = function() {
[183] Fix | Delete
$(window).trigger('step4')
[184] Fix | Delete
};
[185] Fix | Delete
var interval = setInterval(callback, 4000);
[186] Fix | Delete
$(window).on('step3-clearInterval', function() {
[187] Fix | Delete
clearInterval(interval);
[188] Fix | Delete
});
[189] Fix | Delete
callback();
[190] Fix | Delete
}, wfConnectError);
[191] Fix | Delete
};
[192] Fix | Delete
[193] Fix | Delete
$(window).on('step3', WFCentralInstaller.step3);
[194] Fix | Delete
[195] Fix | Delete
// Step 4: Poll for PUT request at `/wp-json/wp/v2/wordfence-auth-grant/` endpoint signed using Wordfence Central private key with short lived JWT.
[196] Fix | Delete
// - Expects verifiable signature of incoming request from Wordfence Central.
[197] Fix | Delete
// - Stores auth grant JWT.
[198] Fix | Delete
WFCentralInstaller.step4 = function() {
[199] Fix | Delete
wfCentralStepAjax('step4', 'wordfence_wfcentral_step4', {}, function(response) {
[200] Fix | Delete
if (response && response.success) {
[201] Fix | Delete
$(window).trigger('step3-clearInterval');
[202] Fix | Delete
$(window).trigger('step5');
[203] Fix | Delete
}
[204] Fix | Delete
}, wfConnectError);
[205] Fix | Delete
};
[206] Fix | Delete
[207] Fix | Delete
$(window).on('step4', WFCentralInstaller.step4);
[208] Fix | Delete
[209] Fix | Delete
// Step 5: Makes GET request to `/central/api/site/<guid>/access-token` endpoint signed using Wordfence plugin private key with auth grant JWT.
[210] Fix | Delete
// - Expects 200 response with access token.
[211] Fix | Delete
WFCentralInstaller.step5 = function() {
[212] Fix | Delete
wfCentralStepAjax('step5', 'wordfence_wfcentral_step5', {
[213] Fix | Delete
'auth-grant': authGrant
[214] Fix | Delete
}, function(response) {
[215] Fix | Delete
$(window).trigger('step6', response);
[216] Fix | Delete
}, wfConnectError);
[217] Fix | Delete
};
[218] Fix | Delete
[219] Fix | Delete
$(window).on('step5', WFCentralInstaller.step5);
[220] Fix | Delete
[221] Fix | Delete
// Step 6: Installation complete. Redirect user back to Wordfence Central with access token.
[222] Fix | Delete
WFCentralInstaller.step6 = function(response) {
[223] Fix | Delete
wfCentralStepAjax('step6', 'wordfence_wfcentral_step6', {}, function(response) {
[224] Fix | Delete
document.location.href = response['redirect-url'];
[225] Fix | Delete
}, wfConnectError);
[226] Fix | Delete
};
[227] Fix | Delete
[228] Fix | Delete
$(window).on('step6', WFCentralInstaller.step6);
[229] Fix | Delete
[230] Fix | Delete
var self = this;
[231] Fix | Delete
[232] Fix | Delete
$(function() {
[233] Fix | Delete
// if (!authGrant) {
[234] Fix | Delete
// wfConnectError('Auth grant not found.');
[235] Fix | Delete
// return;
[236] Fix | Delete
// }
[237] Fix | Delete
[238] Fix | Delete
if (!connected && authGrant) {
[239] Fix | Delete
for (var i = 0; i < currentStep; i++) {
[240] Fix | Delete
var el = $('#wf-central-progress-step' + i);
[241] Fix | Delete
el.removeClass('pending')
[242] Fix | Delete
.addClass('complete-success');
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
WFCentralInstaller['step' + currentStep]();
[246] Fix | Delete
}
[247] Fix | Delete
});
[248] Fix | Delete
[249] Fix | Delete
})(jQuery);
[250] Fix | Delete
</script>
[251] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function