: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
const PAGE_DASHBOARD = 'dashboard';
const PAGE_DASHBOARD_OPTIONS = 'dashboard-options';
const PAGE_FIREWALL = 'firewall';
const PAGE_FIREWALL_OPTIONS = 'firewall-options';
const PAGE_BLOCKING = 'blocking';
const PAGE_BLOCKING_OPTIONS = 'blocking-options';
const PAGE_SCAN = 'scan';
const PAGE_SCAN_OPTIONS = 'scan-options';
const PAGE_TOOLS_2FA = 'tools-2fa';
const PAGE_TOOLS_LIVE_TRAFFIC = 'tools-2fa';
const PAGE_TOOLS_WHOIS = 'tools-whois';
const PAGE_TOOLS_IMPORT_EXPORT = 'tools-import-export';
const PAGE_TOOLS_DIAGNOSTICS = 'tools-diagnostics';
const PAGE_SUPPORT = 'support';
* Provides validation for a user-provided page identifier.
* @param string $identifier
public static function isValidPage($identifier) {
case self::PAGE_DASHBOARD:
case self::PAGE_DASHBOARD_OPTIONS:
case self::PAGE_FIREWALL:
case self::PAGE_FIREWALL_OPTIONS:
case self::PAGE_BLOCKING:
case self::PAGE_BLOCKING_OPTIONS:
case self::PAGE_SCAN_OPTIONS:
case self::PAGE_TOOLS_2FA:
case self::PAGE_TOOLS_LIVE_TRAFFIC:
case self::PAGE_TOOLS_IMPORT_EXPORT:
case self::PAGE_TOOLS_WHOIS:
case self::PAGE_TOOLS_DIAGNOSTICS:
* Convenience function for returning the user-displayable label for the given page.
* @param string $identifier
public static function pageLabel($identifier) {
$page = new wfPage($identifier);
* Convenience function for returning the canonical URL for the given page.
* @param string $identifier
* @param string|bool $source The source page identifier to append to the URL if wanted.
public static function pageURL($identifier, $source = false) {
$page = new wfPage($identifier);
return $page->url($source);
public function __construct($identifier) {
$this->_identifier = $identifier;
public function __get($key) {
return $this->_identifier;
throw new OutOfBoundsException("{$key} is not a valid property");
public function __isset($key) {
* Returns the user-displayable label for the page.
public function label() {
switch ($this->identifier) {
case self::PAGE_DASHBOARD:
return __('Dashboard', 'wordfence');
case self::PAGE_DASHBOARD_OPTIONS:
return __('Global Options', 'wordfence');
case self::PAGE_FIREWALL:
return __('Firewall', 'wordfence');
case self::PAGE_FIREWALL_OPTIONS:
return __('Firewall Options', 'wordfence');
case self::PAGE_BLOCKING:
return __('Blocking', 'wordfence');
case self::PAGE_BLOCKING_OPTIONS:
return __('Blocking Options', 'wordfence');
return __('Scan', 'wordfence');
case self::PAGE_SCAN_OPTIONS:
return __('Scan Options', 'wordfence');
case self::PAGE_TOOLS_2FA:
return __('Two-Factor Authentication', 'wordfence');
case self::PAGE_TOOLS_LIVE_TRAFFIC:
return __('Live Traffic', 'wordfence');
case self::PAGE_TOOLS_IMPORT_EXPORT:
return __('Import/Export Options', 'wordfence');
case self::PAGE_TOOLS_WHOIS:
return __('Whois Lookup', 'wordfence');
case self::PAGE_TOOLS_DIAGNOSTICS:
return __('Diagnostics', 'wordfence');
return __('Support', 'wordfence');
* Returns the canonical URL for the page.
* @param string|bool $source The source page identifier to append to the URL if wanted.
public function url($source = false) {
switch ($this->identifier) {
case self::PAGE_DASHBOARD:
case self::PAGE_DASHBOARD_OPTIONS:
$subpage = 'global_options';
case self::PAGE_FIREWALL:
case self::PAGE_FIREWALL_OPTIONS:
$subpage = 'waf_options';
case self::PAGE_BLOCKING:
case self::PAGE_BLOCKING_OPTIONS:
$subpage = 'blocking_options';
case self::PAGE_SCAN_OPTIONS:
$subpage = 'scan_options';
case self::PAGE_TOOLS_2FA:
$page = 'WordfenceTools';
case self::PAGE_TOOLS_LIVE_TRAFFIC:
$page = 'WordfenceTools';
$subpage = 'livetraffic';
case self::PAGE_TOOLS_IMPORT_EXPORT:
$page = 'WordfenceTools';
$subpage = 'importexport';
case self::PAGE_TOOLS_WHOIS:
$page = 'WordfenceTools';
case self::PAGE_TOOLS_DIAGNOSTICS:
$page = 'WordfenceTools';
$subpage = 'diagnostics';
$page = 'WordfenceSupport';
$baseURL .= 'page=' . rawurlencode($page);
if (!empty($subpage)) { $baseURL .= '&subpage=' . rawurlencode($subpage); }
if (self::isValidPage($source)) { $baseURL .= '&source=' . rawurlencode($source); }
if (!empty($hash)) { $baseURL .= $this->_hashURLEncode($hash); }
if (function_exists('network_admin_url') && is_multisite()) {
return network_admin_url($baseURL);
return admin_url($baseURL);
* Splits a URI hash component and URL-encodes its members.
private function _hashURLEncode($hash) {
$components = explode('#', $hash);
foreach ($components as &$c) {
return implode('#', $components);
* Returns an ordered array of the pages required to reach this page, this page being the last entry in the array.
public function breadcrumbs() {
switch ($this->identifier) {
case self::PAGE_DASHBOARD:
case self::PAGE_DASHBOARD_OPTIONS:
return array(new wfPage(wfPage::PAGE_DASHBOARD), $this);
case self::PAGE_FIREWALL:
case self::PAGE_FIREWALL_OPTIONS:
return array(new wfPage(wfPage::PAGE_FIREWALL), $this);
case self::PAGE_BLOCKING:
case self::PAGE_BLOCKING_OPTIONS:
return array(new wfPage(wfPage::PAGE_BLOCKING), $this);
case self::PAGE_SCAN_OPTIONS:
return array(new wfPage(wfPage::PAGE_SCAN), $this);
case self::PAGE_TOOLS_2FA:
case self::PAGE_TOOLS_LIVE_TRAFFIC:
case self::PAGE_TOOLS_IMPORT_EXPORT:
case self::PAGE_TOOLS_WHOIS:
case self::PAGE_TOOLS_DIAGNOSTICS: