Restricted Site Access - Version 7.0.1

Version Description

  • Bug fix: Avoid redirect loop when the unrestricted page is set to be the static front page.
  • Bug fix: Fall back to the login screen if the unrestricted page is no longer published.
Download this release

Release Info

Developer helen
Plugin Icon 128x128 Restricted Site Access
Version 7.0.1
Comparing to
See all releases

Code changes from version 7.0.0 to 7.0.1

Files changed (2) hide show
  1. readme.txt +4 -0
  2. restricted_site_access.php +15 -9
readme.txt CHANGED
@@ -108,6 +108,10 @@ define( 'RSA_IP_WHITELIST', '192.0.0.1|192.0.0.10' );
108
 
109
  == Changelog ==
110
 
 
 
 
 
111
  = 7.0.0 =
112
  * Feature: WP-CLI support! 🎉 Try `wp rsa` to get started.
113
  * Feature: Whitelist IPs via the `RSA_IP_WHITELIST` constant.
108
 
109
  == Changelog ==
110
 
111
+ = 7.0.1 =
112
+ * Bug fix: Avoid redirect loop when the unrestricted page is set to be the static front page.
113
+ * Bug fix: Fall back to the login screen if the unrestricted page is no longer published.
114
+
115
  = 7.0.0 =
116
  * Feature: WP-CLI support! 🎉 Try `wp rsa` to get started.
117
  * Feature: Whitelist IPs via the `RSA_IP_WHITELIST` constant.
restricted_site_access.php CHANGED
@@ -3,14 +3,14 @@
3
  * Plugin Name: Restricted Site Access
4
  * Plugin URI: http://10up.com/plugins/restricted-site-access-wordpress/
5
  * Description: <strong>Limit access your site</strong> to visitors who are logged in or accessing the site from a set of specific IP addresses. Send restricted visitors to the log in page, redirect them, or display a message or page. <strong>Powerful control over redirection</strong>, including <strong>SEO friendly redirect headers</strong>. Great solution for Extranets, publicly hosted Intranets, or parallel development sites.
6
- * Version: 7.0.0
7
  * Author: Jake Goldman, 10up, Oomph
8
  * Author URI: http://10up.com
9
  * License: GPLv2 or later
10
  * Text Domain: restricted-site-access
11
  */
12
 
13
- define( 'RSA_VERSION', '7.0.0' );
14
 
15
  class Restricted_Site_Access {
16
 
@@ -302,20 +302,26 @@ class Restricted_Site_Access {
302
  if ( ! empty( self::$rsa_options['page'] ) ) {
303
  $page = get_post( self::$rsa_options['page'] );
304
 
305
- // If the selected page isn't found, fall back to default values.
306
- if ( ! $page ) {
307
  self::$rsa_options['head_code'] = 302;
308
  $current_path = empty( $_SERVER['REQUEST_URI'] ) ? home_url() : $_SERVER['REQUEST_URI'];
309
  self::$rsa_options['redirect_url'] = wp_login_url( $current_path );
 
310
  }
311
 
312
- // Prevents infinite loops.
313
- if ( ! isset( $wp->query_vars['pagename'] ) || $wp->query_vars['pagename'] !== $page->post_name ) {
314
- self::$rsa_options['redirect_url'] = get_permalink( $page->ID );
315
- break;
316
- } else {
 
 
317
  return;
318
  }
 
 
 
319
  }
320
 
321
  case 3:
3
  * Plugin Name: Restricted Site Access
4
  * Plugin URI: http://10up.com/plugins/restricted-site-access-wordpress/
5
  * Description: <strong>Limit access your site</strong> to visitors who are logged in or accessing the site from a set of specific IP addresses. Send restricted visitors to the log in page, redirect them, or display a message or page. <strong>Powerful control over redirection</strong>, including <strong>SEO friendly redirect headers</strong>. Great solution for Extranets, publicly hosted Intranets, or parallel development sites.
6
+ * Version: 7.0.1
7
  * Author: Jake Goldman, 10up, Oomph
8
  * Author URI: http://10up.com
9
  * License: GPLv2 or later
10
  * Text Domain: restricted-site-access
11
  */
12
 
13
+ define( 'RSA_VERSION', '7.0.1' );
14
 
15
  class Restricted_Site_Access {
16
 
302
  if ( ! empty( self::$rsa_options['page'] ) ) {
303
  $page = get_post( self::$rsa_options['page'] );
304
 
305
+ // If the selected page isn't found or isn't published, fall back to default values.
306
+ if ( ! $page || 'publish' !== $page->post_status ) {
307
  self::$rsa_options['head_code'] = 302;
308
  $current_path = empty( $_SERVER['REQUEST_URI'] ) ? home_url() : $_SERVER['REQUEST_URI'];
309
  self::$rsa_options['redirect_url'] = wp_login_url( $current_path );
310
+ break;
311
  }
312
 
313
+ // Are we already on the selected page?
314
+ // There's a separate unpleasant conditional to match the page on front because of the way query vars are (not) filled at this point
315
+ if (
316
+ ( isset( $wp->query_vars['pagename'] ) && $wp->query_vars['pagename'] === $page->post_name )
317
+ ||
318
+ ( empty ( $wp->query_vars ) && 'page' === get_option( 'show_on_front' ) && (int) self::$rsa_options['page'] === (int) get_option( 'page_on_front' ) )
319
+ ) {
320
  return;
321
  }
322
+
323
+ self::$rsa_options['redirect_url'] = get_permalink( $page->ID );
324
+ break;
325
  }
326
 
327
  case 3: