diff --git a/languages/config-expander-nl_NL.mo b/languages/config-expander-nl_NL.mo index dc3118c..1da1450 100644 Binary files a/languages/config-expander-nl_NL.mo and b/languages/config-expander-nl_NL.mo differ diff --git a/languages/config-expander-nl_NL.po b/languages/config-expander-nl_NL.po index 48bfe4c..583456e 100644 --- a/languages/config-expander-nl_NL.po +++ b/languages/config-expander-nl_NL.po @@ -19,6 +19,19 @@ msgstr "De vereiste plugin voor de Config Expander package Advanced Cust msgid "This link does not work, go to our website: %s." msgstr "Deze link bestaat niet, ga naar onze website: %s." -#: src/Protection/Protect.php:80 +#: src/Protection/Protect.php:89 msgid "Viewing this page requires a login session. Please log in first." msgstr "Het bekijken van deze pagina vereist een login sessie. Graag eerst inloggen." + +#. translators: %s: visitor IP address +#: src/Protection/Protect.php:97 +msgid "Your IP address is %s. Please contact the administrator to request a whitelist." +msgstr "Jouw IP-adres is %s. Neem contact op met de beheerder om een whitelist aan te vragen." + +#: src/Protection/Protect.php:104 +msgid "Access Denied" +msgstr "Toegang geweigerd" + +#: src/Protection/Protect.php:108 +msgid "Go to login page" +msgstr "Ga naar de inlogpagina" diff --git a/languages/config-expander.pot b/languages/config-expander.pot index a8d32d7..8579935 100644 --- a/languages/config-expander.pot +++ b/languages/config-expander.pot @@ -20,6 +20,19 @@ msgstr "" msgid "This link does not work, go to our website: %s." msgstr "" -#: src/Protection/Protect.php:80 -msgid "You're not allowed to view this page." +#: src/Protection/Protect.php:89 +msgid "Viewing this page requires a login session. Please log in first." +msgstr "" + +#. translators: %s: visitor IP address +#: src/Protection/Protect.php:97 +msgid "Your IP address is %s. Please contact the administrator to request a whitelist." +msgstr "" + +#: src/Protection/Protect.php:104 +msgid "Access Denied" +msgstr "" + +#: src/Protection/Protect.php:108 +msgid "Go to login page" msgstr "" diff --git a/src/ACF/ACFServiceProvider.php b/src/ACF/ACFServiceProvider.php index ee16a1d..bc2b7f3 100644 --- a/src/ACF/ACFServiceProvider.php +++ b/src/ACF/ACFServiceProvider.php @@ -134,6 +134,26 @@ public function addLocalFieldGroup(): void 'ajax' => 0, 'placeholder' => '', ], + [ + 'key' => 'field_666962be81793', + 'label' => 'Toon IP bij geweigerde toegang', + 'name' => 'show_ip_on_deny', + 'aria-label' => '', + 'type' => 'true_false', + 'instructions' => 'Toon het IP-adres van de bezoeker bij geweigerde toegang.', + 'required' => 0, + 'conditional_logic' => 0, + 'wrapper' => [ + 'width' => '', + 'class' => '', + 'id' => '', + ], + 'message' => '', + 'default_value' => 0, + 'ui' => 1, + 'ui_on_text' => 'Aan', + 'ui_off_text' => 'Uit', + ], [ 'key' => 'field_666845f07125a', 'label' => 'IP-adres whitelist', diff --git a/src/Protection/Protect.php b/src/Protection/Protect.php index 0a22983..4e63195 100644 --- a/src/Protection/Protect.php +++ b/src/Protection/Protect.php @@ -37,7 +37,7 @@ protected function authorizeAccess(string $type): void */ protected function setNoCacheHeader(): void { - header('Cache-Control: no-cache'); + nocache_headers(); } protected function checkIfVisitorHasAccess(string $type): bool @@ -86,9 +86,28 @@ protected function currentProtectionTypeMatchesWhitelist(string $type, Whitelist protected function denyAccess(): void { - header('HTTP/1.0 401 Unauthorized'); - echo __('Viewing this page requires a login session. Please log in first.', 'config-expander'); - exit; + $message = __('Viewing this page requires a login session. Please log in first.', 'config-expander'); + + $showIp = function_exists('get_field') && (bool) get_field('show_ip_on_deny', 'options'); + $loginProtected = function_exists('get_field') && in_array(get_field('type_protection_website', 'options'), ['login', 'both'], true); + + if ($showIp && $loginProtected) { + $message .= ' ' . sprintf( + /* translators: %s: visitor IP address */ + __('Your IP address is %s. Please contact the administrator to request a whitelist.', 'config-expander'), + esc_html($this->ipCurrentVisitor()) + ); + } + + wp_die( + $message, + __('Access Denied', 'config-expander'), + [ + 'response' => 401, + 'link_url' => wp_login_url(), + 'link_text' => __('Go to login page', 'config-expander'), + ] + ); } protected function ipCurrentVisitor(): string