Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/content-protector/build/blocks/protected-content/render.php
+++ b/content-protector/build/blocks/protected-content/render.php
@@ -1,270 +1,263 @@
-<?php
-/**
- * Server-side rendering for the Protected Content block.
- *
- * @package Passster
- *
- * @var array $attributes Block attributes.
- * @var string $content Block content (inner blocks).
- * @var WP_Block $block Block instance.
- */
-
-defined( 'ABSPATH' ) || exit;
-
-// Early exit if classes not loaded yet (edge case).
-if ( ! class_exists( 'passsterPS_Conditional' ) || ! class_exists( 'passsterPS_Form' ) ) {
- echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- return;
-}
-
-// Ensure we have a valid block ID.
-if ( empty( $attributes['blockId'] ) ) {
- $attributes['blockId'] = 'ps-' . wp_generate_password( 8, false );
-}
-
-// Find the synced Protected Area by block ID.
-$synced_area_id = 0;
-$synced_areas = get_posts( array(
- 'post_type' => 'protected_areas',
- 'posts_per_page' => 1,
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => '_passster_block_id',
- 'value' => $attributes['blockId'],
- ),
- ),
-) );
-if ( ! empty( $synced_areas ) ) {
- $synced_area_id = $synced_areas[0];
-}
-
-use passsterPS_Conditional;
-use passsterPS_Form;
-
-// Get block attributes.
-$block_id = ! empty( $attributes['blockId'] ) ? sanitize_text_field( $attributes['blockId'] ) : '';
-$protection_type = ! empty( $attributes['protectionType'] ) ? sanitize_text_field( $attributes['protectionType'] ) : 'password';
-$password = ! empty( $attributes['password'] ) ? $attributes['password'] : '';
-$passwords = ! empty( $attributes['passwords'] ) ? $attributes['passwords'] : '';
-$password_list = ! empty( $attributes['passwordList'] ) ? absint( $attributes['passwordList'] ) : 0;
-
-// User Restriction attributes.
-$user_restriction = ! empty( $attributes['userRestriction'] );
-$user_restriction_type = ! empty( $attributes['userRestrictionType'] ) ? sanitize_text_field( $attributes['userRestrictionType'] ) : 'username';
-$user_restriction_value = ! empty( $attributes['userRestrictionValue'] ) ? sanitize_text_field( $attributes['userRestrictionValue'] ) : '';
-
-// Override Defaults attributes.
-$overwrite_defaults = ! empty( $attributes['overwriteDefaults'] );
-$headline = ! empty( $attributes['headline'] ) ? sanitize_text_field( $attributes['headline'] ) : '';
-$instruction = ! empty( $attributes['instruction'] ) ? wp_kses_post( $attributes['instruction'] ) : '';
-$placeholder = ! empty( $attributes['placeholder'] ) ? sanitize_text_field( $attributes['placeholder'] ) : '';
-$button_label = ! empty( $attributes['buttonLabel'] ) ? sanitize_text_field( $attributes['buttonLabel'] ) : '';
-$form_id = ! empty( $attributes['formId'] ) ? sanitize_text_field( $attributes['formId'] ) : '';
-
-// Advanced Options attributes.
-$advanced_options = ! empty( $attributes['advancedOptions'] );
-$redirect_url = ! empty( $attributes['redirectUrl'] ) ? esc_url( $attributes['redirectUrl'] ) : '';
-$hide_form = ! empty( $attributes['hideForm'] );
-
-// Schedule attributes (PRO only).
-$schedule_enabled = ! empty( $attributes['scheduleEnabled'] );
-$schedule_start = ! empty( $attributes['scheduleStart'] ) ? $attributes['scheduleStart'] : '';
-$schedule_end = ! empty( $attributes['scheduleEnd'] ) ? $attributes['scheduleEnd'] : '';
-
-// Check schedule - if outside the scheduled period, show content without protection.
-if ( $schedule_enabled && passster_fs()->is_plan_or_trial__premium_only( 'pro' ) ) {
- $now = current_time( 'timestamp' );
- $is_within_schedule = true;
-
- if ( ! empty( $schedule_start ) ) {
- $start_time = strtotime( $schedule_start );
- if ( $now < $start_time ) {
- $is_within_schedule = false;
- }
- }
-
- if ( ! empty( $schedule_end ) ) {
- $end_time = strtotime( $schedule_end );
- if ( $now > $end_time ) {
- $is_within_schedule = false;
- }
- }
-
- // If outside schedule, show content without protection.
- if ( ! $is_within_schedule ) {
- echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- return;
- }
-}
-
-// If no protection is set, just render the content.
-if ( 'password' === $protection_type && empty( $password ) ) {
- echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- return;
-}
-
-if ( 'passwords' === $protection_type && empty( $passwords ) ) {
- echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- return;
-}
-
-if ( 'password_list' === $protection_type && empty( $password_list ) ) {
- echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- return;
-}
-
-// Build attributes array for validation.
-$atts = array();
-
-switch ( $protection_type ) {
- case 'password':
- $atts['password'] = $password;
- break;
- case 'passwords':
- $atts['passwords'] = $passwords;
- break;
- case 'password_list':
- $atts['password_list'] = $password_list;
- break;
-}
-
-// Add user restriction to validation attributes if enabled.
-if ( $user_restriction && ! empty( $user_restriction_value ) && 'no-role' !== $user_restriction_value ) {
- if ( 'user-role' === $user_restriction_type ) {
- $atts['role'] = $user_restriction_value;
- } else {
- $atts['user'] = $user_restriction_value;
- }
-}
-
-// Check if already unlocked.
-$is_unlocked = false;
-if ( class_exists( PS_Conditional::class ) ) {
- $is_unlocked = PS_Conditional::is_valid( $atts );
-}
-
-// If unlocked, show content.
-if ( $is_unlocked ) {
- echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- return;
-}
-
-// If hide_form is enabled and not unlocked, show nothing (or just the content for cookie-based access).
-if ( $advanced_options && $hide_form ) {
- echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- return;
-}
-
-// Get global options for form defaults.
-$options = get_option( 'passster', array() );
-
-// Build the protection form using global settings.
-$form = PS_Form::get_password_form();
-
-// Form ID - use custom ID if set, otherwise block ID.
-$final_form_id = ! empty( $form_id ) ? $form_id : 'ps-block-' . $block_id;
-$form = str_replace( '[PASSSTER_ID]', esc_attr( $final_form_id ), $form );
-
-// Hide form placeholder.
-$form = str_replace( '[PASSSTER_HIDE]', '', $form );
-
-// Redirect URL.
-if ( $advanced_options && ! empty( $redirect_url ) ) {
- $form = str_replace( '[PASSSTER_REDIRECT]', esc_url( $redirect_url ), $form );
-} else {
- $form = str_replace( '[PASSSTER_REDIRECT]', '', $form );
-}
-
-// Label.
-$form = str_replace( '[PASSSTER_LABEL]', esc_html__( 'Enter your password', 'content-protector' ), $form );
-
-// Headline tag.
-$allowed_headline_tags = array( 'span', 'p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' );
-$headline_tag = isset( $options['headline_tag'] ) && in_array( $options['headline_tag'], $allowed_headline_tags, true ) ? $options['headline_tag'] : 'span';
-$form = str_replace( '[PASSSTER_HEADLINE_TAG]', $headline_tag, $form );
-
-// Headline - use override if enabled and set, otherwise global.
-if ( ! empty( $options['hide_headline'] ) ) {
- $form = str_replace( '[PASSSTER_FORM_HEADLINE]', '', $form );
-} elseif ( $overwrite_defaults && ! empty( $headline ) ) {
- $form = str_replace( '[PASSSTER_FORM_HEADLINE]', esc_html( $headline ), $form );
-} else {
- $form = str_replace( '[PASSSTER_FORM_HEADLINE]', esc_html( $options['headline'] ?? '' ), $form );
-}
-
-// Instruction - use override if enabled and set, otherwise global.
-if ( $overwrite_defaults && ! empty( $instruction ) ) {
- $form = str_replace( '[PASSSTER_FORM_INSTRUCTIONS]', wp_kses_post( $instruction ), $form );
-} else {
- $form = str_replace( '[PASSSTER_FORM_INSTRUCTIONS]', wp_kses_post( $options['instruction'] ?? '' ), $form );
-}
-
-// Placeholder - use override if enabled and set, otherwise global.
-if ( $overwrite_defaults && ! empty( $placeholder ) ) {
- $form = str_replace( '[PASSSTER_PLACEHOLDER]', esc_attr( $placeholder ), $form );
-} else {
- $form = str_replace( '[PASSSTER_PLACEHOLDER]', esc_attr( $options['placeholder'] ?? '' ), $form );
-}
-
-// Button label - use override if enabled and set, otherwise global.
-if ( $overwrite_defaults && ! empty( $button_label ) ) {
- $form = str_replace( '[PASSSTER_BUTTON_LABEL]', esc_html( $button_label ), $form );
-} else {
- $form = str_replace( '[PASSSTER_BUTTON_LABEL]', esc_html( $options['button_label'] ?? '' ), $form );
-}
-
-// Protection type placeholder.
-$form = str_replace( '[PASSSTER_TYPE]', esc_attr( $protection_type ), $form );
-
-// Protection mode - 'block' for Content Lock blocks (REST API validates from block attributes).
-$form = str_replace( '[PASSSTER_PROTECTION]', 'block', $form );
-
-// Password list placeholders.
-$form = str_replace( '[PASSSTER_LIST]', esc_attr( $password_list ), $form );
-$form = str_replace( '[PASSSTER_LISTS]', '', $form );
-
-// Area placeholder (set to 0 for blocks - we use block_id instead).
-$form = str_replace( '[PASSSTER_AREA]', '0', $form );
-
-// ACF placeholder (not used in blocks).
-$form = str_replace( '[PASSSTER_ACF]', '', $form );
-
-// Store content for JS to reveal after unlock.
-$content_encoded = base64_encode( $content );
-
-// Wrapper classes.
-$wrapper_classes = array( 'passster-protected-content', 'wp-block-passster-protected-content' );
-if ( ! empty( $attributes['align'] ) ) {
- $wrapper_classes[] = 'align' . $attributes['align'];
-}
-if ( ! empty( $attributes['className'] ) ) {
- $wrapper_classes[] = $attributes['className'];
-}
-
-// Data attributes for JS handling.
-$data_attrs = array(
- 'block-id' => $block_id,
- 'protection-type' => $protection_type,
- 'post-id' => get_the_ID(),
-);
-
-if ( $advanced_options && ! empty( $redirect_url ) ) {
- $data_attrs['redirect'] = $redirect_url;
-}
-
-// Output.
-?>
-<div
- class="<?php echo esc_attr( implode( ' ', $wrapper_classes ) ); ?>"
- <?php foreach ( $data_attrs as $key => $value ) : ?>
- data-<?php echo esc_attr( $key ); ?>="<?php echo esc_attr( $value ); ?>"
- <?php endforeach; ?>
->
- <div class="passster-protected-content__form">
- <?php echo $form; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
- </div>
- <div class="passster-protected-content__content" style="display: none;" data-content="<?php echo esc_attr( $content_encoded ); ?>">
- </div>
-</div>
-<?php
+<?php
+/**
+ * Server-side rendering for the Protected Content block.
+ *
+ * @package Passster
+ *
+ * @var array $attributes Block attributes.
+ * @var string $content Block content (inner blocks).
+ * @var WP_Block $block Block instance.
+ */
+
+defined( 'ABSPATH' ) || exit;
+
+// Early exit if classes not loaded yet (edge case).
+if ( ! class_exists( 'passsterPS_Conditional' ) || ! class_exists( 'passsterPS_Form' ) ) {
+ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+}
+
+// Ensure we have a valid block ID.
+if ( empty( $attributes['blockId'] ) ) {
+ $attributes['blockId'] = 'ps-' . wp_generate_password( 8, false );
+}
+
+// Find the synced Protected Area by block ID.
+$synced_area_id = 0;
+$synced_areas = get_posts( array(
+ 'post_type' => 'protected_areas',
+ 'posts_per_page' => 1,
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'key' => '_passster_block_id',
+ 'value' => $attributes['blockId'],
+ ),
+ ),
+) );
+if ( ! empty( $synced_areas ) ) {
+ $synced_area_id = $synced_areas[0];
+}
+
+use passsterPS_Conditional;
+use passsterPS_Form;
+
+// Get block attributes.
+$block_id = ! empty( $attributes['blockId'] ) ? sanitize_text_field( $attributes['blockId'] ) : '';
+$protection_type = ! empty( $attributes['protectionType'] ) ? sanitize_text_field( $attributes['protectionType'] ) : 'password';
+$password = ! empty( $attributes['password'] ) ? $attributes['password'] : '';
+$passwords = ! empty( $attributes['passwords'] ) ? $attributes['passwords'] : '';
+$password_list = ! empty( $attributes['passwordList'] ) ? absint( $attributes['passwordList'] ) : 0;
+
+// User Restriction attributes.
+$user_restriction = ! empty( $attributes['userRestriction'] );
+$user_restriction_type = ! empty( $attributes['userRestrictionType'] ) ? sanitize_text_field( $attributes['userRestrictionType'] ) : 'username';
+$user_restriction_value = ! empty( $attributes['userRestrictionValue'] ) ? sanitize_text_field( $attributes['userRestrictionValue'] ) : '';
+
+// Override Defaults attributes.
+$overwrite_defaults = ! empty( $attributes['overwriteDefaults'] );
+$headline = ! empty( $attributes['headline'] ) ? sanitize_text_field( $attributes['headline'] ) : '';
+$instruction = ! empty( $attributes['instruction'] ) ? wp_kses_post( $attributes['instruction'] ) : '';
+$placeholder = ! empty( $attributes['placeholder'] ) ? sanitize_text_field( $attributes['placeholder'] ) : '';
+$button_label = ! empty( $attributes['buttonLabel'] ) ? sanitize_text_field( $attributes['buttonLabel'] ) : '';
+$form_id = ! empty( $attributes['formId'] ) ? sanitize_text_field( $attributes['formId'] ) : '';
+
+// Advanced Options attributes.
+$advanced_options = ! empty( $attributes['advancedOptions'] );
+$redirect_url = ! empty( $attributes['redirectUrl'] ) ? esc_url( $attributes['redirectUrl'] ) : '';
+$hide_form = ! empty( $attributes['hideForm'] );
+
+// Schedule attributes (PRO only).
+$schedule_enabled = ! empty( $attributes['scheduleEnabled'] );
+$schedule_start = ! empty( $attributes['scheduleStart'] ) ? $attributes['scheduleStart'] : '';
+$schedule_end = ! empty( $attributes['scheduleEnd'] ) ? $attributes['scheduleEnd'] : '';
+
+// Check schedule - if outside the scheduled period, show content without protection.
+if ( $schedule_enabled && passster_fs()->is_plan_or_trial__premium_only( 'pro' ) ) {
+ $now = current_time( 'timestamp' );
+ $is_within_schedule = true;
+
+ if ( ! empty( $schedule_start ) ) {
+ $start_time = strtotime( $schedule_start );
+ if ( $now < $start_time ) {
+ $is_within_schedule = false;
+ }
+ }
+
+ if ( ! empty( $schedule_end ) ) {
+ $end_time = strtotime( $schedule_end );
+ if ( $now > $end_time ) {
+ $is_within_schedule = false;
+ }
+ }
+
+ // If outside schedule, show content without protection.
+ if ( ! $is_within_schedule ) {
+ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+ }
+}
+
+// If no protection is set, just render the content.
+if ( 'password' === $protection_type && empty( $password ) ) {
+ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+}
+
+if ( 'passwords' === $protection_type && empty( $passwords ) ) {
+ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+}
+
+if ( 'password_list' === $protection_type && empty( $password_list ) ) {
+ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+}
+
+// Build attributes array for validation.
+$atts = array();
+
+switch ( $protection_type ) {
+ case 'password':
+ $atts['password'] = $password;
+ break;
+ case 'passwords':
+ $atts['passwords'] = $passwords;
+ break;
+ case 'password_list':
+ $atts['password_list'] = $password_list;
+ break;
+}
+
+// Add user restriction to validation attributes if enabled.
+if ( $user_restriction && ! empty( $user_restriction_value ) && 'no-role' !== $user_restriction_value ) {
+ if ( 'user-role' === $user_restriction_type ) {
+ $atts['role'] = $user_restriction_value;
+ } else {
+ $atts['user'] = $user_restriction_value;
+ }
+}
+
+// Check if already unlocked.
+$is_unlocked = false;
+if ( class_exists( PS_Conditional::class ) ) {
+ $is_unlocked = PS_Conditional::is_valid( $atts );
+}
+
+// If unlocked, show content.
+if ( $is_unlocked ) {
+ echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+}
+
+if ( $advanced_options && $hide_form ) {
+ return;
+}
+
+// Get global options for form defaults.
+$options = get_option( 'passster', array() );
+
+// Build the protection form using global settings.
+$form = PS_Form::get_password_form();
+
+// Form ID - use custom ID if set, otherwise block ID.
+$final_form_id = ! empty( $form_id ) ? $form_id : 'ps-block-' . $block_id;
+$form = str_replace( '[PASSSTER_ID]', esc_attr( $final_form_id ), $form );
+
+// Hide form placeholder.
+$form = str_replace( '[PASSSTER_HIDE]', '', $form );
+
+// Redirect URL.
+if ( $advanced_options && ! empty( $redirect_url ) ) {
+ $form = str_replace( '[PASSSTER_REDIRECT]', esc_url( $redirect_url ), $form );
+} else {
+ $form = str_replace( '[PASSSTER_REDIRECT]', '', $form );
+}
+
+// Label.
+$form = str_replace( '[PASSSTER_LABEL]', esc_html__( 'Enter your password', 'content-protector' ), $form );
+
+// Headline tag.
+$allowed_headline_tags = array( 'span', 'p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' );
+$headline_tag = isset( $options['headline_tag'] ) && in_array( $options['headline_tag'], $allowed_headline_tags, true ) ? $options['headline_tag'] : 'span';
+$form = str_replace( '[PASSSTER_HEADLINE_TAG]', $headline_tag, $form );
+
+// Headline - use override if enabled and set, otherwise global.
+if ( ! empty( $options['hide_headline'] ) ) {
+ $form = str_replace( '[PASSSTER_FORM_HEADLINE]', '', $form );
+} elseif ( $overwrite_defaults && ! empty( $headline ) ) {
+ $form = str_replace( '[PASSSTER_FORM_HEADLINE]', esc_html( $headline ), $form );
+} else {
+ $form = str_replace( '[PASSSTER_FORM_HEADLINE]', esc_html( $options['headline'] ?? '' ), $form );
+}
+
+// Instruction - use override if enabled and set, otherwise global.
+if ( $overwrite_defaults && ! empty( $instruction ) ) {
+ $form = str_replace( '[PASSSTER_FORM_INSTRUCTIONS]', wp_kses_post( $instruction ), $form );
+} else {
+ $form = str_replace( '[PASSSTER_FORM_INSTRUCTIONS]', wp_kses_post( $options['instruction'] ?? '' ), $form );
+}
+
+// Placeholder - use override if enabled and set, otherwise global.
+if ( $overwrite_defaults && ! empty( $placeholder ) ) {
+ $form = str_replace( '[PASSSTER_PLACEHOLDER]', esc_attr( $placeholder ), $form );
+} else {
+ $form = str_replace( '[PASSSTER_PLACEHOLDER]', esc_attr( $options['placeholder'] ?? '' ), $form );
+}
+
+// Button label - use override if enabled and set, otherwise global.
+if ( $overwrite_defaults && ! empty( $button_label ) ) {
+ $form = str_replace( '[PASSSTER_BUTTON_LABEL]', esc_html( $button_label ), $form );
+} else {
+ $form = str_replace( '[PASSSTER_BUTTON_LABEL]', esc_html( $options['button_label'] ?? '' ), $form );
+}
+
+// Protection type placeholder.
+$form = str_replace( '[PASSSTER_TYPE]', esc_attr( $protection_type ), $form );
+
+// Protection mode - 'block' for Content Lock blocks (REST API validates from block attributes).
+$form = str_replace( '[PASSSTER_PROTECTION]', 'block', $form );
+
+// Password list placeholders.
+$form = str_replace( '[PASSSTER_LIST]', esc_attr( $password_list ), $form );
+$form = str_replace( '[PASSSTER_LISTS]', '', $form );
+
+// Area placeholder (set to 0 for blocks - we use block_id instead).
+$form = str_replace( '[PASSSTER_AREA]', '0', $form );
+
+// ACF placeholder (not used in blocks).
+$form = str_replace( '[PASSSTER_ACF]', '', $form );
+
+// Wrapper classes.
+$wrapper_classes = array( 'passster-protected-content', 'wp-block-passster-protected-content' );
+if ( ! empty( $attributes['align'] ) ) {
+ $wrapper_classes[] = 'align' . $attributes['align'];
+}
+if ( ! empty( $attributes['className'] ) ) {
+ $wrapper_classes[] = $attributes['className'];
+}
+
+// Data attributes for JS handling.
+$data_attrs = array(
+ 'block-id' => $block_id,
+ 'protection-type' => $protection_type,
+ 'post-id' => get_the_ID(),
+);
+
+if ( $advanced_options && ! empty( $redirect_url ) ) {
+ $data_attrs['redirect'] = $redirect_url;
+}
+
+// Output.
+?>
+<div
+ class="<?php echo esc_attr( implode( ' ', $wrapper_classes ) ); ?>"
+ <?php foreach ( $data_attrs as $key => $value ) : ?>
+ data-<?php echo esc_attr( $key ); ?>="<?php echo esc_attr( $value ); ?>"
+ <?php endforeach; ?>
+>
+ <div class="passster-protected-content__form">
+ <?php echo $form; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
+ </div>
+</div>
+<?php
--- a/content-protector/content-protector.php
+++ b/content-protector/content-protector.php
@@ -1,77 +1,77 @@
-<?php
-
-/**
- * Plugin Name: Passster
- * Plugin URI: https://passster.com/
- * Description: A simple plugin to password-protect your complete website, some pages/posts or just parts of your content.
- * Version: 4.3.5
- * Author: WPChill
- * Author URI: https://wpchill.com
- * License: GPL-2.0+
- * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
- * Text Domain: content-protector
- * Domain Path: /languages
- *
- *
- *
- * NOTE:
- * Patrick Posner transferred ownership rights on: 6th of December, 2024 when ownership was handed over to WPChill
- */
-define( 'PASSSTER_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
-define( 'PASSSTER_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
-define( 'PASSSTER_VERSION', '4.3.5' );
-// run plugin.
-if ( !function_exists( 'passster_run_plugin' ) ) {
- add_action( 'plugins_loaded', 'passster_run_plugin' );
- /**
- * Run plugin
- *
- * @return void
- * @throws Exception
- */
- function passster_run_plugin() {
- // Include files.
- require_once PASSSTER_PATH . '/inc/class-ps-conditional.php';
- require_once PASSSTER_PATH . '/inc/class-ps-helper.php';
- require_once PASSSTER_PATH . '/inc/class-ps-form.php';
- require_once PASSSTER_PATH . '/inc/class-ps-public.php';
- require_once PASSSTER_PATH . '/inc/class-ps-migrator.php';
- require_once PASSSTER_PATH . '/inc/class-ps-block-editor.php';
- require_once PASSSTER_PATH . '/inc/class-ps-rest-handler.php';
- require_once PASSSTER_PATH . '/inc/class-ps-rest-api.php';
- require_once PASSSTER_PATH . '/inc/class-ps-protected-posts.php';
- require_once PASSSTER_PATH . '/inc/class-ps-category-lock.php';
- // admin.
- require_once PASSSTER_PATH . '/inc/admin/inc/class-ps-admin-settings.php';
- require_once PASSSTER_PATH . '/inc/admin/inc/class-ps-upsells.php';
- require_once PASSSTER_PATH . '/inc/admin/inc/class-ps-admin.php';
- require_once PASSSTER_PATH . '/inc/admin/inc/class-ps-meta.php';
- require_once PASSSTER_PATH . '/inc/admin/inc/class-ps-dynamic-styles.php';
- // load Freemius.
- require_once PASSSTER_PATH . '/inc/freemius-setup.php';
- // localize.
- $textdomain_dir = plugin_basename( __DIR__ ) . '/languages';
- load_plugin_textdomain( 'content-protector', false, $textdomain_dir );
- if ( !get_option( 'passster_secure_key' ) ) {
- add_option( 'passster_secure_key', bin2hex( random_bytes( 32 ) ) );
- }
- passsterPS_Admin::get_instance();
- passsterPS_Admin_Settings::get_instance();
- passsterPS_Meta::get_instance();
- passsterPS_Dynamic_Styles::get_instance();
- passsterPS_Form::get_instance();
- passsterPS_Public::get_instance();
- passsterPS_Block_Editor::get_instance();
- passsterPS_Rest_Handler::get_instance();
- passsterPS_Rest_API::get_instance();
- passsterPS_Upsells::get_instance();
- // Maybe migrate settings.
- $options = get_option( 'passster' );
- if ( empty( $options ) ) {
- passsterPS_Migrator::migrate();
- }
- passsterPS_Protected_Posts::get_instance();
- passsterPS_Category_Lock::get_instance();
- }
-
+<?php
+
+/**
+ * Plugin Name: Passster
+ * Plugin URI: https://passster.com/
+ * Description: A simple plugin to password-protect your complete website, some pages/posts or just parts of your content.
+ * Version: 4.3.6
+ * Author: WPChill
+ * Author URI: https://wpchill.com
+ * License: GPL-2.0+
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
+ * Text Domain: content-protector
+ * Domain Path: /languages
+ *
+ *
+ *
+ * NOTE:
+ * Patrick Posner transferred ownership rights on: 6th of December, 2024 when ownership was handed over to WPChill
+ */
+define( 'PASSSTER_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
+define( 'PASSSTER_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
+define( 'PASSSTER_VERSION', '4.3.6' );
+// run plugin.
+if ( !function_exists( 'passster_run_plugin' ) ) {
+ add_action( 'plugins_loaded', 'passster_run_plugin' );
+ /**
+ * Run plugin
+ *
+ * @return void
+ * @throws Exception
+ */
+ function passster_run_plugin() {
+ // Include files.
+ require_once PASSSTER_PATH . '/inc/class-ps-conditional.php';
+ require_once PASSSTER_PATH . '/inc/class-ps-helper.php';
+ require_once PASSSTER_PATH . '/inc/class-ps-form.php';
+ require_once PASSSTER_PATH . '/inc/class-ps-public.php';
+ require_once PASSSTER_PATH . '/inc/class-ps-migrator.php';
+ require_once PASSSTER_PATH . '/inc/class-ps-block-editor.php';
+ require_once PASSSTER_PATH . '/inc/class-ps-rest-handler.php';
+ require_once PASSSTER_PATH . '/inc/class-ps-rest-api.php';
+ require_once PASSSTER_PATH . '/inc/class-ps-protected-posts.php';
+ require_once PASSSTER_PATH . '/inc/class-ps-category-lock.php';
+ // admin.
+ require_once PASSSTER_PATH . '/inc/admin/inc/class-ps-admin-settings.php';
+ require_once PASSSTER_PATH . '/inc/admin/inc/class-ps-upsells.php';
+ require_once PASSSTER_PATH . '/inc/admin/inc/class-ps-admin.php';
+ require_once PASSSTER_PATH . '/inc/admin/inc/class-ps-meta.php';
+ require_once PASSSTER_PATH . '/inc/admin/inc/class-ps-dynamic-styles.php';
+ // load Freemius.
+ require_once PASSSTER_PATH . '/inc/freemius-setup.php';
+ // localize.
+ $textdomain_dir = plugin_basename( __DIR__ ) . '/languages';
+ load_plugin_textdomain( 'content-protector', false, $textdomain_dir );
+ if ( !get_option( 'passster_secure_key' ) ) {
+ add_option( 'passster_secure_key', bin2hex( random_bytes( 32 ) ) );
+ }
+ passsterPS_Admin::get_instance();
+ passsterPS_Admin_Settings::get_instance();
+ passsterPS_Meta::get_instance();
+ passsterPS_Dynamic_Styles::get_instance();
+ passsterPS_Form::get_instance();
+ passsterPS_Public::get_instance();
+ passsterPS_Block_Editor::get_instance();
+ passsterPS_Rest_Handler::get_instance();
+ passsterPS_Rest_API::get_instance();
+ passsterPS_Upsells::get_instance();
+ // Maybe migrate settings.
+ $options = get_option( 'passster' );
+ if ( empty( $options ) ) {
+ passsterPS_Migrator::migrate();
+ }
+ passsterPS_Protected_Posts::get_instance();
+ passsterPS_Category_Lock::get_instance();
+ }
+
}
No newline at end of file
--- a/content-protector/inc/admin/build/index.asset.php
+++ b/content-protector/inc/admin/build/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '5506435cfdba9b51fb83');
+<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '88e25b3186311c5d09ee');
--- a/content-protector/inc/admin/inc/class-ps-admin-settings.php
+++ b/content-protector/inc/admin/inc/class-ps-admin-settings.php
@@ -1,332 +1,332 @@
-<?php
-
-namespace passster;
-
-class PS_Admin_Settings {
- /**
- * Contains instance or null
- *
- * @var object|null
- */
- private static $instance = null;
-
- /**
- * Returns instance of PS_Admin_Settings.
- *
- * @return object
- */
- public static function get_instance() {
- if ( null === self::$instance ) {
- self::$instance = new self();
- }
- return self::$instance;
- }
-
- /**
- * Setting up admin fields
- *
- * @return void
- */
- public function __construct() {
- add_action( 'admin_menu', array($this, 'add_menu') );
- add_action( 'admin_menu', array($this, 'add_settings_submenu'), 99 );
- // Add Settings last
- add_action( 'rest_api_init', array($this, 'rest_api_init') );
- }
-
- public function add_menu() {
- add_menu_page(
- __( 'Passster', 'content-protector' ),
- 'Passster',
- apply_filters( 'passster_user_capability', 'manage_options' ),
- 'passster',
- array($this, 'render_settings'),
- 'dashicons-lock',
- 85
- );
- }
-
- /**
- * Add Settings submenu at the end (priority 99)
- */
- public function add_settings_submenu() {
- $settings_suffix = add_submenu_page(
- 'passster',
- __( 'Options', 'content-protector' ),
- __( 'Settings', 'content-protector' ),
- apply_filters( 'passster_user_capability', 'manage_options' ),
- 'passster-settings',
- array($this, 'render_settings')
- );
- add_action( "admin_print_scripts-{$settings_suffix}", array($this, 'add_settings_scripts') );
- }
-
- public function add_settings_scripts() {
- $screen = get_current_screen();
- wp_enqueue_script(
- 'passster-settings',
- PASSSTER_URL . '/inc/admin/build/index.js',
- array(
- 'wp-api',
- 'wp-components',
- 'wp-element',
- 'wp-api-fetch',
- 'wp-data',
- 'wp-i18n'
- ),
- PASSSTER_VERSION,
- true
- );
- $options = get_option( 'passster' );
- // Freemius
- $fs_slug = 'content-protector';
- $fs_id = '1938';
- $fs_affix = passster_fs()->get_unique_affix();
- $args = array(
- 'screen' => 'passster-settings',
- 'version' => PASSSTER_VERSION,
- 'logo' => PASSSTER_URL . '/assets/admin/passster-logo.svg',
- 'is_pro' => passster_fs()->is_plan_or_trial__premium_only( 'pro' ),
- 'is_premium_build' => passster_fs()->is_premium(),
- 'account_url' => admin_url( 'admin.php?page=' . $fs_slug . '-account' ),
- 'activation_url' => '#',
- 'upgrade_url' => passster_fs()->get_upgrade_url(),
- 'fs_affix' => $fs_affix,
- );
- // Add Freemius license activation dialog on settings page
- add_action( 'admin_footer', array($this, 'add_license_activation_dialog') );
- if ( isset( $options['global_protection_id'] ) ) {
- $args['global_edit_url'] = admin_url( 'post.php?post=' . esc_html( $options['global_protection_id'] ) . '&action=edit', 'https' );
- }
- wp_localize_script( 'passster-settings', 'options', $args );
- // Make the blocks translatable.
- if ( function_exists( 'wp_set_script_translations' ) ) {
- wp_set_script_translations( 'passster-settings', 'content-protector', PASSSTER_PATH . '/languages' );
- }
- wp_enqueue_style( 'passster-settings-style', PASSSTER_URL . '/inc/admin/build/index.css', array('wp-components') );
- }
-
- public function render_settings() {
- ?>
- <div id="passster-settings"></div>
- <?php
- }
-
- /**
- * Add Freemius license activation dialog to settings page.
- */
- public function add_license_activation_dialog() {
- $fs = passster_fs();
- // On the free build the AJAX handler is not registered by Freemius, so the dialog is useless.
- if ( !$fs->is_premium() ) {
- return;
- }
- $vars = array(
- 'id' => $fs->get_id(),
- );
- fs_require_template( 'forms/license-activation.php', $vars );
- fs_require_template( 'forms/resend-key.php', $vars );
- }
-
- public function rest_api_init() {
- register_rest_route( 'passster/v1', '/settings', array(
- 'methods' => 'GET',
- 'callback' => [$this, 'get_settings'],
- 'permission_callback' => function () {
- return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
- },
- ) );
- register_rest_route( 'passster/v1', '/system-status', array(
- 'methods' => 'GET',
- 'callback' => [$this, 'get_system_status'],
- 'permission_callback' => function () {
- return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
- },
- ) );
- register_rest_route( 'passster/v1', '/settings', array(
- 'methods' => 'POST',
- 'callback' => [$this, 'save_settings'],
- 'permission_callback' => function () {
- return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
- },
- ) );
- register_rest_route( 'passster/v1', '/migrate', array(
- 'methods' => 'POST',
- 'callback' => [$this, 'migrate_settings'],
- 'permission_callback' => function () {
- return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
- },
- ) );
- register_rest_route( 'passster/v1', '/pages', array(
- 'methods' => 'GET',
- 'callback' => [$this, 'get_pages'],
- 'permission_callback' => function () {
- return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
- },
- ) );
- register_rest_route( 'passster/v1', '/excludable-pages', array(
- 'methods' => 'GET',
- 'callback' => [$this, 'get_excludable_pages'],
- 'permission_callback' => function () {
- return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
- },
- ) );
- register_rest_route( 'passster/v1', '/edit-url', array(
- 'methods' => 'GET',
- 'callback' => [$this, 'get_edit_url'],
- 'permission_callback' => function () {
- return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
- },
- ) );
- register_rest_route( 'passster/v1', '/post-title', array(
- 'methods' => 'GET',
- 'callback' => [$this, 'get_post_title'],
- 'permission_callback' => function () {
- return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
- },
- ) );
- register_rest_route( 'passster/v1', '/child-pages', array(
- 'methods' => 'GET',
- 'callback' => [$this, 'get_child_pages'],
- 'permission_callback' => function () {
- return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
- },
- ) );
- }
-
- public function get_settings() {
- return get_option( 'passster' );
- }
-
- public function get_system_status() {
- return array(
- 'PHP' => array(
- 'Version' => phpversion(),
- ),
- 'WordPress' => array(
- 'Permalinks' => strlen( get_option( 'permalink_structure' ) ) !== 0,
- 'SSL' => is_ssl(),
- ),
- );
- }
-
- public function save_settings( $request ) {
- if ( $request->get_params() ) {
- $options = $request->get_params();
- foreach ( $options as $key => $value ) {
- // Allow HTML in instruction field (links, basic formatting)
- if ( 'instruction' === $key ) {
- $options[$key] = wp_kses_post( $value );
- continue;
- }
- // Allow HTML in error message field too
- if ( 'error' === $key ) {
- $options[$key] = wp_kses_post( $value );
- continue;
- }
- // Arrays (like exclude_pages) - sanitize each item
- if ( is_array( $value ) ) {
- $options[$key] = array_map( 'sanitize_text_field', $value );
- continue;
- }
- // Everything else - sanitize as text
- $options[$key] = sanitize_text_field( $value );
- }
- update_option( 'passster', $options );
- }
- return wp_json_encode( [
- "status" => 200,
- "message" => "Ok",
- ] );
- }
-
- public function migrate_settings() {
- PS_Migrator::migrate();
- return wp_json_encode( [
- "status" => 200,
- "message" => "Ok",
- ] );
- }
-
- public function get_pages() {
- $args = array(
- 'post_type' => 'page',
- 'post_status' => 'publish',
- 'numberposts' => -1,
- );
- $pages = get_posts( $args );
- // Build selectable pages array.
- $selectable_pages = array();
- foreach ( $pages as $page ) {
- $selectable_pages[] = array(
- 'label' => $page->post_title,
- 'value' => $page->ID,
- );
- }
- return $selectable_pages;
- }
-
- public function get_excludable_pages() {
- $args = array(
- 'post_type' => 'page',
- 'post_status' => 'publish',
- 'numberposts' => -1,
- );
- $pages = get_posts( $args );
- // Build selectable pages array.
- $selectable_pages = array();
- foreach ( $pages as $page ) {
- $object = new StdClass();
- $object->value = $page->ID;
- $object->label = $page->post_title;
- $selectable_pages[] = $object;
- }
- return $selectable_pages;
- }
-
- public function get_edit_url( $request ) {
- if ( $request->get_params() ) {
- $options = $request->get_params();
- return admin_url( 'post.php?post=' . esc_html( $options['post_id'] ) . '&action=edit', 'https' );
- }
- return wp_json_encode( [
- "status" => 400,
- "message" => "Not found",
- ] );
- }
-
- public function get_post_title( $request ) {
- if ( $request->get_params() ) {
- $options = $request->get_params();
- $post_id = esc_html( $options['post_id'] );
- if ( get_post_status( $post_id ) && 'publish' === get_post_status( $post_id ) ) {
- return get_the_title( $post_id );
- }
- }
- return false;
- }
-
- public function get_child_pages( $request ) {
- if ( $request->get_params() ) {
- $options = $request->get_params();
- $parent_id = esc_html( $options['post_id'] );
- $args = array(
- 'post_type' => 'page',
- 'post_status' => 'publish',
- 'numberposts' => -1,
- );
- $pages = get_posts( $args );
- $childs = get_page_children( $parent_id, $pages );
- $child_ids = array();
- foreach ( $childs as $child ) {
- $child_ids[] = $child->ID;
- }
- return $child_ids;
- }
- return wp_json_encode( [
- "status" => 400,
- "message" => "Not found",
- ] );
- }
-
-}
+<?php
+
+namespace passster;
+
+class PS_Admin_Settings {
+ /**
+ * Contains instance or null
+ *
+ * @var object|null
+ */
+ private static $instance = null;
+
+ /**
+ * Returns instance of PS_Admin_Settings.
+ *
+ * @return object
+ */
+ public static function get_instance() {
+ if ( null === self::$instance ) {
+ self::$instance = new self();
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Setting up admin fields
+ *
+ * @return void
+ */
+ public function __construct() {
+ add_action( 'admin_menu', array($this, 'add_menu') );
+ add_action( 'admin_menu', array($this, 'add_settings_submenu'), 99 );
+ // Add Settings last
+ add_action( 'rest_api_init', array($this, 'rest_api_init') );
+ }
+
+ public function add_menu() {
+ add_menu_page(
+ __( 'Passster', 'content-protector' ),
+ 'Passster',
+ apply_filters( 'passster_user_capability', 'manage_options' ),
+ 'passster',
+ array($this, 'render_settings'),
+ 'dashicons-lock',
+ 85
+ );
+ }
+
+ /**
+ * Add Settings submenu at the end (priority 99)
+ */
+ public function add_settings_submenu() {
+ $settings_suffix = add_submenu_page(
+ 'passster',
+ __( 'Options', 'content-protector' ),
+ __( 'Settings', 'content-protector' ),
+ apply_filters( 'passster_user_capability', 'manage_options' ),
+ 'passster-settings',
+ array($this, 'render_settings')
+ );
+ add_action( "admin_print_scripts-{$settings_suffix}", array($this, 'add_settings_scripts') );
+ }
+
+ public function add_settings_scripts() {
+ $screen = get_current_screen();
+ wp_enqueue_script(
+ 'passster-settings',
+ PASSSTER_URL . '/inc/admin/build/index.js',
+ array(
+ 'wp-api',
+ 'wp-components',
+ 'wp-element',
+ 'wp-api-fetch',
+ 'wp-data',
+ 'wp-i18n'
+ ),
+ PASSSTER_VERSION,
+ true
+ );
+ $options = get_option( 'passster' );
+ // Freemius
+ $fs_slug = 'content-protector';
+ $fs_id = '1938';
+ $fs_affix = passster_fs()->get_unique_affix();
+ $args = array(
+ 'screen' => 'passster-settings',
+ 'version' => PASSSTER_VERSION,
+ 'logo' => PASSSTER_URL . '/assets/admin/passster-logo.svg',
+ 'is_pro' => passster_fs()->is_plan_or_trial__premium_only( 'pro' ),
+ 'is_premium_build' => passster_fs()->is_premium(),
+ 'account_url' => admin_url( 'admin.php?page=' . $fs_slug . '-account' ),
+ 'activation_url' => '#',
+ 'upgrade_url' => passster_fs()->get_upgrade_url(),
+ 'fs_affix' => $fs_affix,
+ );
+ // Add Freemius license activation dialog on settings page
+ add_action( 'admin_footer', array($this, 'add_license_activation_dialog') );
+ if ( isset( $options['global_protection_id'] ) ) {
+ $args['global_edit_url'] = admin_url( 'post.php?post=' . esc_html( $options['global_protection_id'] ) . '&action=edit', 'https' );
+ }
+ wp_localize_script( 'passster-settings', 'options', $args );
+ // Make the blocks translatable.
+ if ( function_exists( 'wp_set_script_translations' ) ) {
+ wp_set_script_translations( 'passster-settings', 'content-protector', PASSSTER_PATH . '/languages' );
+ }
+ wp_enqueue_style( 'passster-settings-style', PASSSTER_URL . '/inc/admin/build/index.css', array('wp-components') );
+ }
+
+ public function render_settings() {
+ ?>
+ <div id="passster-settings"></div>
+ <?php
+ }
+
+ /**
+ * Add Freemius license activation dialog to settings page.
+ */
+ public function add_license_activation_dialog() {
+ $fs = passster_fs();
+ // On the free build the AJAX handler is not registered by Freemius, so the dialog is useless.
+ if ( !$fs->is_premium() ) {
+ return;
+ }
+ $vars = array(
+ 'id' => $fs->get_id(),
+ );
+ fs_require_template( 'forms/license-activation.php', $vars );
+ fs_require_template( 'forms/resend-key.php', $vars );
+ }
+
+ public function rest_api_init() {
+ register_rest_route( 'passster/v1', '/settings', array(
+ 'methods' => 'GET',
+ 'callback' => [$this, 'get_settings'],
+ 'permission_callback' => function () {
+ return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
+ },
+ ) );
+ register_rest_route( 'passster/v1', '/system-status', array(
+ 'methods' => 'GET',
+ 'callback' => [$this, 'get_system_status'],
+ 'permission_callback' => function () {
+ return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
+ },
+ ) );
+ register_rest_route( 'passster/v1', '/settings', array(
+ 'methods' => 'POST',
+ 'callback' => [$this, 'save_settings'],
+ 'permission_callback' => function () {
+ return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
+ },
+ ) );
+ register_rest_route( 'passster/v1', '/migrate', array(
+ 'methods' => 'POST',
+ 'callback' => [$this, 'migrate_settings'],
+ 'permission_callback' => function () {
+ return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
+ },
+ ) );
+ register_rest_route( 'passster/v1', '/pages', array(
+ 'methods' => 'GET',
+ 'callback' => [$this, 'get_pages'],
+ 'permission_callback' => function () {
+ return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
+ },
+ ) );
+ register_rest_route( 'passster/v1', '/excludable-pages', array(
+ 'methods' => 'GET',
+ 'callback' => [$this, 'get_excludable_pages'],
+ 'permission_callback' => function () {
+ return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
+ },
+ ) );
+ register_rest_route( 'passster/v1', '/edit-url', array(
+ 'methods' => 'GET',
+ 'callback' => [$this, 'get_edit_url'],
+ 'permission_callback' => function () {
+ return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
+ },
+ ) );
+ register_rest_route( 'passster/v1', '/post-title', array(
+ 'methods' => 'GET',
+ 'callback' => [$this, 'get_post_title'],
+ 'permission_callback' => function () {
+ return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
+ },
+ ) );
+ register_rest_route( 'passster/v1', '/child-pages', array(
+ 'methods' => 'GET',
+ 'callback' => [$this, 'get_child_pages'],
+ 'permission_callback' => function () {
+ return current_user_can( apply_filters( 'passster_user_capability', 'manage_options' ) );
+ },
+ ) );
+ }
+
+ public function get_settings() {
+ return get_option( 'passster' );
+ }
+
+ public function get_system_status() {
+ return array(
+ 'PHP' => array(
+ 'Version' => phpversion(),
+ ),
+ 'WordPress' => array(
+ 'Permalinks' => strlen( get_option( 'permalink_structure' ) ) !== 0,
+ 'SSL' => is_ssl(),
+ ),
+ );
+ }
+
+ public function save_settings( $request ) {
+ if ( $request->get_params() ) {
+ $options = $request->get_params();
+ foreach ( $options as $key => $value ) {
+ // Allow HTML in instruction field (links, basic formatting)
+ if ( 'instruction' === $key ) {
+ $options[$key] = wp_kses_post( $value );
+ continue;
+ }
+ // Allow HTML in error message field too
+ if ( 'error' === $key ) {
+ $options[$key] = wp_kses_post( $value );
+ continue;
+ }
+ // Arrays (like exclude_pages) - sanitize each item
+ if ( is_array( $value ) ) {
+ $options[$key] = array_map( 'sanitize_text_field', $value );
+ continue;
+ }
+ // Everything else - sanitize as text
+ $options[$key] = sanitize_text_field( $value );
+ }
+ update_option( 'passster', $options );
+ }
+ return wp_json_encode( [
+ "status" => 200,
+ "message" => "Ok",
+ ] );
+ }
+
+ public function migrate_settings() {
+ PS_Migrator::migrate();
+ return wp_json_encode( [
+ "status" => 200,
+ "message" => "Ok",
+ ] );
+ }
+
+ public function get_pages() {
+ $args = array(
+ 'post_type' => 'page',
+ 'post_status' => 'publish',
+ 'numberposts' => -1,
+ );
+ $pages = get_posts( $args );
+ // Build selectable pages array.
+ $selectable_pages = array();
+ foreach ( $pages as $page ) {
+ $selectable_pages[] = array(
+ 'label' => $page->post_title,
+ 'value' => $page->ID,
+ );
+ }
+ return $selectable_pages;
+ }
+
+ public function get_excludable_pages() {
+ $args = array(
+ 'post_type' => 'page',
+ 'post_status' => 'publish',
+ 'numberposts' => -1,
+ );
+ $pages = get_posts( $args );
+ // Build selectable pages array.
+ $selectable_pages = array();
+ foreach ( $pages as $page ) {
+ $object = new StdClass();
+ $object->value = $page->ID;
+ $object->label = $page->post_title;
+ $selectable_pages[] = $object;
+ }
+ return $selectable_pages;
+ }
+
+ public function get_edit_url( $request ) {
+ if ( $request->get_params() ) {
+ $options = $request->get_params();
+ return admin_url( 'post.php?post=' . esc_html( $options['post_id'] ) . '&action=edit', 'https' );
+ }
+ return wp_json_encode( [
+ "status" => 400,
+ "message" => "Not found",
+ ] );
+ }
+
+ public function get_post_title( $request ) {
+ if ( $request->get_params() ) {
+ $options = $request->get_params();
+ $post_id = esc_html( $options['post_id'] );
+ if ( get_post_status( $post_id ) && 'publish' === get_post_status( $post_id ) ) {
+ return get_the_title( $post_id );
+ }
+ }
+ return false;
+ }
+
+ public function get_child_pages( $request ) {
+ if ( $request->get_params() ) {
+ $options = $request->get_params();
+ $parent_id = esc_html( $options['post_id'] );
+ $args = array(
+ 'post_type' => 'page',
+ 'post_status' => 'publish',
+ 'numberposts' => -1,
+ );
+ $pages = get_posts( $args );
+ $childs = get_page_children( $parent_id, $pages );
+ $child_ids = array();
+ foreach ( $childs as $child ) {
+ $child_ids[] = $child->ID;
+ }
+ return $child_ids;
+ }
+ return wp_json_encode( [
+ "status" => 400,
+ "message" => "Not found",
+ ] );
+ }
+
+}
--- a/content-protector/inc/admin/inc/class-ps-admin.php
+++ b/content-protector/inc/admin/inc/class-ps-admin.php
@@ -1,945 +1,945 @@
-<?php
-
-namespace passster;
-
-class PS_Admin {
- /**
- * Contains instance or null
- *
- * @var object|null
- */
- private static $instance = null;
-
- /**
- * Returns instance of PS_Admin.
- *
- * @return object
- */
- public static function get_instance() {
- if ( null === self::$instance ) {
- self::$instance = new self();
- }
- return self::$instance;
- }
-
- public function __construct() {
- // Check permissions before include settings.
- add_action( 'admin_menu', array($this, 'remove_custom_fields_metabox') );
- add_action( 'init', array($this, 'register_password_areas') );
- add_filter( 'manage_protected_areas_posts_columns', array($this, 'set_area_columns') );
- // Register columns for all public post types (post, page, and custom).
- add_action( 'init', array($this, 'register_post_type_columns'), 99 );
- add_action(
- 'manage_protected_areas_posts_custom_column',
- array($this, 'set_area_columns_content'),
- 10,
- 2
- );
- // Modify row actions and edit links for block-sourced areas.
- add_filter(
- 'post_row_actions',
- array($this, 'modify_area_row_actions'),
- 10,
- 2
- );
- add_filter(
- 'get_edit_post_link',
- array($this, 'modify_area_edit_link'),
- 10,
- 3
- );
- // Quick edit AJAX handler.
- add_action( 'wp_ajax_passster_quick_edit_area', array($this, 'ajax_quick_edit_area') );
- // Quick edit UI assets.
- add_action( 'admin_footer-edit.php', array($this, 'quick_edit_ui') );
- // Generate shortcode meta on every save so it appears in the list table.
- add_action(
- 'save_post_protected_areas',
- array($this, 'save_area_shortcode'),
- 20,
- 1
- );
- }
-
- /**
- * Register Password column for all public post types.
- *
- * @return void
- */
- public function register_post_type_columns() {
- $post_types = get_post_types( array(
- 'public' => true,
- ), 'names' );
- foreach ( $post_types as $post_type ) {
- if ( 'attachment' === $post_type || 'protected_areas' === $post_type ) {
- continue;
- }
- add_filter( "manage_{$post_type}_posts_columns", array($this, 'set_post_columns') );
- add_action(
- "manage_{$post_type}_posts_custom_column",
- array($this, 'set_post_columns_content'),
- 10,
- 2
- );
- }
- }
-
- /**
- * Remove Custom Fields meta box
- */
- public function remove_custom_fields_metabox() {
- $post_types = get_post_types( array(
- 'public' => true,
- 'exclude_from_search' => false,
- ), 'names' );
- remove_meta_box( 'postcustom', $post_types, 'normal' );
- }
-
- /**
- * Generate and save shortcode meta on post save so it appears in the list table.
- *
- * @param int $post_id Post ID.
- */
- public function save_area_shortcode( $post_id ) {
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
- return;
- }
- if ( wp_is_post_revision( $post_id ) ) {
- return;
- }
- $source = get_post_meta( $post_id, '_passster_source', true );
- if ( 'block' === $source ) {
- return;
- }
- $protection_type = get_post_meta( $post_id, 'passster_protection_type', true );
- $password = get_post_meta( $post_id, 'passster_password', true );
- $passwords = get_post_meta( $post_id, 'passster_passwords', true );
- $password_list = get_post_meta( $post_id, 'passster_password_list', true );
- $shortcode = '';
- switch ( $protection_type ) {
- case 'passwords':
- if ( !empty( $passwords ) ) {
- $shortcode = '[passster passwords="' . esc_attr( $passwords ) . '" area="' . $post_id . '"]';
- }
- break;
- case 'password_list':
- if ( !empty( $password_list ) ) {
- $shortcode = '[passster password_list="' . esc_attr( $password_list ) . '" area="' . $post_id . '"]';
- }
- break;
- case 'recaptcha':
- $shortcode = '[passster recaptcha="true" area="' . $post_id . '"]';
- break;
- case 'turnstile':
- $shortcode = '[passster turnstile="true" area="' . $post_id . '"]';
- break;
- default:
- if ( !empty( $password ) ) {
- $shortcode = '[passster password="' . esc_attr( $password ) . '" area="' . $post_id . '"]';
- }
- break;
- }
- if ( !empty( $shortcode ) ) {
- update_post_meta( $post_id, 'passster_area_shortcode', $shortcode );
- }
- }
-
- /**
- * Register post type "protected areas"
- *
- * @return void
- */
- public function register_password_areas() {
- $labels = array(
- 'name' => _x( 'Protected Areas', 'post type general name', 'content-protector' ),
- 'singular_name' => _x( 'Protected Area', 'post type singular name', 'content-protector' ),
- 'menu_name' => _x( 'Protected Areas', 'admin menu', 'content-protector' ),
- 'name_admin_bar' => _x( 'Protected Area', 'add new on admin bar', 'content-protector' ),
- 'add_new' => _x( 'Add New', 'content-protector' ),
- 'add_new_item' => __( 'Add New Protected Area', 'content-protector' ),
- 'new_item' => __( 'New Protected Area', 'content-protector' ),
- 'edit_item' => __( 'Edit Protected Area', 'content-protector' ),
- 'view_item' => __( 'View Protected Area', 'content-protector' ),
- 'all_items' => __( 'Protected Areas', 'content-protector' ),
- 'search_items' => __( 'Search Protected Areas', 'content-protector' ),
- 'parent_item_colon' => __( 'Parent Protected Area', 'content-protector' ),
- 'not_found' => __( 'No Protected Areas found.', 'content-protector' ),
- 'not_found_in_trash' => __( 'No Protected Areas found in Trash.', 'content-protector' ),
- );
- $args = array(
- 'labels' => $labels,
- 'description' => __( 'Manageable protected areas', 'content-protector' ),
- 'public' => false,
- 'publicly_queryable' => false,
- 'show_ui' => true,
- 'show_