Changeset 3470679
- Timestamp:
- 02/26/2026 08:52:54 PM (4 weeks ago)
- Location:
- simple-page-access-restriction/trunk
- Files:
-
- 10 added
- 7 edited
-
changelog.txt (modified) (1 diff)
-
includes/admin/admin.php (modified) (2 diffs)
-
includes/admin/settings/settings.php (modified) (2 diffs)
-
includes/class-redirection.php (modified) (2 diffs)
-
includes/functions.php (modified) (1 diff)
-
includes/restrictions (added)
-
includes/restrictions/archive.php (added)
-
includes/restrictions/authors.php (added)
-
includes/restrictions/functions.php (added)
-
includes/restrictions/other.php (added)
-
includes/restrictions/posts.php (added)
-
includes/restrictions/seo.php (added)
-
includes/restrictions/singular.php (added)
-
includes/restrictions/terms.php (added)
-
includes/restrictions/users.php (added)
-
readme.txt (modified) (2 diffs)
-
simple-page-access-restriction.php (modified) (8 diffs)
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 1 6 = Version 1.0.34 - January 15, 2026 = 2 7 * Fix: Restriction of standard post taxonomies -
simple-page-access-restriction/trunk/includes/admin/admin.php
r3349084 r3470679 1 1 <?php 2 3 use function PS_Simple_Page_Access_Restriction\Restrictions\is_post_restricted; 2 4 3 5 // Exit if accessed directly … … 86 88 echo 87 89 '<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' : '' ) . ' /> 89 91 <span>' . __( 'For Logged-In Users Only', 'simple-page-access-restriction' ) . '</span> 90 92 </label>'; -
simple-page-access-restriction/trunk/includes/admin/settings/settings.php
r3300680 r3470679 7 7 */ 8 8 9 use function PS_Simple_Page_Access_Restriction\Restrictions\is_post_restricted; 10 9 11 // Exit if accessed directly 10 12 if ( ! defined( 'ABSPATH' ) ) { … … 57 59 */ 58 60 59 if ( ps_simple_par_is_page_restricted( $setting_login_page ) ) {61 if ( is_post_restricted( $setting_login_page ) ) { 60 62 $message = __( 'The page you selected is itself login protected. Please select a page which is unrestricted for guest visitors.', 'simple-page-access-restriction' ); 61 63 -
simple-page-access-restriction/trunk/includes/class-redirection.php
r3030099 r3470679 7 7 8 8 namespace Simple_Page_Access_Restriction\Classes; 9 10 use function PS_Simple_Page_Access_Restriction\Restrictions\is_post_restricted; 9 11 10 12 // Exit if accessed directly. … … 125 127 126 128 // Check if the post is not restricted. 127 if ( ! ps_simple_par_is_page_restricted( $post_id ) ) {129 if ( ! is_post_restricted( $post_id ) ) { 128 130 return; 129 131 } -
simple-page-access-restriction/trunk/includes/functions.php
r3105724 r3470679 153 153 } 154 154 155 if ( ! function_exists( 'ps_simple_par_is_page_restricted' ) ) {156 /**157 * Helper function for returning an array of saved settings158 *159 * @return array160 */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 166 155 if ( ! function_exists( 'ps_simple_par_is_new_post_restricted' ) ) { 167 156 /** -
simple-page-access-restriction/trunk/readme.txt
r3440442 r3470679 8 8 Tested up to: 6.9 9 9 Requires PHP: 5.6 10 Stable Tag: 1.0.3 410 Stable Tag: 1.0.35 11 11 License: GPL v2 or later 12 12 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 116 116 117 117 == 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 118 123 = Version 1.0.34 - January 15, 2026 = 119 124 * Fix: Restriction of standard post taxonomies -
simple-page-access-restriction/trunk/simple-page-access-restriction.php
r3440442 r3470679 4 4 * Plugin URI: https://www.pluginsandsnippets.com/downloads/simple-page-access-restriction/ 5 5 * 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.3 46 * Version: 1.0.35 7 7 * Author: Plugins & Snippets 8 8 * Author URI: https://www.pluginsandsnippets.com/ … … 10 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 11 * Text Domain: simple-page-access-restriction 12 * Requires at least: 3.913 * Tested up to: 6. 812 * Requires at least: 4.4 13 * Tested up to: 6.9 14 14 * 15 15 * @package Simple_Page_Access_Restriction … … 18 18 * 19 19 */ 20 21 use function PS_Simple_Page_Access_Restriction\Restrictions\handle_request; 22 use function PS_Simple_Page_Access_Restriction\Restrictions\is_current_user_allowed; 23 use function PS_Simple_Page_Access_Restriction\Restrictions\is_post_restricted; 24 use function PS_Simple_Page_Access_Restriction\Restrictions\send_headers; 20 25 21 26 // Exit if accessed directly … … 116 121 require_once SIMPLE_PAGE_ACCESS_RESTRICTION_DIR . 'includes/functions.php'; 117 122 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'; 118 133 } 119 134 … … 129 144 add_action( 'init', array( $this, 'add_rest_api_filters' ) ); 130 145 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 ); 132 148 } 133 149 … … 188 204 189 205 /** 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 * 194 216 * @access public 195 217 * @since 1.0.0 196 218 * @return void 197 219 */ 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(); 241 223 } 242 224 … … 245 227 */ 246 228 public function add_rest_api_filters() { 247 // Check if the re 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() ) { 249 231 return; 250 232 } … … 307 289 public function filter_rest_response( $response, $post ) { 308 290 // Check the post. 309 if ( ps_simple_par_is_page_restricted( $post->ID ) ) {291 if ( is_post_restricted( $post->ID ) ) { 310 292 // Set the response. 311 293 $response = new WP_REST_Response( null, 403 );
Note: See TracChangeset
for help on using the changeset viewer.