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.../modules/login-se.../views/options
File: option-roles.php
<?php
[0] Fix | Delete
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
[1] Fix | Delete
[2] Fix | Delete
use WordfenceLS\Controller_Settings;
[3] Fix | Delete
use WordfenceLS\Text\Model_JavaScript;
[4] Fix | Delete
[5] Fix | Delete
$states = array(
[6] Fix | Delete
Controller_Settings::STATE_2FA_DISABLED => __('Disabled', 'wordfence'),
[7] Fix | Delete
Controller_Settings::STATE_2FA_OPTIONAL => __('Optional', 'wordfence'),
[8] Fix | Delete
Controller_Settings::STATE_2FA_REQUIRED => __('Required', 'wordfence')
[9] Fix | Delete
);
[10] Fix | Delete
[11] Fix | Delete
$gracePeriod = Controller_Settings::shared()->get_int(Controller_Settings::OPTION_REQUIRE_2FA_USER_GRACE_PERIOD, Controller_Settings::DEFAULT_REQUIRE_2FA_USER_GRACE_PERIOD);
[12] Fix | Delete
$woocommerceIntegrationEnabled = Controller_Settings::shared()->get_bool(\WordfenceLS\Controller_Settings::OPTION_ENABLE_WOOCOMMERCE_INTEGRATION);
[13] Fix | Delete
[14] Fix | Delete
$requiredRoles = array();
[15] Fix | Delete
foreach ($options as $option) {
[16] Fix | Delete
if ($option['state'] === Controller_Settings::STATE_2FA_REQUIRED) {
[17] Fix | Delete
$requiredRoles[$option['role']] = $option['title'];
[18] Fix | Delete
}
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
$customerRoleWarning = __('Requiring 2FA for customers is not recommended as some customers may experience difficulties setting up or using two-factor authentication. Instead, using the "Optional" mode for users with the customer role is recommended which will allow customers to enable 2FA, but will not require them to do so.', 'wordfence');
[22] Fix | Delete
[23] Fix | Delete
?>
[24] Fix | Delete
<ul class="wfls-option wfls-option-2fa-roles">
[25] Fix | Delete
<li class="wfls-option-title">
[26] Fix | Delete
<label><?php esc_html_e('2FA Roles', 'wordfence') ?></label>
[27] Fix | Delete
</li>
[28] Fix | Delete
<li class="wfls-option-content">
[29] Fix | Delete
<ul>
[30] Fix | Delete
<?php foreach ($options as $option): ?>
[31] Fix | Delete
<?php $selectId = 'wfls-2fa-role-' . $option['name']; ?>
[32] Fix | Delete
<li>
[33] Fix | Delete
<label for="<?php echo esc_attr($selectId) ?>"><?php echo esc_html($option['title']) ?></label>
[34] Fix | Delete
<select id="<?php echo esc_attr($selectId) ?>" name="<?php echo esc_attr($option['name']) ?>" class="wfls-option-select">
[35] Fix | Delete
<?php foreach ($states as $key => $label): ?>
[36] Fix | Delete
<?php if (!$option['allow_disabling'] && $key === Controller_Settings::STATE_2FA_DISABLED) continue; ?>
[37] Fix | Delete
<option
[38] Fix | Delete
value="<?php echo esc_attr($key); ?>"
[39] Fix | Delete
<?php if($option['state'] === $key): ?> selected<?php endif ?>
[40] Fix | Delete
<?php if(!$option['editable']): ?> disabled<?php endif ?>
[41] Fix | Delete
>
[42] Fix | Delete
<?php echo esc_html($label) ?>
[43] Fix | Delete
</option>
[44] Fix | Delete
<?php endforeach ?>
[45] Fix | Delete
</select>
[46] Fix | Delete
</li>
[47] Fix | Delete
<?php endforeach ?>
[48] Fix | Delete
</ul>
[49] Fix | Delete
<p id="wfls-customer-2fa-required-warning" class="wfls-notice" style="display: none;"><?php echo esc_html($customerRoleWarning) ?></p>
[50] Fix | Delete
<?php if ($hasWoocommerce && !$woocommerceIntegrationEnabled): ?>
[51] Fix | Delete
<p class="wfls-woocommerce-customer-integration-message"><small><?php esc_html_e('In order to use 2FA with the WooCommerce customer role, you must either enable the "WooCommerce integration" option or use the "wordfence_2fa_management" shortcode to provide customers with access to the 2FA management interface. The default interface is only available through WordPress admin pages which are not accessible to users in the customer role.', 'wordfence') ?></small></p>
[52] Fix | Delete
<?php endif ?>
[53] Fix | Delete
</li>
[54] Fix | Delete
<li class="wfls-2fa-grace-period-container">
[55] Fix | Delete
<label for="wfls-2fa-grace-period" class="wfls-primary-label"><?php esc_html_e('Grace Period', 'wordfence') ?></label>
[56] Fix | Delete
<input id="wfls-2fa-grace-period" type="text" pattern="[0-9]+" value="<?php echo (int)$gracePeriod; ?>" class="wfls-option-input wfls-option-input-required" name="<?php echo esc_html(Controller_Settings::OPTION_REQUIRE_2FA_USER_GRACE_PERIOD) ?>" maxlength="2">
[57] Fix | Delete
<label for="wfls-2fa-grace-period"><?php esc_html_e('days', 'wordfence') ?></label>
[58] Fix | Delete
<div id="wfls-grace-period-zero-warning" style="display: none;">
[59] Fix | Delete
<strong><?php esc_html_e('Setting the grace period to 0 will prevent users in roles where 2FA is required, including newly created users, from logging in if they have not already enabled two-factor authentication.', 'wordfence') ?></strong>
[60] Fix | Delete
<a href="<?php echo esc_attr(\WordfenceLS\Controller_Support::esc_supportURL(\WordfenceLS\Controller_Support::ITEM_MODULE_LOGIN_SECURITY_ROLES)) ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e('Learn More', 'wordfence') ?></a>
[61] Fix | Delete
</div>
[62] Fix | Delete
<small><?php esc_html_e('For roles that require 2FA, users will have this many days to set up 2FA. Failure to set up 2FA during this period will result in the user losing account access. This grace period will apply to new users from the time of account creation. For existing users, this grace period will apply relative to the time at which the requirement is implemented. This grace period will not automatically apply to admins and must be manually enabled for each admin user.', 'wordfence') ?></small>
[63] Fix | Delete
</li>
[64] Fix | Delete
<?php if (!empty($requiredRoles)): ?>
[65] Fix | Delete
<li class="wfls-2fa-notification-action">
[66] Fix | Delete
<h4><?php esc_html_e('2FA Notifications', 'wordfence') ?></h4>
[67] Fix | Delete
<p>
[68] Fix | Delete
<small><?php esc_html_e('Send an email to users with the selected role to notify them of the grace period for enabling 2FA. Select the desired role and optionally specify the URL to be sent in the email to setup 2FA. If left blank, the URL defaults to the standard wordpress login and Wordfence’s Two-Factor Authentication plugin page. For example, if using WooCommerce, input the relative URL of the account page.', 'wordfence') ?></small>
[69] Fix | Delete
<a href="<?php echo \WordfenceLS\Controller_Support::esc_supportURL(\WordfenceLS\Controller_Support::ITEM_MODULE_LOGIN_SECURITY_2FA_NOTIFICATIONS) ?>" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="<?php echo \WordfenceLS\Controller_WordfenceLS::shared()->should_use_core_font_awesome_styles() ? 'wf-fa wf-fa-question-circle-o' : 'wfls-fa wfls-fa-question-circle-o'; ?>" aria-hidden="true"></i></a>
[70] Fix | Delete
</p>
[71] Fix | Delete
<div>
[72] Fix | Delete
<label><?php esc_html_e('2FA Role', 'wordfence') ?></label>
[73] Fix | Delete
<select id="wfls-grace-period-notification-role">
[74] Fix | Delete
<?php foreach ($requiredRoles as $role => $label): ?>
[75] Fix | Delete
<option value="<?php echo esc_attr($role) ?>"><?php echo esc_html($label) ?></option>
[76] Fix | Delete
<?php endforeach ?>
[77] Fix | Delete
</select>
[78] Fix | Delete
</div>
[79] Fix | Delete
<div>
[80] Fix | Delete
<label><?php esc_html_e('2FA Relative URL (optional)', 'wordfence') ?></label>
[81] Fix | Delete
<input id="wfls-grace-period-notification-url" type="text" placeholder="ex: /my-account/">
[82] Fix | Delete
</div>
[83] Fix | Delete
<button class="wfls-btn wfls-btn-default wfls-btn-sm" id="wfls-send-grace-period-notification"><?php esc_html_e('Notify', 'wordfence') ?></button>
[84] Fix | Delete
</li>
[85] Fix | Delete
<?php endif ?>
[86] Fix | Delete
</ul>
[87] Fix | Delete
<script>
[88] Fix | Delete
(function($) {
[89] Fix | Delete
function sendGracePeriodNotification(notifyAll) {
[90] Fix | Delete
var request = {
[91] Fix | Delete
role: $('#wfls-grace-period-notification-role').val(),
[92] Fix | Delete
url: $('#wfls-grace-period-notification-url').val(),
[93] Fix | Delete
};
[94] Fix | Delete
if (typeof notifyAll !== "undefined" && notifyAll)
[95] Fix | Delete
request.notify_all = true;
[96] Fix | Delete
WFLS.ajax('wordfence_ls_send_grace_period_notification', request,
[97] Fix | Delete
function(response) {
[98] Fix | Delete
if (response.error) {
[99] Fix | Delete
var settings = {
[100] Fix | Delete
additional_buttons: []
[101] Fix | Delete
};
[102] Fix | Delete
if (response.limit_exceeded) {
[103] Fix | Delete
settings.additional_buttons.push({
[104] Fix | Delete
label: '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Send Anyway', 'wordfence')); ?>',
[105] Fix | Delete
id: 'wfls-send-grace-period-notification-over-limit'
[106] Fix | Delete
});
[107] Fix | Delete
}
[108] Fix | Delete
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Sending Notification', 'wordfence')); ?>', response.error, settings);
[109] Fix | Delete
}
[110] Fix | Delete
else {
[111] Fix | Delete
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Notification Sent', 'wordfence')); ?>', response.confirmation);
[112] Fix | Delete
}
[113] Fix | Delete
if (request.notify_all) {
[114] Fix | Delete
WFLS.panelClose();
[115] Fix | Delete
}
[116] Fix | Delete
},
[117] Fix | Delete
function (error) {
[118] Fix | Delete
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Sending Notification', 'wordfence')); ?>', '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('An error was encountered while trying to send the notification. Please try again.', 'wordfence')); ?>');
[119] Fix | Delete
if (request.notify_all) {
[120] Fix | Delete
WFLS.panelClose();
[121] Fix | Delete
}
[122] Fix | Delete
});
[123] Fix | Delete
}
[124] Fix | Delete
$('#wfls-send-grace-period-notification').on('click', function(e) {
[125] Fix | Delete
e.preventDefault();
[126] Fix | Delete
e.stopPropagation();
[127] Fix | Delete
sendGracePeriodNotification();
[128] Fix | Delete
});
[129] Fix | Delete
$(document).on('click', '#wfls-send-grace-period-notification-over-limit', function() {
[130] Fix | Delete
sendGracePeriodNotification(true);
[131] Fix | Delete
$(this).prop("disabled", true);
[132] Fix | Delete
});
[133] Fix | Delete
$('#wfls-2fa-grace-period').on('input', function(e) {
[134] Fix | Delete
var value = $(this).val();
[135] Fix | Delete
value = value.replace(/[^0-9]/g, '');
[136] Fix | Delete
value = parseInt(value);
[137] Fix | Delete
if (isNaN(value))
[138] Fix | Delete
value = '';
[139] Fix | Delete
if (value === 0) {
[140] Fix | Delete
$("#wfls-grace-period-zero-warning").show();
[141] Fix | Delete
}
[142] Fix | Delete
else {
[143] Fix | Delete
$("#wfls-grace-period-zero-warning").hide();
[144] Fix | Delete
}
[145] Fix | Delete
$(this).val(value);
[146] Fix | Delete
}).trigger('input');
[147] Fix | Delete
var customerRoleInput = $('#wfls-2fa-role-enabled-roles\\.customer');
[148] Fix | Delete
function isCustomerRoleRequired() {
[149] Fix | Delete
return customerRoleInput.val() === 'required';
[150] Fix | Delete
}
[151] Fix | Delete
function toggleCustomerRoleWarning() {
[152] Fix | Delete
$("#wfls-customer-2fa-required-warning").toggle(isCustomerRoleRequired());
[153] Fix | Delete
}
[154] Fix | Delete
toggleCustomerRoleWarning();
[155] Fix | Delete
customerRoleInput.on('change', function(e) {
[156] Fix | Delete
toggleCustomerRoleWarning();
[157] Fix | Delete
if (isCustomerRoleRequired()) {
[158] Fix | Delete
WFLS.displayModalMessage(
[159] Fix | Delete
<?php Model_JavaScript::echo_string_literal(__('Not Recommended', 'wordfence')) ?>,
[160] Fix | Delete
<?php Model_JavaScript::echo_string_literal($customerRoleWarning) ?>,
[161] Fix | Delete
[
[162] Fix | Delete
{
[163] Fix | Delete
label: <?php Model_JavaScript::echo_string_literal(__('Make Optional', 'wordfence')) ?>,
[164] Fix | Delete
id: 'wfls-customer-role-warning-revert',
[165] Fix | Delete
type: 'primary'
[166] Fix | Delete
},
[167] Fix | Delete
{
[168] Fix | Delete
label: <?php Model_JavaScript::echo_string_literal(__('Proceed', 'wordfence')) ?>,
[169] Fix | Delete
id: 'wfls-generic-modal-close',
[170] Fix | Delete
type: 'danger'
[171] Fix | Delete
}
[172] Fix | Delete
]
[173] Fix | Delete
);
[174] Fix | Delete
}
[175] Fix | Delete
});
[176] Fix | Delete
$('body').on('click', '#wfls-customer-role-warning-revert', function() {
[177] Fix | Delete
customerRoleInput.val('optional').trigger('change');
[178] Fix | Delete
$('#wfls-generic-modal-close').trigger('click');
[179] Fix | Delete
});
[180] Fix | Delete
})(jQuery);
[181] Fix | Delete
</script>
[182] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function