diff --git a/CHANGELOG.md b/CHANGELOG.md index 850911d..f1aee7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.3.0] - 2026-01-08 + +### Added + +- New `[passwp_login]` shortcode for rendering a password form on public pages +- New Customize option for the password input placeholder + +### Changed + +- Unified default texts: "Enter password" placeholder and "Login" button +- Shortcode output uses common WordPress login form CSS classes + ## [1.2.2] - 2025-12-15 ### Security & Fixed diff --git a/assets/js/customize.js b/assets/js/customize.js index a57982a..071bde4 100644 --- a/assets/js/customize.js +++ b/assets/js/customize.js @@ -57,6 +57,7 @@ heading_color: '#1e1e1e', text_color: '#666666', font_family: 'system-ui, -apple-system, sans-serif', + password_placeholder: '', button_text: '', button_bg_color: '#667eea', button_text_color: '#ffffff', @@ -79,6 +80,7 @@ heading_color: '#1e1e1e', text_color: '#666666', font_family: 'system-ui, -apple-system, sans-serif', + password_placeholder: '', button_text: '', button_bg_color: '#2193b0', button_text_color: '#ffffff', @@ -101,6 +103,7 @@ heading_color: '#e5e5e5', text_color: '#a0a0a0', font_family: 'system-ui, -apple-system, sans-serif', + password_placeholder: '', button_text: '', button_bg_color: '#6366f1', button_text_color: '#ffffff', @@ -227,6 +230,7 @@ // Text fields. $('#passwp_heading_text').val(values.heading_text); + $('#passwp_password_placeholder').val(values.password_placeholder); $('#passwp_button_text').val(values.button_text); $('#passwp_footer_text').val(values.footer_text); $('#passwp_footer_link').val(values.footer_link); @@ -290,6 +294,7 @@ const headingColor = $('#passwp_heading_color').val() || '#1e1e1e'; const textColor = $('#passwp_text_color').val() || '#666666'; const fontFamily = $('#passwp_font_family').val() || 'system-ui, -apple-system, sans-serif'; + const passwordPlaceholder = $('#passwp_password_placeholder').val(); const buttonText = $('#passwp_button_text').val(); const buttonBgColor = $('#passwp_button_bg_color').val() || '#667eea'; const buttonTextColor = $('#passwp_button_text_color').val() || '#ffffff'; @@ -353,19 +358,26 @@ $preview.find('.passwp-preview-text').css('color', textColor); // Form input. - $preview.find('.passwp-preview-form input[type="password"]').css('border-radius', inputBorderRadius + 'px'); + const $passwordInput = $preview.find('.passwp-preview-form input[type="password"]'); + $passwordInput.css('border-radius', inputBorderRadius + 'px'); + if ($passwordInput.length) { + const defaultPlaceholder = $passwordInput.data('defaultPlaceholder') || $passwordInput.attr('placeholder') || ''; + $passwordInput.attr('placeholder', passwordPlaceholder || defaultPlaceholder); + } // Remember me. $preview.find('.passwp-preview-remember').toggle(showRememberMe).css('color', textColor); // Button. - $preview.find('.passwp-preview-form button').css({ + const $button = $preview.find('.passwp-preview-form button'); + $button.css({ 'background-color': buttonBgColor, 'color': buttonTextColor, 'border-radius': buttonBorderRadius + 'px' }); - if (buttonText) { - $preview.find('.passwp-preview-form button').text(buttonText); + if ($button.length) { + const defaultButtonText = $button.data('defaultText') || $button.text() || ''; + $button.text(buttonText || defaultButtonText); } // Footer. diff --git a/composer.json b/composer.json index 19c2487..42f216c 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Password protects all pages and posts except the front page", "type": "wordpress-plugin", "license": "GPL-2.0+", - "version": "1.2.2", + "version": "1.3.0", "require": { "php": ">=8.3", "yahnis-elsts/plugin-update-checker": "^5.6" diff --git a/includes/AdminSettings.php b/includes/AdminSettings.php index 1e3340b..1b4b228 100644 --- a/includes/AdminSettings.php +++ b/includes/AdminSettings.php @@ -49,6 +49,7 @@ final class AdminSettings { 'heading_color' => '#1a1a2e', 'text_color' => '#4a5568', 'font_family' => 'system-ui, -apple-system, sans-serif', + 'password_placeholder' => '', 'button_text' => '', 'button_bg_color' => '#667eea', 'button_text_color' => '#ffffff', @@ -605,6 +606,18 @@ class="passwp-range-value">

+
+ + +

+ +

+
+
@@ -679,6 +692,11 @@ class="passwp-range-value"> $settings The customize settings. */ private function render_preview_content( array $settings ): void { + $default_password_placeholder = __( 'Enter password', 'passwp-posts' ); + $password_placeholder = $settings[ 'password_placeholder' ] ?: $default_password_placeholder; + $default_button_text = __( 'Login', 'passwp-posts' ); + $button_text = $settings[ 'button_text' ] ?: $default_button_text; + $bg_style = ''; if ( ! empty( $settings[ 'bg_image' ] ) ) { $bg_style = sprintf( 'background-image: url(%s); background-size: cover; background-position: center;', esc_url( $settings[ 'bg_image' ] ) ); @@ -712,7 +730,8 @@ private function render_preview_content( array $settings ): void {

- @@ -722,9 +741,9 @@ private function render_preview_content( array $settings ): void { -
@@ -1031,9 +1050,10 @@ private function sanitize_customize_settings( array $input ): array { $sanitized[ 'show_remember_me' ] = ! empty( $input[ 'show_remember_me' ] ); // Text fields. - $sanitized[ 'heading_text' ] = sanitize_text_field( $input[ 'heading_text' ] ?? '' ); - $sanitized[ 'button_text' ] = sanitize_text_field( $input[ 'button_text' ] ?? '' ); - $sanitized[ 'footer_text' ] = sanitize_text_field( $input[ 'footer_text' ] ?? '' ); + $sanitized[ 'heading_text' ] = sanitize_text_field( $input[ 'heading_text' ] ?? '' ); + $sanitized[ 'password_placeholder' ] = sanitize_text_field( $input[ 'password_placeholder' ] ?? '' ); + $sanitized[ 'button_text' ] = sanitize_text_field( $input[ 'button_text' ] ?? '' ); + $sanitized[ 'footer_text' ] = sanitize_text_field( $input[ 'footer_text' ] ?? '' ); // Font family - allow only safe values. $allowed_fonts = [ diff --git a/includes/Shortcodes.php b/includes/Shortcodes.php new file mode 100644 index 0000000..1063ddb --- /dev/null +++ b/includes/Shortcodes.php @@ -0,0 +1,129 @@ +register_shortcodes( ... ) ); + } + + /** + * Register plugin shortcodes. + */ + public function register_shortcodes(): void { + add_shortcode( 'passwp_login', $this->render_passwp_login( ... ) ); + } + + /** + * Render the [passwp_login] shortcode. + * + * @param array|string $atts Shortcode attributes. + */ + public function render_passwp_login( array|string $atts = [] ): string { + $settings = get_option( 'passwp_posts_settings', [] ); + + if ( empty( $settings[ 'enabled' ] ) || empty( $settings[ 'password_hash' ] ) ) { + return ''; + } + + if ( is_user_logged_in() ) { + return ''; + } + + $password_hash = (string) $settings[ 'password_hash' ]; + if ( $this->cookie_handler->is_valid_cookie( $password_hash ) ) { + return ''; + } + + $customize = AdminSettings::get_customize_settings(); + + $placeholder = ! empty( $customize[ 'password_placeholder' ] ) + ? (string) $customize[ 'password_placeholder' ] + : __( 'Enter password', 'passwp-posts' ); + + $button_text = ! empty( $customize[ 'button_text' ] ) + ? (string) $customize[ 'button_text' ] + : __( 'Login', 'passwp-posts' ); + + $redirect_attr = ''; + if ( is_array( $atts ) && isset( $atts[ 'redirect' ] ) ) { + $redirect_attr = (string) $atts[ 'redirect' ]; + } + + $default_redirect = home_url( '/' ); + $raw_referer = wp_get_raw_referer(); + $redirect_url_raw = $redirect_attr !== '' ? $redirect_attr : ( $raw_referer ?: $default_redirect ); + $redirect_url_raw = esc_url_raw( $redirect_url_raw ); + $redirect_url = $redirect_url_raw !== '' ? $redirect_url_raw : $default_redirect; + if ( function_exists( '\\wp_validate_redirect' ) ) { + $redirect_url = wp_validate_redirect( $redirect_url, $default_redirect ); + } + + $error = isset( $_GET[ 'passwp_error' ] ) + ? sanitize_text_field( wp_unslash( $_GET[ 'passwp_error' ] ) ) + : ''; + + $error_messages = [ + 'invalid' => __( 'Incorrect password. Please try again.', 'passwp-posts' ), + 'no_password' => __( 'No password has been configured. Please contact the site administrator.', 'passwp-posts' ), + ]; + $error_message = isset( $error_messages[ $error ] ) ? $error_messages[ $error ] : ''; + + $nonce_field = wp_nonce_field( 'passwp_posts_auth', 'passwp_posts_nonce', true, false ); + if ( ! is_string( $nonce_field ) ) { + $nonce_field = ''; + } + + $show_remember_me = ! empty( $customize[ 'show_remember_me' ] ); + + $html = ''; + + return $html; + } +} diff --git a/languages/passwp-posts-nb_NO.l10n.php b/languages/passwp-posts-nb_NO.l10n.php index 3463287..51a5d89 100644 --- a/languages/passwp-posts-nb_NO.l10n.php +++ b/languages/passwp-posts-nb_NO.l10n.php @@ -1,2 +1,2 @@ 'passwp-posts','plural-forms'=>'nplurals=2; plural=(n != 1);','language'=>'nb_NO','project-id-version'=>'PassWP Posts 1.0.1','pot-creation-date'=>'2025-12-11T22:48:24+00:00','po-revision-date'=>'2025-12-11 23:50+0100','x-generator'=>'WP-CLI 2.12.0','messages'=>['PassWP Posts'=>'PassWP Posts','https://developer.suspended.no/passwp-posts'=>'https://developer.suspended.no/passwp-posts','Password protects all pages and posts except the front page. Logged-in users bypass the password.'=>'Passordbeskytter alle sider og innlegg unntatt forsiden. Innloggede brukere omgår passordet.','Per Soderlind'=>'Per Soderlind','https://soderlind.no'=>'https://soderlind.no','PassWP Posts Settings'=>'PassWP Posts-innstillinger','Password Protection Settings'=>'Innstillinger for passordbeskyttelse','Enable Protection'=>'Aktiver beskyttelse','Password'=>'Passord','Remember Me Duration'=>'Varighet for «Husk meg»','Protection Mode'=>'Beskyttelsesmodus','Excluded Pages/Posts'=>'Ekskluderte sider/innlegg','Protected Pages/Posts'=>'Beskyttede sider/innlegg','Search for pages or posts...'=>'Søk etter sider eller innlegg...','Show password'=>'Vis passord','Hide password'=>'Skjul passord','Save Settings'=>'Lagre innstillinger','Configure password protection for your site. The front page is always public. Logged-in users bypass the password.'=>'Konfigurer passordbeskyttelse for nettstedet ditt. Forsiden er alltid offentlig. Innloggede brukere omgår passordet.','Enable password protection'=>'Aktiver passordbeskyttelse','When enabled, visitors must enter a password to view protected content.'=>'Når aktivert, må besøkende taste inn et passord for å se beskyttet innhold.','Leave blank to keep current password'=>'La stå tomt for å beholde nåværende passord','Enter password'=>'Skriv inn passord','Toggle password visibility'=>'Veksle passordsynlighet','A password is currently set. Enter a new password to change it, or leave blank to keep the current password.'=>'Et passord er allerede satt. Skriv inn et nytt passord for å endre det, eller la stå tomt for å beholde nåværende passord.','Enter the password visitors will use to access protected content.'=>'Skriv inn passordet besøkende skal bruke for å få tilgang til beskyttet innhold.','days'=>'dager','How long visitors stay authenticated after entering the password.'=>'Hvor lenge besøkende forblir autentisert etter å ha tastet inn passordet.','Protect all pages and posts (except front page)'=>'Beskytt alle sider og innlegg (unntatt forsiden)','Protect only selected pages and posts'=>'Beskytt kun valgte sider og innlegg','These pages and posts will not require a password.'=>'Disse sidene og innleggene vil ikke kreve passord.','Only these pages and posts will require a password.'=>'Kun disse sidene og innleggene vil kreve passord.','Permission denied.'=>'Tilgang nektet.','Security check failed.'=>'Sikkerhetssjekk mislyktes.','Incorrect password. Please try again.'=>'Feil passord. Vennligst prøv igjen.','No password has been configured. Please contact the site administrator.'=>'Ingen passord er konfigurert. Vennligst kontakt nettstedets administrator.','Password Required - %s'=>'Passord påkrevd - %s','Password Required'=>'Passord påkrevd','This content is protected. Please enter the password to continue.'=>'Dette innholdet er beskyttet. Vennligst skriv inn passordet for å fortsette.','Remember me'=>'Husk meg','Submit'=>'Send inn','Back to home'=>'Tilbake til forsiden','Are you sure you want to reset all customize settings to defaults?'=>'Er du sikker på at du vil tilbakestille alle tilpasningsinnstillinger til standard?','Select Image'=>'Velg bilde','Use this image'=>'Bruk dette bildet','Remove'=>'Fjern','General'=>'Generelt','Customize'=>'Tilpass','Preset Themes'=>'Forhåndsdefinerte temaer','Default Purple'=>'Standard lilla','Business Blue'=>'Profesjonell blå','Dark Mode'=>'Mørk modus','Background'=>'Bakgrunn','Background Color'=>'Bakgrunnsfarge','Gradient End Color'=>'Gradient sluttfarge','Leave empty for solid color background.'=>'La stå tom for ensfarget bakgrunn.','Background Image'=>'Bakgrunnsbilde','Card Styling'=>'Kortstil','Card Background Color'=>'Kortets bakgrunnsfarge','Card Border Radius'=>'Kortets hjørneradius','Card Shadow'=>'Kortskygge','Logo'=>'Logo','Logo Image'=>'Logobilde','Logo Width'=>'Logobredde','Typography'=>'Typografi','Heading Text'=>'Overskriftstekst','Heading Color'=>'Overskriftsfarge','Text Color'=>'Tekstfarge','Font Family'=>'Skrifttype','System Default'=>'Systemstandard','Segoe UI'=>'Segoe UI','Georgia'=>'Georgia','Courier New'=>'Courier New','Button'=>'Knapp','Button Text'=>'Knappetekst','Button Background Color'=>'Knappens bakgrunnsfarge','Button Text Color'=>'Knappens tekstfarge','Button Border Radius'=>'Knappens hjørneradius','Form Options'=>'Skjemavalg','Show Remember Me'=>'Vis «Husk meg»','Input Border Radius'=>'Inntastingsfeltets hjørneradius','Footer'=>'Bunntekst','Footer Text'=>'Bunntekst','Footer Link URL'=>'Bunntekst lenke-URL','Reset to Defaults'=>'Tilbakestill til standard','Live Preview'=>'Direktevisning','Password Protected'=>'Passordbeskyttet','Enter the password to access this content.'=>'Skriv inn passordet for å få tilgang til dette innholdet.']]; \ No newline at end of file +return [ 'domain' => 'passwp-posts', 'plural-forms' => 'nplurals=2; plural=(n != 1);', 'language' => 'nb_NO', 'project-id-version' => 'PassWP Posts 1.0.1', 'pot-creation-date' => '2025-12-11T22:48:24+00:00', 'po-revision-date' => '2025-12-11 23:50+0100', 'x-generator' => 'WP-CLI 2.12.0', 'messages' => [ 'PassWP Posts' => 'PassWP Posts', 'https://developer.suspended.no/passwp-posts' => 'https://developer.suspended.no/passwp-posts', 'Password protects all pages and posts except the front page. Logged-in users bypass the password.' => 'Passordbeskytter alle sider og innlegg unntatt forsiden. Innloggede brukere omgår passordet.', 'Per Soderlind' => 'Per Soderlind', 'https://soderlind.no' => 'https://soderlind.no', 'PassWP Posts Settings' => 'PassWP Posts-innstillinger', 'Password Protection Settings' => 'Innstillinger for passordbeskyttelse', 'Enable Protection' => 'Aktiver beskyttelse', 'Password' => 'Passord', 'Remember Me Duration' => 'Varighet for «Husk meg»', 'Protection Mode' => 'Beskyttelsesmodus', 'Excluded Pages/Posts' => 'Ekskluderte sider/innlegg', 'Protected Pages/Posts' => 'Beskyttede sider/innlegg', 'Search for pages or posts...' => 'Søk etter sider eller innlegg...', 'Show password' => 'Vis passord', 'Hide password' => 'Skjul passord', 'Save Settings' => 'Lagre innstillinger', 'Configure password protection for your site. The front page is always public. Logged-in users bypass the password.' => 'Konfigurer passordbeskyttelse for nettstedet ditt. Forsiden er alltid offentlig. Innloggede brukere omgår passordet.', 'Enable password protection' => 'Aktiver passordbeskyttelse', 'When enabled, visitors must enter a password to view protected content.' => 'Når aktivert, må besøkende taste inn et passord for å se beskyttet innhold.', 'Leave blank to keep current password' => 'La stå tomt for å beholde nåværende passord', 'Enter password' => 'Skriv inn passord', 'Toggle password visibility' => 'Veksle passordsynlighet', 'A password is currently set. Enter a new password to change it, or leave blank to keep the current password.' => 'Et passord er allerede satt. Skriv inn et nytt passord for å endre det, eller la stå tomt for å beholde nåværende passord.', 'Enter the password visitors will use to access protected content.' => 'Skriv inn passordet besøkende skal bruke for å få tilgang til beskyttet innhold.', 'days' => 'dager', 'How long visitors stay authenticated after entering the password.' => 'Hvor lenge besøkende forblir autentisert etter å ha tastet inn passordet.', 'Protect all pages and posts (except front page)' => 'Beskytt alle sider og innlegg (unntatt forsiden)', 'Protect only selected pages and posts' => 'Beskytt kun valgte sider og innlegg', 'These pages and posts will not require a password.' => 'Disse sidene og innleggene vil ikke kreve passord.', 'Only these pages and posts will require a password.' => 'Kun disse sidene og innleggene vil kreve passord.', 'Permission denied.' => 'Tilgang nektet.', 'Security check failed.' => 'Sikkerhetssjekk mislyktes.', 'Incorrect password. Please try again.' => 'Feil passord. Vennligst prøv igjen.', 'No password has been configured. Please contact the site administrator.' => 'Ingen passord er konfigurert. Vennligst kontakt nettstedets administrator.', 'Password Required - %s' => 'Passord påkrevd - %s', 'Password Required' => 'Passord påkrevd', 'This content is protected. Please enter the password to continue.' => 'Dette innholdet er beskyttet. Vennligst skriv inn passordet for å fortsette.', 'Remember me' => 'Husk meg', 'Back to home' => 'Tilbake til forsiden', 'Are you sure you want to reset all customize settings to defaults?' => 'Er du sikker på at du vil tilbakestille alle tilpasningsinnstillinger til standard?', 'Select Image' => 'Velg bilde', 'Use this image' => 'Bruk dette bildet', 'Remove' => 'Fjern', 'General' => 'Generelt', 'Customize' => 'Tilpass', 'Preset Themes' => 'Forhåndsdefinerte temaer', 'Default Purple' => 'Standard lilla', 'Business Blue' => 'Profesjonell blå', 'Dark Mode' => 'Mørk modus', 'Background' => 'Bakgrunn', 'Background Color' => 'Bakgrunnsfarge', 'Gradient End Color' => 'Gradient sluttfarge', 'Leave empty for solid color background.' => 'La stå tom for ensfarget bakgrunn.', 'Background Image' => 'Bakgrunnsbilde', 'Card Styling' => 'Kortstil', 'Card Background Color' => 'Kortets bakgrunnsfarge', 'Card Border Radius' => 'Kortets hjørneradius', 'Card Shadow' => 'Kortskygge', 'Logo' => 'Logo', 'Logo Image' => 'Logobilde', 'Logo Width' => 'Logobredde', 'Typography' => 'Typografi', 'Heading Text' => 'Overskriftstekst', 'Heading Color' => 'Overskriftsfarge', 'Text Color' => 'Tekstfarge', 'Font Family' => 'Skrifttype', 'System Default' => 'Systemstandard', 'Segoe UI' => 'Segoe UI', 'Georgia' => 'Georgia', 'Courier New' => 'Courier New', 'Button' => 'Knapp', 'Button Text' => 'Knappetekst', 'Button Background Color' => 'Knappens bakgrunnsfarge', 'Button Text Color' => 'Knappens tekstfarge', 'Button Border Radius' => 'Knappens hjørneradius', 'Form Options' => 'Skjemavalg', 'Password Placeholder' => 'Plassholder for passord', 'Leave empty to use the default text.' => 'La stå tomt for å bruke standardteksten.', 'Show Remember Me' => 'Vis «Husk meg»', 'Input Border Radius' => 'Inntastingsfeltets hjørneradius', 'Footer' => 'Bunntekst', 'Footer Text' => 'Bunntekst', 'Footer Link URL' => 'Bunntekst lenke-URL', 'Reset to Defaults' => 'Tilbakestill til standard', 'Live Preview' => 'Direktevisning', 'Password Protected' => 'Passordbeskyttet', 'Enter the password to access this content.' => 'Skriv inn passordet for å få tilgang til dette innholdet.', 'Login' => 'Logg inn' ] ]; \ No newline at end of file diff --git a/languages/passwp-posts-nb_NO.mo b/languages/passwp-posts-nb_NO.mo index 4e72467..236a3df 100644 Binary files a/languages/passwp-posts-nb_NO.mo and b/languages/passwp-posts-nb_NO.mo differ diff --git a/languages/passwp-posts-nb_NO.po b/languages/passwp-posts-nb_NO.po index b2afd2d..76deca7 100644 --- a/languages/passwp-posts-nb_NO.po +++ b/languages/passwp-posts-nb_NO.po @@ -16,7 +16,7 @@ msgstr "" #. Plugin Name of the plugin #: passwp-posts.php -#: includes/AdminSettings.php:80 +#: includes/AdminSettings.php:81 msgid "PassWP Posts" msgstr "PassWP Posts" @@ -40,343 +40,358 @@ msgstr "Per Soderlind" msgid "https://soderlind.no" msgstr "https://soderlind.no" -#: includes/AdminSettings.php:79 +#: includes/AdminSettings.php:80 msgid "PassWP Posts Settings" msgstr "PassWP Posts-innstillinger" -#: includes/AdminSettings.php:104 +#: includes/AdminSettings.php:105 msgid "Password Protection Settings" msgstr "Innstillinger for passordbeskyttelse" -#: includes/AdminSettings.php:112 +#: includes/AdminSettings.php:113 msgid "Enable Protection" msgstr "Aktiver beskyttelse" -#: includes/AdminSettings.php:121 -#: includes/AdminSettings.php:709 -#: templates/password-form.php:155 +#: includes/AdminSettings.php:122 +#: includes/Shortcodes.php:107 +#: templates/password-form.php:161 msgid "Password" msgstr "Passord" -#: includes/AdminSettings.php:130 +#: includes/AdminSettings.php:131 msgid "Remember Me Duration" msgstr "Varighet for «Husk meg»" -#: includes/AdminSettings.php:139 +#: includes/AdminSettings.php:140 msgid "Protection Mode" msgstr "Beskyttelsesmodus" -#: includes/AdminSettings.php:148 +#: includes/AdminSettings.php:149 msgid "Excluded Pages/Posts" msgstr "Ekskluderte sider/innlegg" -#: includes/AdminSettings.php:157 +#: includes/AdminSettings.php:158 msgid "Protected Pages/Posts" msgstr "Beskyttede sider/innlegg" -#: includes/AdminSettings.php:254 +#: includes/AdminSettings.php:261 msgid "Search for pages or posts..." msgstr "Søk etter sider eller innlegg..." -#: includes/AdminSettings.php:255 +#: includes/AdminSettings.php:262 msgid "Show password" msgstr "Vis passord" -#: includes/AdminSettings.php:256 +#: includes/AdminSettings.php:263 msgid "Hide password" msgstr "Skjul passord" -#: includes/AdminSettings.php:351 -#: includes/AdminSettings.php:650 +#: includes/AdminSettings.php:358 +#: includes/AdminSettings.php:668 msgid "Save Settings" msgstr "Lagre innstillinger" -#: includes/AdminSettings.php:750 +#: includes/AdminSettings.php:775 msgid "Configure password protection for your site. The front page is always public. Logged-in users bypass the password." msgstr "Konfigurer passordbeskyttelse for nettstedet ditt. Forsiden er alltid offentlig. Innloggede brukere omgår passordet." -#: includes/AdminSettings.php:762 +#: includes/AdminSettings.php:787 msgid "Enable password protection" msgstr "Aktiver passordbeskyttelse" -#: includes/AdminSettings.php:765 +#: includes/AdminSettings.php:790 msgid "When enabled, visitors must enter a password to view protected content." msgstr "Når aktivert, må besøkende taste inn et passord for å se beskyttet innhold." -#: includes/AdminSettings.php:780 +#: includes/AdminSettings.php:805 msgid "Leave blank to keep current password" msgstr "La stå tomt for å beholde nåværende passord" -#: includes/AdminSettings.php:780 -#: templates/password-form.php:158 +#: includes/AdminSettings.php:614 +#: includes/AdminSettings.php:694 +#: includes/AdminSettings.php:805 +#: includes/Shortcodes.php:61 +#: templates/password-form.php:23 msgid "Enter password" msgstr "Skriv inn passord" -#: includes/AdminSettings.php:783 +#: includes/AdminSettings.php:808 msgid "Toggle password visibility" msgstr "Veksle passordsynlighet" -#: includes/AdminSettings.php:789 +#: includes/AdminSettings.php:814 msgid "A password is currently set. Enter a new password to change it, or leave blank to keep the current password." msgstr "Et passord er allerede satt. Skriv inn et nytt passord for å endre det, eller la stå tomt for å beholde nåværende passord." -#: includes/AdminSettings.php:793 +#: includes/AdminSettings.php:818 msgid "Enter the password visitors will use to access protected content." msgstr "Skriv inn passordet besøkende skal bruke for å få tilgang til beskyttet innhold." -#: includes/AdminSettings.php:809 +#: includes/AdminSettings.php:834 msgid "days" msgstr "dager" -#: includes/AdminSettings.php:811 +#: includes/AdminSettings.php:836 msgid "How long visitors stay authenticated after entering the password." msgstr "Hvor lenge besøkende forblir autentisert etter å ha tastet inn passordet." -#: includes/AdminSettings.php:826 +#: includes/AdminSettings.php:851 msgid "Protect all pages and posts (except front page)" msgstr "Beskytt alle sider og innlegg (unntatt forsiden)" -#: includes/AdminSettings.php:831 +#: includes/AdminSettings.php:856 msgid "Protect only selected pages and posts" msgstr "Beskytt kun valgte sider og innlegg" -#: includes/AdminSettings.php:866 +#: includes/AdminSettings.php:891 msgid "These pages and posts will not require a password." msgstr "Disse sidene og innleggene vil ikke kreve passord." -#: includes/AdminSettings.php:901 +#: includes/AdminSettings.php:926 msgid "Only these pages and posts will require a password." msgstr "Kun disse sidene og innleggene vil kreve passord." -#: includes/AdminSettings.php:1086 +#: includes/AdminSettings.php:1116 msgid "Permission denied." msgstr "Tilgang nektet." -#: includes/Protection.php:158 +#: includes/Protection.php:163 msgid "Security check failed." msgstr "Sikkerhetssjekk mislyktes." -#: templates/password-form.php:25 +#: includes/Shortcodes.php:86 +#: templates/password-form.php:31 msgid "Incorrect password. Please try again." msgstr "Feil passord. Vennligst prøv igjen." -#: templates/password-form.php:26 +#: includes/Shortcodes.php:87 +#: templates/password-form.php:32 msgid "No password has been configured. Please contact the site administrator." msgstr "Ingen passord er konfigurert. Vennligst kontakt nettstedets administrator." #. translators: %s is the site name. -#: templates/password-form.php:48 +#: templates/password-form.php:54 #, php-format msgid "Password Required - %s" msgstr "Passord påkrevd - %s" -#: templates/password-form.php:129 +#: templates/password-form.php:135 msgid "Password Required" msgstr "Passord påkrevd" -#: templates/password-form.php:132 +#: templates/password-form.php:138 msgid "This content is protected. Please enter the password to continue." msgstr "Dette innholdet er beskyttet. Vennligst skriv inn passordet for å fortsette." -#: includes/AdminSettings.php:715 -#: templates/password-form.php:165 +#: includes/AdminSettings.php:740 +#: includes/Shortcodes.php:116 +#: templates/password-form.php:171 msgid "Remember me" msgstr "Husk meg" -#: includes/AdminSettings.php:721 -#: templates/password-form.php:170 -msgid "Submit" -msgstr "Send inn" - -#: includes/AdminSettings.php:737 -#: templates/password-form.php:185 +#: includes/AdminSettings.php:762 +#: templates/password-form.php:191 msgid "Back to home" msgstr "Tilbake til forsiden" -#: includes/AdminSettings.php:293 +#: includes/AdminSettings.php:300 msgid "Are you sure you want to reset all customize settings to defaults?" msgstr "Er du sikker på at du vil tilbakestille alle tilpasningsinnstillinger til standard?" -#: includes/AdminSettings.php:294 -#: includes/AdminSettings.php:428 -#: includes/AdminSettings.php:487 +#: includes/AdminSettings.php:301 +#: includes/AdminSettings.php:435 +#: includes/AdminSettings.php:494 msgid "Select Image" msgstr "Velg bilde" -#: includes/AdminSettings.php:295 +#: includes/AdminSettings.php:302 msgid "Use this image" msgstr "Bruk dette bildet" -#: includes/AdminSettings.php:296 -#: includes/AdminSettings.php:429 -#: includes/AdminSettings.php:488 +#: includes/AdminSettings.php:303 +#: includes/AdminSettings.php:436 +#: includes/AdminSettings.php:495 msgid "Remove" msgstr "Fjern" -#: includes/AdminSettings.php:323 +#: includes/AdminSettings.php:330 msgid "General" msgstr "Generelt" -#: includes/AdminSettings.php:327 +#: includes/AdminSettings.php:334 msgid "Customize" msgstr "Tilpass" -#: includes/AdminSettings.php:371 +#: includes/AdminSettings.php:378 msgid "Preset Themes" msgstr "Forhåndsdefinerte temaer" -#: includes/AdminSettings.php:376 +#: includes/AdminSettings.php:383 msgid "Default Purple" msgstr "Standard lilla" -#: includes/AdminSettings.php:381 +#: includes/AdminSettings.php:388 msgid "Business Blue" msgstr "Profesjonell blå" -#: includes/AdminSettings.php:385 +#: includes/AdminSettings.php:392 msgid "Dark Mode" msgstr "Mørk modus" -#: includes/AdminSettings.php:393 +#: includes/AdminSettings.php:400 msgid "Background" msgstr "Bakgrunn" -#: includes/AdminSettings.php:396 +#: includes/AdminSettings.php:403 msgid "Background Color" msgstr "Bakgrunnsfarge" -#: includes/AdminSettings.php:405 +#: includes/AdminSettings.php:412 msgid "Gradient End Color" msgstr "Gradient sluttfarge" -#: includes/AdminSettings.php:412 +#: includes/AdminSettings.php:419 msgid "Leave empty for solid color background." msgstr "La stå tom for ensfarget bakgrunn." -#: includes/AdminSettings.php:417 +#: includes/AdminSettings.php:424 msgid "Background Image" msgstr "Bakgrunnsbilde" -#: includes/AdminSettings.php:436 +#: includes/AdminSettings.php:443 msgid "Card Styling" msgstr "Kortstil" -#: includes/AdminSettings.php:440 +#: includes/AdminSettings.php:447 msgid "Card Background Color" msgstr "Kortets bakgrunnsfarge" -#: includes/AdminSettings.php:449 +#: includes/AdminSettings.php:456 msgid "Card Border Radius" msgstr "Kortets hjørneradius" -#: includes/AdminSettings.php:461 +#: includes/AdminSettings.php:468 msgid "Card Shadow" msgstr "Kortskygge" -#: includes/AdminSettings.php:473 +#: includes/AdminSettings.php:480 msgid "Logo" msgstr "Logo" -#: includes/AdminSettings.php:476 +#: includes/AdminSettings.php:483 msgid "Logo Image" msgstr "Logobilde" -#: includes/AdminSettings.php:493 +#: includes/AdminSettings.php:500 msgid "Logo Width" msgstr "Logobredde" -#: includes/AdminSettings.php:507 +#: includes/AdminSettings.php:514 msgid "Typography" msgstr "Typografi" -#: includes/AdminSettings.php:510 +#: includes/AdminSettings.php:517 msgid "Heading Text" msgstr "Overskriftstekst" -#: includes/AdminSettings.php:518 +#: includes/AdminSettings.php:525 msgid "Heading Color" msgstr "Overskriftsfarge" -#: includes/AdminSettings.php:526 +#: includes/AdminSettings.php:533 msgid "Text Color" msgstr "Tekstfarge" -#: includes/AdminSettings.php:534 +#: includes/AdminSettings.php:541 msgid "Font Family" msgstr "Skrifttype" -#: includes/AdminSettings.php:538 +#: includes/AdminSettings.php:545 msgid "System Default" msgstr "Systemstandard" -#: includes/AdminSettings.php:541 +#: includes/AdminSettings.php:548 msgid "Segoe UI" msgstr "Segoe UI" -#: includes/AdminSettings.php:544 +#: includes/AdminSettings.php:551 msgid "Georgia" msgstr "Georgia" -#: includes/AdminSettings.php:547 +#: includes/AdminSettings.php:554 msgid "Courier New" msgstr "Courier New" -#: includes/AdminSettings.php:555 +#: includes/AdminSettings.php:562 msgid "Button" msgstr "Knapp" -#: includes/AdminSettings.php:558 +#: includes/AdminSettings.php:565 msgid "Button Text" msgstr "Knappetekst" -#: includes/AdminSettings.php:566 +#: includes/AdminSettings.php:573 msgid "Button Background Color" msgstr "Knappens bakgrunnsfarge" -#: includes/AdminSettings.php:576 +#: includes/AdminSettings.php:583 msgid "Button Text Color" msgstr "Knappens tekstfarge" -#: includes/AdminSettings.php:586 +#: includes/AdminSettings.php:593 msgid "Button Border Radius" msgstr "Knappens hjørneradius" -#: includes/AdminSettings.php:600 +#: includes/AdminSettings.php:607 msgid "Form Options" msgstr "Skjemavalg" -#: includes/AdminSettings.php:604 +#: includes/AdminSettings.php:610 +msgid "Password Placeholder" +msgstr "Plassholder for passord" + +#: includes/AdminSettings.php:616 +msgid "Leave empty to use the default text." +msgstr "La stå tomt for å bruke standardteksten." + +#: includes/AdminSettings.php:622 msgid "Show Remember Me" msgstr "Vis «Husk meg»" -#: includes/AdminSettings.php:615 +#: includes/AdminSettings.php:633 msgid "Input Border Radius" msgstr "Inntastingsfeltets hjørneradius" -#: includes/AdminSettings.php:629 +#: includes/AdminSettings.php:647 msgid "Footer" msgstr "Bunntekst" -#: includes/AdminSettings.php:632 +#: includes/AdminSettings.php:650 msgid "Footer Text" msgstr "Bunntekst" -#: includes/AdminSettings.php:640 +#: includes/AdminSettings.php:658 msgid "Footer Link URL" msgstr "Bunntekst lenke-URL" -#: includes/AdminSettings.php:652 +#: includes/AdminSettings.php:670 msgid "Reset to Defaults" msgstr "Tilbakestill til standard" -#: includes/AdminSettings.php:658 +#: includes/AdminSettings.php:676 msgid "Live Preview" msgstr "Direktevisning" -#: includes/AdminSettings.php:701 +#: includes/AdminSettings.php:724 msgid "Password Protected" msgstr "Passordbeskyttet" -#: includes/AdminSettings.php:705 +#: includes/AdminSettings.php:728 msgid "Enter the password to access this content." msgstr "Skriv inn passordet for å få tilgang til dette innholdet." + +#: includes/AdminSettings.php:696 +#: includes/Shortcodes.php:65 +#: templates/password-form.php:26 +msgid "Login" +msgstr "Logg inn" diff --git a/languages/passwp-posts.pot b/languages/passwp-posts.pot index 2d1e5c2..3a892f9 100644 --- a/languages/passwp-posts.pot +++ b/languages/passwp-posts.pot @@ -1,22 +1,22 @@ -# Copyright (C) 2025 Per Soderlind +# Copyright (C) 2026 Per Soderlind # This file is distributed under the GPL-2.0+. msgid "" msgstr "" -"Project-Id-Version: PassWP Posts 1.2.0\n" +"Project-Id-Version: PassWP Posts 1.3.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/passwp-posts\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2025-12-15T16:46:53+00:00\n" +"POT-Creation-Date: 2026-01-08T12:54:45+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.12.0\n" "X-Domain: passwp-posts\n" #. Plugin Name of the plugin #: passwp-posts.php -#: includes/AdminSettings.php:80 +#: includes/AdminSettings.php:81 msgid "PassWP Posts" msgstr "" @@ -40,343 +40,358 @@ msgstr "" msgid "https://soderlind.no" msgstr "" -#: includes/AdminSettings.php:79 +#: includes/AdminSettings.php:80 msgid "PassWP Posts Settings" msgstr "" -#: includes/AdminSettings.php:104 +#: includes/AdminSettings.php:105 msgid "Password Protection Settings" msgstr "" -#: includes/AdminSettings.php:112 +#: includes/AdminSettings.php:113 msgid "Enable Protection" msgstr "" -#: includes/AdminSettings.php:121 -#: includes/AdminSettings.php:709 -#: templates/password-form.php:155 +#: includes/AdminSettings.php:122 +#: includes/Shortcodes.php:107 +#: templates/password-form.php:161 msgid "Password" msgstr "" -#: includes/AdminSettings.php:130 +#: includes/AdminSettings.php:131 msgid "Remember Me Duration" msgstr "" -#: includes/AdminSettings.php:139 +#: includes/AdminSettings.php:140 msgid "Protection Mode" msgstr "" -#: includes/AdminSettings.php:148 +#: includes/AdminSettings.php:149 msgid "Excluded Pages/Posts" msgstr "" -#: includes/AdminSettings.php:157 +#: includes/AdminSettings.php:158 msgid "Protected Pages/Posts" msgstr "" -#: includes/AdminSettings.php:254 +#: includes/AdminSettings.php:261 msgid "Search for pages or posts..." msgstr "" -#: includes/AdminSettings.php:255 +#: includes/AdminSettings.php:262 msgid "Show password" msgstr "" -#: includes/AdminSettings.php:256 +#: includes/AdminSettings.php:263 msgid "Hide password" msgstr "" -#: includes/AdminSettings.php:293 +#: includes/AdminSettings.php:300 msgid "Are you sure you want to reset all customize settings to defaults?" msgstr "" -#: includes/AdminSettings.php:294 -#: includes/AdminSettings.php:428 -#: includes/AdminSettings.php:487 +#: includes/AdminSettings.php:301 +#: includes/AdminSettings.php:435 +#: includes/AdminSettings.php:494 msgid "Select Image" msgstr "" -#: includes/AdminSettings.php:295 +#: includes/AdminSettings.php:302 msgid "Use this image" msgstr "" -#: includes/AdminSettings.php:296 -#: includes/AdminSettings.php:429 -#: includes/AdminSettings.php:488 +#: includes/AdminSettings.php:303 +#: includes/AdminSettings.php:436 +#: includes/AdminSettings.php:495 msgid "Remove" msgstr "" -#: includes/AdminSettings.php:323 +#: includes/AdminSettings.php:330 msgid "General" msgstr "" -#: includes/AdminSettings.php:327 +#: includes/AdminSettings.php:334 msgid "Customize" msgstr "" -#: includes/AdminSettings.php:351 -#: includes/AdminSettings.php:650 +#: includes/AdminSettings.php:358 +#: includes/AdminSettings.php:668 msgid "Save Settings" msgstr "" -#: includes/AdminSettings.php:371 +#: includes/AdminSettings.php:378 msgid "Preset Themes" msgstr "" -#: includes/AdminSettings.php:376 +#: includes/AdminSettings.php:383 msgid "Default Purple" msgstr "" -#: includes/AdminSettings.php:381 +#: includes/AdminSettings.php:388 msgid "Business Blue" msgstr "" -#: includes/AdminSettings.php:385 +#: includes/AdminSettings.php:392 msgid "Dark Mode" msgstr "" -#: includes/AdminSettings.php:393 +#: includes/AdminSettings.php:400 msgid "Background" msgstr "" -#: includes/AdminSettings.php:396 +#: includes/AdminSettings.php:403 msgid "Background Color" msgstr "" -#: includes/AdminSettings.php:405 +#: includes/AdminSettings.php:412 msgid "Gradient End Color" msgstr "" -#: includes/AdminSettings.php:412 +#: includes/AdminSettings.php:419 msgid "Leave empty for solid color background." msgstr "" -#: includes/AdminSettings.php:417 +#: includes/AdminSettings.php:424 msgid "Background Image" msgstr "" -#: includes/AdminSettings.php:436 +#: includes/AdminSettings.php:443 msgid "Card Styling" msgstr "" -#: includes/AdminSettings.php:440 +#: includes/AdminSettings.php:447 msgid "Card Background Color" msgstr "" -#: includes/AdminSettings.php:449 +#: includes/AdminSettings.php:456 msgid "Card Border Radius" msgstr "" -#: includes/AdminSettings.php:461 +#: includes/AdminSettings.php:468 msgid "Card Shadow" msgstr "" -#: includes/AdminSettings.php:473 +#: includes/AdminSettings.php:480 msgid "Logo" msgstr "" -#: includes/AdminSettings.php:476 +#: includes/AdminSettings.php:483 msgid "Logo Image" msgstr "" -#: includes/AdminSettings.php:493 +#: includes/AdminSettings.php:500 msgid "Logo Width" msgstr "" -#: includes/AdminSettings.php:507 +#: includes/AdminSettings.php:514 msgid "Typography" msgstr "" -#: includes/AdminSettings.php:510 +#: includes/AdminSettings.php:517 msgid "Heading Text" msgstr "" -#: includes/AdminSettings.php:518 +#: includes/AdminSettings.php:525 msgid "Heading Color" msgstr "" -#: includes/AdminSettings.php:526 +#: includes/AdminSettings.php:533 msgid "Text Color" msgstr "" -#: includes/AdminSettings.php:534 +#: includes/AdminSettings.php:541 msgid "Font Family" msgstr "" -#: includes/AdminSettings.php:538 +#: includes/AdminSettings.php:545 msgid "System Default" msgstr "" -#: includes/AdminSettings.php:541 +#: includes/AdminSettings.php:548 msgid "Segoe UI" msgstr "" -#: includes/AdminSettings.php:544 +#: includes/AdminSettings.php:551 msgid "Georgia" msgstr "" -#: includes/AdminSettings.php:547 +#: includes/AdminSettings.php:554 msgid "Courier New" msgstr "" -#: includes/AdminSettings.php:555 +#: includes/AdminSettings.php:562 msgid "Button" msgstr "" -#: includes/AdminSettings.php:558 +#: includes/AdminSettings.php:565 msgid "Button Text" msgstr "" -#: includes/AdminSettings.php:566 +#: includes/AdminSettings.php:573 msgid "Button Background Color" msgstr "" -#: includes/AdminSettings.php:576 +#: includes/AdminSettings.php:583 msgid "Button Text Color" msgstr "" -#: includes/AdminSettings.php:586 +#: includes/AdminSettings.php:593 msgid "Button Border Radius" msgstr "" -#: includes/AdminSettings.php:600 +#: includes/AdminSettings.php:607 msgid "Form Options" msgstr "" -#: includes/AdminSettings.php:604 +#: includes/AdminSettings.php:610 +msgid "Password Placeholder" +msgstr "" + +#: includes/AdminSettings.php:614 +#: includes/AdminSettings.php:694 +#: includes/AdminSettings.php:805 +#: includes/Shortcodes.php:61 +#: templates/password-form.php:23 +msgid "Enter password" +msgstr "" + +#: includes/AdminSettings.php:616 +msgid "Leave empty to use the default text." +msgstr "" + +#: includes/AdminSettings.php:622 msgid "Show Remember Me" msgstr "" -#: includes/AdminSettings.php:615 +#: includes/AdminSettings.php:633 msgid "Input Border Radius" msgstr "" -#: includes/AdminSettings.php:629 +#: includes/AdminSettings.php:647 msgid "Footer" msgstr "" -#: includes/AdminSettings.php:632 +#: includes/AdminSettings.php:650 msgid "Footer Text" msgstr "" -#: includes/AdminSettings.php:640 +#: includes/AdminSettings.php:658 msgid "Footer Link URL" msgstr "" -#: includes/AdminSettings.php:652 +#: includes/AdminSettings.php:670 msgid "Reset to Defaults" msgstr "" -#: includes/AdminSettings.php:658 +#: includes/AdminSettings.php:676 msgid "Live Preview" msgstr "" -#: includes/AdminSettings.php:701 +#: includes/AdminSettings.php:696 +#: includes/Shortcodes.php:65 +#: templates/password-form.php:26 +msgid "Login" +msgstr "" + +#: includes/AdminSettings.php:724 msgid "Password Protected" msgstr "" -#: includes/AdminSettings.php:705 +#: includes/AdminSettings.php:728 msgid "Enter the password to access this content." msgstr "" -#: includes/AdminSettings.php:715 -#: templates/password-form.php:165 +#: includes/AdminSettings.php:740 +#: includes/Shortcodes.php:116 +#: templates/password-form.php:171 msgid "Remember me" msgstr "" -#: includes/AdminSettings.php:721 -#: templates/password-form.php:170 -msgid "Submit" -msgstr "" - -#: includes/AdminSettings.php:737 -#: templates/password-form.php:185 +#: includes/AdminSettings.php:762 +#: templates/password-form.php:191 msgid "Back to home" msgstr "" -#: includes/AdminSettings.php:750 +#: includes/AdminSettings.php:775 msgid "Configure password protection for your site. The front page is always public. Logged-in users bypass the password." msgstr "" -#: includes/AdminSettings.php:762 +#: includes/AdminSettings.php:787 msgid "Enable password protection" msgstr "" -#: includes/AdminSettings.php:765 +#: includes/AdminSettings.php:790 msgid "When enabled, visitors must enter a password to view protected content." msgstr "" -#: includes/AdminSettings.php:780 +#: includes/AdminSettings.php:805 msgid "Leave blank to keep current password" msgstr "" -#: includes/AdminSettings.php:780 -#: templates/password-form.php:158 -msgid "Enter password" -msgstr "" - -#: includes/AdminSettings.php:783 +#: includes/AdminSettings.php:808 msgid "Toggle password visibility" msgstr "" -#: includes/AdminSettings.php:789 +#: includes/AdminSettings.php:814 msgid "A password is currently set. Enter a new password to change it, or leave blank to keep the current password." msgstr "" -#: includes/AdminSettings.php:793 +#: includes/AdminSettings.php:818 msgid "Enter the password visitors will use to access protected content." msgstr "" -#: includes/AdminSettings.php:809 +#: includes/AdminSettings.php:834 msgid "days" msgstr "" -#: includes/AdminSettings.php:811 +#: includes/AdminSettings.php:836 msgid "How long visitors stay authenticated after entering the password." msgstr "" -#: includes/AdminSettings.php:826 +#: includes/AdminSettings.php:851 msgid "Protect all pages and posts (except front page)" msgstr "" -#: includes/AdminSettings.php:831 +#: includes/AdminSettings.php:856 msgid "Protect only selected pages and posts" msgstr "" -#: includes/AdminSettings.php:866 +#: includes/AdminSettings.php:891 msgid "These pages and posts will not require a password." msgstr "" -#: includes/AdminSettings.php:901 +#: includes/AdminSettings.php:926 msgid "Only these pages and posts will require a password." msgstr "" -#: includes/AdminSettings.php:1086 +#: includes/AdminSettings.php:1116 msgid "Permission denied." msgstr "" -#: includes/Protection.php:158 +#: includes/Protection.php:163 msgid "Security check failed." msgstr "" -#: templates/password-form.php:25 +#: includes/Shortcodes.php:86 +#: templates/password-form.php:31 msgid "Incorrect password. Please try again." msgstr "" -#: templates/password-form.php:26 +#: includes/Shortcodes.php:87 +#: templates/password-form.php:32 msgid "No password has been configured. Please contact the site administrator." msgstr "" #. translators: %s is the site name. -#: templates/password-form.php:48 +#: templates/password-form.php:54 #, php-format msgid "Password Required - %s" msgstr "" -#: templates/password-form.php:129 +#: templates/password-form.php:135 msgid "Password Required" msgstr "" -#: templates/password-form.php:132 +#: templates/password-form.php:138 msgid "This content is protected. Please enter the password to continue." msgstr "" diff --git a/package.json b/package.json index dfb61c1..55730e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "passwp-posts", - "version": "1.2.2", + "version": "1.3.0", "description": "Password protects all pages and posts except the front page", "type": "module", "scripts": { diff --git a/passwp-posts.php b/passwp-posts.php index b478be8..7d373a3 100644 --- a/passwp-posts.php +++ b/passwp-posts.php @@ -3,7 +3,7 @@ * Plugin Name: PassWP Posts * Plugin URI: https://developer.suspended.no/passwp-posts * Description: Password protects all pages and posts except the front page. Logged-in users bypass the password. - * Version: 1.2.1 + * Version: 1.3.0 * Author: Per Soderlind * Author URI: https://soderlind.no * License: GPL-2.0+ @@ -22,7 +22,7 @@ defined( 'ABSPATH' ) || exit; // Plugin constants. -define( 'PASSWP_POSTS_VERSION', '1.2.1' ); +define( 'PASSWP_POSTS_VERSION', '1.3.0' ); define( 'PASSWP_POSTS_PATH', plugin_dir_path( __FILE__ ) ); define( 'PASSWP_POSTS_URL', plugin_dir_url( __FILE__ ) ); define( 'PASSWP_POSTS_BASENAME', plugin_basename( __FILE__ ) ); @@ -36,6 +36,7 @@ use PassWP\Posts\CookieHandler; use PassWP\Posts\Protection; use PassWP\Posts\GitHubPluginUpdater; +use PassWP\Posts\Shortcodes; /** * Initialize the plugin. @@ -55,6 +56,7 @@ function passwp_posts_init(): void { // Initialize components. new AdminSettings(); new Protection(); + new Shortcodes(); } add_action( 'plugins_loaded', passwp_posts_init( ... ) ); diff --git a/readme.txt b/readme.txt index c3396ce..c7b0fb5 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: password, protection, privacy, security, access control Requires at least: 6.8 Tested up to: 6.9 Requires PHP: 8.3 -Stable tag: 1.2.2 +Stable tag: 1.3.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -115,6 +115,18 @@ You may need to exclude protected pages from caching or configure your caching p == Changelog == += 1.3.0 = +* Added shortcode [passwp_login] to render a theme-styled password form on public pages +* Added Customize option for password placeholder text +* Unified default texts: "Enter password" placeholder and "Login" button +* Shortcode output uses common WordPress login form CSS classes + += 1.2.2 = +* Hardened redirect handling to reject unsafe external URLs +* Fixed session cookie expiration handling in browsers +* Improved footer link customize key compatibility +* Added PHPUnit coverage for redirect validation + = 1.2.1 = * Improved documentation with clearer explanation of single-password concept * Added detailed use case examples (staging sites, client portals, etc.) diff --git a/templates/password-form.php b/templates/password-form.php index e3fa804..ef54108 100644 --- a/templates/password-form.php +++ b/templates/password-form.php @@ -20,6 +20,12 @@ // Get customize settings. $customize = PassWP\Posts\AdminSettings::get_customize_settings(); +$default_password_placeholder = __( 'Enter password', 'passwp-posts' ); +$password_placeholder = ! empty( $customize[ 'password_placeholder' ] ) ? $customize[ 'password_placeholder' ] : $default_password_placeholder; + +$default_button_text = __( 'Login', 'passwp-posts' ); +$button_text = ! empty( $customize[ 'button_text' ] ) ? $customize[ 'button_text' ] : $default_button_text; + // Error messages. $error_messages = array( 'invalid' => __( 'Incorrect password. Please try again.', 'passwp-posts' ), @@ -155,7 +161,7 @@ class="passwp-posts-form">
@@ -167,7 +173,7 @@ class="passwp-posts-form"> diff --git a/tests/ShortcodesTest.php b/tests/ShortcodesTest.php new file mode 100644 index 0000000..89109ec --- /dev/null +++ b/tests/ShortcodesTest.php @@ -0,0 +1,122 @@ +justReturn( + array( + 'enabled' => false, + 'password_hash' => 'hash', + ) + ); + Functions\when( 'is_user_logged_in' )->justReturn( false ); + + $shortcodes = new Shortcodes(); + $this->assertSame( '', $shortcodes->render_passwp_login() ); + } + + public function test_shortcode_renders_form_with_default_texts_and_referer_redirect(): void { + Functions\when( 'get_option' )->justReturn( + array( + 'enabled' => true, + 'password_hash' => 'hash', + 'customize' => array( + 'show_remember_me' => true, + ), + ) + ); + Functions\when( 'is_user_logged_in' )->justReturn( false ); + Functions\when( 'wp_get_raw_referer' )->justReturn( 'https://example.com/front' ); + Functions\when( 'wp_nonce_field' )->alias( + static function ( $action, $name, $referer = true, $echo = true ) { + return ''; + } + ); + + $_GET = array(); + $_COOKIE = array(); + + $shortcodes = new Shortcodes(); + $html = $shortcodes->render_passwp_login(); + + $this->assertStringContainsString( 'class="passwp-login"', $html ); + $this->assertStringContainsString( 'action="https://example.com/wp-admin/admin-post.php"', $html ); + $this->assertStringContainsString( 'name="action" value="passwp_posts_auth"', $html ); + $this->assertStringContainsString( 'name="passwp_redirect" value="https://example.com/front"', $html ); + $this->assertStringContainsString( 'name="passwp_password"', $html ); + $this->assertStringContainsString( 'placeholder="Enter password"', $html ); + $this->assertStringContainsString( '', $html ); + $this->assertStringContainsString( 'name="passwp_remember" value="1"', $html ); + } + + public function test_shortcode_returns_empty_when_cookie_is_valid(): void { + Functions\when( 'get_option' )->justReturn( + array( + 'enabled' => true, + 'password_hash' => 'hash', + ) + ); + Functions\when( 'is_user_logged_in' )->justReturn( false ); + Functions\when( 'wp_salt' )->justReturn( 'test_salt' ); + Functions\when( 'wp_get_raw_referer' )->justReturn( 'https://example.com/front' ); + Functions\when( 'wp_nonce_field' )->alias( + static function () { + return ''; + } + ); + + $cookie_handler = new CookieHandler(); + $cookie_name = $cookie_handler->get_cookie_name(); + $cookie_value = $cookie_handler->generate_cookie_value( 'hash' ); + $_COOKIE = array( $cookie_name => $cookie_value ); + + $shortcodes = new Shortcodes(); + $this->assertSame( '', $shortcodes->render_passwp_login() ); + } + + public function test_shortcode_uses_custom_placeholder_and_button_text(): void { + Functions\when( 'get_option' )->justReturn( + array( + 'enabled' => true, + 'password_hash' => 'hash', + 'customize' => array( + 'password_placeholder' => 'Secret', + 'button_text' => 'Sign in', + 'show_remember_me' => false, + ), + ) + ); + Functions\when( 'is_user_logged_in' )->justReturn( false ); + Functions\when( 'wp_get_raw_referer' )->justReturn( '' ); + Functions\when( 'wp_nonce_field' )->alias( + static function () { + return ''; + } + ); + + $_GET = array(); + $_COOKIE = array(); + + $shortcodes = new Shortcodes(); + $html = $shortcodes->render_passwp_login(); + + $this->assertStringContainsString( 'placeholder="Secret"', $html ); + $this->assertStringContainsString( '', $html ); + $this->assertStringNotContainsString( 'name="passwp_remember"', $html ); + $this->assertStringContainsString( 'name="passwp_redirect" value="https://example.com/"', $html ); + } +}