My Private Site - Version 3.0.5

Version Description

  • Added a compatibility mode option on the Advanced tab which will hopefully finally fix the Elementor issues
Download this release

Release Info

Developer dgewirtz
Plugin Icon 128x128 My Private Site
Version 3.0.5
Comparing to
See all releases

Code changes from version 3.0.3 to 3.0.5

admin/advanced.php CHANGED
@@ -92,6 +92,24 @@ function my_private_site_admin_advanced_section_data($section_options) {
92
  my_private_site_preload_cmb2_field_filter('jr_ps_admin_advanced_password_reset_url', $handler_function);
93
  }
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  // although this feature was in Jonradio's original code, there's nothing he does with it other than set it
96
  // $section_options->add_field(array(
97
  // 'name' => 'Validate Login URL',
@@ -236,7 +254,7 @@ function my_private_site_tab_advanced_process_buttons() {
236
  if (!function_exists('my_private_site_pp_plugin_updater')) {
237
  if (isset($_POST["jr_ps_admin_advanced_password_reset_url"])) {
238
  $reset_url = my_private_site_validate_url($_POST["jr_ps_admin_advanced_password_reset_url"]);
239
- if($_POST["jr_ps_admin_advanced_password_reset_url"] != '' and $reset_url == false){
240
  my_private_site_flag_cmb2_submit_button_error('jr_ps_button_advanced_save',
241
  'Valid password reset URL must be provided.');
242
  return;
@@ -276,6 +294,11 @@ function my_private_site_tab_advanced_process_buttons() {
276
  $settings['login_url'] = '';
277
  }
278
 
 
 
 
 
 
279
  if (isset($_POST["jr_ps_admin_advanced_custom_landing"])) {
280
  $settings['override_omit'] = true;
281
  } else {
@@ -334,6 +357,13 @@ function my_private_site_admin_advanced_preload($data, $object_id, $args, $field
334
  return false;
335
  }
336
  break;
 
 
 
 
 
 
 
337
  case 'jr_ps_admin_advanced_custom_landing':
338
  if (isset($settings['override_omit'])) {
339
  return $settings['override_omit'];
92
  my_private_site_preload_cmb2_field_filter('jr_ps_admin_advanced_password_reset_url', $handler_function);
93
  }
94
 
95
+ $compatibility_mode = array(
96
+ 'STANDARD' => 'Standard',
97
+ 'ELEMENTOR' => 'Elementor Fix',
98
+ );
99
+
100
+ $compatibility_desc = "Adjust this setting if My Private Site doesn't properly block access.";
101
+
102
+ $section_options->add_field(array(
103
+ 'name' => __('Compatibility Mode'),
104
+ 'id' => 'jr_ps_admin_advanced_compatibility_mode',
105
+ 'type' => 'select',
106
+ 'default' => 'STANDARD',
107
+ // the index key of the label array below
108
+ 'options' => $compatibility_mode,
109
+ 'desc' => $compatibility_desc,
110
+ ));
111
+ my_private_site_preload_cmb2_field_filter('jr_ps_admin_advanced_compatibility_mode', $handler_function);
112
+
113
  // although this feature was in Jonradio's original code, there's nothing he does with it other than set it
114
  // $section_options->add_field(array(
115
  // 'name' => 'Validate Login URL',
254
  if (!function_exists('my_private_site_pp_plugin_updater')) {
255
  if (isset($_POST["jr_ps_admin_advanced_password_reset_url"])) {
256
  $reset_url = my_private_site_validate_url($_POST["jr_ps_admin_advanced_password_reset_url"]);
257
+ if ($_POST["jr_ps_admin_advanced_password_reset_url"] != '' and $reset_url == false) {
258
  my_private_site_flag_cmb2_submit_button_error('jr_ps_button_advanced_save',
259
  'Valid password reset URL must be provided.');
260
  return;
294
  $settings['login_url'] = '';
295
  }
296
 
297
+ if (isset($_POST["jr_ps_admin_advanced_compatibility_mode"])) {
298
+ $compatibility_mode = trim($_POST['jr_ps_admin_advanced_compatibility_mode']);
299
+ $settings['compatibility_mode'] = $compatibility_mode;
300
+ }
301
+
302
  if (isset($_POST["jr_ps_admin_advanced_custom_landing"])) {
303
  $settings['override_omit'] = true;
304
  } else {
357
  return false;
358
  }
359
  break;
360
+ case 'jr_ps_admin_advanced_compatibility_mode':
361
+ if (isset($settings['compatibility_mode'])) {
362
+ return $settings['compatibility_mode'];
363
+ } else {
364
+ return 'STANDARD';
365
+ }
366
+ break;
367
  case 'jr_ps_admin_advanced_custom_landing':
368
  if (isset($settings['override_omit'])) {
369
  return $settings['override_omit'];
includes/public.php CHANGED
@@ -13,17 +13,31 @@ if (!defined('ABSPATH')) exit;
13
 
14
  Unfortunately, a wpengine.com (hosting site) mandatory plugin
15
  appears to be blocking this hook, so the next hook in time sequence
16
- is being used:
17
- 'get_header'
 
 
18
  */
19
- add_action('get_header', 'jr_ps_force_login');
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  add_action('login_init', 'jr_ps_login');
22
  add_filter('login_url', 'jr_ps_login_url');
23
  add_action('wp_login_failed', 'jr_ps_login_failed');
24
  add_action('wp_authenticate', 'jr_ps_wp_authenticate', 10, 2);
25
 
26
- $settings = get_option('jr_ps_settings');
27
  if ($settings['wplogin_php']) {
28
  /* Run this Filter "last" (Priority=100) to be sure that Paid Memberships Pro
29
  has already runs its Filter.
@@ -223,7 +237,7 @@ function jr_ps_force_login() {
223
  */
224
  $url = wp_login_url();
225
  }
226
-
227
  /* wp_redirect( $url ) goes to $url right after exit on the line that follows.
228
  */
229
  wp_redirect($url);
13
 
14
  Unfortunately, a wpengine.com (hosting site) mandatory plugin
15
  appears to be blocking this hook, so the next hook in time sequence
16
+ is being used: 'get_header'
17
+
18
+ Elementor was also screwing up the force login hook. By flipping bacl
19
+ to template_redirect, it seems to work. Elementor on WPEngine? Who knows?
20
  */
21
+ $settings = get_option('jr_ps_settings');
22
+ if (isset($settings['compatibility_mode'])) {
23
+ $compatibility_mode = $settings['compatibility_mode'];
24
+ } else {
25
+ $compatibility_mode = 'STANDARD';
26
+ }
27
+ switch($compatibility_mode){
28
+ case 'STANDARD':
29
+ add_action('get_header', 'jr_ps_force_login');
30
+ break;
31
+ case 'ELEMENTOR':
32
+ add_action('template_redirect', 'jr_ps_force_login');
33
+ break;
34
+ }
35
 
36
  add_action('login_init', 'jr_ps_login');
37
  add_filter('login_url', 'jr_ps_login_url');
38
  add_action('wp_login_failed', 'jr_ps_login_failed');
39
  add_action('wp_authenticate', 'jr_ps_wp_authenticate', 10, 2);
40
 
 
41
  if ($settings['wplogin_php']) {
42
  /* Run this Filter "last" (Priority=100) to be sure that Paid Memberships Pro
43
  has already runs its Filter.
237
  */
238
  $url = wp_login_url();
239
  }
240
+ // looks like wp_login_url is returning the current page
241
  /* wp_redirect( $url ) goes to $url right after exit on the line that follows.
242
  */
243
  wp_redirect($url);
jonradio-private-site.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: My Private Site
4
  Plugin URI: http://zatzlabs.com/plugins/
5
  Description: Easily secure posts, pages, or your entire WordPress site by requiring visitors to login.
6
- Version: 3.0.3
7
  Author: David Gewirtz
8
  Author URI: http://zatzlabs.com/plugins/
9
  License: GPLv2
3
  Plugin Name: My Private Site
4
  Plugin URI: http://zatzlabs.com/plugins/
5
  Description: Easily secure posts, pages, or your entire WordPress site by requiring visitors to login.
6
+ Version: 3.0.5
7
  Author: David Gewirtz
8
  Author URI: http://zatzlabs.com/plugins/
9
  License: GPLv2
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dgewirtz
3
  Donate link: http://zatzlabs.com/lab-notes/
4
  Tags: login, visibility, private, security, plugin, pages, page, posts, post
5
  Requires at least: 3.0
6
- Tested up to: 5.8
7
- Stable tag: 3.0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -90,6 +90,13 @@ Whenever you change your WordPress Permalinks (Settings-Permalinks in Admin pane
90
 
91
  == Changelog ==
92
 
 
 
 
 
 
 
 
93
  = 3.0.3 =
94
  * Added Advanced feature allowing users to specify custom password reset page
95
 
3
  Donate link: http://zatzlabs.com/lab-notes/
4
  Tags: login, visibility, private, security, plugin, pages, page, posts, post
5
  Requires at least: 3.0
6
+ Tested up to: 5.8.1
7
+ Stable tag: 3.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
90
 
91
  == Changelog ==
92
 
93
+ = 3.0.5 =
94
+ * Added a compatibility mode option on the Advanced tab which will hopefully finally fix the Elementor issues
95
+
96
+ = 3.0.4 =
97
+ * Possible fix for Elementor incompatibility issues
98
+ * Fixed some small bugs
99
+
100
  = 3.0.3 =
101
  * Added Advanced feature allowing users to specify custom password reset page
102
 
util/utilities5.php CHANGED
@@ -367,8 +367,9 @@ function my_private_site_is_referred_by_page($page) {
367
 
368
  $parts_list = parse_url($referring_page);
369
 
370
- $query = $parts_list["query"];
371
- if (!isset($query)) {
 
372
  $query = '';
373
  }
374
 
367
 
368
  $parts_list = parse_url($referring_page);
369
 
370
+ if(isset($parts_list["query"])) {
371
+ $query = $parts_list["query"];
372
+ } else {
373
  $query = '';
374
  }
375