first commit

This commit is contained in:
Rachit Bhargava
2023-07-21 17:12:10 -04:00
parent d0fe47dde4
commit 5d0f0734d8
14003 changed files with 2829464 additions and 0 deletions

View File

@@ -0,0 +1,128 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
$optionName = \WordfenceLS\Controller_Settings::OPTION_RECAPTCHA_THRESHOLD;
$currentValue = \WordfenceLS\Controller_Settings::shared()->get_float($optionName, 0.5);
$selectOptions = array(
array('label' => __('1.0 (definitely a human)', 'wordfence-2fa'), 'value' => 1.0),
array('label' => __('0.9', 'wordfence-2fa'), 'value' => 0.9),
array('label' => __('0.8', 'wordfence-2fa'), 'value' => 0.8),
array('label' => __('0.7', 'wordfence-2fa'), 'value' => 0.7),
array('label' => __('0.6', 'wordfence-2fa'), 'value' => 0.6),
array('label' => __('0.5 (probably a human)', 'wordfence-2fa'), 'value' => 0.5),
array('label' => __('0.4', 'wordfence-2fa'), 'value' => 0.4),
array('label' => __('0.3', 'wordfence-2fa'), 'value' => 0.3),
array('label' => __('0.2', 'wordfence-2fa'), 'value' => 0.2),
array('label' => __('0.1', 'wordfence-2fa'), 'value' => 0.1),
array('label' => __('0.0 (definitely a bot)', 'wordfence-2fa'), 'value' => 0.0),
);
?>
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li>
<ul id="wfls-option-recaptcha-threshold" class="wfls-option wfls-option-select" data-select-option="<?php echo esc_attr($optionName); ?>" data-original-select-value="<?php echo esc_attr($currentValue); ?>">
<li class="wfls-option-spacer"></li>
<li class="wfls-option-content">
<ul>
<li class="wfls-option-title">
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li><span id="wfls-option-recaptcha-threshold-label"><strong><?php esc_html_e('reCAPTCHA human/bot threshold score', 'wordfence-2fa'); ?></strong></span></li>
<li class="wfls-option-subtitle"><?php esc_html_e('A reCAPTCHA score equal to or higher than this value will be considered human. Anything lower will be treated as a bot and require additional verification for login and registration.', 'wordfence-2fa'); ?></li>
</ul>
</li>
<li class="wfls-option-select wfls-padding-add-top-xs-small">
<select aria-labelledby="wfls-option-recaptcha-threshold-label">
<?php foreach ($selectOptions as $o): ?>
<option class="wfls-option-select-option" value="<?php echo esc_attr($o['value']); ?>"<?php if (((int) ($o['value'] * 10)) == ((int) ($currentValue * 10))) { echo ' selected'; } ?>><?php echo esc_html($o['label']); ?></option>
<?php endforeach; ?>
</select>
</li>
</ul>
</li>
</ul>
</li>
<li>
<ul class="wfls-option">
<li class="wfls-option-spacer"></li>
<li class="wfls-recaptcha-score-history">
<div class="wfls-recaptcha-chart-container">
<canvas id="wfls-recaptcha-score-history"></canvas>
</div>
<div class="wfls-center">
<a href="#" id="wfls-reset-recaptcha-score-stats" class="wfls-text-small"><?php esc_html_e('Reset Score Statistics', 'wordfence-2fa'); ?></a>
</div>
</li>
</ul>
</li>
</ul>
<script type="application/javascript">
<?php
$stats = \WordfenceLS\Controller_Settings::shared()->get_array(\WordfenceLS\Controller_Settings::OPTION_CAPTCHA_STATS);
?>
(function($) {
$(function() {
$('#wfls-reset-recaptcha-score-stats').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
WFLS.ajax('wordfence_ls_reset_recaptcha_stats', {}, function(res) {
if (res.success) {
window.location.reload(true);
}
else {
if (res.hasOwnProperty('html') && res.html) {
WFLS.panelModalHTML((WFLS.screenSize(500) ? '300px' : '400px'), 'Error Resetting reCAPTCHA Statistics', res.error);
}
else {
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), 'Error Resetting reCAPTCHA Statistics', res.error);
}
}
});
});
});
$(window).on('wfls-tab-change.recaptcha-score-history', function(e, target) {
if (target == 'settings') {
var barChartData = {
labels: ['0.0', '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1.0'],
datasets: [{
label: '<?php esc_attr_e('Requests', 'wordfence-2fa'); ?>',
backgroundColor: 'rgba(75,192,192,0.4)',
borderColor: 'rgba(75,192,192,1.0)',
borderWidth: 1,
data: <?php echo json_encode($stats['counts']) ?>
}]
};
new Chart($('#wfls-recaptcha-score-history'), {
type: 'bar',
data: barChartData,
options: {
responsive: true,
legend: {
display: false,
},
title: {
display: true,
text: '<?php esc_attr_e('reCAPTCHA Score History', 'wordfence-2fa'); ?>'
},
scales: {
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: '<?php esc_attr_e('Count', 'wordfence-2fa'); ?>'
},
ticks: {
min: 0,
precision: 0,
stepSize: <?php echo max(10, pow(10, floor(log10(array_sum($stats['counts']) / 5)))); ?>
}
}]
}
}
});
$(window).off('wfls-tab-change.recaptcha-score-history');
}
});
})(jQuery);
</script>

View File

@@ -0,0 +1,160 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
$enableOptionName = \WordfenceLS\Controller_Settings::OPTION_ENABLE_AUTH_CAPTCHA;
$currentEnableValue = \WordfenceLS\Controller_Settings::shared()->get_bool($enableOptionName);
$siteKeyOptionName = \WordfenceLS\Controller_Settings::OPTION_RECAPTCHA_SITE_KEY;
$siteKeyValue = \WordfenceLS\Controller_Settings::shared()->get($siteKeyOptionName);
$secretOptionName = \WordfenceLS\Controller_Settings::OPTION_RECAPTCHA_SECRET;
$secretValue = \WordfenceLS\Controller_Settings::shared()->get($secretOptionName);
?>
<ul id="wfls-option-enable-auth-captcha" data-option="<?php echo esc_attr($enableOptionName); ?>" data-enabled-value="1" data-disabled-value="0" data-original-value="<?php echo $currentEnableValue ? '1' : '0'; ?>">
<li>
<ul class="wfls-option wfls-padding-add-bottom-small">
<li id="wfls-enable-auth-captcha" class="wfls-option-checkbox<?php echo ($currentEnableValue ? ' wfls-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($currentEnableValue ? 'true' : 'false'); ?>" tabindex="0"><i class="wfls-ion-ios-checkmark-empty" aria-hidden="true" aria-labelledby="wfls-enable-auth-captcha-label"></i></li>
<li class="wfls-option-title">
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li>
<strong id="wfls-enable-auth-captcha-label"><?php esc_html_e('Enable reCAPTCHA on the login and user registration pages', 'wordfence-2fa'); ?></strong>
</li>
<li class="wfls-option-subtitle"><?php printf(__('reCAPTCHA v3 does not make users solve puzzles or click a checkbox like previous versions. The only visible part is the reCAPTCHA logo. If a visitor\'s browser fails the CAPTCHA, Wordfence will send an email to the user\'s address with a link they can click to verify that they are a user of your site. You can read further details <a href="%s" target="_blank" rel="noopener noreferrer">in our documentation</a>.', 'wordfence-2fa'), \WordfenceLS\Controller_Support::esc_supportURL(\WordfenceLS\Controller_Support::ITEM_MODULE_LOGIN_SECURITY_CAPTCHA)); ?></li>
</ul>
</li>
</ul>
</li>
<li>
<ul class="wfls-option wfls-padding-no-top">
<li class="wfls-option-spacer"></li>
<li>
<table>
<tr class="wfls-option wfls-option-text" data-original-value="<?php echo esc_attr($siteKeyValue); ?>" data-text-option="<?php echo esc_attr($siteKeyOptionName); ?>">
<th id="wfls-enable-captcha-site-key-label" class="wfls-padding-add-bottom"><?php esc_html_e('reCAPTCHA v3 Site Key', 'wordfence-2fa'); ?></th>
<td class="wfls-option-text wfls-padding-add-bottom"><input type="text" name="recaptchaSiteKey" id="input-recaptchaSiteKey" class="wfls-form-control" value="<?php echo esc_attr($siteKeyValue); ?>"<?php if (!$currentEnableValue) { echo ' disabled'; } ?>></td>
</tr>
<tr class="wfls-option wfls-option-text" data-original-value="<?php echo esc_attr($secretValue); ?>" data-text-option="<?php echo esc_attr($secretOptionName); ?>">
<th id="wfls-enable-captcha-secret-label"><?php esc_html_e('reCAPTCHA v3 Secret', 'wordfence-2fa'); ?></th>
<td class="wfls-option-text"><input type="text" name="recaptchaSecret" id="input-recaptchaSecret" class="wfls-form-control" value="<?php echo esc_attr($secretValue); ?>"<?php if (!$currentEnableValue) { echo ' disabled'; } ?>></td>
</tr>
</table>
</li>
</ul>
<ul class="wfls-option wfls-padding-no-top">
<li class="wfls-option-spacer"></li>
<li class="wfls-option-title">
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li class="wfls-option-subtitle"><?php echo wp_kses(__('Note: This feature requires a free site key and secret for the <a href="https://www.google.com/recaptcha/about/" target="_blank" rel="noopener noreferrer">Google reCAPTCHA v3 Service</a>. To set up new reCAPTCHA keys, log into your Google account and go to the <a href="https://www.google.com/recaptcha/admin" target="_blank" rel="noopener noreferrer">reCAPTCHA admin page</a>.', 'wordfence-2fa'), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()))); ?></li>
</ul>
</li>
</ul>
</li>
</ul>
<script type="application/javascript">
(function($) {
$(function() {
$('#wfls-enable-auth-captcha').on('keydown', function(e) {
if (e.keyCode == 32) {
e.preventDefault();
e.stopPropagation();
$(this).trigger('click');
}
});
$('#wfls-enable-auth-captcha').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var optionElement = $('#wfls-option-enable-auth-captcha');
if (optionElement.hasClass('wfls-disabled')) {
return;
}
var option = optionElement.data('option');
var value = false;
var isActive = $(this).hasClass('wfls-checked');
if (isActive) {
$(this).removeClass('wfls-checked').attr('aria-checked', 'false');
$('#input-recaptchaSiteKey, #input-recaptchaSecret').attr('disabled', true);
value = optionElement.data('disabledValue');
}
else {
$(this).addClass('wfls-checked').attr('aria-checked', 'true');
$('#input-recaptchaSiteKey, #input-recaptchaSecret').attr('disabled', false);
value = optionElement.data('enabledValue');
}
var originalValue = optionElement.data('originalValue');
if (originalValue == value) {
delete WFLS.pendingChanges[option];
}
else {
WFLS.pendingChanges[option] = value;
}
$(optionElement).trigger('change', [false]);
WFLS.updatePendingChanges();
});
$('#wfls-enable-auth-captcha-label').on('click', function(e) {
var links = $(this).find('a');
var buffer = 10;
for (var i = 0; i < links.length; i++) {
var t = $(links[i]).offset().top;
var l = $(links[i]).offset().left;
var b = t + $(links[i]).height();
var r = l + $(links[i]).width();
if (e.pageX > l - buffer && e.pageX < r + buffer && e.pageY > t - buffer && e.pageY < b + buffer) {
return;
}
}
$(this).closest('.wfls-option').find('.wfls-option-checkbox').trigger('click');
}).css('cursor', 'pointer');
$('#input-recaptchaSiteKey, #input-recaptchaSecret').on('change paste keyup', function() {
var e = this;
setTimeout(function() {
var optionElement = $(e).closest('.wfls-option');
var option = optionElement.data('textOption');
if (typeof option !== 'undefined') {
var value = $(e).val();
var originalValue = $(optionElement).data('originalValue');
if (originalValue == value) {
delete WFLS.pendingChanges[option];
}
else {
WFLS.pendingChanges[option] = value;
}
$(optionElement).trigger('change', [false]);
WFLS.updatePendingChanges();
}
}, 4);
});
$(window).on('wflsOptionsReset', function() {
$('#wfls-enable-auth-captcha').each(function() {
var enabledValue = $(this).data('enabledValue');
var disabledValue = $(this).data('disabledValue');
var originalValue = $(this).data('originalValue');
if (enabledValue == originalValue) {
$(this).find('#wfls-enable-auth-captcha.wfls-option-checkbox').addClass('wfls-checked').attr('aria-checked', 'true');
}
else {
$(this).find('#wfls-enable-auth-captcha.wfls-option-checkbox').removeClass('wfls-checked').attr('aria-checked', 'false');
}
$(this).trigger('change', [true]);
});
$('#input-recaptchaSiteKey, #input-recaptchaSecret').each(function() {
$(this).val($(this).data('originalValue'));
$(this).attr('disabled', !$('#wfls-enable-auth-captcha.wfls-option-checkbox').hasClass('wfls-checked'));
});
});
});
})(jQuery);
</script>

View File

@@ -0,0 +1,165 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents the global option OPTION_IP_SOURCE with a value select menu and text area (hidden by default) for trusted proxies.
*/
$selectOptions = array(
array('value' => \WordfenceLS\Model_Request::IP_SOURCE_AUTOMATIC, 'label' => esc_html__('Use the most secure method to get visitor IP addresses. Prevents spoofing and works with most sites.', 'wordfence-2fa') . ' <strong>' . esc_html__('(Recommended)', 'wordfence-2fa') . '</strong>'),
array('value' => \WordfenceLS\Model_Request::IP_SOURCE_REMOTE_ADDR, 'label' => esc_html__('Use PHP\'s built in REMOTE_ADDR and don\'t use anything else. Very secure if this is compatible with your site.', 'wordfence-2fa')),
array('value' => \WordfenceLS\Model_Request::IP_SOURCE_X_FORWARDED_FOR, 'label' => esc_html__('Use the X-Forwarded-For HTTP header. Only use if you have a front-end proxy or spoofing may result.', 'wordfence-2fa')),
array('value' => \WordfenceLS\Model_Request::IP_SOURCE_X_REAL_IP, 'label' => esc_html__('Use the X-Real-IP HTTP header. Only use if you have a front-end proxy or spoofing may result.', 'wordfence-2fa')),
);
?>
<ul class="wfls-flex-vertical wfls-flex-full-width">
<li>
<ul id="wfls-option-ip-source" class="wfls-option wfls-option-ip-source" data-option="<?php echo esc_attr(\WordfenceLS\Controller_Settings::OPTION_IP_SOURCE); ?>" data-original-value="<?php echo esc_attr(\WordfenceLS\Controller_Settings::shared()->get(\WordfenceLS\Controller_Settings::OPTION_IP_SOURCE)); ?>" data-text-area-option="<?php echo esc_attr(\WordfenceLS\Controller_Settings::OPTION_IP_TRUSTED_PROXIES); ?>" data-original-text-area-value="<?php echo esc_attr(\WordfenceLS\Controller_Settings::shared()->get(\WordfenceLS\Controller_Settings::OPTION_IP_TRUSTED_PROXIES)); ?>">
<li class="wfls-option-content wfls-no-right">
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li class="wfls-option-title"><strong><?php esc_html_e('How to get IPs', 'wordfence-2fa'); ?></strong></li>
<li>
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li class="wfls-padding-add-left">
<ul class="wfls-flex-vertical wfls-flex-align-left" role="radiogroup">
<?php foreach ($selectOptions as $o): ?>
<li class="wfls-padding-add-top-small"><input type="radio" class="wfls-option-radio" name="wfls-ip-source" value="<?php echo esc_attr($o['value']); ?>" id="wfls-ip-source-<?php echo esc_attr(preg_replace('/[^a-z0-9]/i', '-', $o['value'])); ?>"<?php if ($o['value'] == \WordfenceLS\Controller_Settings::shared()->get(\WordfenceLS\Controller_Settings::OPTION_IP_SOURCE)) { echo ' checked'; } ?>><label for="wfls-ip-source-<?php echo esc_attr(preg_replace('/[^a-z0-9]/i', '-', $o['value'])); ?>">&nbsp;&nbsp;</label><?php echo $o['label']; ?></li>
<?php endforeach; ?>
</ul>
</li>
<li class="wfls-option-ip-source-details wfls-padding-add-top">
<div class="wfls-left">Detected IP(s): <span id="wfls-ip-source-preview-all"><?php echo \WordfenceLS\Model_Request::current()->detected_ip_preview(); ?></span></div>
<div class="wfls-left">Your IP with this setting: <span id="wfls-ip-source-preview-single"><?php echo esc_html(\WordfenceLS\Model_Request::current()->ip()); ?></span></div>
<div class="wfls-left"><a href="#" id="wfls-ip-source-trusted-proxies-show">+ Edit trusted proxies</a></div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li id="wfls-ip-source-trusted-proxies">
<ul id="wfls-option-ip-source-trusted-proxies" class="wfls-option wfls-option-textarea" data-text-option="<?php echo esc_attr(\WordfenceLS\Controller_Settings::OPTION_IP_TRUSTED_PROXIES); ?>" data-original-text-value="<?php echo esc_attr(\WordfenceLS\Controller_Settings::shared()->get(\WordfenceLS\Controller_Settings::OPTION_IP_TRUSTED_PROXIES)); ?>">
<li class="wfls-option-spacer"></li>
<li class="wfls-option-content wfls-no-right">
<ul>
<li class="wfls-option-title">
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li><?php esc_html_e('Trusted Proxies', 'wordfence-2fa'); ?></li>
<li class="wfls-option-subtitle"><?php esc_html_e('These IPs (or CIDR ranges) will be ignored when determining the requesting IP via the X-Forwarded-For HTTP header. Enter one IP or CIDR range per line.', 'wordfence-2fa'); ?></li>
</ul>
</li>
<li class="wfls-option-textarea">
<textarea spellcheck="false" autocapitalize="none" autocomplete="off" name="howGetIPs_trusted_proxies"><?php echo esc_html(\WordfenceLS\Controller_Settings::shared()->get(\WordfenceLS\Controller_Settings::OPTION_IP_TRUSTED_PROXIES)); ?></textarea>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<script type="application/javascript">
(function($) {
$(function() {
var updateIPPreview = function() {
WFLS.updateIPPreview({ip_source: $('input[name="wfls-ip-source"]:checked').val(), ip_source_trusted_proxies: $('#wfls-ip-source-trusted-proxies textarea').val()}, function(ret) {
if (ret && ret.ip) {
$('#wfls-ip-source-preview-all').html(ret.preview);
$('#wfls-ip-source-preview-single').html(ret.ip);
}
});
};
$('input[name="wfls-ip-source"]').on('change', function() {
var optionElement = $(this).closest('.wfls-option.wfls-option-ip-source');
var option = optionElement.data('option');
var value = $('input[name="wfls-ip-source"]:checked').val();
var originalValue = optionElement.data('originalValue');
if (originalValue == value) {
delete WFLS.pendingChanges[option];
}
else {
WFLS.pendingChanges[option] = value;
}
WFLS.updatePendingChanges();
updateIPPreview();
});
var coalescingUpdateTimer;
$('#wfls-ip-source-trusted-proxies textarea').on('change paste keyup', function() {
var e = this;
setTimeout(function() {
clearTimeout(coalescingUpdateTimer);
coalescingUpdateTimer = setTimeout(updateIPPreview, 1000);
var optionElement = $(e).closest('.wfls-option.wfls-option-textarea');
var option = optionElement.data('textOption');
var value = $(e).val();
var originalValue = optionElement.data('originalTextValue');
if (originalValue == value) {
delete WFLS.pendingChanges[option];
}
else {
WFLS.pendingChanges[option] = value;
}
WFLS.updatePendingChanges();
}, 4);
});
$(window).on('wflsOptionsReset', function() {
$('input[name="wfls-ip-source"]').each(function() {
var optionElement = $(this).closest('.wfls-option.wfls-option-ip-source');
var option = optionElement.data('option');
var originalValue = optionElement.data('originalValue');
$(this).prop('checked', originalValue == $(this).attr('value'));
});
$('#wfls-ip-source-trusted-proxies textarea').each(function() {
var optionElement = $(this).closest('.wfls-option.wfls-option-textarea');
var originalValue = optionElement.data('originalTextAreaValue');
$(this).val(originalValue);
});
updateIPPreview();
});
$('#wfls-ip-source-trusted-proxies-show').each(function() {
$(this).on('keydown', function(e) {
if (e.keyCode == 32) {
e.preventDefault();
e.stopPropagation();
$(this).trigger('click');
}
});
$(this).on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var isActive = $('#wfls-ip-source-trusted-proxies').hasClass('wfls-active');
if (isActive) {
$('#wfls-ip-source-trusted-proxies').slideUp({
always: function() {
$('#wfls-ip-source-trusted-proxies').removeClass('wfls-active');
}
});
}
else {
$(this).parent().slideUp();
$('#wfls-ip-source-trusted-proxies').slideDown({
always: function() {
$('#wfls-ip-source-trusted-proxies').addClass('wfls-active');
}
});
}
});
});
});
})(jQuery);
</script>

View File

@@ -0,0 +1,37 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents an option-styled text value.
*
* Expects $title (or $titleHTML) to be defined. $helpLink may also be defined.
*
* @var string $title The title shown for the option.
* @var string $titleHTML The raw HTML title shown for the option. This supersedes $title.
* @var string $helpLink If defined, the link to the corresponding external help page.
*/
if (!isset($titleHTML)) {
$titleHTML = esc_html($title);
}
?>
<ul class="wfls-option wfls-option-label">
<?php if (!isset($noSpacer) || !$noSpacer): ?>
<li class="wfls-option-spacer"></li>
<?php endif; ?>
<li class="wfls-option-content">
<ul>
<li class="wfls-option-title">
<?php if (isset($subtitle)): ?>
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li>
<?php endif; ?>
<?php echo $titleHTML; ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?>
<?php if (isset($subtitle)): ?>
</li>
<li class="wfls-option-subtitle"><?php echo esc_html($subtitle); ?></li>
</ul>
<?php endif; ?>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,88 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
$maxFailures = (int) \WordfenceLS\Controller_Time::FAILURE_LIMIT;
$cronDisabled = \WordfenceLS\Controller_Settings::shared()->is_ntp_cron_disabled($failureCount);
$id = 'wfls-option-ntp';
?>
<ul id="<?php echo esc_attr($id); ?>" class="wfls-option wfls-flex-vertical wfls-flex-align-left">
<li class="wfls-option-title"><strong><?php esc_html_e('NTP', 'wordfence-2fa') ?></strong></li>
<li class="wfls-option-content">
<p><?php esc_html_e('NTP is a protocol that allows for remote time synchronization. Wordfence Login Security uses this protocol to ensure that it has the most accurate time which is necessary for TOTP-based two-factor authentication.', 'wordfence-2fa') ?></p>
<?php if (\WordfenceLS\Controller_Settings::shared()->is_ntp_disabled_via_constant()): ?>
<p><?php esc_html_e('The constant WORDFENCE_LS_DISABLE_NTP is defined which disables NTP entirely. Remove this constant or set it to a falsy value to enable NTP.', 'wordfence-2fa') ?></p>
<?php elseif ($cronDisabled): ?>
<?php if ($failureCount > 0): ?>
<p><strong><?php echo sprintf(esc_html__('NTP is currently disabled as %d subsequent attempts have failed.', 'wordfence-2fa'), $maxFailures) ?></strong></p>
<?php else: ?>
<p><?php esc_html_e('NTP was manually disabled.', 'wordfence-2fa') ?></p>
<?php endif ?>
<button id="wfls-reset-ntp-failure-count" class="wfls-btn wfls-btn-sm wfls-btn-default"><?php esc_html_e('Reset', 'wordfence-2fa') ?></button>
<?php else: ?>
<p><?php echo wp_kses(__('NTP is currently <strong>enabled</strong>.', 'wordfence-2fa'), array('strong'=>array())); ?></p>
<?php if ($failureCount > 0): ?>
<?php $remainingAttempts = $maxFailures - $failureCount; ?>
<p>
<strong><?php esc_html_e('NTP updates are currently failing.', 'wordfence-2fa') ?></strong>
<?php echo $remainingAttempts > 0 ? sprintf(esc_html__('NTP will be automatically disabled after %d more attempts.', 'wordfence-2fa'), $remainingAttempts) : esc_html__('NTP will be automatically disabled after 1 more attempt.', 'wordfence-2fa') ?>
</p>
<?php endif ?>
<button id="wfls-disable-ntp" class="wfls-btn wfls-btn-sm wfls-btn-default"><?php esc_html_e('Disable', 'wordfence-2fa') ?></button>
<?php endif ?>
</li>
</ul>
<script>
(function($) {
$(function() {
$('#wfls-reset-ntp-failure-count').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
function handleError(message) {
WFLS.panelModal(
(WFLS.screenSize(500) ? '300px' : '400px'),
'<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Resetting NTP', 'wordfence-2fa')); ?>',
typeof message === 'undefined' ? '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('An error was encountered while trying to reset the NTP state. Please try again.', 'wordfence-2fa')); ?>' : message
);
}
WFLS.ajax('wordfence_ls_reset_ntp_failure_count', [],
function(response) {
if (response.error) {
handleError(response.error);
}
else {
window.location.reload();
}
},
function (error) {
handleError();
});
});
$('#wfls-disable-ntp').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
function handleError(message) {
WFLS.panelModal(
(WFLS.screenSize(500) ? '300px' : '400px'),
'<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Disabling NTP', 'wordfence-2fa')); ?>',
typeof message === 'undefined' ? '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('An error was encountered while trying to disable NTP. Please try again.', 'wordfence-2fa')); ?>' : message
);
}
WFLS.ajax('wordfence_ls_disable_ntp', [],
function(response) {
if (response.error) {
handleError(response.error);
}
else {
window.location.reload();
}
},
function (error) {
handleError();
});
});
});
})(jQuery);
</script>

View File

@@ -0,0 +1,183 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
use WordfenceLS\Controller_Settings;
use WordfenceLS\Text\Model_JavaScript;
$states = array(
Controller_Settings::STATE_2FA_DISABLED => __('Disabled', 'wordfence-2fa'),
Controller_Settings::STATE_2FA_OPTIONAL => __('Optional', 'wordfence-2fa'),
Controller_Settings::STATE_2FA_REQUIRED => __('Required', 'wordfence-2fa')
);
$gracePeriod = Controller_Settings::shared()->get_int(Controller_Settings::OPTION_REQUIRE_2FA_USER_GRACE_PERIOD, Controller_Settings::DEFAULT_REQUIRE_2FA_USER_GRACE_PERIOD);
$woocommerceIntegrationEnabled = Controller_Settings::shared()->get_bool(\WordfenceLS\Controller_Settings::OPTION_ENABLE_WOOCOMMERCE_INTEGRATION);
$requiredRoles = array();
foreach ($options as $option) {
if ($option['state'] === Controller_Settings::STATE_2FA_REQUIRED) {
$requiredRoles[$option['role']] = $option['title'];
}
}
$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-2fa');
?>
<ul class="wfls-option wfls-option-2fa-roles">
<li class="wfls-option-title">
<label><?php esc_html_e('2FA Roles', 'wordfence-2fa') ?></label>
</li>
<li class="wfls-option-content">
<ul>
<?php foreach ($options as $option): ?>
<?php $selectId = 'wfls-2fa-role-' . $option['name']; ?>
<li>
<label for="<?php echo esc_attr($selectId) ?>"><?php echo esc_html($option['title']) ?></label>
<select id="<?php echo esc_attr($selectId) ?>" name="<?php echo esc_attr($option['name']) ?>" class="wfls-option-select">
<?php foreach ($states as $key => $label): ?>
<?php if (!$option['allow_disabling'] && $key === Controller_Settings::STATE_2FA_DISABLED) continue; ?>
<option
value="<?php echo esc_attr($key); ?>"
<?php if($option['state'] === $key): ?> selected<?php endif ?>
<?php if(!$option['editable']): ?> disabled<?php endif ?>
>
<?php echo esc_html($label) ?>
</option>
<?php endforeach ?>
</select>
</li>
<?php endforeach ?>
</ul>
<p id="wfls-customer-2fa-required-warning" class="wfls-notice" style="display: none;"><?php echo esc_html($customerRoleWarning) ?></p>
<?php if ($hasWoocommerce && !$woocommerceIntegrationEnabled): ?>
<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-2fa') ?></small></p>
<?php endif ?>
</li>
<li class="wfls-2fa-grace-period-container">
<label for="wfls-2fa-grace-period" class="wfls-primary-label"><?php esc_html_e('Grace Period', 'wordfence-2fa') ?></label>
<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">
<label for="wfls-2fa-grace-period"><?php esc_html_e('days', 'wordfence-2fa') ?></label>
<div id="wfls-grace-period-zero-warning" style="display: none;">
<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-2fa') ?></strong>
<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-2fa') ?></a>
</div>
<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-2fa') ?></small>
</li>
<?php if (!empty($requiredRoles)): ?>
<li class="wfls-2fa-notification-action">
<h4><?php esc_html_e('2FA Notifications', 'wordfence-2fa') ?></h4>
<p>
<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 Wordfences Two-Factor Authentication plugin page. For example, if using WooCommerce, input the relative URL of the account page.', 'wordfence-2fa') ?></small>
<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>
</p>
<div>
<label><?php esc_html_e('2FA Role', 'wordfence-2fa') ?></label>
<select id="wfls-grace-period-notification-role">
<?php foreach ($requiredRoles as $role => $label): ?>
<option value="<?php echo esc_attr($role) ?>"><?php echo esc_html($label) ?></option>
<?php endforeach ?>
</select>
</div>
<div>
<label><?php esc_html_e('2FA Relative URL (optional)', 'wordfence-2fa') ?></label>
<input id="wfls-grace-period-notification-url" type="text" placeholder="ex: /my-account/">
</div>
<button class="wfls-btn wfls-btn-default wfls-btn-sm" id="wfls-send-grace-period-notification"><?php esc_html_e('Notify', 'wordfence-2fa') ?></button>
</li>
<?php endif ?>
</ul>
<script>
(function($) {
function sendGracePeriodNotification(notifyAll) {
var request = {
role: $('#wfls-grace-period-notification-role').val(),
url: $('#wfls-grace-period-notification-url').val(),
};
if (typeof notifyAll !== "undefined" && notifyAll)
request.notify_all = true;
WFLS.ajax('wordfence_ls_send_grace_period_notification', request,
function(response) {
if (response.error) {
var settings = {
additional_buttons: []
};
if (response.limit_exceeded) {
settings.additional_buttons.push({
label: '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Send Anyway', 'wordfence-2fa')); ?>',
id: 'wfls-send-grace-period-notification-over-limit'
});
}
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Sending Notification', 'wordfence-2fa')); ?>', response.error, settings);
}
else {
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Notification Sent', 'wordfence-2fa')); ?>', response.confirmation);
}
if (request.notify_all) {
WFLS.panelClose();
}
},
function (error) {
WFLS.panelModal((WFLS.screenSize(500) ? '300px' : '400px'), '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('Error Sending Notification', 'wordfence-2fa')); ?>', '<?php echo \WordfenceLS\Text\Model_JavaScript::esc_js(__('An error was encountered while trying to send the notification. Please try again.', 'wordfence-2fa')); ?>');
if (request.notify_all) {
WFLS.panelClose();
}
});
}
$('#wfls-send-grace-period-notification').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
sendGracePeriodNotification();
});
$(document).on('click', '#wfls-send-grace-period-notification-over-limit', function() {
sendGracePeriodNotification(true);
$(this).prop("disabled", true);
});
$('#wfls-2fa-grace-period').on('input', function(e) {
var value = $(this).val();
value = value.replace(/[^0-9]/g, '');
value = parseInt(value);
if (isNaN(value))
value = '';
if (value === 0) {
$("#wfls-grace-period-zero-warning").show();
}
else {
$("#wfls-grace-period-zero-warning").hide();
}
$(this).val(value);
}).trigger('input');
var customerRoleInput = $('#wfls-2fa-role-enabled-roles\\.customer');
function isCustomerRoleRequired() {
return customerRoleInput.val() === 'required';
}
function toggleCustomerRoleWarning() {
$("#wfls-customer-2fa-required-warning").toggle(isCustomerRoleRequired());
}
toggleCustomerRoleWarning();
customerRoleInput.on('change', function(e) {
toggleCustomerRoleWarning();
if (isCustomerRoleRequired()) {
WFLS.displayModalMessage(
<?php Model_JavaScript::echo_string_literal(__('Not Recommended', 'wordfence-2fa')) ?>,
<?php Model_JavaScript::echo_string_literal($customerRoleWarning) ?>,
[
{
label: <?php Model_JavaScript::echo_string_literal(__('Make Optional', 'wordfence-2fa')) ?>,
id: 'wfls-customer-role-warning-revert',
type: 'primary'
},
{
label: <?php Model_JavaScript::echo_string_literal(__('Proceed', 'wordfence-2fa')) ?>,
id: 'wfls-generic-modal-close',
type: 'danger'
}
]
);
}
});
$('body').on('click', '#wfls-customer-role-warning-revert', function() {
customerRoleInput.val('optional').trigger('change');
$('#wfls-generic-modal-close').trigger('click');
});
})(jQuery);
</script>

View File

@@ -0,0 +1,32 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents an option with a popup menu for detailed value selection.
*
* Expects $selectOptionName, $selectOptions, $selectValue, and $title to be defined. $helpLink may also be defined.
*
* @var string $selectOptionName The option name for the select portion.
* @var array $selectOptions An array of the possible values for $selectOptionName. The array is of the format array(array('value' => <the internal value>, 'label' => <a display label>), ...)
* @var string $selectValue The current value of $selectOptionName.
* @var string $title The title shown for the option.
* @var string $helpLink If defined, the link to the corresponding external help page.
* @var bool $premium If defined, the option will be tagged as premium only and not allow its value to change for free users.
*/
$id = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $selectOptionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wfls-option wfls-option-select<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wfls-option-premium'; } ?>" data-select-option="<?php echo esc_attr($selectOptionName); ?>" data-original-select-value="<?php echo esc_attr($selectValue); ?>">
<li class="wfls-option-spacer"></li>
<li class="wfls-option-content">
<ul>
<li class="wfls-option-title"><span id="<?php echo esc_attr($id); ?>-label"><?php echo esc_html($title); ?></span><?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' <a href="https://www.wordfence.com/gnl1optionUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer" class="wfls-premium-link">' . esc_html__('Premium Feature', 'wordfence-2fa') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?></li>
<li class="wfls-option-select wfls-padding-add-top-xs-small">
<select<?php echo (!(!wfConfig::p() && isset($premium) && $premium) ? '' : ' disabled'); ?> aria-labelledby="<?php echo esc_attr($id); ?>-label">
<?php foreach ($selectOptions as $o): ?>
<option class="wfls-option-select-option" value="<?php echo esc_attr($o['value']); ?>"<?php if ($o['value'] == $selectValue) { echo ' selected'; } ?>><?php echo esc_html($o['label']); ?></option>
<?php endforeach; ?>
</select>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,43 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents a switch option.
*
* @var string $optionName The option name for the switch. Required.
* @var string $value The current value of $optionName. Required.
* @var string|\WordfenceLS\Text\Model_HTML $title The title shown for the option. Required.
* @var array $states An array of the possible states for the switch. The array matches the format array('value' => <value>, 'label' => <label>) Required.
* @var string $helpLink If defined, the link to the corresponding external help page. Optional.
* @var string $alignment If defined, controls the alignment of the switch control. Optional.
*/
$id = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $optionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wfls-option wfls-option-switch" data-option-name="<?php echo esc_attr($optionName); ?>" data-original-value="<?php echo esc_attr($value); ?>">
<?php if (!isset($noSpacer) || !$noSpacer): ?>
<li class="wfls-option-spacer"></li>
<?php endif; ?>
<li class="wfls-option-content wfls-no-right">
<ul>
<li class="wfls-option-title">
<?php if (isset($subtitle)): ?>
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li>
<?php endif; ?>
<span id="<?php echo esc_attr($id); ?>-label"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($title); ?></span><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?>
<?php if (isset($subtitle)): ?>
</li>
<li class="wfls-option-subtitle"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($subtitle); ?></li>
</ul>
<?php endif; ?>
</li>
<li class="wfls-option-switch<?php if (isset($alignment)) { echo ' ' . $alignment; } ?> wfls-padding-add-top-xs-small">
<ul class="wfls-switch" role="radiogroup" aria-labelledby="<?php echo esc_attr($id); ?>-label">
<?php foreach ($states as $s): ?>
<li<?php if ($s['value'] == $value) { echo ' class="wfls-active"'; } ?> data-option-value="<?php echo esc_attr($s['value']); ?>" role="radio" aria-checked="<?php echo ($s['value'] == $value ? 'true' : 'false'); ?>" tabindex="0"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($s['label']); ?></li>
<?php endforeach; ?>
</ul>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,42 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents a text field option.
*
* Expects $textOptionName, $textValue, and $title to be defined. $placeholder and $helpLink may also be defined.
*
* @var string $textOptionName The option name for the text field.
* @var string $textValue The current value of $textOptionName.
* @var string $title The title shown for the option.
* @var string $placeholder If defined, the placeholder for the text field.
* @var string $helpLink If defined, the link to the corresponding external help page.
* @var bool $premium If defined, the option will be tagged as premium only and not allow its value to change for free users.
*/
if (!isset($placeholder)) {
$placeholder = '';
}
$id = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $textOptionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wfls-option wfls-option-text<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wfls-option-premium'; } ?>" data-text-option="<?php echo esc_attr($textOptionName); ?>" data-original-text-value="<?php echo esc_attr($textValue); ?>">
<li class="wfls-option-spacer"></li>
<li class="wfls-option-content">
<ul>
<li class="wfls-option-title">
<?php if (isset($subtitle)): ?>
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li>
<?php endif; ?>
<span id="<?php echo esc_attr($id); ?>-label"><?php echo esc_html($title); ?></span><?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' <a href="https://www.wordfence.com/gnl1optionUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer" class="wfls-premium-link">' . esc_html__('Premium Feature', 'wordfence-2fa') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?>
<?php if (isset($subtitle)): ?>
</li>
<li class="wfls-option-subtitle"><?php echo esc_html($subtitle); ?></li>
</ul>
<?php endif; ?>
</li>
<li class="wfls-option-text">
<input type="text" value="<?php echo esc_attr($textValue); ?>" placeholder="<?php echo esc_attr($placeholder); ?>"<?php echo (!(!wfConfig::p() && isset($premium) && $premium) ? '' : ' disabled'); ?> aria-labelledby="<?php echo esc_attr($id); ?>-label">
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,55 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents a text area option.
*
* Expects $textOptionName, $textValue, and $title to be defined. $helpLink, $premium, and $noSpacer may also be defined.
*
* @var string $textOptionName The option name for the text field. Required.
* @var string $textValue The current value of $textOptionName. Required.
* @var string|\WordfenceLS\Text\Model_HTML $title The title shown for the option. Required.
* @var string|\WordfenceLS\Text\Model_HTML $subtitle The title shown for the option. Optional.
* @var string $subtitlePosition The position for the subtitle: 'value' for below the value, 'title' for below the title. Optional.
* @var string $helpLink If defined, the link to the corresponding external help page. Optional.
* @var bool $noSpacer If defined and truthy, the spacer will be omitted. Optional.
*/
if (!isset($subtitlePosition)) { //May be 'title' to appear below the title or 'value' to appear below the field
$subtitlePosition = 'title';
}
$id = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $textOptionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wfls-option wfls-option-textarea" data-text-option="<?php echo esc_attr($textOptionName); ?>" data-original-text-value="<?php echo esc_attr($textValue); ?>">
<?php if (!isset($noSpacer) || !$noSpacer): ?>
<li class="wfls-option-spacer"></li>
<?php endif; ?>
<li class="wfls-option-content wfls-no-right">
<ul>
<li class="wfls-option-title<?php if (isset($alignTitle)) { echo $alignTitle == 'top' ? ' wfls-option-title-top' : ($alignTitle == 'bottom' ? 'wfls-option-title-bottom' : ''); } ?>">
<?php if (isset($subtitleHTML) && $subtitlePosition == 'title'): ?>
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li>
<?php endif; ?>
<span id="<?php echo esc_attr($id); ?>-label"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($title); ?></span><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?>
<?php if (isset($subtitle) && $subtitlePosition == 'title'): ?>
</li>
<li class="wfls-option-subtitle"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($subtitle); ?></li>
</ul>
<?php endif; ?>
</li>
<li class="wfls-option-textarea">
<?php if (isset($subtitle) && $subtitlePosition == 'value'): ?>
<ul class="wfls-flex-vertical wfls-flex-align-left wfls-flex-full-width">
<li>
<?php endif; ?>
<textarea aria-labelledby="<?php echo esc_attr($id); ?>-label"><?php echo esc_html($textValue); ?></textarea>
<?php if (isset($subtitle) && $subtitlePosition == 'value'): ?>
</li>
<li class="wfls-option-subtitle"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($subtitle); ?></li>
</ul>
<?php endif; ?>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,39 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents a boolean option with a switch toggle control.
*
* Expects $optionName, $enabledValue, $disabledValue, $value, and $title to be defined. $helpLink may also be defined.
*
* @var string $optionName The option name.
* @var string $enabledValue The value to save in $option if the toggle is enabled.
* @var string $disabledValue The value to save in $option if the toggle is disabled.
* @var string $value The current value of $optionName.
* @var string $title The title shown for the option.
* @var string $htmlTitle The unescaped title shown for the option.
* @var string $helpLink If defined, the link to the corresponding external help page.
* @var bool $premium If defined, the option will be tagged as premium only and not allow its value to change for free users.
* @var bool $disabled If defined and truthy, the option will start out disabled.
*/
if (isset($subtitle) && !isset($subtitleHTML)) {
$subtitleHTML = esc_html($subtitle);
}
$id = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $optionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wfls-option wfls-option-toggled-boolean-switch<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wfls-option-premium'; } ?><?php if (isset($disabled) && $disabled) { echo ' wfls-disabled'; } ?>" data-option="<?php echo esc_attr($optionName); ?>" data-enabled-value="<?php echo esc_attr($enabledValue); ?>" data-disabled-value="<?php echo esc_attr($disabledValue); ?>" data-original-value="<?php echo esc_attr($value == $enabledValue ? $enabledValue : $disabledValue); ?>">
<li class="wfls-boolean-switch<?php echo ($value == $enabledValue ? ' wfls-active' : ''); ?>" role="checkbox" aria-checked="<?php echo ($value == $enabledValue ? 'true' : 'false'); ?>" tabindex="0" aria-labelledby="<?php echo esc_attr($id); ?>-label"><a href="#" class="wfls-boolean-switch-handle"></a></li>
<li class="wfls-option-title">
<?php if (isset($subtitleHTML)): ?>
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li>
<?php endif; ?>
<span id="<?php echo esc_attr($id); ?>-label"><?php echo (!empty($title)) ? esc_html($title) : ''; echo (!empty($htmlTitle)) ? wp_kses($htmlTitle, 'post') : ''; ?></span><?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' <a href="https://www.wordfence.com/gnl1optionUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer" class="wfls-premium-link">' . esc_html__('Premium Feature', 'wordfence-2fa') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?>
<?php if (isset($subtitleHTML)): ?>
</li>
<li class="wfls-option-subtitle"><?php echo $subtitleHTML; ?></li>
</ul>
<?php endif; ?>
</li>
</ul>

View File

@@ -0,0 +1,35 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents multiple boolean options under a single heading with a checkbox toggle control for each.
*
* @var array $options The options shown. The structure is defined below. Required.
* @var string|\WordfenceLS\Text\Model_HTML $title The overall title shown for the options. Required.
* @var string $helpLink The link to the corresponding external help page. Optional.
* @var bool $wrap Whether or not the options should be allowed to wrap. Optional, defaults to false.
*
* $options is an array of
* array(
* 'name' => string <option name>,
* 'enabledValue' => string <value saved if the toggle is enabled>,
* 'disabledValue' => string <value saved if the toggle is disabled>,
* 'value' => string <current value of the option>,
* 'title' => string|\Wordfence2FA\Text\Model_HTML <title displayed to label the checkbox>,
* 'editable' => bool Whether or not the option can be edited, defaults to true.
* )
*/
?>
<ul class="wfls-option wfls-option-toggled-multiple">
<li class="wfls-option-title"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($title); ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?></li>
<li class="wfls-option-checkboxes<?php if (isset($wrap) && $wrap) { echo ' wfls-option-checkboxes-wrap'; } ?>">
<?php
foreach ($options as $o):
$id = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $o['name']);
?>
<ul id="<?php echo esc_attr($id); ?>" data-option="<?php echo esc_attr($o['name']); ?>" data-enabled-value="<?php echo esc_attr($o['enabledValue']); ?>" data-disabled-value="<?php echo esc_attr($o['disabledValue']); ?>" data-original-value="<?php echo esc_attr($o['value'] == $o['enabledValue'] ? $o['enabledValue'] : $o['disabledValue']); ?>">
<li class="wfls-option-checkbox<?php echo ($o['value'] == $o['enabledValue'] ? ' wfls-checked' : ''); ?><?php echo (isset($o['editable']) && !$o['editable'] ? ' wfls-disabled' : ''); ?>" role="checkbox" aria-checked="<?php echo ($o['value'] == $o['enabledValue'] ? 'true' : 'false'); ?>" tabindex="0" aria-labelledby="<?php echo esc_attr($id); ?>-label"><i class="wfls-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li id="<?php echo esc_attr($id); ?>-label" class="wfls-option-title"><?php echo esc_html($o['title']); ?></li>
</ul>
<?php endforeach; ?>
</li>
</ul>

View File

@@ -0,0 +1,33 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents a boolean option with a checkbox toggle control.
*
* Expects $optionName, $enabledValue, $disabledValue, $value, and $title to be defined. $helpLink may also be defined.
*
* @var string $optionName The option name.
* @var string $enabledValue The value to save in $option if the toggle is enabled.
* @var string $disabledValue The value to save in $option if the toggle is disabled.
* @var string $value The current value of $optionName.
* @var string $title The title shown for the option.
* @var string $htmlTitle The unescaped title shown for the option.
* @var string $helpLink If defined, the link to the corresponding external help page.
* @var bool $premium If defined, the option will be tagged as premium only and not allow its value to change for free users.
*/
$id = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $optionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wfls-option wfls-option-toggled-segmented<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wfls-option-premium'; } ?>" data-option="<?php echo esc_attr($optionName); ?>" data-enabled-value="<?php echo esc_attr($enabledValue); ?>" data-disabled-value="<?php echo esc_attr($disabledValue); ?>" data-original-value="<?php echo esc_attr($value == $enabledValue ? $enabledValue : $disabledValue); ?>">
<li class="wfls-option-title"><?php echo (!empty($title)) ? esc_html($title) : ''; echo (!empty($htmlTitle)) ? wp_kses($htmlTitle, 'post') : ''; ?><?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' <a href="https://www.wordfence.com/gnl1optionUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer" class="wfls-premium-link">' . esc_html__('Premium Feature', 'wordfence-2fa') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?></li>
<li class="wfls-option-segments">
<?php
$onId = sanitize_key('wfls-segment-' . $optionName . '-on');
$offId = sanitize_key('wfls-segment-' . $optionName . '-off');
?>
<input id="<?php echo esc_attr($onId) ?>" type="radio" name="<?php echo esc_attr($optionName) ?>" value="<?php echo esc_attr($enabledValue) ?>"<?php echo ($value == $enabledValue ? ' checked' : ''); ?><?php echo (!(!wfConfig::p() && isset($premium) && $premium) ? '' : ' disabled'); ?>>
<label class="wfls-segment-first" for="<?php echo esc_attr($onId) ?>">On</label>
<input id="<?php echo esc_attr($offId) ?>" type="radio" name="<?php echo esc_attr($optionName) ?>" value="<?php echo esc_attr($disabledValue) ?>"<?php echo ($value == $disabledValue ? ' checked' : ''); ?><?php echo (!(!wfConfig::p() && isset($premium) && $premium) ? '' : ' disabled'); ?>>
<label class="wfls-segment-last" for="<?php echo esc_attr($offId) ?>">Off</label>
</li>
</ul>

View File

@@ -0,0 +1,37 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents an option with a boolean on/off toggle checkbox and popup menu for detailed value selection.
*
* Expects $toggleOptionName, $enabledToggleValue, $disabledToggleValue, $toggleValue, $selectOptionName, $selectOptions, $selectValue, and $title to be defined. $helpLink may also be defined.
*
* @var string $toggleOptionName The option name for the toggle portion.
* @var string $enabledToggleValue The value to save in $toggleOption if the toggle is enabled.
* @var string $disabledToggleValue The value to save in $toggleOption if the toggle is disabled.
* @var string $toggleValue The current value of $toggleOptionName.
* @var string $selectOptionName The option name for the select portion.
* @var array $selectOptions An array of the possible values for $selectOptionName. The array is of the format array(array('value' => <the internal value>, 'label' => <a display label>), ...)
* @var string $selectValue The current value of $selectOptionName.
* @var string $title The title shown for the option.
* @var string $helpLink If defined, the link to the corresponding external help page.
* @var bool $premium If defined, the option will be tagged as premium only and not allow its value to change for free users.
*/
$toggleID = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $toggleOptionName);
$selectID = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $selectOptionName);
?>
<ul class="wfls-option wfls-option-toggled-select<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wfls-option-premium'; } ?>" data-toggle-option="<?php echo esc_attr($toggleOptionName); ?>" data-enabled-toggle-value="<?php echo esc_attr($enabledToggleValue); ?>" data-disabled-toggle-value="<?php echo esc_attr($disabledToggleValue); ?>" data-original-toggle-value="<?php echo esc_attr($toggleValue == $enabledToggleValue ? $enabledToggleValue : $disabledToggleValue); ?>" data-select-option="<?php echo esc_attr($selectOptionName); ?>" data-original-select-value="<?php echo esc_attr($selectValue); ?>">
<li id="<?php echo esc_attr($toggleID); ?>" class="wfls-option-checkbox<?php echo ($toggleValue == $enabledToggleValue ? ' wfls-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($toggleValue == $enabledToggleValue ? 'true' : 'false'); ?>" tabindex="0"><i class="wfls-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li class="wfls-option-content">
<ul id="<?php echo esc_attr($selectID); ?>">
<li class="wfls-option-title"><span id="<?php echo esc_attr($selectID); ?>-label"><?php echo esc_html($title); ?></span><?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' <a href="https://www.wordfence.com/gnl1optionUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer" class="wfls-premium-link">' . esc_html__('Premium Feature', 'wordfence-2fa') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?></li>
<li class="wfls-option-select wfls-padding-add-top-xs-small">
<select<?php echo ($toggleValue == $enabledToggleValue && !(!wfConfig::p() && isset($premium) && $premium) ? '' : ' disabled'); ?> aria-labelledby="<?php echo esc_attr($selectID); ?>-label">
<?php foreach ($selectOptions as $o): ?>
<option class="wfls-option-select-option" value="<?php echo esc_attr($o['value']); ?>"<?php if ($o['value'] == $selectValue) { echo ' selected'; } ?>><?php echo esc_html($o['label']); ?></option>
<?php endforeach; ?>
</select>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,56 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents a boolean option with a checkbox toggle control and a sub-option toggle.
*
* Expects $optionName, $enabledValue, $disabledValue, $value, and $title to be defined for the primary option. $helpLink may also be defined.
* Expects $subOptionName, $subEnabledValue, $subDisabledValue, $subValue, and $subTitle to be defined for the sub-option. $subHelpLink may also be defined.
*
* @var string $optionName The option name.
* @var string $enabledValue The value to save in $optionName if the toggle is enabled.
* @var string $disabledValue The value to save in $optionName if the toggle is disabled.
* @var string $value The current value of $optionName.
* @var string $title The title shown for the option.
* @var string $htmlTitle The unescaped title shown for the option.
* @var string $helpLink If defined, the link to the corresponding external help page.
* @var bool $premium If defined, the option will be tagged as premium only and not allow its value to change for free users.
*
* @var string $subOptionName The sub-option name.
* @var string $subEnabledValue The value to save in $subOptionName if the toggle is enabled.
* @var string $subDisabledValue The value to save in $subOptionName if the toggle is disabled.
* @var string $subValue The current value of $subOptionName.
* @var string $subTitle The title shown for the sub-option.
* @var string $subHtmlTitle The unescaped title shown for the sub-option.
* @var string $subHelpLink If defined, the link to the corresponding external help page for the sub-option.
* @var bool $subPremium If defined, the sub-option will be tagged as premium only and not allow its value to change for free users.
*/
if (isset($title) && !isset($htmlTitle)) {
$htmlTitle = esc_html($title);
}
if (isset($subTitle) && !isset($subHtmlTitle)) {
$subHtmlTitle = esc_html($subTitle);
}
$id = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $optionName);
$subID = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $subOptionName);
?>
<ul class="wfls-flex-vertical wfls-flex-full-width">
<li>
<ul id="<?php echo esc_attr($id); ?>" class="wfls-option wfls-option-toggled<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wfls-option-premium'; } ?>" data-option="<?php echo esc_attr($optionName); ?>" data-enabled-value="<?php echo esc_attr($enabledValue); ?>" data-disabled-value="<?php echo esc_attr($disabledValue); ?>" data-original-value="<?php echo esc_attr($value == $enabledValue ? $enabledValue : $disabledValue); ?>">
<li class="wfls-option-checkbox<?php echo ($value == $enabledValue ? ' wfls-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($value == $enabledValue ? 'true' : 'false'); ?>" tabindex="0" aria-labelledby="<?php echo esc_attr($id); ?>-label"><i class="wfls-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li class="wfls-option-title">
<span id="<?php echo esc_attr($id); ?>-label"><?php echo $htmlTitle; ?></span><?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' <a href="https://www.wordfence.com/gnl1optionUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer" class="wfls-premium-link">' . esc_html__('Premium Feature', 'wordfence-2fa') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?>
</li>
</ul>
</li>
<li class="wfls-option-sub">
<ul id="<?php echo esc_attr($subID); ?>" class="wfls-option wfls-option-toggled<?php if (!wfConfig::p() && isset($subPremium) && $subPremium) { echo ' wfls-option-premium'; } ?>" data-option="<?php echo esc_attr($subOptionName); ?>" data-enabled-value="<?php echo esc_attr($subEnabledValue); ?>" data-disabled-value="<?php echo esc_attr($subDisabledValue); ?>" data-original-value="<?php echo esc_attr($subValue == $subEnabledValue ? $subEnabledValue : $subDisabledValue); ?>">
<li class="wfls-option-checkbox<?php echo ($subValue == $subEnabledValue ? ' wfls-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($subValue == $subEnabledValue ? 'true' : 'false'); ?>" tabindex="0" aria-labelledby="<?php echo esc_attr($subID); ?>-label"><i class="wfls-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li class="wfls-option-title">
<span id="<?php echo esc_attr($subID); ?>-label"><?php echo $subHtmlTitle; ?></span><?php if (!wfConfig::p() && isset($subPremium) && $subPremium) { echo ' <a href="https://www.wordfence.com/gnl1optionUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer" class="wfls-premium-link">' . esc_html__('Premium Feature', 'wordfence-2fa') . '</a>'; } ?><?php if (isset($subHelpLink)) { echo ' <a href="' . esc_attr($subHelpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,30 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents an option with a boolean on/off toggle checkbox and text area for detailed value entry.
*
* Expects $toggleOptionName, $enabledToggleValue, $disabledToggleValue, $toggleValue, $textAreaOptionName, $textAreaValue, and $title to be defined. $helpLink may also be defined.
*
* @var string $toggleOptionName The option name for the toggle portion.
* @var string $enabledToggleValue The value to save in $toggleOption if the toggle is enabled.
* @var string $disabledToggleValue The value to save in $toggleOption if the toggle is disabled.
* @var string $toggleValue The current value of $toggleOptionName.
* @var string $textAreaOptionName The option name for the text area portion.
* @var string $textAreaValue The current value of $textAreaOptionName.
* @var string $title The title shown for the option.
* @var string $helpLink If defined, the link to the corresponding external help page.
* @var bool $premium If defined, the option will be tagged as premium only and not allow its value to change for free users.
*/
$toggleID = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $toggleOptionName);
$textAreaID = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $textAreaOptionName);
?>
<ul class="wfls-option wfls-option-toggled-textarea<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wfls-option-premium'; } ?>" data-toggle-option="<?php echo esc_attr($toggleOptionName); ?>" data-enabled-toggle-value="<?php echo esc_attr($enabledToggleValue); ?>" data-disabled-toggle-value="<?php echo esc_attr($disabledToggleValue); ?>" data-original-toggle-value="<?php echo esc_attr($toggleValue == $enabledToggleValue ? $enabledToggleValue : $disabledToggleValue); ?>" data-text-area-option="<?php echo esc_attr($textAreaOptionName); ?>" data-original-text-area-value="<?php echo esc_attr($textAreaValue); ?>">
<li id="<?php echo esc_attr($toggleID); ?>" class="wfls-option-checkbox<?php echo ($toggleValue == $enabledToggleValue ? ' wfls-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($toggleValue == $enabledToggleValue ? 'true' : 'false'); ?>" tabindex="0"><i class="wfls-ion-ios-checkmark-empty" aria-hidden="true" aria-labelledby="<?php echo esc_attr($toggleID); ?>-label"></i></li>
<li class="wfls-option-title"><span id="<?php echo esc_attr($toggleID); ?>-label"><?php echo esc_html($title); ?></span><?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' <a href="https://www.wordfence.com/gnl1optionUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer" class="wfls-premium-link">' . esc_html__('Premium Feature', 'wordfence-2fa') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?></li>
<li id="<?php echo esc_attr($textAreaID); ?>" class="wfls-option-textarea">
<select<?php echo ($toggleValue == $enabledToggleValue && !(!wfConfig::p() && isset($premium) && $premium) ? '' : ' disabled'); ?> aria-labelledby="<?php echo esc_attr($toggleID); ?>-label">
<textarea<?php echo (!(!wfConfig::p() && isset($premium) && $premium) ? '' : ' disabled'); ?>><?php echo esc_html($textAreaValue); ?></textarea>
</select>
</li>
</ul>

View File

@@ -0,0 +1,33 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents a boolean option with a checkbox toggle control.
*
* @var string $optionName The option name. Required.
* @var string $enabledValue The value to save in $option if the toggle is enabled. Required.
* @var string $disabledValue The value to save in $option if the toggle is disabled. Required.
* @var string $value The current value of $optionName. Required.
* @var string|\WordfenceLS\Text\Model_HTML $title The title shown for the option. Required.
* @var string|\WordfenceLS\Text\Model_HTML $subtitle The title shown for the option. Optional.
* @var string $helpLink If defined, the link to the corresponding external help page. Optional.
* @var bool $disabled If defined and truthy, the option will start out disabled. Optional.
* @var bool $child If true, this option will be rendered ar a child option. Optional.
*/
$id = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $optionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wfls-option wfls-option-toggled<?php if (isset($disabled) && $disabled) { echo ' wfls-disabled'; } if (isset($child) && $child) { echo ' wfls-child-option'; }?>" data-option="<?php echo esc_attr($optionName); ?>" data-enabled-value="<?php echo esc_attr($enabledValue); ?>" data-disabled-value="<?php echo esc_attr($disabledValue); ?>" data-original-value="<?php echo esc_attr($value == $enabledValue ? $enabledValue : $disabledValue); ?>">
<li class="wfls-option-checkbox<?php echo ($value == $enabledValue ? ' wfls-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($value == $enabledValue ? 'true' : 'false'); ?>" tabindex="0" aria-labelledby="<?php echo esc_attr($id); ?>-label"><i class="wfls-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li class="wfls-option-title">
<?php if (isset($subtitle)): ?>
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li>
<?php endif; ?>
<span id="<?php echo esc_attr($id); ?>-label"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($title); ?></span><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?>
<?php if (isset($subtitle)): ?>
</li>
<li class="wfls-option-subtitle"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($subtitle); ?></li>
</ul>
<?php endif; ?>
</li>
</ul>

View File

@@ -0,0 +1,39 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* Presents an option with a token field for value entry.
*
* Expects $tokenOptionName, $tokenValue, and $title to be defined. $helpLink may also be defined.
*
* @var string $tokenOptionName The option name.
* @var array $tokenValue The current value of $tokenOptionName. It will be JSON-encoded as an array of strings.
* @var string $title The title shown for the option.
* @var string $helpLink If defined, the link to the corresponding external help page.
* @var bool $premium If defined, the option will be tagged as premium only and not allow its value to change for free users.
*/
$id = 'wfls-option-' . preg_replace('/[^a-z0-9]/i', '-', $tokenOptionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wfls-option wfls-option-token<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wfls-option-premium'; } ?>" data-token-option="<?php echo esc_attr($tokenOptionName); ?>" data-original-token-value="<?php echo esc_attr(json_encode($tokenValue)); ?>">
<li class="wfls-option-spacer"></li>
<li class="wfls-flex-vertical wfls-flex-align-left">
<div class="wfls-option-title">
<?php if (isset($subtitle)): ?>
<ul class="wfls-flex-vertical wfls-flex-align-left">
<li>
<?php endif; ?>
<span id="<?php echo esc_attr($id); ?>-label"><?php echo esc_html($title); ?></span><?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' <a href="https://www.wordfence.com/gnl1optionUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer" class="wfls-premium-link">' . esc_html__('Premium Feature', 'wordfence-2fa') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wfls-inline-help"><i class="' . (\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>'; } ?>
<?php if (isset($subtitle)): ?>
</li>
<li class="wfls-option-subtitle"><?php echo esc_html($subtitle); ?></li>
</ul>
<?php endif; ?>
</div>
<select multiple<?php echo (!(!wfConfig::p() && isset($premium) && $premium) ? '' : ' disabled'); ?> aria-labelledby="<?php echo esc_attr($id); ?>-label">
<?php foreach ($tokenValue as $o): ?>
<option value="<?php echo esc_attr($o); ?>" selected><?php echo esc_html($o); ?></option>
<?php endforeach; ?>
</select>
<div class="wfls-option-token-tags"></div>
</li>
</ul>