My Private Site - Version 2.7

Version Description

  • Add Custom Login URL setting
Download this release

Release Info

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

Version 2.7

includes/admin-settings.php ADDED
@@ -0,0 +1,663 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Initiated when in the Admin panels.
4
+ Used to create the Settings page for the plugin.
5
+ */
6
+
7
+ // Exit if .php file accessed directly
8
+ if ( !defined( 'ABSPATH' ) ) exit;
9
+
10
+ DEFINE( 'JR_PS_BELOW_FIELDS', '<br /> &nbsp; ' );
11
+
12
+ require_once( jr_ps_path() . 'includes/functions-admin.php' );
13
+
14
+ add_action( 'admin_menu', 'jr_ps_admin_hook' );
15
+ // Runs just before admin_init (below)
16
+
17
+ /**
18
+ * Add Admin Menu item for plugin
19
+ *
20
+ * Plugin needs its own Page in the Settings section of the Admin menu.
21
+ *
22
+ */
23
+ function jr_ps_admin_hook() {
24
+ // Add Settings Page for this Plugin
25
+ global $jr_ps_plugin_data;
26
+ add_users_page( $jr_ps_plugin_data['Name'], 'Private Site', 'add_users', 'jr_ps_settings', 'jr_ps_settings_page' );
27
+ add_options_page( $jr_ps_plugin_data['Name'], 'Private Site', 'manage_options', 'jr_ps_settings', 'jr_ps_settings_page' );
28
+ }
29
+
30
+ /**
31
+ * Settings page for plugin
32
+ *
33
+ * Display and Process Settings page for this plugin.
34
+ *
35
+ */
36
+ function jr_ps_settings_page() {
37
+ global $jr_ps_plugin_data;
38
+ add_thickbox();
39
+ echo '<div class="wrap">';
40
+ echo '<h2>' . $jr_ps_plugin_data['Name'] . '</h2>';
41
+
42
+ // Required because it is only called automatically for Admin Pages in the Settings section
43
+ settings_errors( 'jr_ps_settings' );
44
+
45
+ echo '<h3>Overview</h3><p>';
46
+ $settings = get_option( 'jr_ps_settings' );
47
+ if ( $settings['private_site'] ) {
48
+ echo 'This';
49
+ } else {
50
+ echo 'If you click the <b>Private Site</b> checkbox below, this';
51
+ }
52
+ ?>
53
+ Plugin creates a Private Site,
54
+ by ensuring that site visitors login
55
+ before viewing your web site.
56
+ The only things visible to anyone not logged in, including Search Engines, are:
57
+ <ul>
58
+ <li>
59
+ &raquo; Your site's WordPress Login page;
60
+ </li>
61
+ <li>
62
+ &raquo; Any selections in the
63
+ <b>
64
+ Visible Exclusions
65
+ </b>
66
+ section (below);
67
+ </li>
68
+ <li>
69
+ &raquo; Any non-WordPress components of your web site, such as HTML, PHP, ASP or other non-WordPress web page files;
70
+ </li>
71
+ <li>
72
+ &raquo; Images and other media and text files, but only when accessed directly by their URL,
73
+ or from a browser's directory view, if available.
74
+ </li>
75
+ </ul>
76
+ Other means are available to hide most of the files mentioned above.
77
+ </p>
78
+ <p>
79
+ To see your site, each visitor will need to be registered as a User on your WordPress site.
80
+ They will also have to enter their Username and Password on the WordPress login screen.
81
+ </p>
82
+ <p>
83
+ You can choose what they see after they login by selecting a <b>Landing Location</b> in the section below.
84
+ </p>
85
+ <form action="options.php" method="POST">
86
+ <?php
87
+ // Plugin Settings are displayed and entered here:
88
+ settings_fields( 'jr_ps_settings' );
89
+ do_settings_sections( 'jr_ps_settings_page' );
90
+ echo '<p><input name="save" type="submit" value="Save Changes" class="button-primary" /></p></form>';
91
+
92
+ /* Turn off Warning about Private Site defaulting to OFF
93
+ once Admin has seen Settings page.
94
+ */
95
+ $internal_settings = get_option( 'jr_ps_internal_settings' );
96
+ if ( isset( $internal_settings['warning_privacy'] ) ) {
97
+ unset( $internal_settings['warning_privacy'] );
98
+ update_option( 'jr_ps_internal_settings', $internal_settings );
99
+ }
100
+ }
101
+
102
+ add_action( 'admin_init', 'jr_ps_admin_init' );
103
+
104
+ /**
105
+ * Register and define the settings
106
+ *
107
+ * Everything to be stored and/or can be set by the user
108
+ *
109
+ */
110
+ function jr_ps_admin_init() {
111
+ register_setting( 'jr_ps_settings', 'jr_ps_settings', 'jr_ps_validate_settings' );
112
+ add_settings_section( 'jr_ps_private_settings_section',
113
+ 'Make Site Private',
114
+ 'jr_ps_private_settings_expl',
115
+ 'jr_ps_settings_page'
116
+ );
117
+ add_settings_field( 'private_site',
118
+ 'Private Site',
119
+ 'jr_ps_echo_private_site',
120
+ 'jr_ps_settings_page',
121
+ 'jr_ps_private_settings_section'
122
+ );
123
+ add_settings_section( 'jr_ps_self_registration_section',
124
+ 'Allow Self-Registration',
125
+ 'jr_ps_self_registration_expl',
126
+ 'jr_ps_settings_page'
127
+ );
128
+ if ( is_multisite() ) {
129
+ /* Clone Network Admin panels: Settings-Network Settings-Registration Settings-Allow new registrations.
130
+ It will be Read-Only except for Super Administrators.
131
+ */
132
+ add_settings_field( 'registrations',
133
+ 'Allow new registrations',
134
+ 'jr_ps_echo_registrations',
135
+ 'jr_ps_settings_page',
136
+ 'jr_ps_self_registration_section'
137
+ );
138
+ } else {
139
+ /* Clone Site Admin panels: Settings-General Settings-Membership
140
+ */
141
+ add_settings_field( 'membership',
142
+ 'Membership',
143
+ 'jr_ps_echo_membership',
144
+ 'jr_ps_settings_page',
145
+ 'jr_ps_self_registration_section'
146
+ );
147
+ }
148
+ add_settings_field( 'reveal_registration',
149
+ 'Reveal Registration Page',
150
+ 'jr_ps_echo_reveal_registration',
151
+ 'jr_ps_settings_page',
152
+ 'jr_ps_self_registration_section'
153
+ );
154
+ add_settings_section( 'jr_ps_landing_settings_section',
155
+ 'Landing Location',
156
+ 'jr_ps_landing_settings_expl',
157
+ 'jr_ps_settings_page'
158
+ );
159
+ add_settings_field( 'landing',
160
+ 'Where to after Login?',
161
+ 'jr_ps_echo_landing',
162
+ 'jr_ps_settings_page',
163
+ 'jr_ps_landing_settings_section'
164
+ );
165
+ add_settings_field( 'specific_url',
166
+ 'Specific URL',
167
+ 'jr_ps_echo_specific_url',
168
+ 'jr_ps_settings_page',
169
+ 'jr_ps_landing_settings_section'
170
+ );
171
+ add_settings_section( 'jr_ps_custom_login_section',
172
+ 'Custom Login',
173
+ 'jr_ps_custom_login_expl',
174
+ 'jr_ps_settings_page'
175
+ );
176
+ add_settings_field( 'custom_login',
177
+ 'Custom Login page?',
178
+ 'jr_ps_echo_custom_login',
179
+ 'jr_ps_settings_page',
180
+ 'jr_ps_custom_login_section'
181
+ );
182
+ add_settings_field( 'login_url',
183
+ 'Custom Login URL',
184
+ 'jr_ps_echo_login_url',
185
+ 'jr_ps_settings_page',
186
+ 'jr_ps_custom_login_section'
187
+ );
188
+ add_settings_section( 'jr_ps_exclusions_section',
189
+ 'Visible Exclusions',
190
+ 'jr_ps_exclusions_expl',
191
+ 'jr_ps_settings_page'
192
+ );
193
+ add_settings_field( 'excl_home',
194
+ 'Site Home Always Visible?<br /><code>' . get_home_url() . '</code>',
195
+ 'jr_ps_echo_excl_home',
196
+ 'jr_ps_settings_page',
197
+ 'jr_ps_exclusions_section'
198
+ );
199
+ add_settings_field( 'excl_url_add',
200
+ 'Add URL to be Always Visible',
201
+ 'jr_ps_echo_excl_url_add',
202
+ 'jr_ps_settings_page',
203
+ 'jr_ps_exclusions_section'
204
+ );
205
+ add_settings_field( 'excl_url_del',
206
+ 'Current Visible URL Entries',
207
+ 'jr_ps_echo_excl_url_del',
208
+ 'jr_ps_settings_page',
209
+ 'jr_ps_exclusions_section'
210
+ );
211
+ }
212
+
213
+ /**
214
+ * Section text for Section1
215
+ *
216
+ * Display an explanation of this Section
217
+ *
218
+ */
219
+ function jr_ps_private_settings_expl() {
220
+ ?>
221
+ <p>
222
+ You will only have a Private Site if the checkbox just below is checked.
223
+ This allows you to disable the Private Site functionality
224
+ without deactivating the Plugin.
225
+ </p>
226
+ <?php
227
+ }
228
+
229
+ function jr_ps_echo_private_site() {
230
+ $settings = get_option( 'jr_ps_settings' );
231
+ echo '<input type="checkbox" id="private_site" name="jr_ps_settings[private_site]" value="true"'
232
+ . checked( TRUE, $settings['private_site'], FALSE ) . ' />';
233
+ echo ' (This plugin is currently ';
234
+ if ( $settings['private_site'] ) {
235
+ echo 'enabled; click checkbox to disable)';
236
+ } else {
237
+ echo 'disabled; click checkbox to enable)';
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Section text for Section2
243
+ *
244
+ * Display an explanation of this Section
245
+ *
246
+ */
247
+ function jr_ps_self_registration_expl() {
248
+ echo '
249
+ <p>
250
+ If you want Users to be able to Register themselves on a Private Site,
251
+ there are two Settings involved.
252
+ First
253
+ is the WordPress Setting that actually allows new Users to self-register.
254
+ It is shown here as a convenience,
255
+ but:
256
+ <ol>
257
+ <li>This is the same
258
+ ';
259
+ if ( is_multisite() ) {
260
+ echo '<b>Allow New Registrations</b> field displayed on the <b>Network Settings</b> Admin panel;</li>';
261
+ } else {
262
+ echo '<b>Membership</b> field displayed on the <b>General Settings</b> Admin panel;</li>';
263
+ }
264
+ if ( is_multisite() && !is_super_admin() ) {
265
+ echo '<li>The field is greyed out below because only Super Administrators can change this field.';
266
+ } else {
267
+ echo '<li>Clicking the Save Changes button will update its value.';
268
+ }
269
+ echo '
270
+ </li>
271
+ </ol>
272
+ </p>
273
+ <p>
274
+ Second, is a Setting
275
+ (Reveal Registration Page)
276
+ for this plugin,
277
+ to make the WordPress User Registration page visible to Visitors who are not logged on.
278
+ Since Users cannot log on until they are Registered,
279
+ this Setting must be selected (check mark) for Self-Registration.
280
+ </p>
281
+ ';
282
+ }
283
+
284
+ function jr_ps_echo_registrations() {
285
+ $setting = get_site_option( 'registration' );
286
+ foreach ( array(
287
+ 'none' => 'Registration is disabled.',
288
+ 'user' => 'User accounts may be registered.',
289
+ 'blog' => 'Logged in users may register new sites.',
290
+ 'all' => 'Both sites and user accounts can be registered.'
291
+ ) as $value => $description ) {
292
+ echo '<input type="radio" id="registrations" name="jr_ps_settings[registrations]" '
293
+ . checked( $value, $setting, FALSE )
294
+ . ' value="' . $value . '" '
295
+ . disabled( is_super_admin(), FALSE, FALSE )
296
+ . ' /> ' . $description . '<br />';
297
+ }
298
+ }
299
+
300
+ function jr_ps_echo_membership() {
301
+ echo '<input type="checkbox" id="membership" name="jr_ps_settings[membership]" value="1" '
302
+ . checked( '1', get_option( 'users_can_register' ), FALSE ) . ' /> Anyone can register';
303
+ }
304
+
305
+ function jr_ps_echo_reveal_registration() {
306
+ $settings = get_option( 'jr_ps_settings' );
307
+ echo '<input type="checkbox" id="reveal_registration" name="jr_ps_settings[reveal_registration]" value="true"'
308
+ . checked( TRUE, $settings['reveal_registration'], FALSE ) . ' />';
309
+ echo ' Do not block WordPress standard User Registration page (Advanced Setting: a check mark in this checkbox is recommended)';
310
+ }
311
+
312
+ /**
313
+ * Section text for Section3
314
+ *
315
+ * Display an explanation of this Section
316
+ *
317
+ */
318
+ function jr_ps_landing_settings_expl() {
319
+ ?>
320
+ <p>
321
+ What do you want your visitors to see immediately after they login?
322
+ For most Private Sites, the default
323
+ <b>Return to same URL</b>
324
+ setting works best,
325
+ as it takes visitors to where they would have been had they already been logged on when they clicked a link or entered a URL,
326
+ just as if they hit the browser's Back button twice and then the Refresh button after logging in.
327
+ </p>
328
+ <p>
329
+ <b>Specific URL</b> only applies when <b>Go to specific URL</b> is selected.
330
+ </p>
331
+ <?php
332
+ }
333
+
334
+ function jr_ps_echo_landing() {
335
+ $settings = get_option( 'jr_ps_settings' );
336
+ $first = TRUE;
337
+ foreach ( array(
338
+ 'return' => 'Return to same URL',
339
+ 'home' => 'Go to Site Home',
340
+ 'admin' => 'Go to WordPress Admin Dashboard',
341
+ 'omit' => 'Omit <code>?redirect_to=</code> from URL (a check mark in this checkbox is recommended for Custom Login pages)',
342
+ 'url' => 'Go to Specific URL'
343
+ ) as $val => $desc ) {
344
+ if ( $first ) {
345
+ $first = FALSE;
346
+ } else {
347
+ echo '<br />';
348
+ }
349
+ echo '<input type="radio" id="landing" name="jr_ps_settings[landing]" '
350
+ . checked( $val, $settings['landing'], FALSE )
351
+ . ' value="' . $val . '" /> ' . $desc;
352
+ }
353
+ }
354
+
355
+ function jr_ps_echo_specific_url() {
356
+ $settings = get_option( 'jr_ps_settings' );
357
+ echo '<input type="text" id="specific_url" name="jr_ps_settings[specific_url]" size="100" maxlength="256" value="';
358
+ echo esc_url( $settings['specific_url'] )
359
+ . '" />'
360
+ . JR_PS_BELOW_FIELDS
361
+ . '(cut and paste URL here of Page, Post or other)'
362
+ . JR_PS_BELOW_FIELDS
363
+ . 'URL must begin with <code>'
364
+ . trim( get_home_url(), '\ /' )
365
+ . '/</code>';
366
+ }
367
+
368
+ /**
369
+ * Section text for Section4
370
+ *
371
+ * Display an explanation of this Section
372
+ *
373
+ */
374
+ function jr_ps_custom_login_expl() {
375
+ echo '<p>If you have a Custom Login page at a different URL than the standard WordPress Login <code>'
376
+ . wp_login_url()
377
+ . '</code>, then you will need to specify it here. Otherwise, visitors will be redirected to the standard WordPress Login.</p>';
378
+ echo '<p>If the Custom Login page is not based on the standard WordPress Login page, it may not accept the <code>?redirect_to=http://landingurl</code> Query that is automatically added to the URL of the Custom Login page. Select Omit for "Where to after Login?" in the Landing Location section to remove the <code>redirect_to</code> Query.</p>';
379
+ echo '<p>Even with the Custom Login page selected, the standard WordPress login page will still appear in certain circumstances, such as logging into the Admin panels.<p>';
380
+ }
381
+
382
+ function jr_ps_echo_custom_login() {
383
+ $settings = get_option( 'jr_ps_settings' );
384
+ echo '<input type="checkbox" id="custom_login" name="jr_ps_settings[custom_login]" value="true" '
385
+ . checked( TRUE, $settings['custom_login'], FALSE )
386
+ . ' />';
387
+ }
388
+
389
+ function jr_ps_echo_login_url() {
390
+ $settings = get_option( 'jr_ps_settings' );
391
+ echo '<input type="text" id="login_url" name="jr_ps_settings[login_url]" size="100" maxlength="256" value="'
392
+ . esc_url( $settings['login_url'] )
393
+ . '" />'
394
+ . JR_PS_BELOW_FIELDS
395
+ . '(cut and paste Custom Login URL here; leave blank otherwise)'
396
+ . JR_PS_BELOW_FIELDS
397
+ . 'URL must begin with <code>'
398
+ . trim( get_home_url(), '\ /' )
399
+ . '/</code>';
400
+ }
401
+
402
+ /**
403
+ * Section text for Section5
404
+ *
405
+ * Display an explanation of this Section
406
+ *
407
+ */
408
+ function jr_ps_exclusions_expl() {
409
+ ?>
410
+ <p>
411
+ If you want to use your Site Home to interest visitors in registering for your site so they can see the rest of your site,
412
+ you obviously need Site Home visible to everyone.
413
+ You can add additional Visible site URLs,
414
+ one entry at a time,
415
+ in the
416
+ <b>
417
+ Add URL to be Always Visible
418
+ </b>
419
+ field.
420
+ </p>
421
+ <?php
422
+ }
423
+
424
+ function jr_ps_echo_excl_home() {
425
+ $settings = get_option( 'jr_ps_settings' );
426
+ echo '<input type="checkbox" id="excl_home" name="jr_ps_settings[excl_home]" value="true"'
427
+ . checked( TRUE, $settings['excl_home'], FALSE ) . ' /> Site Home is visible to everyone?';
428
+ }
429
+
430
+ function jr_ps_echo_excl_url_add() {
431
+ echo '<input id="excl_url_add" name="jr_ps_settings[excl_url_add]" type="text" size="100" maxlength="256" value="" />'
432
+ . JR_PS_BELOW_FIELDS
433
+ . '(cut and paste URL here of Page, Post or other)'
434
+ . JR_PS_BELOW_FIELDS
435
+ . 'URL must begin with <code>'
436
+ . trim( get_home_url(), '\ /' )
437
+ . '/</code>';
438
+ }
439
+
440
+ function jr_ps_echo_excl_url_del() {
441
+ $settings = get_option( 'jr_ps_settings' );
442
+ if ( empty( $settings['excl_url'] ) ) {
443
+ echo 'None. To add a Visible URL Entry, fill in the fields above.';
444
+ } else {
445
+ $first = TRUE;
446
+ foreach ( $settings['excl_url'] as $index => $arr ) {
447
+ if ( $first ) {
448
+ $first = FALSE;
449
+ } else {
450
+ echo '<br />';
451
+ }
452
+ $display_url = $arr[0];
453
+ echo "Delete <input type='checkbox' id='excl_url_del' name='jr_ps_settings[excl_url_del][]' value='$index' />"
454
+ . " <a href='$display_url' target='_blank'>$display_url</a>";
455
+ }
456
+ }
457
+ echo '<br />The Custom Login URL, if specified, is always Visible.';
458
+ }
459
+
460
+ function jr_ps_validate_settings( $input ) {
461
+ $valid = array();
462
+ $settings = get_option( 'jr_ps_settings' );
463
+
464
+ if ( isset( $input['private_site'] ) && ( $input['private_site'] === 'true' ) ) {
465
+ $valid['private_site'] = TRUE;
466
+ } else {
467
+ $valid['private_site'] = FALSE;
468
+ }
469
+
470
+ if ( isset( $input['reveal_registration'] ) && ( $input['reveal_registration'] === 'true' ) ) {
471
+ $valid['reveal_registration'] = TRUE;
472
+ } else {
473
+ $valid['reveal_registration'] = FALSE;
474
+ }
475
+
476
+ $url = jr_v1_sanitize_url( $input['specific_url'] );
477
+ if ( '' !== $url ) {
478
+ if ( FALSE === $url ) {
479
+ /* Reset to previous URL value and generate an error message.
480
+ */
481
+ $url = $settings['specific_url'];
482
+ add_settings_error(
483
+ 'jr_ps_settings',
484
+ 'jr_ps_urlerror',
485
+ 'Landing Location URL is not a valid URL<br /><code>'
486
+ . sanitize_text_field( $input['specific_url'] ) . '</code>',
487
+ 'error'
488
+ );
489
+ } else {
490
+ if ( !jr_ps_site_url( $url ) ) {
491
+ /* Reset to previous URL value and generate an error message.
492
+ */
493
+ $url = $settings['specific_url'];
494
+ add_settings_error(
495
+ 'jr_ps_settings',
496
+ 'jr_ps_urlerror',
497
+ 'Error in Landing Location URL. It must point to someplace on this WordPress web site<br /><code>'
498
+ . sanitize_text_field( $input['specific_url'] ) . '</code>',
499
+ 'error'
500
+ );
501
+ }
502
+ }
503
+ }
504
+ $valid['specific_url'] = $url;
505
+
506
+ if ( 'url' === $input['landing'] ) {
507
+ if ( '' === $valid['specific_url'] ) {
508
+ add_settings_error(
509
+ 'jr_ps_settings',
510
+ 'jr_ps_nourlerror',
511
+ 'Error in Landing Location: <i>Go to Specific URL</i> selected but no URL specified. Set to default <i>Return to same URL</i>.',
512
+ 'error'
513
+ );
514
+ $valid['landing'] = 'return';
515
+ } else {
516
+ $valid['landing'] = 'url';
517
+ }
518
+ } else {
519
+ if ( '' !== $valid['specific_url'] ) {
520
+ add_settings_error(
521
+ 'jr_ps_settings',
522
+ 'jr_ps_nourlerror',
523
+ 'Error in Landing Location: URL specified when not valid. URL deleted.',
524
+ 'error'
525
+ );
526
+ $valid['specific_url'] = '';
527
+ }
528
+ $valid['landing'] = $input['landing'];
529
+ }
530
+
531
+ $url = jr_v1_sanitize_url( $input['login_url'] );
532
+ if ( '' !== $url ) {
533
+ if ( FALSE === $url ) {
534
+ /* Reset to previous URL value and generate an error message.
535
+ */
536
+ $url = $settings['login_url'];
537
+ add_settings_error(
538
+ 'jr_ps_settings',
539
+ 'jr_ps_urlerror',
540
+ 'Custom Login URL is not a valid URL<br /><code>'
541
+ . sanitize_text_field( $input['login_url'] ) . '</code>',
542
+ 'error'
543
+ );
544
+ } else {
545
+ if ( !jr_ps_site_url( $url ) ) {
546
+ /* Reset to previous URL value and generate an error message.
547
+ */
548
+ $url = $settings['login_url'];
549
+ add_settings_error(
550
+ 'jr_ps_settings',
551
+ 'jr_ps_urlerror',
552
+ 'Error in Custom Login URL. It must point to someplace on this WordPress web site<br /><code>'
553
+ . sanitize_text_field( $input['login_url'] ) . '</code>',
554
+ 'error'
555
+ );
556
+ }
557
+ }
558
+ }
559
+ $valid['login_url'] = $url;
560
+
561
+ if ( isset( $input['custom_login'] ) && ( $input['custom_login'] === 'true' ) ) {
562
+ if ( '' === $valid['login_url'] ) {
563
+ add_settings_error(
564
+ 'jr_ps_settings',
565
+ 'jr_ps_nourlerror',
566
+ 'Error in Custom Login: <i>Custom Login page?</i> checkbox selected but no URL specified. Checkbox deselected.',
567
+ 'error'
568
+ );
569
+ $valid['custom_login'] = FALSE;
570
+ } else {
571
+ $valid['custom_login'] = TRUE;
572
+ /* Was Custom Login just turned on?
573
+ If so, be sure Landing Location is set to Omit.
574
+ */
575
+ if ( !$setting['custom_login'] && ( 'omit' !== $valid['landing'] ) ) {
576
+ $valid['landing'] = 'omit';
577
+ add_settings_error(
578
+ 'jr_ps_settings',
579
+ 'jr_ps_setomit',
580
+ 'Landing Location changed to "Omit", recommended for Custom Login pages.',
581
+ 'updated'
582
+ );
583
+ }
584
+ }
585
+ } else {
586
+ $valid['custom_login'] = FALSE;
587
+ }
588
+
589
+ if ( isset( $input['excl_home'] ) && ( $input['excl_home'] === 'true' ) ) {
590
+ $valid['excl_home'] = TRUE;
591
+ } else {
592
+ $valid['excl_home'] = FALSE;
593
+ }
594
+
595
+ if ( is_multisite() ) {
596
+ if ( is_super_admin() ) {
597
+ if ( isset( $input['registrations'] ) ) {
598
+ update_site_option( 'registration', $input['registrations'] );
599
+ }
600
+ }
601
+ } else {
602
+ if ( isset( $input['membership'] ) ) {
603
+ $mem = $input['membership'];
604
+ } else {
605
+ $mem = '0';
606
+ }
607
+ update_option( 'users_can_register', $mem );
608
+ }
609
+
610
+ if ( isset( $settings['excl_url'] ) ) {
611
+ $valid['excl_url'] = $settings['excl_url'];
612
+ } else {
613
+ $valid['excl_url'] = array();
614
+ }
615
+ /* Delete URLs to Exclude from Privacy.
616
+ */
617
+ if ( isset ( $input['excl_url_del'] ) ) {
618
+ foreach ( $input['excl_url_del'] as $excl_url_del ) {
619
+ unset( $valid['excl_url'][$excl_url_del] );
620
+ }
621
+ }
622
+
623
+ /* Add a URL to Exclude from Privacy.
624
+ */
625
+ $url = jr_v1_sanitize_url( $input['excl_url_add'] );
626
+ if ( '' !== $url ) {
627
+ if ( FALSE === $url ) {
628
+ add_settings_error(
629
+ 'jr_ps_settings',
630
+ 'jr_ps_urlerror',
631
+ 'Always Visible URL is not a valid URL<br /><code>'
632
+ . sanitize_text_field( $input['excl_url_add'] ) . '</code>',
633
+ 'error'
634
+ );
635
+ } else {
636
+ if ( jr_ps_site_url( $url ) ) {
637
+ $valid['excl_url'][] = array( $url, jr_v1_prep_url( $url ) );
638
+ } else {
639
+ add_settings_error(
640
+ 'jr_ps_settings',
641
+ 'jr_ps_urlerror',
642
+ 'Error in Always Visible URL. It must point to someplace on this WordPress web site<br /><code>'
643
+ . sanitize_text_field( $input['excl_url_add'] ) . '</code>',
644
+ 'error'
645
+ );
646
+ }
647
+ }
648
+ }
649
+
650
+ $errors = get_settings_errors();
651
+ if ( empty( $errors ) ) {
652
+ add_settings_error(
653
+ 'jr_ps_settings',
654
+ 'jr_ps_saved',
655
+ 'Settings Saved',
656
+ 'updated'
657
+ );
658
+ }
659
+
660
+ return $valid;
661
+ }
662
+
663
+ ?>
includes/all-admin.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Loaded for all Admin panels.
4
+ */
5
+
6
+ // Exit if .php file accessed directly
7
+ if ( !defined( 'ABSPATH' ) ) exit;
8
+
9
+ $internal_settings = get_option( 'jr_ps_internal_settings' );
10
+ if ( isset( $internal_settings['warning_privacy'] ) ) {
11
+ add_action( 'all_admin_notices', 'jr_ps_warning_privacy' );
12
+ /**
13
+ * Warn that Private Site is turned OFF by default
14
+ *
15
+ * Put Warning on top of every Admin page (visible to Admins only)
16
+ * until Admin visits plugin's Settings page.
17
+ *
18
+ */
19
+ function jr_ps_warning_privacy() {
20
+ global $jr_ps_plugin_data;
21
+ if ( current_user_can( 'manage_options' ) ) {
22
+ echo '<div class="updated"><p><b>Private Site is currently turned off on ' . $jr_ps_plugin_data['Name'] . ' plugin <a href="'
23
+ . admin_url( 'options-general.php?page=jr_ps_settings' )
24
+ . '">Settings page</a>.</b></p></div>';
25
+ }
26
+ }
27
+ }
28
+
29
+ ?>
includes/common-functions.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* jonradio Common Functions,
3
+ intended for use in more than one jonradio plugin,
4
+ and others are encouraged to use for their own purposes.
5
+ See details below license.
6
+ */
7
+
8
+ /* Copyright 2013 jonradio (email : info@zatz.com)
9
+
10
+ This program is free software; you can redistribute it and/or modify
11
+ it under the terms of the GNU General Public License as published by
12
+ the Free Software Foundation; either version 2 of the License, or
13
+ (at your option) any later version.
14
+
15
+ This program is distributed in the hope that it will be useful,
16
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ GNU General Public License for more details.
19
+
20
+ You should have received a copy of the GNU General Public License
21
+ along with this program; if not, write to the Free Software
22
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
+ */
24
+
25
+ /* Concept and Usage
26
+ Each function name is prefixed with jr_v followed by a Version Number (integer) then another underscore
27
+ then the function name.
28
+ Each function is preceded by a check for previous existence,
29
+ so that multiple plugins can use the same function without generating duplicate function definition errors.
30
+ By incorporating the Version Number into the function name, there is no danger of a plugin using the wrong version.
31
+ Standard usage is to have all these functions stored in each plugin's folder as /includes/common-functions.php
32
+ Each function has its own Version Number, which only increases when the function actually changes;
33
+ which means that common-functions.php will normally include many different version numbers in its functions;
34
+ i.e. - the version number applies independently to each function, not to the common-functions.php file as a whole.
35
+ */
36
+
37
+ // Exit if .php file accessed directly
38
+ if ( !defined( 'ABSPATH' ) ) exit;
39
+
40
+ /**
41
+ * Do two URLs point at the same location on a web site?
42
+ *
43
+ * Preps URL, if string
44
+ *
45
+ * @param string/array $url1 URL to compare, a string, or an array in special format created by companion function
46
+ * @param string/array $url2 URL to compare, a string, or an array in special format created by companion function
47
+ * @return bool bool TRUE if both URLs point to the same place (page, etc.); FALSE otherwise
48
+ */
49
+ if ( !function_exists( 'jr_v1_same_url' ) ) {
50
+ function jr_v1_same_url( $url1, $url2 ) {
51
+ if ( !is_array( $url1 ) ) {
52
+ $url1 = jr_v1_prep_url( $url1 );
53
+ }
54
+ if ( !is_array( $url2 ) ) {
55
+ $url2 = jr_v1_prep_url( $url2 );
56
+ }
57
+ return ( $url1 == $url2 );
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Standardize a URL into an array of values that can be accurately compared with another
63
+ *
64
+ * Preps URL, by removing any UTF Left-to-right Mark (LRM), usually found as a suffix,
65
+ * translating the URL to lower-case, removing prefix http[s]//:[www.],
66
+ * any embedded index.php and any trailing slash or #bookmark,
67
+ * and breaks up ?keyword=value queries into array elements.
68
+ *
69
+ * @param string $url URL to create an array from, in special format for accurate comparison
70
+ * @return array array of standardized attributes of the URL
71
+ */
72
+ if ( !function_exists( 'jr_v1_prep_url' ) ) {
73
+ function jr_v1_prep_url( $url ) {
74
+ /* Handle troublesome %E2%80%8E UTF Left-to-right Mark (LRM) suffix first.
75
+ */
76
+ if ( FALSE === stripos( $url, '%E2%80%8E' ) ) {
77
+ if ( FALSE === stripos( rawurlencode( $url ), '%E2%80%8E' ) ) {
78
+ $url_clean = $url;
79
+ } else {
80
+ $url_clean = rawurldecode( str_ireplace( '%E2%80%8E', '', rawurlencode( $url ) ) );
81
+ }
82
+ } else {
83
+ $url_clean = str_ireplace( '%E2%80%8E', '', $url );
84
+ }
85
+ $url_clean = trim( $url_clean );
86
+
87
+ /* parse_url(), especially before php Version 5.4.7,
88
+ has a history of problems when Scheme is not present,
89
+ especially for LocalHost as a Host,
90
+ so add a prefix of http:// if :// is not found
91
+ */
92
+ if ( FALSE === strpos( $url_clean, '://' ) ) {
93
+ $url_clean = "http://$url_clean";
94
+ }
95
+
96
+ $parse_array = parse_url( mb_strtolower( $url_clean ) );
97
+ /* Get rid of URL components that do not matter to us in our comparison of URLs
98
+ */
99
+ foreach ( array( 'scheme', 'port', 'user', 'pass', 'fragment' ) as $component ) {
100
+ unset ( $parse_array[$component] );
101
+ }
102
+ /* Remove www. from host
103
+ */
104
+ if ( 'www.' === substr( $parse_array['host'], 0, 4 ) ) {
105
+ $parse_array['host'] = substr( $parse_array['host'], 4 );
106
+ }
107
+ if ( isset( $parse_array['path'] ) ) {
108
+ /* Remove any index.php occurences in path, since these can be spurious in IIS
109
+ and perhaps other environments.
110
+ */
111
+ $parse_array['path'] = str_replace( 'index.php', '', $parse_array['path'] );
112
+ /* Remove leading and trailing slashes from path
113
+ */
114
+ $parse_array['path'] = trim( $parse_array['path'], "/\\" );
115
+ /* Remove an empty Path component, or it won't array-match
116
+ */
117
+ if ( empty( $parse_array['path'] ) ) {
118
+ unset( $parse_array['path'] );
119
+ }
120
+ }
121
+ /* Take /?keyword=value&keyword=value URL query parameters
122
+ and break them up into array( keyword => value, keyword => value )
123
+ */
124
+ if ( isset( $parse_array['query'] ) ) {
125
+ $parms = explode( '&', $parse_array['query'] );
126
+ $parse_array['query'] = array();
127
+ foreach( $parms as $parm ) {
128
+ $split = explode( '=', $parm );
129
+ $parse_array['query'][$split[0]] = $split[1];
130
+ }
131
+ }
132
+ return $parse_array;
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Sanitize a URL
138
+ *
139
+ * Preps URL, by removing any UTF Left-to-right Mark (LRM), usually found as a suffix,
140
+ * and then checks if URL is blank.
141
+ *
142
+ * @param string $url URL
143
+ * @return string/bool Sanitized URL; bool FALSE if invalid URL;
144
+ * zero length string if URL not specified
145
+ */
146
+ if ( !function_exists( 'jr_v1_sanitize_url' ) ) {
147
+ function jr_v1_sanitize_url( $url ) {
148
+ /* Handle troublesome %E2%80%8E UTF Left-to-right Mark (LRM) suffix first.
149
+ */
150
+ if ( FALSE === stripos( $url, '%E2%80%8E' ) ) {
151
+ if ( FALSE === stripos( rawurlencode( $url ), '%E2%80%8E' ) ) {
152
+ $url_clean = $url;
153
+ } else {
154
+ $url_clean = rawurldecode( str_ireplace( '%E2%80%8E', '', rawurlencode( $url ) ) );
155
+ }
156
+ } else {
157
+ $url_clean = str_ireplace( '%E2%80%8E', '', $url );
158
+ }
159
+ $url_clean = trim( $url_clean );
160
+ if ( empty( $url_clean ) ) {
161
+ return '';
162
+ }
163
+ /* Add a prefix of http:// if :// is not found
164
+ and be sure scheme is http: or https:
165
+ */
166
+ if ( FALSE === strpos( $url_clean, '://' ) ) {
167
+ if ( is_ssl()
168
+ || ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
169
+ && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) ) {
170
+ $s = 's';
171
+ } else {
172
+ $s = '';
173
+ }
174
+ $url_clean = "http$s://$url_clean";
175
+ } else {
176
+ if ( !in_array( strtolower( parse_url( $url_clean, PHP_URL_SCHEME ) ), array( 'http', 'https' ) ) ) {
177
+ return FALSE;
178
+ }
179
+ }
180
+ return $url_clean;
181
+ }
182
+ }
183
+
184
+ ?>
includes/functions-admin.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Is the URL on the current WordPress web site?
5
+ *
6
+ * Checks if URL begins with Site Home URL.
7
+ * Strip http[s]://[www.] and leading and trailing blanks and convert to lower-case before comparing,
8
+ * to allow http, etc. to be omitted on entry
9
+ *
10
+ * @param string $url URL to be checked to be sure it is "on" the current WordPress web site
11
+ * @return bool bool TRUE if URL is on current WordPress web site; FALSE otherwise
12
+ */
13
+ function jr_ps_site_url( $url ) {
14
+ $site_home = jr_ps_urlcompare_prep( get_home_url() );
15
+ return ( substr( jr_ps_urlcompare_prep( $url ), 0, strlen( $site_home ) ) === $site_home );
16
+ }
17
+
18
+ /**
19
+ * Prepare a URL for comparison with another URL
20
+ *
21
+ * Strip [http[s]://][www.] and leading and trailing blanks, and convert to lower-case,
22
+ * to:
23
+ * (1) permit comparison of "synonym" URLs; and
24
+ * (2) allow http to be omitted when inputting a URL
25
+ *
26
+ * @param string $url URL to be prepped for comparison
27
+ * @return string URL prepped for comparison
28
+ */
29
+ function jr_ps_urlcompare_prep( $url ) {
30
+ $prep_url = strtolower( trim( $url ) );
31
+ if ( 'http' === substr( $prep_url, 0, 4 ) ) {
32
+ if ( 's' === substr( $prep_url, 4, 1 ) ) {
33
+ $cursor = 5; // Next character to look at in URL
34
+ } else {
35
+ $cursor = 4;
36
+ }
37
+ if ( '://' === substr( $prep_url, $cursor, 3 ) ) {
38
+ $cursor = $cursor + 3;
39
+ }
40
+ } else {
41
+ $cursor = 0;
42
+ }
43
+ if ( 'www.' === substr( $prep_url, $cursor, 4 ) ) {
44
+ $cursor = $cursor + 4;
45
+ }
46
+ return substr( $prep_url, $cursor );
47
+ }
48
+
49
+ ?>
includes/index.html ADDED
File without changes
includes/installed-plugins.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Initiated when in the Admin panels.
4
+ Used to handle the plugin's entry on the Install Plugins page.
5
+ */
6
+
7
+ /* Support WordPress Version 3.0.x before is_network_admin() existed
8
+ */
9
+ if ( function_exists( 'is_network_admin' ) && is_network_admin() ) {
10
+ // Add Link to the plugin's entry on the Network Admin "Plugins" Page, for easy access
11
+ add_filter( 'network_admin_plugin_action_links_' . jr_ps_plugin_basename(), 'jr_ps_plugin_network_action_links', 10, 1 );
12
+
13
+ /**
14
+ * Creates Settings link right on the Network Plugins Page entry.
15
+ *
16
+ * Helps the user understand where to go immediately upon Activation of the Plugin
17
+ * by creating entries on the Plugins page, right beside Deactivate and Edit.
18
+ *
19
+ * @param array $links Existing links for our Plugin, supplied by WordPress
20
+ * @param string $file Name of Plugin currently being processed
21
+ * @return string $links Updated set of links for our Plugin
22
+ */
23
+ function jr_ps_plugin_network_action_links( $links ) {
24
+ // The "page=" query string value must be equal to the slug
25
+ // of the Settings admin page.
26
+ array_push( $links, '<a href="' . get_bloginfo('wpurl') . '/wp-admin/network/settings.php?page=jr_ps_network_settings' . '">Settings</a>' );
27
+ return $links;
28
+ }
29
+ } else {
30
+ // Add Link to the plugin's entry on the Admin "Plugins" Page, for easy access
31
+ add_filter( 'plugin_action_links_' . jr_ps_plugin_basename(), 'jr_ps_plugin_action_links', 10, 1 );
32
+
33
+ if ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( jr_ps_plugin_basename() ) ) {
34
+ // Add entry for the plugin on the each site's Admin "Plugins" Page, when Network Activated and not normally shown
35
+ add_action( 'pre_current_active_plugins', 'jr_ps_show_plugin' );
36
+
37
+ function jr_ps_show_plugin() {
38
+ global $wp_list_table;
39
+ global $jr_ps_path;
40
+ $wp_list_table->items[jr_ps_plugin_basename()] = get_plugin_data( $jr_ps_path . basename( jr_ps_plugin_basename() ) );
41
+ uasort( $wp_list_table->items, 'jr_ps_sort_plugins' );
42
+ return;
43
+ }
44
+
45
+ function jr_ps_sort_plugins( $a, $b ) {
46
+ return strcasecmp( $a['Name'], $b['Name'] );
47
+ }
48
+
49
+ /**
50
+ * Creates Settings entry right on the Plugins Page entry.
51
+ *
52
+ * Helps the user understand where to go immediately upon Activation of the Plugin
53
+ * by creating entries on the Plugins page, right beside Deactivate and Edit.
54
+ *
55
+ * @param array $links Existing links for our Plugin, supplied by WordPress
56
+ * @param string $file Name of Plugin currently being processed
57
+ * @return string $links Updated set of links for our Plugin
58
+ */
59
+ function jr_ps_plugin_action_links( $links ) {
60
+ /* Delete existing Links and replace with "Network Activated" (not a link)
61
+ and "Settings" as a link to Plugin Settings page.
62
+ The "page=" query string value must be equal to the slug
63
+ of the Settings admin page.
64
+ */
65
+ return array( 'Network Activated',
66
+ '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=jr_ps_settings' . '">Settings</a>'
67
+ );
68
+ }
69
+ } else {
70
+ /**
71
+ * Creates Settings entry right on the Plugins Page entry.
72
+ *
73
+ * Helps the user understand where to go immediately upon Activation of the Plugin
74
+ * by creating entries on the Plugins page, right beside Deactivate and Edit.
75
+ *
76
+ * @param array $links Existing links for our Plugin, supplied by WordPress
77
+ * @param string $file Name of Plugin currently being processed
78
+ * @return string $links Updated set of links for our Plugin
79
+ */
80
+ function jr_ps_plugin_action_links( $links ) {
81
+ /* Add "Settings" to the end of existing Links
82
+ The "page=" query string value must be equal to the slug
83
+ of the Settings admin page.
84
+ */
85
+ array_push( $links, '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=jr_ps_settings' . '">Settings</a>' );
86
+ return $links;
87
+ }
88
+ }
89
+ }
90
+
91
+ ?>
includes/net-settings.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Initiated when in the Network Admin panels.
4
+ Used to create the Settings page for the plugin.
5
+ */
6
+
7
+ add_action( 'network_admin_menu', 'jr_ps_network_admin_hook' );
8
+ // Runs just after admin_init
9
+
10
+ /**
11
+ * Add Network Admin Menu item for plugin
12
+ *
13
+ * Plugin needs its own Page in the Settings section of the Network Admin menu.
14
+ *
15
+ */
16
+ function jr_ps_network_admin_hook() {
17
+ // Add Network Settings Page for this Plugin
18
+ global $jr_ps_plugin_data;
19
+ add_submenu_page( 'settings.php', $jr_ps_plugin_data['Name'], 'Private Sites', 'manage_network_options', 'jr_ps_network_settings', 'jr_ps_network_settings_page' );
20
+ }
21
+
22
+ /**
23
+ * Network Settings page for plugin
24
+ *
25
+ * Display and Process Settings page for this plugin.
26
+ *
27
+ */
28
+ function jr_ps_network_settings_page() {
29
+ global $jr_ps_plugin_data;
30
+ add_thickbox();
31
+ echo '<div class="wrap">';
32
+ screen_icon( 'plugins' );
33
+ echo '<h2>' . $jr_ps_plugin_data['Name'] . '</h2>';
34
+ ?>
35
+ <p>
36
+ This Plugin has been <b>Network Activated</b> in a WordPress Multisite ("Network") installation.
37
+ Since all of this plugin's Settings can be specified separately for each individual WordPress site,
38
+ you will need to go to the Admin pages for each Site,
39
+ and review the plugin's Settings page,
40
+ making changes appropriate for that Site.
41
+ The plugin's Settings page can be found by opening the <b>Settings</b> submenu on the left sidebar of each Admin page for the Site
42
+ and selecting <b>Private Site</b>.
43
+ Or from the <b>Settings</b> link in the plugin's entry on the <b>Installed Plugins</b> page for the Site
44
+ <i>(WordPress does not list Network Activated plugins on each Site's Installed Plugins page,
45
+ but this plugin has added its own entry for your convenience)</i>.
46
+ </p>
47
+ <p>
48
+ Alternatively, you can <b>Network Deactivate</b> this plugin
49
+ and <b>Activate</b> it individually on each Site where you wish to use it.
50
+ </p>
51
+ <p>
52
+ If you would prefer, when this plugin is Network Activated,
53
+ to have a single set of Settings that would apply to all Sites in a WordPress network,
54
+ and/or be able to view and change all of the Settings for all Sites from this one Network Settings page that you are now viewing,
55
+ <a href="http://zatzlabs.com/contact-us/">please contact the Plugin author</a>
56
+ and this will be added to a future version of this plugin if there is enough interest expressed by webmasters such as you.
57
+ </p>
58
+ <?php
59
+ }
60
+
61
+ ?>
includes/public.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Initiated when on the "public" web site,
4
+ i.e. - not an Admin panel.
5
+ */
6
+
7
+ // Exit if .php file accessed directly
8
+ if ( !defined( 'ABSPATH' ) ) exit;
9
+
10
+ add_action( 'login_init', 'jr_ps_login' );
11
+ add_action( 'wp', 'jr_ps_force_login' );
12
+
13
+ /**
14
+ * Login Detection
15
+ *
16
+ * Set a global variable, $jr_ps_is_login, whenever a login occurs
17
+ *
18
+ * @return NULL Nothing is returned
19
+ */
20
+ function jr_ps_login() {
21
+ global $jr_ps_is_login;
22
+ $jr_ps_is_login = TRUE;
23
+ }
24
+
25
+ /**
26
+ * Present a login screen to anyone not logged in
27
+ *
28
+ * Check for already logged in or just logged in.
29
+ * Only called when is_admin() is FALSE
30
+ *
31
+ * @return NULL Nothing is returned
32
+ */
33
+ function jr_ps_force_login() {
34
+ global $jr_ps_is_login;
35
+ if ( is_user_logged_in() || isset( $jr_ps_is_login ) ) {
36
+ return;
37
+ }
38
+
39
+ $settings = get_option( 'jr_ps_settings' );
40
+ /* URL of current page without http://, i.e. - starting with domain
41
+ */
42
+ $current_url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
43
+ if ( $settings['excl_home'] && jr_v1_same_url( get_home_url(), $current_url ) ) {
44
+ return;
45
+ }
46
+ if ( $settings['custom_login'] && !empty( $settings['login_url'] ) && jr_v1_same_url( $settings['login_url'], $current_url ) ) {
47
+ return;
48
+ }
49
+ if ( isset( $settings['excl_url'] ) ) {
50
+ foreach ( $settings['excl_url'] as $arr ) {
51
+ /* Test the pre-parsed URL in the URL Exclusion list
52
+ */
53
+ if ( jr_v1_same_url( $arr[1], $current_url ) ) {
54
+ return;
55
+ }
56
+ }
57
+ }
58
+
59
+ if ( $settings['reveal_registration'] ) {
60
+ $buddypress_path = 'buddypress/bp-loader.php';
61
+ $buddypress_active = is_plugin_active( $buddypress_path );
62
+ /* URL of Registration Page varies between Multisite (Network)
63
+ and Single Site WordPress.
64
+ Plus, wp_registration_url function was introduced in
65
+ WordPress Version 3.6.
66
+ */
67
+ if ( is_multisite() ) {
68
+ $reg_url = get_site_url( 0, 'wp-signup.php' );
69
+ $buddypress_active = $buddypress_active || is_plugin_active_for_network( $buddypress_path );
70
+ } else {
71
+ if ( function_exists( 'wp_registration_url' ) ) {
72
+ $reg_url = wp_registration_url();
73
+ } else {
74
+ $reg_url = get_site_url( 0, 'wp-login.php?action=register' );
75
+ }
76
+ }
77
+ if ( jr_v1_same_url( $reg_url, $current_url )
78
+ || ( $buddypress_active
79
+ && ( jr_v1_same_url( get_site_url( 0, 'register' ), $current_url )
80
+ || jr_v1_same_url( get_site_url( 0, 'activate' ),
81
+ parse_url( $current_url, PHP_URL_HOST )
82
+ . parse_url( $current_url, PHP_URL_PATH ) ) ) ) ) {
83
+ /* BuddyPress plugin redirects Registration URL to
84
+ either {current site}/register/ or {main site}/register/
85
+ and has its own Activation at /activate/?key=...
86
+ */
87
+ return;
88
+ }
89
+ }
90
+
91
+ /* Must exclude all of the pages generated by the Theme My Login plugin
92
+ */
93
+ $theme_my_login_path = 'theme-my-login/theme-my-login.php';
94
+ $theme_my_login_active = is_plugin_active( $theme_my_login_path );
95
+ if ( is_multisite() ) {
96
+ $theme_my_login_active = $theme_my_login_active || is_plugin_active_for_network( $theme_my_login_path );
97
+ }
98
+ if ( $theme_my_login_active ) {
99
+ if ( NULL !== ( $page = get_post( $null = NULL ) ) ) {
100
+ /* Some Versions of WordPress required that get_post() have a parameter
101
+ */
102
+ if ( ( 'page' === $page->post_type )
103
+ && in_array( $page->post_name, array( 'login', 'logout', 'lostpassword', 'register', 'resetpass' ) )
104
+ && stripos( $page->post_content, 'theme-my-login' ) ) {
105
+ return;
106
+ }
107
+ }
108
+ }
109
+
110
+ switch ( $settings['landing'] ) {
111
+ case 'return':
112
+ // $_SERVER['HTTPS'] can be off in IIS
113
+ if ( empty( $_SERVER['HTTPS'] ) || ( $_SERVER['HTTPS'] == 'off' ) ) {
114
+ $http = 'http://';
115
+ } else {
116
+ $http = 'https://';
117
+ }
118
+ $after_login_url = $http . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
119
+ break;
120
+ case 'home':
121
+ $after_login_url = get_home_url();
122
+ break;
123
+ case 'admin':
124
+ $after_login_url = get_admin_url();
125
+ break;
126
+ case 'url':
127
+ $after_login_url = trim( $settings['specific_url'] );
128
+ break;
129
+ case 'omit':
130
+ $after_login_url = '';
131
+ break;
132
+ }
133
+
134
+ if ( $settings['custom_login'] && !empty( $settings['login_url'] ) ) {
135
+ if ( empty( $after_login_url ) ) {
136
+ $url = $settings['login_url'];
137
+ } else {
138
+ $url = add_query_arg( 'redirect_to', $after_login_url, $settings['login_url'] );
139
+ }
140
+ } else {
141
+ /* Avoid situations where specific URL is requested,
142
+ but URL is blank.
143
+ */
144
+ if ( empty( $after_login_url ) ) {
145
+ $url = wp_login_url();
146
+ } else {
147
+ $url = wp_login_url( $after_login_url );
148
+ }
149
+ }
150
+
151
+ /* Next line:
152
+ wp_redirect( $url ) goes to $url right after exit on the line that follows;
153
+ wp_login_url() returns the standard WordPress login URL;
154
+ $after_login_url is the URL passed to the standard WordPress login URL,
155
+ via the ?redirect_to= URL query parameter, to go to after login is complete.
156
+ */
157
+ wp_redirect( $url );
158
+ exit;
159
+ }
160
+
161
+ ?>
index.html ADDED
File without changes
jonradio-private-site.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: jonradio Private Site
4
+ Plugin URI: http://zatzlabs.com/plugins/
5
+ Description: Creates a Private Site by allowing only those logged on to view the WordPress web site. Settings select the initial destination after login.
6
+ Version: 2.7
7
+ Author: David Gewirtz
8
+ Author URI: http://zatzlabs.com/plugins/
9
+ License: GPLv2
10
+ */
11
+
12
+ /* Copyright 2013 jonradio (email : info@zatz.com)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+
29
+ /* Exit if .php file accessed directly
30
+ */
31
+ if ( !defined( 'ABSPATH' ) ) exit;
32
+
33
+ global $jr_ps_path;
34
+ $jr_ps_path = plugin_dir_path( __FILE__ );
35
+ /**
36
+ * Return Plugin's full directory path with trailing slash
37
+ *
38
+ * Local XAMPP install might return:
39
+ * C:\xampp\htdocs\wpbeta\wp-content\plugins\jonradio-private-site/
40
+ *
41
+ */
42
+ function jr_ps_path() {
43
+ global $jr_ps_path;
44
+ return $jr_ps_path;
45
+ }
46
+
47
+ global $jr_ps_plugin_basename;
48
+ $jr_ps_plugin_basename = plugin_basename( __FILE__ );
49
+ /**
50
+ * Return Plugin's Basename
51
+ *
52
+ * For this plugin, it would be:
53
+ * jonradio-multiple-themes/jonradio-multiple-themes.php
54
+ *
55
+ */
56
+ function jr_ps_plugin_basename() {
57
+ global $jr_ps_plugin_basename;
58
+ return $jr_ps_plugin_basename;
59
+ }
60
+
61
+ if ( !function_exists( 'get_plugin_data' ) ) {
62
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
63
+ }
64
+
65
+ global $jr_ps_plugin_data;
66
+ $jr_ps_plugin_data = get_plugin_data( __FILE__ );
67
+ $jr_ps_plugin_data['slug'] = basename( dirname( __FILE__ ) );
68
+
69
+ /* Detect initial activation or a change in plugin's Version number
70
+
71
+ Sometimes special processing is required when the plugin is updated to a new version of the plugin.
72
+ Also used in place of standard activation and new site creation exits provided by WordPress.
73
+ Once that is complete, update the Version number in the plugin's Network-wide settings.
74
+ */
75
+
76
+ if ( ( FALSE === ( $internal_settings = get_option( 'jr_ps_internal_settings' ) ) )
77
+ || empty( $internal_settings['version'] ) )
78
+ {
79
+ /* Plugin is either:
80
+ - updated from a version so old that Version was not yet stored in the plugin's settings, or
81
+ - first use after install:
82
+ - first time ever installed, or
83
+ - installed previously and properly uninstalled (data deleted)
84
+ */
85
+
86
+ $old_version = '0.1';
87
+ } else {
88
+ $old_version = $internal_settings['version'];
89
+ }
90
+
91
+ $settings = get_option( 'jr_ps_settings' );
92
+ if ( empty( $settings ) ) {
93
+ $settings = array(
94
+ 'private_site' => FALSE,
95
+ 'reveal_registration' => TRUE,
96
+ 'landing' => 'return',
97
+ 'specific_url' => '',
98
+ 'custom_login' => FALSE,
99
+ 'login_url' => '',
100
+ 'excl_url' => array(),
101
+ 'excl_home' => FALSE
102
+ );
103
+ /* Add if Settings don't exist, re-initialize if they were empty.
104
+ */
105
+ update_option( 'jr_ps_settings', $settings );
106
+ /* New install on this site, old version or corrupt settings
107
+ */
108
+ $old_version = $jr_ps_plugin_data['Version'];
109
+ }
110
+
111
+ if ( version_compare( $old_version, $jr_ps_plugin_data['Version'], '!=' ) ) {
112
+ /* Create, if internal settings do not exist; update if they do exist
113
+ */
114
+ $internal_settings['version'] = $jr_ps_plugin_data['Version'];
115
+ if ( version_compare( $old_version, '2', '<' ) ) {
116
+ /* Previous versions turned Privacy on at Activation;
117
+ Now it is a Setting on the Settings page,
118
+ so warn Admin.
119
+ */
120
+ $internal_settings['warning_privacy'] = TRUE;
121
+ }
122
+ update_option( 'jr_ps_internal_settings', $internal_settings );
123
+
124
+ /* Handle all Settings changes made in old plugin versions
125
+ */
126
+ if ( version_compare( $old_version, '2.1', '<' ) ) {
127
+ $settings['reveal_registration'] = FALSE;
128
+ }
129
+ if ( version_compare( $old_version, '2.3', '<' ) ) {
130
+ $settings['excl_home'] = FALSE;
131
+ }
132
+ if ( version_compare( $old_version, '2.5', '<' ) ) {
133
+ $settings['excl_url'] = array();
134
+ }
135
+ if ( version_compare( $old_version, '2.7', '<' ) ) {
136
+ $settings['custom_login'] = FALSE;
137
+ $settings['login_url'] = '';
138
+ }
139
+ update_option( 'jr_ps_settings', $settings );
140
+ }
141
+
142
+ require_once( jr_ps_path() . 'includes/common-functions.php' );
143
+ if ( is_admin() ) {
144
+ require_once( jr_ps_path() . 'includes/all-admin.php' );
145
+ /* Support WordPress Version 3.0.x before is_network_admin() existed
146
+ */
147
+ if ( function_exists( 'is_network_admin' ) && is_network_admin() ) {
148
+ // Network Admin pages in Network/Multisite install
149
+ if ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( jr_ps_plugin_basename() ) ) {
150
+ // Network Admin Settings page for Plugin
151
+ require_once( jr_ps_path() . 'includes/net-settings.php' );
152
+ }
153
+ } else {
154
+ // Regular (non-Network) Admin pages
155
+ // Settings page for Plugin
156
+ require_once( jr_ps_path() . 'includes/admin-settings.php' );
157
+ }
158
+ // All changes to all Admin-Installed Plugins pages
159
+ require_once( jr_ps_path() . 'includes/installed-plugins.php' );
160
+ } else {
161
+ /* Public WordPress content, i.e. - not Admin pages
162
+ Do nothing if Private Site setting not set by Administrator
163
+ */
164
+ if ( $settings['private_site'] ) {
165
+ // Private Site code
166
+ require_once( jr_ps_path() . 'includes/public.php' );
167
+ }
168
+ }
169
+
170
+ /* Documentation of Research Done for this Plugin:
171
+ Registration URL (based on a root install in http://localhost):
172
+ WordPress 3.6.1 without jonradio Private Site installed
173
+ Single Site - not a network
174
+ http://localhost/wp-login.php?action=register
175
+ Primary Site of a Network
176
+ http://localhost/wp-signup.php
177
+ Secondary Site of a Network
178
+ http://localhost/wp-signup.php
179
+ This last URL needs a lot of thought because it means that what begins on one site ends up on another.
180
+
181
+ WordPress 3.7-beta without jonradio Private Site installed
182
+ Single Site - not a network
183
+ http://localhost/wp-login.php?action=register
184
+ Primary Site of a Network
185
+ http://localhost/wp-signup.php
186
+ Secondary Site of a Network
187
+ http://localhost/wp-signup.php
188
+
189
+ WordPress 3.0.0 without jonradio Private Site installed
190
+ Single Site - not a network
191
+ http://localhost/wp-login.php?action=register
192
+ Primary Site of a Network
193
+ http://localhost/wp-signup.php
194
+ Secondary Site of a Network
195
+ http://localhost/wp-signup.php
196
+
197
+ wp_registration_url() was not available prior to WordPress Version 3.6.0
198
+
199
+ Self-Registration allows potential Users to Register their own ID and Password without Administrator intervention or knowledge.
200
+ It is controlled by:
201
+ get_option( 'users_can_register' ) - non-Network
202
+ '1' - allows Self-Registration
203
+ '0' - no Self-Registration
204
+ get_site_option( 'registration' ) - Network (Multisite)
205
+ 'user' - allows Self-Registration
206
+ 'none' - no Self-Registration
207
+ 'blog' - Users can create new Sites in a Network
208
+ 'all' - allows Self-Registration and the creation of new Sites in a Network
209
+ */
210
+
211
+ ?>
readme.txt ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === jonradio Private Site ===
2
+ Contributors: dgewirtz
3
+ Donate link: http://zatzlabs.com/plugins/
4
+ Tags: login, visibility, private, security, plugin, pages, page, posts, post
5
+ Requires at least: 3.0
6
+ Tested up to: 3.8
7
+ Stable tag: 2.7
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Create a Private Site visible only to your registered users.
12
+
13
+ == Description ==
14
+
15
+ Allows the Administrator to restrict a WordPress-based web site to viewing only by registered users who are logged on. Any attempt, by anyone not logged, to view any Page, Post or other part of the site will display a WordPress login screen.
16
+
17
+ Login prompts are provided whenever a non-logged in user ("site visitor") attempts to access any URL controlled by WordPress on the web site. This plugin does not control non-WordPress web pages, such as .html and .php files created by hand or by other software products. Or images and other media and text files directly accessed by their URL, or from a browser's directory view, if available.
18
+
19
+ Features and Settings:
20
+
21
+ * Supports WordPress Networks ("Multisite"), with Network-wide Settings planned for a future version
22
+ * Visible Exclusions settings allow the entry of a list of URLs that will always be visible, and never be hidden by the plugin; a separate Setting is provided for hiding or revealing Site Home without the need to enter its URL
23
+ * Supports Custom Login and Registration pages at URLs different than the standard WordPress Login and Registration URLs
24
+ * Landing Location settings determine what the User sees after successfully logging in
25
+ * User Self-Registration settings (varies between Network and Non-Network WordPress) are presented on the plugin's Settings page for easy access
26
+ * No known Theme incompatibilities, and only known Plugin incompatibility is with the A5 Custom Login plugin
27
+ * Special functionality is included to not hide Login- and Registration-related URLs used by BuddyPress and Theme My Login plugins
28
+ * Remember Me improvements at Login via free companion plugin, jonradio Remember Me, which can be downloaded separately from the WordPress Plugin Repository
29
+ * Overrides WordPress hiding of Network Activated plugins, just for itself; tp provide this feature for all plugins, use the free companion plugin, jonradio Reveal Network Activated Plugins, which can be downloaded separately from the WordPress Plugin Repository
30
+ * Setting to disable the plugin so that other plugin Settings can be changed when the Site is not set to Private
31
+
32
+ If you allow Self-Registration, where new Users can Register themselves, you will need to select the "Reveal User Registration Page" setting or new Users will be blocked from seeing the WordPress Registration screen (on WordPress Networks, turning off the Reveal User Registration Page setting on the "Main Site" will prevent Registration from all Sites). For convenience, the WordPress Setting that controls Self-Registration of Users has been added to the Plugin's Settings page.
33
+
34
+ Another Setting allows the Private Site feature to be turned off. When the plugin is installed and activated, the Private Site feature is set off by default, to allow the Administrator an opportunity to become familiarized with the plugin's features and to set the desired settings. A warning that the site is not private appears after first activation of the plugin until the Administrator visits the plugin's Settings page.
35
+
36
+ If a WordPress Network is defined, the plugin can be activated individually for select sites. Or Network Activated. In either case, each site will have its own Settings page where the Private Site feature can be turned off (default) or on for just the one site, and a Landing Location defined for each site.
37
+
38
+ Yes, there are other plugins that hide some or all WordPress content for any site visitor who is not logged on. But when I was searching for a solution for one of the web sites I support, I decided to "write my own" because I knew how it worked and felt comfortable that there would be no way for anyone not logged in to view the site, including Search Engines.
39
+
40
+ == Installation ==
41
+
42
+ This section describes how to install the *jonradio Private Site* plugin and get it working.
43
+
44
+ 1. Use **Add Plugin** within the WordPress Admin panel to download and install this *jonradio Private Site* plugin from the WordPress.org plugin repository (preferred method). Or download and unzip this plugin, then upload the `/jonradio-private-site/` directory to your WordPress web site's `/wp-content/plugins/` directory
45
+ 1. Activate the *jonradio Private Site* plugin through the **Installed Plugins** Admin panel in WordPress. If you have a WordPress Network ("Multisite"), you can either **Network Activate** this plugin, or Activate it individually on the sites where you wish to use it.
46
+ 1. Go to the plugin's Settings page to make the Site **Private**, and set where the user ends up after logging in: the **Landing Location**.
47
+ 1. If you allow Self-Registration, where new Users can set up their own User Name on your WordPress site or Network, you will want to select **Reveal User Registration Page** on the plugin's Settings page.
48
+
49
+ == Frequently Asked Questions ==
50
+
51
+ = How do I fix Redirect Loops (browser cycles for a long time then gives up)? =
52
+
53
+ By far, the most common way to create a Redirect Loop on your browser with this *jonradio Private Site* plugin is to specify both Custom Login page and Landing Location on the plugin's Settings page. Simply setting "Where to after Login?" in the Landing Location section to "Omit ?redirect_to= from URL" should correct the problem.
54
+
55
+ This problem has been observed when the URL of the Custom Login page is a WordPress Page. It occurs because, for Page URLs, WordPress uses the ?redirect_to= Query keyword for purposes other than a Landing Location.
56
+
57
+ = What happened? I changed my Permalinks and now some things don't work. =
58
+
59
+ Whenever you change your WordPress Permalinks (Settings-Permalinks in Admin panels), this *jonradio Private Site* plugin does **not** automatically change any URLs you have entered in the plugin's Settings. You will therefore want to make changes to URLs in the plugin's Settings whenever you change Permalinks.
60
+
61
+ == Changelog ==
62
+
63
+ = 2.7 =
64
+ * Add Custom Login URL setting
65
+
66
+ = 2.6.1 =
67
+ * Older versions of WordPress require a parameter be passed to get_post()
68
+
69
+ = 2.6 =
70
+ * Detect and make visible Login-associated Pages created by the Theme My Login plugin
71
+
72
+ = 2.5 =
73
+ * Allow other URLs to be Always Visible with new Setting
74
+
75
+ = 2.4.2 =
76
+ * Reveal BuddyPress /activate/ Activation page when Reveal Registration selected
77
+
78
+ = 2.4.1 =
79
+ * Fix bug in URL matching for Root, where one URL has a trailing slash and the other does not
80
+
81
+ = 2.4 =
82
+ * Handle BuddyPress' redirection of Register URL in Reveal Registration
83
+
84
+ = 2.3 =
85
+ * Add Setting to Reveal Home Page on a Private Site
86
+ * Fixed Problems with wp_registration_url function in WordPress prior to Version 3.6
87
+
88
+ = 2.2 =
89
+ * Add the WordPress User Self-Registration field to the plugin's Settings page
90
+ * Add the Settings page to the User submenu of Admin panel, too
91
+
92
+ = 2.1 =
93
+ * Add a settings checkbox to reveal the Register page for User Self-Registration
94
+
95
+ = 2.0 =
96
+ * Add Settings page, specifying Landing Location and turning Private Site off and on
97
+ * Warning for new default of OFF for Private Site until Settings are first viewed
98
+ * Add Networking Settings information page
99
+ * Track plugin version number in internal settings
100
+ * Replace WordPress Activation/Deactivation hooks with Version checking code from jonradio Multiple Themes
101
+ * Add Plugin entry on individual sites when plugin is Network Activated, and Settings link on all Plugin entries
102
+
103
+ = 1.1 =
104
+ * Change Action Hook to 'wp' from 'wp_head' to avoid Modify Header errors when certain other plugins are present
105
+
106
+ = 1.0 =
107
+ * Add readme.txt and screenshots
108
+ * Add in-line documentation for php functions
109
+
110
+ == Upgrade Notice ==
111
+
112
+ = 2.7 =
113
+ Support Custom Login page
114
+
115
+ = 2.6.1 =
116
+ Support Theme My Login plugin with older versions of WordPress
117
+
118
+ = 2.6 =
119
+ Support Theme My Login plugin
120
+
121
+ = 2.5 =
122
+ Allow many Always Visible pages
123
+
124
+ = 2.4.2 =
125
+ Reveal BuddyPress Activation page
126
+
127
+ = 2.4.1 =
128
+ Home Page better URL matching for Root Home Pages
129
+
130
+ = 2.4 =
131
+ Support BuddyPress
132
+
133
+ = 2.3 =
134
+ New Setting to display Home Page on a Private Site.
135
+
136
+ = 2.2 =
137
+ Display WordPress Self-Registration field on plugin Settings page.
138
+
139
+ = 2.1 =
140
+ Allow User Self-Registration by "revealing" the Register page to those not logged in.
141
+
142
+ = 2.0 =
143
+ Create a Settings page that defines where the user ends up after logging in
144
+
145
+ = 1.1 =
146
+ Should eliminate Modify Header errors due to conflict with other plugins
147
+
148
+ = 1.0 =
149
+ Production version, updated to meet WordPress Repository standards
uninstall.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Ensure call comes from WordPress, not a hacker or anyone else trying direct access.
3
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
4
+ exit ();
5
+
6
+
7
+ /* Remove any tables, options, and such created by this Plugin */
8
+ if ( function_exists('is_multisite') && is_multisite() ) {
9
+ global $wpdb, $site_id;
10
+ $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = $site_id" );
11
+ foreach ($blogs as $blog_obj) {
12
+ delete_blog_option( $blog_obj->blog_id, 'jr_ps_settings' );
13
+ delete_blog_option( $blog_obj->blog_id, 'jr_ps_internal_settings' );
14
+ }
15
+ } else {
16
+ delete_option( 'jr_ps_settings' );
17
+ delete_option( 'jr_ps_internal_settings' );
18
+ }
19
+ ?>