Merged in feature/from-pantheon (pull request #16)

code from pantheon

* code from pantheon
This commit is contained in:
Tony Volpe
2024-01-10 17:03:02 +00:00
parent 054b4fffc9
commit 4eb982d7a8
16492 changed files with 3475854 additions and 0 deletions

View File

@@ -0,0 +1,169 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
/**
* Presents the top controls on the All Options page.
*
* Expects $indexOptions. $suppressControls may be defined to hide the options-saving controls. If not truthy, $restoreDefaultsSection and $restoreDefaultsMessage must also be defined.
*
* @var array $indexOptions An array of the index options to allow searching. The key should be the element ID to scroll to and the value is the name of the option.
* @var string $restoreDefaultsMessage The message shown in the restore defaults prompt
*/
if (isset($backLabel) && !isset($backLabelHTML)) {
$backLabelHTML = esc_html($backLabel);
}
?>
<div class="wf-block wf-block-transparent wf-active">
<div class="wf-block-content">
<ul class="wf-block-left-right wf-block-left-right-nowrap wf-hidden-xs">
<li class="wf-left">
<ul class="wf-flex-horizontal">
<?php if (isset($showIcon) && $showIcon): ?>
<li><div class="wordfence-lock-icon wordfence-icon32 wf-no-top wf-no-right wf-hidden-xs"></div></li>
<?php endif; ?>
<li id="wf-all-options-search"<?php if (isset($showIcon) && $showIcon): ?> class="wf-padding-add-left"<?php endif; ?>>
<select class="wf-options-searcher" multiple>
<?php
foreach ($indexOptions as $element => $label):
?>
<option value="<?php echo esc_attr($element); ?>"><?php echo esc_html($label); ?></option>
<?php
endforeach;
?>
</select>
</li>
</ul>
</li>
<?php if (!isset($suppressControls) || !$suppressControls): ?>
<li class="wf-right">
<a id="wf-restore-defaults" class="wf-btn wf-btn-default wf-btn-callout-subtle" href="#" data-restore-defaults-section="<?php echo esc_attr($restoreDefaultsSection); ?>" role="button"><?php echo wp_kses(/* translators: word order may be reversed as long as HTML remains around "Restore" */ __('<span class="wf-hidden-xs">Restore </span>Defaults', 'wordfence'), array('span'=>array('class'=>array()))); ?></a>&nbsp;&nbsp;<a id="wf-cancel-changes" class="wf-btn wf-btn-default wf-btn-callout-subtle wf-disabled" href="#" role="button"><?php echo wp_kses(/* translators: word order may be reversed as long as HTML remains around "Changes" */ __('Cancel<span class="wf-hidden-xs wf-hidden-sm"> Changes</span>', 'wordfence'), array('span'=>array('class'=>array()))); ?></a>&nbsp;&nbsp;<a id="wf-save-changes" class="wf-btn wf-btn-primary wf-btn-callout-subtle wf-disabled" href="#" role="button"><?php echo wp_kses(/* translators: word order may be reversed as long as HTML remains around "Changes" */ __('Save<span class="wf-hidden-xs wf-hidden-sm"> Changes</span>', 'wordfence'), array('span'=>array('class'=>array()))); ?></a>
</li>
<?php endif; ?>
</ul>
<ul class="wf-block-left-center-right wf-hidden-sm wf-hidden-md wf-hidden-lg">
<li class="wf-left">
<?php if (!isset($suppressLogo) || !$suppressLogo): ?>
<div class="wordfence-lock-icon wordfence-icon32"></div>
<?php endif; ?>
</li>
<li class="wf-center">
<select class="wf-options-searcher" multiple>
<?php
foreach ($indexOptions as $element => $label):
?>
<option value="<?php echo esc_attr($element); ?>"><?php echo esc_html($label); ?></option>
<?php
endforeach;
?>
</select>
</li>
<?php if (!isset($suppressControls) || !$suppressControls): ?>
<li class="wf-right">
<a id="wf-mobile-controls" href="#" data-restore-defaults-section="<?php echo esc_attr($restoreDefaultsSection); ?>" role="button">&bullet;&bullet;&bullet;</a>
</li>
<?php endif; ?>
</ul>
</div>
</div>
<?php if (!isset($suppressControls) || !$suppressControls): ?>
<script type="application/javascript">
(function($) {
$('.wf-options-searcher').css('display', 'none');
$(function() {
var initialTop = parseInt($('.wf-options-controls').css('top'));
$(window).bind("scroll", function() {
if (window.matchMedia("only screen and (max-width: 615px)").matches) {
$(this).scrollTop() > initialTop ? $('.wf-options-controls').css('top', '0px').css('position', 'fixed').css('left', '0px') : $('.wf-options-controls').css('top', initialTop + 'px').css('position', 'absolute').css('left', '-10px');
}
});
$('.wf-options-searcher').wfselect2({
tags: true,
tokenSeparators: [','],
placeholder: <?php echo json_encode(__('Search All Options', 'wordfence')) ?>,
minimumResultsForSearch: -1,
minimumInputLength: 2,
selectOnClose: false,
width: (WFAD.screenSize(WFAD.SCREEN_MD) ? '250px' : '500px'),
createTag: function (params) {
return null; //No custom tags
}
}).on('change', function () {
var selection = $(this).val();
if (Array.isArray(selection)) {
if (selection.length > 0) {
selection = selection[0];
}
else {
selection = false;
}
}
else if (typeof selection !== 'string') {
selection = false;
}
if (selection !== false) {
var el = $('#' + selection);
if (el.is(':visible')) {
$('html, body').animate({
scrollTop: el.offset().top - 100
}, 750);
}
else if (el.is('input[type="hidden"]')) {
$('html, body').animate({
scrollTop: el.parent().offset().top - 100
}, 750);
}
else {
var block = el.closest('.wf-block[data-persistence-key]');
if (!block.hasClass('wf-active') && !block.hasClass('wf-always-active')) {
block.find('.wf-block-content').slideDown({
always: function() {
block.addClass('wf-active');
$('html, body').animate({
scrollTop: el.offset().top - 100
}, 750);
}
});
WFAD.ajax('wordfence_saveDisclosureState', {name: block.data('persistenceKey'), state: true}, function() {}, function() {}, true);
}
}
$('.wf-options-searcher').val('').change();
}
});
if ($('.wf-options-searcher').length > 0) {
$('.wf-options-searcher').data('wfselect2').$container.addClass('wf-select2-placeholder-fix wf-select2-hide-tags');
}
$(window).on('resize', function(e) {
$('.wf-options-searcher').wfselect2({
tags: true,
tokenSeparators: [','],
placeholder: <?php echo json_encode(__('Search All Options', 'wordfence')) ?>,
minimumResultsForSearch: -1,
minimumInputLength: 2,
selectOnClose: false,
width: (WFAD.screenSize(WFAD.SCREEN_MD) ? '250px' : '500px'),
createTag: function (params) {
return null; //No custom tags
}
});
});
});
})(jQuery);
</script>
<script type="text/x-jquery-template" id="wfTmpl_restoreDefaultsPrompt">
<?php
echo wfView::create('common/modal-prompt', array(
'title' => __('Confirm Restore Defaults', 'wordfence'),
'message' => $restoreDefaultsMessage,
'primaryButton' => array('id' => 'wf-restore-defaults-prompt-cancel', 'label' => __('Cancel', 'wordfence'), 'link' => '#'),
'secondaryButtons' => array(array('id' => 'wf-restore-defaults-prompt-confirm', 'labelHTML' => wp_kses(/* translators: word order may be reversed as long as HTML remains around "Defaults" */ __('Restore<span class="wf-hidden-xs"> Defaults</span>', 'wordfence'), array('span'=>array('class'=>array()))), 'link' => '#')),
))->render();
?>
</script>
<?php endif; ?>

View File

@@ -0,0 +1,84 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
/**
* Presents the top controls on an options page.
*
* Expects $backLink and $backLabel (or $backLabelHTML) or alternately just $backLinkBreadcrumbs. $suppressControls may be defined to hide the options-saving controls. If not truthy, $restoreDefaultsSection and $restoreDefaultsMessage must also be defined.
*
* @var string $backLink The link for the back button.
* @var string $backLabel The label for the back button.
* @var string $backLabelHTML The label for the back button as raw HTML.
* @var wfPage[] $backLinkBreadcrumbs An array of wfPage instances of the page's breadcrumbs. The last entry in the array is expected to be a page and will not generate a link.
* @var string $restoreDefaultsMessage The message shown in the restore defaults prompt
*/
if (isset($backLabel) && !isset($backLabelHTML)) {
$backLabelHTML = esc_html($backLabel);
}
?>
<div class="wf-block wf-block-transparent wf-active">
<div class="wf-block-content">
<ul class="wf-block-left-right wf-hidden-xs">
<li class="wf-left">
<?php if (isset($backLinkBreadcrumbs)): ?>
<?php foreach ($backLinkBreadcrumbs as $index => $page): ?>
<a href="<?php echo esc_attr($page->url()); ?>" class="wf-back-link-chevron"><i class="wf-ion-chevron-left wf-back-icon" aria-hidden="true"></i></a>
<?php if ($index < count($backLinkBreadcrumbs) - 1): ?><a href="<?php echo esc_attr($page->url()); ?>" class="wf-back-link"><?php endif; ?><?php echo esc_html($page->label()); ?><?php if ($index < count($backLinkBreadcrumbs) - 1): ?></a><?php endif; ?>
<?php endforeach; ?>
<?php else: ?>
<?php if (!empty($backLink)): ?>
<a href="<?php echo esc_attr($backLink); ?>" class="wf-back-link-chevron"><i class="wf-ion-chevron-left wf-back-icon" aria-hidden="true"></i></a>
<a href="<?php echo esc_attr($backLink); ?>" class="wf-back-link"><?php echo $backLabelHTML; ?></a>
<?php endif; ?>
<?php endif; ?>
</li>
<?php if (!isset($suppressControls) || !$suppressControls): ?>
<li class="wf-right">
<a id="wf-restore-defaults" class="wf-btn wf-btn-default wf-btn-callout-subtle" href="#" data-restore-defaults-section="<?php echo esc_attr($restoreDefaultsSection); ?>" role="button"><?php echo wp_kses(/* translators: word order may be reversed as long as HTML remains around "Restore" */ __('<span class="wf-hidden-xs">Restore </span>Defaults', 'wordfence'), array('span'=>array('class'=>array()))); ?></a>&nbsp;&nbsp;<a id="wf-cancel-changes" class="wf-btn wf-btn-default wf-btn-callout-subtle wf-disabled" href="#" role="button"><?php echo wp_kses(/* translators: word order may be reversed as long as HTML remains around "Changes" */ __('Cancel<span class="wf-hidden-xs wf-hidden-sm"> Changes</span>', 'wordfence'), array('span'=>array('class'=>array()))); ?></a>&nbsp;&nbsp;<a id="wf-save-changes" class="wf-btn wf-btn-primary wf-btn-callout-subtle wf-disabled" href="#" role="button"><?php echo wp_kses(/* translators: word order may be reversed as long as HTML remains around "Changes" */ __('Save<span class="wf-hidden-xs wf-hidden-sm"> Changes</span>', 'wordfence'), array('span'=>array('class'=>array()))); ?></a>
</li>
<?php endif; ?>
</ul>
<ul class="wf-block-left-center-right wf-hidden-sm wf-hidden-md wf-hidden-lg">
<li class="wf-left">
<?php if (!empty($backLink)): ?>
<a href="<?php echo esc_attr($backLink); ?>" class="wf-back-link-chevron"><i class="wf-ion-chevron-left wf-back-icon" aria-hidden="true"></i></a>
<a href="<?php echo esc_attr($backLink); ?>" class="wf-back-link"><?php echo $backLabelHTML; ?></a>
<?php endif ?>
</li>
<li class="wf-center">
<?php if (!isset($suppressLogo) || !$suppressLogo): ?>
<div class="wordfence-lock-icon wordfence-icon32"></div>
<?php endif; ?>
</li>
<?php if (!isset($suppressControls) || !$suppressControls): ?>
<li class="wf-right">
<a id="wf-mobile-controls" href="#" data-restore-defaults-section="<?php echo esc_attr($restoreDefaultsSection); ?>" role="button">&bullet;&bullet;&bullet;</a>
</li>
<?php endif; ?>
</ul>
</div>
</div>
<?php if (!isset($suppressControls) || !$suppressControls): ?>
<script type="application/javascript">
(function($) {
$(function() {
var initialTop = parseInt($('.wf-options-controls').css('top'));
$(window).bind("scroll", function() {
if (window.matchMedia("only screen and (max-width: 615px)").matches) {
$(this).scrollTop() > initialTop ? $('.wf-options-controls').css('top', '0px').css('position', 'fixed').css('left', '0px') : $('.wf-options-controls').css('top', initialTop + 'px').css('position', 'absolute').css('left', '-10px');
}
});
});
})(jQuery);
</script>
<script type="text/x-jquery-template" id="wfTmpl_restoreDefaultsPrompt">
<?php
echo wfView::create('common/modal-prompt', array(
'title' => __('Confirm Restore Defaults', 'wordfence'),
'message' => $restoreDefaultsMessage,
'primaryButton' => array('id' => 'wf-restore-defaults-prompt-cancel', 'label' => __('Cancel', 'wordfence'), 'link' => '#'),
'secondaryButtons' => array(array('id' => 'wf-restore-defaults-prompt-confirm', 'labelHTML' => wp_kses(/* translators: word order may be reversed as long as HTML remains around "Restore" */ __('Restore<span class="wf-hidden-xs"> Defaults</span>', 'wordfence'), array('span'=>array('class'=>array()))), 'link' => '#')),
))->render();
?>
</script>
<?php endif; ?>

View File

@@ -0,0 +1,37 @@
<?php
if (!defined('WORDFENCE_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="wf-option wf-option-label">
<?php if (!isset($noSpacer) || !$noSpacer): ?>
<li class="wf-option-spacer"></li>
<?php endif; ?>
<li class="wf-option-content">
<ul>
<li class="wf-option-title">
<?php if (isset($subtitle)): ?>
<ul class="wf-flex-vertical wf-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="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?>
<?php if (isset($subtitle)): ?>
</li>
<li class="wf-option-subtitle"><?php echo esc_html($subtitle); ?></li>
</ul>
<?php endif; ?>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,32 @@
<?php
if (!defined('WORDFENCE_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 = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $selectOptionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wf-option wf-option-select<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-option-premium'; } ?>" data-select-option="<?php echo esc_attr($selectOptionName); ?>" data-original-select-value="<?php echo esc_attr($selectValue); ?>">
<li class="wf-option-spacer"></li>
<li class="wf-option-content">
<ul>
<li class="wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?></li>
<li class="wf-option-select wf-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="wf-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,50 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
/**
* Presents a switch option.
*
* Expects $optionName, $value, $states, and $title (or $titleHTML) to be defined. $helpLink may also be defined.
*
* @var string $optionName The option name for the switch.
* @var string $value The current value of $optionName.
* @var string $title The title shown for the option.
* @var string $titleHTML The raw HTML title shown for the option. This supersedes $title.
* @var array $states An array of the possible states for the switch. The array matches the format array('value' => <value>, 'label' => <label>)
* @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($titleHTML)) {
$titleHTML = esc_html($title);
}
$id = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $optionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wf-option wf-option-switch<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-option-premium'; } ?>" data-option-name="<?php echo esc_attr($optionName); ?>" data-original-value="<?php echo esc_attr($value); ?>">
<?php if (!isset($noSpacer) || !$noSpacer): ?>
<li class="wf-option-spacer"></li>
<?php endif; ?>
<li class="wf-option-content">
<ul>
<li class="wf-option-title">
<?php if (isset($subtitle)): ?>
<ul class="wf-flex-vertical wf-flex-align-left">
<li>
<?php endif; ?>
<span id="<?php echo esc_attr($id); ?>-label"><?php echo $titleHTML; ?></span><?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' <a href="https://www.wordfence.com/gnl1optionUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer" class="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?>
<?php if (isset($subtitle)): ?>
</li>
<li class="wf-option-subtitle"><?php echo esc_html($subtitle); ?></li>
</ul>
<?php endif; ?>
</li>
<li class="wf-option-switch<?php if (isset($alignment)) { echo ' ' . $alignment; } ?> wf-padding-add-top-xs-small">
<ul class="wf-switch<?php echo (!(!wfConfig::p() && isset($premium) && $premium) ? '' : ' wf-disabled'); ?>" role="radiogroup" aria-labelledby="<?php echo esc_attr($id); ?>-label">
<?php foreach ($states as $s): ?>
<li<?php if ($s['value'] == $value) { echo ' class="wf-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 esc_html($s['label']); ?></li>
<?php endforeach; ?>
</ul>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,42 @@
<?php
if (!defined('WORDFENCE_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 = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $textOptionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wf-option wf-option-text<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-option-premium'; } ?>" data-text-option="<?php echo esc_attr($textOptionName); ?>" data-original-text-value="<?php echo esc_attr($textValue); ?>">
<li class="wf-option-spacer"></li>
<li class="wf-option-content">
<ul>
<li class="wf-option-title">
<?php if (isset($subtitle)): ?>
<ul class="wf-flex-vertical wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?>
<?php if (isset($subtitle)): ?>
</li>
<li class="wf-option-subtitle"><?php echo esc_html($subtitle); ?></li>
</ul>
<?php endif; ?>
</li>
<li class="wf-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,58 @@
<?php
if (!defined('WORDFENCE_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.
* @var string $textValue The current value of $textOptionName.
* @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.
* @var bool $noSpacer If defined and truthy, the spacer will be omitted.
*/
if (!isset($subtitleHTML) && isset($subtitle)) {
$subtitleHTML = esc_html($subtitle);
}
if (!isset($subtitlePosition)) { //May be 'title' to appear below the title or 'value' to appear below the field
$subtitlePosition = 'title';
}
$id = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $textOptionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wf-option wf-option-textarea<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-option-premium'; } ?>" data-text-option="<?php echo esc_attr($textOptionName); ?>" data-original-text-value="<?php echo esc_attr($textValue); ?>">
<?php if (!isset($noSpacer) || !$noSpacer): ?>
<li class="wf-option-spacer"></li>
<?php endif; ?>
<li class="wf-option-content">
<ul>
<li class="wf-option-title<?php if (isset($alignTitle)) { echo $alignTitle == 'top' ? ' wf-option-title-top' : ($alignTitle == 'bottom' ? 'wf-option-title-bottom' : ''); } ?>">
<?php if (isset($subtitleHTML) && $subtitlePosition == 'title'): ?>
<ul class="wf-flex-vertical wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?>
<?php if (isset($subtitleHTML) && $subtitlePosition == 'title'): ?>
</li>
<li class="wf-option-subtitle"><?php echo $subtitleHTML; ?></li>
</ul>
<?php endif; ?>
</li>
<li class="wf-option-textarea">
<?php if (isset($subtitleHTML) && $subtitlePosition == 'value'): ?>
<ul class="wf-flex-vertical wf-flex-align-left wf-flex-full-width">
<li>
<?php endif; ?>
<textarea<?php echo (!(!wfConfig::p() && isset($premium) && $premium) ? '' : ' disabled'); ?> aria-labelledby="<?php echo esc_attr($id); ?>-label"><?php echo esc_html($textValue); ?></textarea>
<?php if (isset($subtitleHTML) && $subtitlePosition == 'value'): ?>
</li>
<li class="wf-option-subtitle"><?php echo $subtitleHTML; ?></li>
</ul>
<?php endif; ?>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,39 @@
<?php
if (!defined('WORDFENCE_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 = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $optionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wf-option wf-option-toggled-boolean-switch<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-option-premium'; } ?><?php if (isset($disabled) && $disabled) { echo ' wf-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="wf-boolean-switch<?php echo ($value == $enabledValue ? ' wf-active' : ''); ?>" role="checkbox" aria-checked="<?php echo ($value == $enabledValue ? 'true' : 'false'); ?>" tabindex="0" aria-labelledby="<?php echo esc_attr($id); ?>-label"><a href="#" class="wf-boolean-switch-handle"></a></li>
<li class="wf-option-title">
<?php if (isset($subtitleHTML)): ?>
<ul class="wf-flex-vertical wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?>
<?php if (isset($subtitleHTML)): ?>
</li>
<li class="wf-option-subtitle"><?php echo $subtitleHTML; ?></li>
</ul>
<?php endif; ?>
</li>
</ul>

View File

@@ -0,0 +1,43 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
/**
* Presents multiple boolean options under a single heading with a checkbox toggle control for each.
*
* Expects $options and $title to be defined. $options is an array of
* array(
* 'name' => <option name>,
* 'enabledValue' => <value saved if the toggle is enabled>,
* 'disabledValue' => <value saved if the toggle is disabled>,
* 'value' => <current value of the option>,
* 'title' => <title displayed to label the checkbox>
* )
*
* $helpLink may also be defined.
*
* @var array $options The options shown. The structure is defined above.
* @var string $title The overall title shown for the options.
* @var string $helpLink If defined, the link to the corresponding external help page.
* @var bool $premium If defined, the options will be tagged as premium only and not allow its values to change for free users.
*/
?>
<ul<?php if (isset($id)) { echo ' id="' . esc_attr($id) . '"'; } ?> class="wf-option wf-option-toggled-multiple<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-option-premium'; } ?>">
<?php if (!isset($noSpacer) || !$noSpacer): ?>
<li class="wf-option-spacer"></li>
<?php endif; ?>
<li class="wf-option-content">
<ul>
<li class="wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?></li>
<li class="wf-option-checkboxes">
<?php
foreach ($options as $o):
$id = 'wf-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="wf-option-checkbox<?php echo ($o['value'] == $o['enabledValue'] ? ' wf-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($o['value'] == $o['enabledValue'] ? 'true' : 'false'); ?>" tabindex="0" aria-labelledby="<?php echo esc_attr($id); ?>-label"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li id="<?php echo esc_attr($id); ?>-label" class="wf-option-title"><?php echo esc_html($o['title']); ?></li>
</ul>
<?php endforeach; ?>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,33 @@
<?php
if (!defined('WORDFENCE_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 = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $optionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wf-option wf-option-toggled-segmented<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-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="wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?></li>
<li class="wf-option-segments">
<?php
$onId = sanitize_key('wf-segment-' . $optionName . '-on');
$offId = sanitize_key('wf-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="wf-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="wf-segment-last" for="<?php echo esc_attr($offId) ?>">Off</label>
</li>
</ul>

View File

@@ -0,0 +1,37 @@
<?php
if (!defined('WORDFENCE_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 = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $toggleOptionName);
$selectID = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $selectOptionName);
?>
<ul class="wf-option wf-option-toggled-select<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-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="wf-option-checkbox<?php echo ($toggleValue == $enabledToggleValue ? ' wf-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($toggleValue == $enabledToggleValue ? 'true' : 'false'); ?>" tabindex="0"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li class="wf-option-content">
<ul id="<?php echo esc_attr($selectID); ?>">
<li class="wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?></li>
<li class="wf-option-select wf-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="wf-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_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 = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $optionName);
$subID = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $subOptionName);
?>
<ul class="wf-flex-vertical wf-flex-full-width">
<li>
<ul id="<?php echo esc_attr($id); ?>" class="wf-option wf-option-toggled<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-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="wf-option-checkbox<?php echo ($value == $enabledValue ? ' wf-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($value == $enabledValue ? 'true' : 'false'); ?>" tabindex="0" aria-labelledby="<?php echo esc_attr($id); ?>-label"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li class="wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?>
</li>
</ul>
</li>
<li class="wf-option-sub">
<ul id="<?php echo esc_attr($subID); ?>" class="wf-option wf-option-toggled<?php if (!wfConfig::p() && isset($subPremium) && $subPremium) { echo ' wf-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="wf-option-checkbox<?php echo ($subValue == $subEnabledValue ? ' wf-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($subValue == $subEnabledValue ? 'true' : 'false'); ?>" tabindex="0" aria-labelledby="<?php echo esc_attr($subID); ?>-label"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li class="wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($subHelpLink)) { echo ' <a href="' . esc_attr($subHelpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,30 @@
<?php
if (!defined('WORDFENCE_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 = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $toggleOptionName);
$textAreaID = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $textAreaOptionName);
?>
<ul class="wf-option wf-option-toggled-textarea<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-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="wf-option-checkbox<?php echo ($toggleValue == $enabledToggleValue ? ' wf-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($toggleValue == $enabledToggleValue ? 'true' : 'false'); ?>" tabindex="0"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true" aria-labelledby="<?php echo esc_attr($toggleID); ?>-label"></i></li>
<li class="wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?></li>
<li id="<?php echo esc_attr($textAreaID); ?>" class="wf-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,43 @@
<?php
if (!defined('WORDFENCE_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.
* @var bool $disabled If defined and truthy, the option will start out disabled.
*/
if (isset($subtitle) && !isset($subtitleHTML)) {
$subtitleHTML = esc_html($subtitle);
}
$id = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $optionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wf-option wf-option-toggled<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-option-premium'; } ?><?php if (isset($disabled) && $disabled) { echo ' wf-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); ?>">
<?php if (!wfConfig::p() && isset($premium) && $premium): ?>
<li class="wf-option-premium-lock"></li>
<?php else: ?>
<li class="wf-option-checkbox<?php echo ($value == $enabledValue ? ' wf-checked' : ''); ?>" role="checkbox" aria-checked="<?php echo ($value == $enabledValue ? 'true' : 'false'); ?>" tabindex="0" aria-labelledby="<?php echo esc_attr($id); ?>-label"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<?php endif; ?>
<li class="wf-option-title">
<?php if (isset($subtitleHTML)): ?>
<ul class="wf-flex-vertical wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?>
<?php if (isset($subtitleHTML)): ?>
</li>
<li class="wf-option-subtitle"><?php echo $subtitleHTML; ?></li>
</ul>
<?php endif; ?>
</li>
</ul>

View File

@@ -0,0 +1,39 @@
<?php
if (!defined('WORDFENCE_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 = 'wf-option-' . preg_replace('/[^a-z0-9]/i', '-', $tokenOptionName);
?>
<ul id="<?php echo esc_attr($id); ?>" class="wf-option wf-option-token<?php if (!wfConfig::p() && isset($premium) && $premium) { echo ' wf-option-premium'; } ?>" data-token-option="<?php echo esc_attr($tokenOptionName); ?>" data-original-token-value="<?php echo esc_attr(json_encode($tokenValue)); ?>">
<li class="wf-option-spacer"></li>
<li class="wf-flex-vertical wf-flex-align-left">
<div class="wf-option-title">
<?php if (isset($subtitle)): ?>
<ul class="wf-flex-vertical wf-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="wf-premium-link">' . esc_html__('Premium Feature', 'wordfence') . '</a>'; } ?><?php if (isset($helpLink)) { echo ' <a href="' . esc_attr($helpLink) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'; } ?>
<?php if (isset($subtitle)): ?>
</li>
<li class="wf-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="wf-option-token-tags"></div>
</li>
</ul>

View File

@@ -0,0 +1,80 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
/**
* Expects $title (or $titleHTML) and $stateKeys to be defined.
*
* @var string $title The page title.
* @var string $titleHTML The page title as raw HTML
* @var string[] $stateKeys An array of state keys that will be controlled by the expand/collapse all button
*/
if (isset($title) && !isset($titleHTML)) {
$titleHTML = esc_html($title);
}
if (isset($helpLabel) && !isset($helpLabelHTML)) {
$helpLabelHTML = esc_html($helpLabel);
}
$expanded = true;
foreach ($stateKeys as $k) {
if (!wfPersistenceController::shared()->isActive($k)) {
$expanded = false;
break;
}
}
?>
<div class="wf-section-title">
<?php if (isset($showIcon) && $showIcon): ?>
<div class="wordfence-lock-icon wordfence-icon32 wf-hidden-xs"></div>
<?php endif; ?>
<h2<?php echo (isset($headerID) ? ' id="' . $headerID . '"' : ''); ?>><?php echo $titleHTML; ?></h2>
<div><a href="#" class="wf-toggle-all-sections wf-btn wf-btn-callout-subtle wf-btn-default" data-collapsed-title="<?php esc_attr_e('Expand All', 'wordfence'); ?>" data-expanded-title="<?php esc_attr_e('Collapse All', 'wordfence'); ?>" data-expanded="<?php echo wfUtils::truthyToInt($expanded); ?>" role="button"></a></div>
</div>
<script type="application/javascript">
(function($) {
$('.wf-toggle-all-sections').text($('.wf-toggle-all-sections').data('expanded') == 1 ? $('.wf-toggle-all-sections').data('expandedTitle') : $('.wf-toggle-all-sections').data('collapsedTitle'));
$(function() {
$('.wf-toggle-all-sections').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
if ($(this).data('expanded') == 1) {
$('.wf-block[data-persistence-key]').each(function() {
var block = $(this);
if (block.hasClass('wf-active')) {
block.find('.wf-block-content').slideUp({
always: function() {
block.removeClass('wf-active');
}
});
}
});
WFAD.ajax('wordfence_saveDisclosureState', {names: <?php echo json_encode($stateKeys) ?>, state: false}, function() {}, function() {}, true);
$(this).data('expanded', 0);
$('.wf-toggle-all-sections').text($('.wf-toggle-all-sections').data('collapsedTitle'));
}
else {
$('.wf-block[data-persistence-key]').each(function() {
var block = $(this);
if (!block.hasClass('wf-active')) {
block.find('.wf-block-content').slideDown({
always: function() {
block.addClass('wf-active');
}
});
}
});
WFAD.ajax('wordfence_saveDisclosureState', {names: <?php echo json_encode($stateKeys) ?>, state: true}, function() {}, function() {}, true);
$(this).data('expanded', 1);
$('.wf-toggle-all-sections').text($('.wf-toggle-all-sections').data('expandedTitle'));
}
});
});
})(jQuery);
</script>