Restricted Site Access - Version 6.0.1

Version Description

  • When plugin is network activated, don't touch individual blog visiblity settings.
  • When plugin is network deactivated, set all individual blogs to default visibility.
Download this release

Release Info

Developer tlovett1
Plugin Icon 128x128 Restricted Site Access
Version 6.0.1
Comparing to
See all releases

Code changes from version 6.0 to 6.0.1

Files changed (2) hide show
  1. readme.txt +4 -0
  2. restricted_site_access.php +26 -10
readme.txt CHANGED
@@ -73,6 +73,10 @@ Page caching plugins often hook into WordPress to quickly serve the last cached
73
 
74
  == Changelog ==
75
 
 
 
 
 
76
  = 6.0 =
77
  * Use Grunt to manage assets.
78
  * Network settings added for management of entire network visibility settings.
73
 
74
  == Changelog ==
75
 
76
+ = 6.0.1 =
77
+ * When plugin is network activated, don't touch individual blog visiblity settings.
78
+ * When plugin is network deactivated, set all individual blogs to default visibility.
79
+
80
  = 6.0 =
81
  * Use Grunt to manage assets.
82
  * Network settings added for management of entire network visibility settings.
restricted_site_access.php CHANGED
@@ -3,13 +3,13 @@
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: 6.0
7
  * Author: Jake Goldman, 10up, Oomph
8
  * Author URI: http://10up.com
9
  * License: GPLv2 or later
10
  */
11
 
12
- define( 'RSA_VERSION', '6.0' );
13
 
14
  class Restricted_Site_Access {
15
 
@@ -53,8 +53,8 @@ class Restricted_Site_Access {
53
  add_action( 'plugins_loaded', array( __CLASS__, 'load_textdomain' ) );
54
  add_action( 'wp_ajax_rsa_ip_check', array( __CLASS__, 'ajax_rsa_ip_check' ) );
55
 
56
- add_action( 'activate_' . self::$basename, array( __CLASS__, 'activation' ) );
57
- add_action( 'deactivate_' . self::$basename, array( __CLASS__, 'deactivation' ) );
58
  add_action( 'wpmu_new_blog', array( __CLASS__, 'set_defaults' ), 10, 6 );
59
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_admin_script' ) );
60
  add_action( 'wp_ajax_rsa_notice_dismiss', array( __CLASS__, 'ajax_notice_dismiss' ) );
@@ -884,16 +884,32 @@ class Restricted_Site_Access {
884
  /**
885
  * activation of plugin: upgrades old versions, immediately sets privacy
886
  */
887
- public static function activation() {
888
- update_option( 'blog_public', 2 );
 
 
889
  }
890
 
891
  /**
892
  * restore privacy option to default value upon deactivating
893
  */
894
- public static function deactivation() {
895
- if ( 2 == get_option( 'blog_public' ) ) {
896
- update_option( 'blog_public', 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
897
  }
898
  }
899
 
@@ -921,7 +937,7 @@ Restricted_Site_Access::get_instance();
921
  * Uninstall routine for the plugin
922
  */
923
  function restricted_site_access_uninstall() {
924
- if ( RSA_IS_NETWORK ){
925
  delete_site_option( 'blog_public' );
926
  delete_site_option( 'rsa_options' );
927
  delete_site_option( 'rsa_mode' );
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: 6.0.1
7
  * Author: Jake Goldman, 10up, Oomph
8
  * Author URI: http://10up.com
9
  * License: GPLv2 or later
10
  */
11
 
12
+ define( 'RSA_VERSION', '6.0.1' );
13
 
14
  class Restricted_Site_Access {
15
 
53
  add_action( 'plugins_loaded', array( __CLASS__, 'load_textdomain' ) );
54
  add_action( 'wp_ajax_rsa_ip_check', array( __CLASS__, 'ajax_rsa_ip_check' ) );
55
 
56
+ add_action( 'activate_' . self::$basename, array( __CLASS__, 'activation' ), 10, 1 );
57
+ add_action( 'deactivate_' . self::$basename, array( __CLASS__, 'deactivation' ), 10, 1 );
58
  add_action( 'wpmu_new_blog', array( __CLASS__, 'set_defaults' ), 10, 6 );
59
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_admin_script' ) );
60
  add_action( 'wp_ajax_rsa_notice_dismiss', array( __CLASS__, 'ajax_notice_dismiss' ) );
884
  /**
885
  * activation of plugin: upgrades old versions, immediately sets privacy
886
  */
887
+ public static function activation( $network_active ) {
888
+ if ( ! $network_active ) {
889
+ update_option( 'blog_public', 2 );
890
+ }
891
  }
892
 
893
  /**
894
  * restore privacy option to default value upon deactivating
895
  */
896
+ public static function deactivation( $network_active ) {
897
+ if ( $network_active ) {
898
+ $sites = get_sites();
899
+
900
+ foreach ( $sites as $site ) {
901
+ switch_to_blog( $site->blog_id );
902
+
903
+ if ( 2 == get_option( 'blog_public' ) ) {
904
+ update_option( 'blog_public', 1 );
905
+ }
906
+
907
+ restore_current_blog();
908
+ }
909
+ } else {
910
+ if ( 2 == get_option( 'blog_public' ) ) {
911
+ update_option( 'blog_public', 1 );
912
+ }
913
  }
914
  }
915
 
937
  * Uninstall routine for the plugin
938
  */
939
  function restricted_site_access_uninstall() {
940
+ if ( RSA_IS_NETWORK ) {
941
  delete_site_option( 'blog_public' );
942
  delete_site_option( 'rsa_options' );
943
  delete_site_option( 'rsa_mode' );