Plugin Directory

Changeset 3470679


Ignore:
Timestamp:
02/26/2026 08:52:54 PM (4 weeks ago)
Author:
pluginsandsnippets
Message:

trunk 1.0.35

Location:
simple-page-access-restriction/trunk
Files:
10 added
7 edited

Legend:

Unmodified
Added
Removed
  • simple-page-access-restriction/trunk/changelog.txt

    r3440442 r3470679  
     1= Version 1.0.35 - February 17 2026 =
     2* Fix: Refactor restriction functions
     3* New: Add noindex and nofollow directives
     4* Test: WordPress version 6.9
     5
    16= Version 1.0.34 - January 15, 2026 =
    27* Fix: Restriction of standard post taxonomies
  • simple-page-access-restriction/trunk/includes/admin/admin.php

    r3349084 r3470679  
    11<?php
     2
     3use function PS_Simple_Page_Access_Restriction\Restrictions\is_post_restricted;
    24
    35// Exit if accessed directly
     
    8688            echo
    8789                '<label ' . ( $is_same_as_login_redirect ? 'style="opacity:0.5;"' : '' ) . '>
    88                     <input type="checkbox" name="_page_access_restricted" value="1" ' . ( $is_same_as_login_redirect ? 'disabled' : '' ) . ' ' . ( ps_simple_par_is_page_restricted( $post->ID ) || $is_new_and_restricted ? 'checked' : '' ) . ' />
     90                    <input type="checkbox" name="_page_access_restricted" value="1" ' . ( $is_same_as_login_redirect ? 'disabled' : '' ) . ' ' . ( is_post_restricted( $post->ID ) || $is_new_and_restricted ? 'checked' : '' ) . ' />
    8991                    <span>' . __( 'For Logged-In Users Only', 'simple-page-access-restriction' ) . '</span>
    9092                </label>';
  • simple-page-access-restriction/trunk/includes/admin/settings/settings.php

    r3300680 r3470679  
    77 */
    88
     9use function PS_Simple_Page_Access_Restriction\Restrictions\is_post_restricted;
     10
    911// Exit if accessed directly
    1012if ( ! defined( 'ABSPATH' ) ) {
     
    5759    */
    5860
    59     if ( ps_simple_par_is_page_restricted( $setting_login_page ) ) {
     61    if ( is_post_restricted( $setting_login_page ) ) {
    6062        $message = __( 'The page you selected is itself login protected. Please select a page which is unrestricted for guest visitors.', 'simple-page-access-restriction' );
    6163
  • simple-page-access-restriction/trunk/includes/class-redirection.php

    r3030099 r3470679  
    77
    88namespace Simple_Page_Access_Restriction\Classes;
     9
     10use function PS_Simple_Page_Access_Restriction\Restrictions\is_post_restricted;
    911
    1012// Exit if accessed directly.
     
    125127
    126128        // Check if the post is not restricted.
    127         if ( ! ps_simple_par_is_page_restricted( $post_id ) ) {
     129        if ( ! is_post_restricted( $post_id ) ) {
    128130            return;
    129131        }
  • simple-page-access-restriction/trunk/includes/functions.php

    r3105724 r3470679  
    153153}
    154154
    155 if ( ! function_exists( 'ps_simple_par_is_page_restricted' ) ) {
    156     /**
    157      * Helper function for returning an array of saved settings
    158      *
    159      * @return array
    160      */
    161     function ps_simple_par_is_page_restricted( $page_id ) {
    162         return 1 === intval( get_post_meta( $page_id, 'page_access_restricted', true ) );
    163     }
    164 }
    165 
    166155if ( ! function_exists( 'ps_simple_par_is_new_post_restricted' ) ) {
    167156    /**
  • simple-page-access-restriction/trunk/readme.txt

    r3440442 r3470679  
    88Tested up to: 6.9
    99Requires PHP: 5.6
    10 Stable Tag: 1.0.34
     10Stable Tag: 1.0.35
    1111License: GPL v2 or later
    1212License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    116116
    117117== Changelog ==
     118= Version 1.0.35 - February 17 2026 =
     119* Fix: Refactor restriction functions
     120* New: Add noindex and nofollow directives
     121* Test: WordPress version 6.9
     122
    118123= Version 1.0.34 - January 15, 2026 =
    119124* Fix: Restriction of standard post taxonomies
  • simple-page-access-restriction/trunk/simple-page-access-restriction.php

    r3440442 r3470679  
    44 * Plugin URI:        https://www.pluginsandsnippets.com/downloads/simple-page-access-restriction/
    55 * Description:       This plugin offers a simple way to restrict visits to select pages only to logged-in users and allows for page redirection to a defined (login) page of your choice.
    6  * Version:           1.0.34
     6 * Version:           1.0.35
    77 * Author:            Plugins & Snippets
    88 * Author URI:        https://www.pluginsandsnippets.com/
     
    1010 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
    1111 * Text Domain:       simple-page-access-restriction
    12  * Requires at least: 3.9
    13  * Tested up to:      6.8
     12 * Requires at least: 4.4
     13 * Tested up to:      6.9
    1414 *
    1515 * @package           Simple_Page_Access_Restriction
     
    1818 *
    1919 */
     20
     21use function PS_Simple_Page_Access_Restriction\Restrictions\handle_request;
     22use function PS_Simple_Page_Access_Restriction\Restrictions\is_current_user_allowed;
     23use function PS_Simple_Page_Access_Restriction\Restrictions\is_post_restricted;
     24use function PS_Simple_Page_Access_Restriction\Restrictions\send_headers;
    2025
    2126// Exit if accessed directly
     
    116121            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/functions.php';
    117122            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/class-redirection.php';
     123
     124            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/restrictions/users.php';
     125            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/restrictions/functions.php';
     126            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/restrictions/posts.php';
     127            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/restrictions/terms.php';
     128            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/restrictions/authors.php';
     129            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/restrictions/singular.php';
     130            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/restrictions/archive.php';
     131            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/restrictions/other.php';
     132            require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/restrictions/seo.php';
    118133        }
    119134
     
    129144            add_action( 'init', array( $this, 'add_rest_api_filters' ) );
    130145            add_filter( 'pre_get_posts', array( $this, 'exclude_restricted_posts' ) );
    131             add_action( 'template_redirect', array( $this, 'check_page_access' ), 1 );
     146            add_action( 'send_headers', array( $this, 'on_send_headers' ) );
     147            add_action( 'template_redirect', array( $this, 'on_template_redirect' ), 1 );
    132148        }
    133149
     
    188204
    189205        /**
    190          * Checks if current request is for a restricted page
    191          * If Yes, and Current User is not logged in then redirects
    192          * user to configured Login Page or to Homepage (if not cofigured)
    193          *
     206         * Run on send_headers.
     207         */
     208        public function on_send_headers() {
     209            // Send the headers.
     210            send_headers();
     211        }
     212
     213        /**
     214         * Run on template redirect.
     215         *
    194216         * @access      public
    195217         * @since       1.0.0
    196218         * @return      void
    197219         */
    198         public function check_page_access() {
    199             $settings = ps_simple_par_get_settings();
    200 
    201             if (
    202                 ! is_user_logged_in() &&
    203                 (
    204                     ( ( is_page() || is_singular() ) && ps_simple_par_is_page_restricted( get_queried_object_id() ) ) ||
    205                     ( function_exists( 'is_shop' ) && is_shop() && ps_simple_par_is_page_restricted( get_option( 'woocommerce_shop_page_id' ) ) ) ||
    206                     ( is_array( $settings['taxonomies'] ) && ! empty( $settings['taxonomies'] ) && (
    207                     is_tax( $settings['taxonomies'] ) ||
    208                     ( in_array( 'category', $settings['taxonomies'], true ) && is_category() ) ||
    209                     ( in_array( 'post_tag', $settings['taxonomies'], true ) && is_tag() )
    210                 ) )
    211                 )
    212             ) {
    213                
    214                 $redirect_url = '';
    215                 if ( 'url' === $settings['redirect_type'] && ! empty( $settings['redirect_url'] ) ) {
    216                     $redirect_url = $settings['redirect_url'];
    217                 } elseif ( 'page' === $settings['redirect_type'] && ! empty( $settings['login_page'] ) && ! ps_simple_par_is_page_restricted( $settings['login_page'] ) ) {
    218                     $redirect_url = get_permalink( $settings['login_page'] );
    219                 }
    220 
    221                 if ( empty( $redirect_url ) ) {
    222                     $redirect_url = home_url( '/' );
    223                 }
    224 
    225                 if ( ! empty( $settings['redirect_parameter'] ) ) {
    226                     // Remove unintentional '?' from the parameter name.
    227                     $settings['redirect_parameter'] = str_replace( '?', '', $settings['redirect_parameter'] );
    228                    
    229                     $redirect_url = add_query_arg( $settings['redirect_parameter'], urlencode( home_url() . $_SERVER['REQUEST_URI'] ), $redirect_url );
    230                 }
    231 
    232                 // Checks if headers have been sent.
    233                 if ( ! headers_sent() ) {
    234                     // Set headers to prevent caching.
    235                     nocache_headers();
    236                 }
    237 
    238                 wp_redirect( apply_filters( 'ps_simple_par_redirect_url', $redirect_url ) );
    239                 exit;
    240             }
     220        public function on_template_redirect() {
     221            // Handle the request.
     222            handle_request();
    241223        }
    242224
     
    245227         */
    246228        public function add_rest_api_filters() {
    247             // Check if there is a logged-in user.
    248             if ( is_user_logged_in() ) {
     229            // Check if the current user is allowed.
     230            if ( is_current_user_allowed() ) {
    249231                return;
    250232            }
     
    307289        public function filter_rest_response( $response, $post ) {
    308290            // Check the post.
    309             if ( ps_simple_par_is_page_restricted( $post->ID ) ) {
     291            if ( is_post_restricted( $post->ID ) ) {
    310292                // Set the response.
    311293                $response = new WP_REST_Response( null, 403 );
Note: See TracChangeset for help on using the changeset viewer.