Version Description
- Use Grunt to manage assets.
- Network settings added for management of entire network visibility settings.
- Display warning if page caching is enabled.
Note: There is currently an edge case bug affecting IP whitelisting. This bug is on the docket to be fixed shortly.
Download this release
Release Info
Developer | tlovett1 |
Plugin | Restricted Site Access |
Version | 6.0 |
Comparing to | |
See all releases |
Code changes from version 5.1 to 6.0
- assets/js/admin.min.js +1 -0
- assets/js/settings.min.js +1 -0
- assets/js/src/admin.js +28 -0
- assets/js/src/settings.js +146 -0
- localization/restricted-site-access-es_ES.po +279 -111
- localization/restricted-site-access.pot +282 -0
- readme.txt +16 -5
- restricted-site-access.dev.js +0 -146
- restricted-site-access.js +0 -1
- restricted_site_access.php +554 -172
assets/js/admin.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(a,b){"use strict";b(".notice").on("click",".notice-dismiss",function(a){a.delegateTarget.getAttribute("data-rsa-notice")&&b.ajax({method:"post",data:{nonce:rsaAdmin.nonce,action:"rsa_notice_dismiss"},url:ajaxurl})})}(window,jQuery);
|
assets/js/settings.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(a,b){"use strict";function c(a){if(""==b.trim(a))return!1;e.add_btn.attr("disabled","disabled");var c=b(d.querySelectorAll("#ip_list input")),f=0;for(c.length;f<c.length;f++)if(c[f].value==a)return b(c[f]).parent().effect("shake",600),e.add_btn.removeAttr("disabled"),!1;jQuery.post(ajaxurl,{action:"rsa_ip_check",ip_address:a},function(c){if(c)return b(e.new_ip.parentNode).effect("shake",600),e.add_btn.removeAttr("disabled"),!1;var d=e.empty_ip.clone().appendTo(e.ip_list_wrap);return d.children("input").val(a),d.removeAttr("id").slideDown(250),a==e.new_ip.value&&b(e.new_ip).val(""),e.add_btn.removeAttr("disabled"),!0})}var d=a.document,e={add_btn:"",new_ip:"",ip_list_wrap:"",empty_ip:"",restrict_radio:"",table:"",redirect_choice:"",message_choice:"",page_choice:"",redirect_fields:"",message_field:"",page_field:""};!function(){e.add_btn=b(d.getElementById("addip")),e.new_ip=d.getElementById("newip"),e.ip_list_wrap=d.getElementById("ip_list"),e.empty_ip=b(d.getElementById("ip_list_empty")),e.restrict_radio=d.getElementById("blog-restricted"),e.table=b(d.getElementById("rsa-send-to-login")).closest("table"),e.redirect_choice=d.getElementById("rsa-redirect-visitor"),e.message_choice=d.getElementById("rsa-display-message"),e.page_choice=d.getElementById("rsa-unblocked-page"),e.redirect_fields=b(d.querySelectorAll(".rsa_redirect_field")).closest("tr"),e.message_field=b(d.getElementById("rsa_message")).closest("tr"),e.page_field=b(d.getElementById("rsa_page")).closest("tr"),e.restrict_radio&&!e.restrict_radio.checked&&e.table.hide(),e.redirect_choice&&!e.redirect_choice.checked&&e.redirect_fields.hide(),e.message_choice&&!e.message_choice.checked&&e.message_field.hide(),e.page_choice&&!e.page_choice.checked&&e.page_field.hide(),b(d.querySelectorAll("#rsa_handle_fields input")).on("change",function(){e.redirect_choice.checked?e.redirect_fields.show():e.redirect_fields.hide(),e.message_choice.checked?e.message_field.show():e.message_field.hide(),e.page_choice.checked?e.page_field.show():e.page_field.hide()}),b(d.querySelectorAll(".option-site-visibility input")).on("change",function(){e.restrict_radio.checked?e.table.show():e.table.hide()}),e.add_btn.on("click",function(){c(e.new_ip.value)});var a=d.getElementById("rsa_myip");null!==a&&b(a).on("click",function(){c(b(this).data("myip"))}),b(e.ip_list_wrap).on("click",".remove_btn",function(){b(this.parentNode).slideUp(250,function(){b(this).remove()})})}()}(window,jQuery);
|
assets/js/src/admin.js
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* 10up
|
3 |
+
* http://10up.com
|
4 |
+
*
|
5 |
+
* Copyright (c) 2013 10up, jakemgold
|
6 |
+
* Licensed under the GPLv2+ license.
|
7 |
+
*/
|
8 |
+
( function ( window, $ ) {
|
9 |
+
|
10 |
+
'use strict';
|
11 |
+
|
12 |
+
$( '.notice' ).on( 'click', '.notice-dismiss', function( event ) {
|
13 |
+
var notice = event.delegateTarget.getAttribute( 'data-rsa-notice' );
|
14 |
+
|
15 |
+
if ( ! notice ) {
|
16 |
+
return;
|
17 |
+
}
|
18 |
+
|
19 |
+
$.ajax( {
|
20 |
+
method: 'post',
|
21 |
+
data: {
|
22 |
+
nonce: rsaAdmin.nonce,
|
23 |
+
action: 'rsa_notice_dismiss'
|
24 |
+
},
|
25 |
+
url: ajaxurl
|
26 |
+
} );
|
27 |
+
} );
|
28 |
+
} )( window, jQuery );
|
assets/js/src/settings.js
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* 10up
|
3 |
+
* http://10up.com
|
4 |
+
*
|
5 |
+
* Copyright (c) 2013 10up, jakemgold
|
6 |
+
* Licensed under the GPLv2+ license.
|
7 |
+
*/
|
8 |
+
(function (window, $) {
|
9 |
+
|
10 |
+
'use strict';
|
11 |
+
var document = window.document;
|
12 |
+
|
13 |
+
var Cache = {
|
14 |
+
add_btn : '',
|
15 |
+
new_ip : '',
|
16 |
+
ip_list_wrap : '',
|
17 |
+
empty_ip : '',
|
18 |
+
restrict_radio : '',
|
19 |
+
table : '',
|
20 |
+
redirect_choice : '',
|
21 |
+
message_choice : '',
|
22 |
+
page_choice : '',
|
23 |
+
redirect_fields : '',
|
24 |
+
message_field : '',
|
25 |
+
page_field : ''
|
26 |
+
};
|
27 |
+
|
28 |
+
function init() {
|
29 |
+
|
30 |
+
Cache.add_btn = $( document.getElementById( 'addip' ) );
|
31 |
+
Cache.new_ip = document.getElementById( 'newip' );
|
32 |
+
Cache.ip_list_wrap = document.getElementById( 'ip_list' );
|
33 |
+
Cache.empty_ip = $( document.getElementById( 'ip_list_empty' ) );
|
34 |
+
Cache.restrict_radio = document.getElementById( 'blog-restricted' );
|
35 |
+
Cache.table = $( document.getElementById( 'rsa-send-to-login' ) ).closest( 'table' );
|
36 |
+
Cache.redirect_choice = document.getElementById( 'rsa-redirect-visitor' );
|
37 |
+
Cache.message_choice = document.getElementById( 'rsa-display-message' );
|
38 |
+
Cache.page_choice = document.getElementById( 'rsa-unblocked-page' );
|
39 |
+
Cache.redirect_fields = $( document.querySelectorAll( '.rsa_redirect_field' ) ).closest( 'tr' );
|
40 |
+
Cache.message_field = $( document.getElementById( 'rsa_message' ) ).closest( 'tr' );
|
41 |
+
Cache.page_field = $( document.getElementById( 'rsa_page' ) ).closest( 'tr' );
|
42 |
+
|
43 |
+
if ( Cache.restrict_radio && ! Cache.restrict_radio.checked ) {
|
44 |
+
Cache.table.hide();
|
45 |
+
}
|
46 |
+
|
47 |
+
if ( Cache.redirect_choice && ! Cache.redirect_choice.checked ) {
|
48 |
+
Cache.redirect_fields.hide();
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( Cache.message_choice && ! Cache.message_choice.checked ) {
|
52 |
+
Cache.message_field.hide();
|
53 |
+
}
|
54 |
+
|
55 |
+
if ( Cache.page_choice && ! Cache.page_choice.checked ) {
|
56 |
+
Cache.page_field.hide();
|
57 |
+
}
|
58 |
+
|
59 |
+
$( document.querySelectorAll( '#rsa_handle_fields input' ) ).on('change',function(){
|
60 |
+
|
61 |
+
if ( Cache.redirect_choice.checked ) {
|
62 |
+
Cache.redirect_fields.show();
|
63 |
+
} else {
|
64 |
+
Cache.redirect_fields.hide();
|
65 |
+
}
|
66 |
+
|
67 |
+
if ( Cache.message_choice.checked ) {
|
68 |
+
Cache.message_field.show();
|
69 |
+
} else {
|
70 |
+
Cache.message_field.hide();
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( Cache.page_choice.checked ) {
|
74 |
+
Cache.page_field.show();
|
75 |
+
} else {
|
76 |
+
Cache.page_field.hide();
|
77 |
+
}
|
78 |
+
|
79 |
+
});
|
80 |
+
|
81 |
+
$( document.querySelectorAll( '.option-site-visibility input' ) ).on('change',function(){
|
82 |
+
if ( Cache.restrict_radio.checked ) {
|
83 |
+
Cache.table.show();
|
84 |
+
} else {
|
85 |
+
Cache.table.hide();
|
86 |
+
}
|
87 |
+
});
|
88 |
+
|
89 |
+
Cache.add_btn.on('click',function(){
|
90 |
+
add_ip( Cache.new_ip.value );
|
91 |
+
});
|
92 |
+
|
93 |
+
var myip_btn = document.getElementById( 'rsa_myip' );
|
94 |
+
if ( null !== myip_btn ) {
|
95 |
+
$( myip_btn ).on('click',function(){
|
96 |
+
add_ip( $( this ).data( 'myip' ) );
|
97 |
+
});
|
98 |
+
}
|
99 |
+
|
100 |
+
$( Cache.ip_list_wrap ).on('click', '.remove_btn', function(){
|
101 |
+
$( this.parentNode ).slideUp( 250, function(){ $( this ).remove(); } );
|
102 |
+
});
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
function add_ip( ip ) {
|
107 |
+
if ( $.trim( ip ) == '' ) {
|
108 |
+
return false;
|
109 |
+
}
|
110 |
+
|
111 |
+
var shake_speed = 600;
|
112 |
+
|
113 |
+
Cache.add_btn.attr( 'disabled', 'disabled' );
|
114 |
+
var ip_list = $( document.querySelectorAll( '#ip_list input' ) );
|
115 |
+
|
116 |
+
for ( var i = 0, l = ip_list.length; i < ip_list.length; i++ ) {
|
117 |
+
if ( ip_list[i].value == ip ) {
|
118 |
+
$( ip_list[i] ).parent().effect( 'shake', shake_speed );
|
119 |
+
Cache.add_btn.removeAttr( 'disabled' );
|
120 |
+
return false;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
jQuery.post( ajaxurl, { action: 'rsa_ip_check', 'ip_address': ip }, function(response) {
|
125 |
+
if ( response ) {
|
126 |
+
$( Cache.new_ip.parentNode ).effect( 'shake', shake_speed );
|
127 |
+
Cache.add_btn.removeAttr( 'disabled' );
|
128 |
+
return false;
|
129 |
+
} else {
|
130 |
+
var new_ip = Cache.empty_ip.clone().appendTo( Cache.ip_list_wrap );
|
131 |
+
new_ip.children( 'input' ).val( ip );
|
132 |
+
new_ip.removeAttr( 'id' ).slideDown( 250 );
|
133 |
+
|
134 |
+
if ( ip == Cache.new_ip.value ) {
|
135 |
+
$( Cache.new_ip ).val( '' );
|
136 |
+
}
|
137 |
+
Cache.add_btn.removeAttr( 'disabled' );
|
138 |
+
|
139 |
+
return true;
|
140 |
+
}
|
141 |
+
} );
|
142 |
+
}
|
143 |
+
|
144 |
+
init();
|
145 |
+
|
146 |
+
})(window,jQuery);
|
localization/restricted-site-access-es_ES.po
CHANGED
@@ -3,196 +3,364 @@
|
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: Restricted Site Access\n"
|
6 |
-
"Report-Msgid-Bugs-To:
|
7 |
-
"
|
|
|
8 |
"PO-Revision-Date: 2011-07-16 16:00-0500\n"
|
9 |
"Last-Translator: Jake Goldman <jake@get10up.com>\n"
|
10 |
"Language-Team: 10up <jake@get10up.com>\n"
|
|
|
11 |
"MIME-Version: 1.0\n"
|
12 |
"Content-Type: text/plain; charset=UTF-8\n"
|
13 |
"Content-Transfer-Encoding: 8bit\n"
|
14 |
|
15 |
-
#: restricted_site_access.php:
|
16 |
-
#: restricted_site_access.php:266
|
17 |
-
msgid "Access to this site is restricted."
|
18 |
-
msgstr "El acceso a este sitio está restringido."
|
19 |
-
|
20 |
-
#: restricted_site_access.php:142
|
21 |
-
#: restricted_site_access.php:316
|
22 |
msgid "Handle restricted visitors"
|
23 |
msgstr "Manejar visitantes restringido"
|
24 |
|
25 |
-
#: restricted_site_access.php:
|
26 |
msgid "Restriction message"
|
27 |
msgstr "Restricción mensaje"
|
28 |
|
29 |
-
#: restricted_site_access.php:
|
30 |
-
#: restricted_site_access.php:321
|
31 |
msgid "Redirect web address"
|
32 |
msgstr "Reorientar dirección web"
|
33 |
|
34 |
-
#: restricted_site_access.php:
|
35 |
-
#: restricted_site_access.php:322
|
36 |
-
msgid "Redirect to same path"
|
37 |
-
msgstr "Redirigir a mismo camino"
|
38 |
-
|
39 |
-
#: restricted_site_access.php:146
|
40 |
-
#: restricted_site_access.php:323
|
41 |
msgid "Redirection status code"
|
42 |
msgstr "Redirección código de estatus"
|
43 |
|
44 |
-
#: restricted_site_access.php:
|
45 |
msgid "Restricted notice page"
|
46 |
msgstr "Página nota restringido"
|
47 |
|
48 |
-
#: restricted_site_access.php:
|
49 |
msgid "Unrestricted IP addresses"
|
50 |
msgstr "Direcciones IP sin restricciones"
|
51 |
|
52 |
-
#: restricted_site_access.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
msgid "Public access to this site has been restricted."
|
54 |
msgstr "Acceso público a este sitio ha sido restringido."
|
55 |
|
56 |
-
#: restricted_site_access.php:
|
57 |
msgid "Restricted Site Access plug-in is blocking public access to this site."
|
58 |
-
msgstr "
|
|
|
59 |
|
60 |
-
#: restricted_site_access.php:
|
61 |
-
msgid "
|
62 |
-
|
|
|
|
|
63 |
|
64 |
-
#: restricted_site_access.php:
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
|
69 |
-
#: restricted_site_access.php:
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
-
#: restricted_site_access.php:
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
76 |
|
77 |
-
#: restricted_site_access.php:
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
-
#: restricted_site_access.php:
|
82 |
-
|
83 |
-
|
|
|
84 |
|
85 |
-
#: restricted_site_access.php:
|
86 |
-
msgid "
|
87 |
-
|
|
|
|
|
|
|
|
|
88 |
|
89 |
-
#: restricted_site_access.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
msgid "Send them to the WordPress login screen"
|
91 |
msgstr "Enviar a la pantalla de login de WordPress"
|
92 |
|
93 |
-
#: restricted_site_access.php:
|
94 |
msgid "Redirect them to a specified web address"
|
95 |
msgstr "Redirigir a una dirección web especificada"
|
96 |
|
97 |
-
#: restricted_site_access.php:
|
98 |
msgid "Show them a simple message"
|
99 |
msgstr "Mostrarles un mensaje simple"
|
100 |
|
101 |
-
#: restricted_site_access.php:
|
102 |
-
|
103 |
-
|
|
|
104 |
|
105 |
-
#: restricted_site_access.php:
|
106 |
-
|
|
|
107 |
msgstr "añadir"
|
108 |
|
109 |
-
#: restricted_site_access.php:
|
110 |
msgid "Enter a single IP address or a range using a subnet prefix"
|
111 |
msgstr "Especificar una única dirección IP o un rango con un prefijo de subred"
|
112 |
|
113 |
-
#: restricted_site_access.php:
|
114 |
-
|
115 |
-
|
116 |
-
msgid "help"
|
117 |
-
msgstr "ayuda"
|
118 |
-
|
119 |
-
#: restricted_site_access.php:257
|
120 |
-
msgid "add my current IP address"
|
121 |
msgstr "añadir mi dirección IP actual"
|
122 |
|
123 |
-
#: restricted_site_access.php:
|
124 |
msgid "To manage IP addresses, you must use a JavaScript enabled browser."
|
125 |
-
msgstr "
|
|
|
|
|
126 |
|
127 |
-
#: restricted_site_access.php:
|
128 |
-
msgid "
|
129 |
-
msgstr "
|
130 |
|
131 |
-
#: restricted_site_access.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
msgid "301 Permanent"
|
133 |
msgstr "301 Permanente"
|
134 |
|
135 |
-
#: restricted_site_access.php:
|
136 |
msgid "302 Undefined"
|
137 |
msgstr "302 Indefinido"
|
138 |
|
139 |
-
#: restricted_site_access.php:
|
140 |
msgid "307 Temporary"
|
141 |
msgstr "307 Temporario"
|
142 |
|
143 |
-
#: restricted_site_access.php:
|
144 |
-
msgid "
|
145 |
-
msgstr "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
-
|
148 |
-
msgid "
|
149 |
-
msgstr "
|
150 |
|
151 |
-
|
152 |
-
msgid "
|
153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
-
|
156 |
-
msgid "
|
157 |
-
msgstr "
|
158 |
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
msgid "Allowed IP addresses"
|
161 |
msgstr "Direcciones IP permitidas"
|
162 |
|
163 |
-
#: restricted_site_access.php:
|
164 |
-
|
165 |
-
|
|
|
|
|
166 |
|
167 |
-
#: restricted_site_access.php:
|
168 |
-
|
169 |
-
|
|
|
|
|
170 |
|
171 |
-
#: restricted_site_access.php:
|
172 |
-
|
173 |
-
|
|
|
|
|
174 |
|
175 |
-
#: restricted_site_access.php:
|
176 |
-
|
177 |
-
|
|
|
|
|
178 |
|
179 |
-
#: restricted_site_access.php:
|
180 |
-
|
181 |
-
|
|
|
|
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
msgstr "la dirección Web del sitio que desea que el visitante la redirección."
|
186 |
|
187 |
-
|
188 |
-
|
189 |
-
msgstr "redirigir al visitante en el mismo camino (URI), entró en este sitio. Normalmente se usa cuando hay dos, los sitios muy similar en las diferentes direcciones de Internet públicas, por ejemplo, un servidor de desarrollo paralelo accesible en Internet, pero no destinados al público."
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
msgstr "redirigir los códigos de estado puede ofrecer a los visitantes algunos, en particular los motores de búsqueda, más información sobre la naturaleza de la redirección. Una redirección 301 le dice a los motores de búsqueda que una página se ha movido permanentemente a la nueva ubicación. 307 indica una redirección temporal. 302 es una redirección indefinido."
|
194 |
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
|
|
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: Restricted Site Access\n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/"
|
7 |
+
"restricted_site_access\n"
|
8 |
+
"POT-Creation-Date: 2016-03-29 01:22:24+00:00\n"
|
9 |
"PO-Revision-Date: 2011-07-16 16:00-0500\n"
|
10 |
"Last-Translator: Jake Goldman <jake@get10up.com>\n"
|
11 |
"Language-Team: 10up <jake@get10up.com>\n"
|
12 |
+
"Language: \n"
|
13 |
"MIME-Version: 1.0\n"
|
14 |
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
|
17 |
+
#: restricted_site_access.php:121 restricted_site_access.php:372
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
msgid "Handle restricted visitors"
|
19 |
msgstr "Manejar visitantes restringido"
|
20 |
|
21 |
+
#: restricted_site_access.php:126 restricted_site_access.php:404
|
22 |
msgid "Restriction message"
|
23 |
msgstr "Restricción mensaje"
|
24 |
|
25 |
+
#: restricted_site_access.php:131 restricted_site_access.php:380
|
|
|
26 |
msgid "Redirect web address"
|
27 |
msgstr "Reorientar dirección web"
|
28 |
|
29 |
+
#: restricted_site_access.php:141 restricted_site_access.php:396
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
msgid "Redirection status code"
|
31 |
msgstr "Redirección código de estatus"
|
32 |
|
33 |
+
#: restricted_site_access.php:146
|
34 |
msgid "Restricted notice page"
|
35 |
msgstr "Página nota restringido"
|
36 |
|
37 |
+
#: restricted_site_access.php:151 restricted_site_access.php:412
|
38 |
msgid "Unrestricted IP addresses"
|
39 |
msgstr "Direcciones IP sin restricciones"
|
40 |
|
41 |
+
#: restricted_site_access.php:333
|
42 |
+
#, fuzzy
|
43 |
+
msgid "Restricted Site Access Settings"
|
44 |
+
msgstr "Página nota restringido"
|
45 |
+
|
46 |
+
#: restricted_site_access.php:336 restricted_site_access.php:339
|
47 |
+
msgid "Mode"
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: restricted_site_access.php:340
|
51 |
+
msgid "<strong>Default</strong> to the settings below when creating a new site"
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: restricted_site_access.php:341
|
55 |
+
msgid "<strong>Enforce</strong> the settings below across all sites"
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
+
#: restricted_site_access.php:346 restricted_site_access.php:356
|
59 |
+
msgid "Site Visibility"
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: restricted_site_access.php:358
|
63 |
+
msgid "Allow search engines to index this site"
|
64 |
+
msgstr ""
|
65 |
+
|
66 |
+
#: restricted_site_access.php:360
|
67 |
+
msgid "Discourage search engines from indexing this site"
|
68 |
+
msgstr ""
|
69 |
+
|
70 |
+
#: restricted_site_access.php:361
|
71 |
+
msgid ""
|
72 |
+
"Note: Neither of these options blocks access to your site — it is up to "
|
73 |
+
"search engines to honor your request."
|
74 |
+
msgstr ""
|
75 |
+
|
76 |
+
#: restricted_site_access.php:364 restricted_site_access.php:650
|
77 |
+
msgid ""
|
78 |
+
"Restrict site access to visitors who are logged in or allowed by IP address"
|
79 |
+
msgstr ""
|
80 |
+
"Restringir acceso al sitio a los visitantes que están registrado o "
|
81 |
+
"autorizados por dirección IP"
|
82 |
+
|
83 |
+
#: restricted_site_access.php:388
|
84 |
+
msgid "Redirect to same path"
|
85 |
+
msgstr "Redirigir a mismo camino"
|
86 |
+
|
87 |
+
#: restricted_site_access.php:462
|
88 |
msgid "Public access to this site has been restricted."
|
89 |
msgstr "Acceso público a este sitio ha sido restringido."
|
90 |
|
91 |
+
#: restricted_site_access.php:476
|
92 |
msgid "Restricted Site Access plug-in is blocking public access to this site."
|
93 |
+
msgstr ""
|
94 |
+
"Restricted Site Access plug-in está bloqueando acceso público a este sitio."
|
95 |
|
96 |
+
#: restricted_site_access.php:532
|
97 |
+
msgid ""
|
98 |
+
"Network visibility settings are currently enforced across all blogs on the "
|
99 |
+
"network."
|
100 |
+
msgstr ""
|
101 |
|
102 |
+
#: restricted_site_access.php:542
|
103 |
+
msgid ""
|
104 |
+
"Please select the page you want to show restricted visitors. If no page is "
|
105 |
+
"selected, WordPress will simply show a general restriction message."
|
106 |
+
msgstr ""
|
107 |
+
"Por favor, seleccione la página que desea mostrar a los visitantes "
|
108 |
+
"restringido. Si no se selecciona la página, WordPress, simplemente se "
|
109 |
+
"mostrará un mensaje de restricción general."
|
110 |
|
111 |
+
#: restricted_site_access.php:544
|
112 |
+
#, fuzzy
|
113 |
+
msgid ""
|
114 |
+
"Please enter the web address you would like to redirect restricted visitors "
|
115 |
+
"to. If no address is entered, visitors will be redirected to the login "
|
116 |
+
"screen."
|
117 |
+
msgstr ""
|
118 |
+
"Por favor, introduzca la dirección Web que desee redirigir a los visitantes "
|
119 |
+
"a restriced. Si no se introduce la dirección, los visitantes va a ser "
|
120 |
+
"redirigido a la pantalla de inicio de sesión."
|
121 |
+
|
122 |
+
#: restricted_site_access.php:583
|
123 |
+
msgid ""
|
124 |
+
"Page caching appears to be enabled. Restricted Site Access may not work as "
|
125 |
+
"expected. <a href=\"https://wordpress.org/plugins/restricted-site-access/#faq"
|
126 |
+
"\">Learn more</a>."
|
127 |
+
msgstr ""
|
128 |
|
129 |
+
#: restricted_site_access.php:601
|
130 |
+
#, fuzzy
|
131 |
+
msgid ""
|
132 |
+
"Choose the method for handling visitors to your site that are restricted."
|
133 |
+
msgstr ""
|
134 |
+
"elegir el método para el manejo de los visitantes de su sitio web que se "
|
135 |
+
"encuentran restringidas."
|
136 |
|
137 |
+
#: restricted_site_access.php:607
|
138 |
+
#, fuzzy
|
139 |
+
msgid ""
|
140 |
+
"enter a single IP address (for example, 192.168.1.105) or an IP range using "
|
141 |
+
"a network prefix (for example, 10.0.0.1/24). Enter your addresses carefully!"
|
142 |
+
msgstr ""
|
143 |
+
"especificar una única dirección IP (por ejemplo, 192.168.1.105) o un rango "
|
144 |
+
"de IP con un prefijo de red (por ejemplo, 10.0.0.1/24). Ingrese su dirección "
|
145 |
+
"con cuidado! Aquí hay una"
|
146 |
|
147 |
+
#: restricted_site_access.php:611
|
148 |
+
#, fuzzy
|
149 |
+
msgid "Here is a handy calculator to check your prefix."
|
150 |
+
msgstr "para comprobar su prefijo."
|
151 |
|
152 |
+
#: restricted_site_access.php:613
|
153 |
+
msgid ""
|
154 |
+
"The redirection fields are only used when \"Handle restricted visitors\" is "
|
155 |
+
"set to \"Redirect them to a specified web address\"."
|
156 |
+
msgstr ""
|
157 |
+
"Los campos de redirección se utiliza sólo cuando \"Manejar visitantes "
|
158 |
+
"restringido\" se pone en \"Redirigir a una dirección web especificada\"."
|
159 |
|
160 |
+
#: restricted_site_access.php:619
|
161 |
+
#, fuzzy
|
162 |
+
msgid "The web address of the site you want the visitor redirected to."
|
163 |
+
msgstr "la dirección Web del sitio que desea que el visitante la redirección."
|
164 |
+
|
165 |
+
#: restricted_site_access.php:625
|
166 |
+
msgid ""
|
167 |
+
"redirect the visitor to the same path (URI) entered at this site. Typically "
|
168 |
+
"used when there are two, very similar sites at different public web "
|
169 |
+
"addresses; for instance, a parallel development server accessible on the "
|
170 |
+
"Internet but not intended for the public."
|
171 |
+
msgstr ""
|
172 |
+
"redirigir al visitante en el mismo camino (URI), entró en este sitio. "
|
173 |
+
"Normalmente se usa cuando hay dos, los sitios muy similar en las diferentes "
|
174 |
+
"direcciones de Internet públicas, por ejemplo, un servidor de desarrollo "
|
175 |
+
"paralelo accesible en Internet, pero no destinados al público."
|
176 |
+
|
177 |
+
#: restricted_site_access.php:631
|
178 |
+
#, fuzzy
|
179 |
+
msgid ""
|
180 |
+
"Redirect status codes can provide certain visitors, particularly search "
|
181 |
+
"engines, more information about the nature of the redirect. A 301 redirect "
|
182 |
+
"tells search engines that a page has moved permanently to the new location. "
|
183 |
+
"307 indicates a temporary redirect. 302 is an undefined redirect."
|
184 |
+
msgstr ""
|
185 |
+
"redirigir los códigos de estado puede ofrecer a los visitantes algunos, en "
|
186 |
+
"particular los motores de búsqueda, más información sobre la naturaleza de "
|
187 |
+
"la redirección. Una redirección 301 le dice a los motores de búsqueda que "
|
188 |
+
"una página se ha movido permanentemente a la nueva ubicación. 307 indica una "
|
189 |
+
"redirección temporal. 302 es una redirección indefinido."
|
190 |
+
|
191 |
+
#: restricted_site_access.php:700
|
192 |
msgid "Send them to the WordPress login screen"
|
193 |
msgstr "Enviar a la pantalla de login de WordPress"
|
194 |
|
195 |
+
#: restricted_site_access.php:703
|
196 |
msgid "Redirect them to a specified web address"
|
197 |
msgstr "Redirigir a una dirección web especificada"
|
198 |
|
199 |
+
#: restricted_site_access.php:706
|
200 |
msgid "Show them a simple message"
|
201 |
msgstr "Mostrarles un mensaje simple"
|
202 |
|
203 |
+
#: restricted_site_access.php:711
|
204 |
+
#, fuzzy
|
205 |
+
msgid "Show them a page"
|
206 |
+
msgstr "Mostrarles un mensaje simple"
|
207 |
|
208 |
+
#: restricted_site_access.php:737
|
209 |
+
#, fuzzy
|
210 |
+
msgid "Add"
|
211 |
msgstr "añadir"
|
212 |
|
213 |
+
#: restricted_site_access.php:738
|
214 |
msgid "Enter a single IP address or a range using a subnet prefix"
|
215 |
msgstr "Especificar una única dirección IP o un rango con un prefijo de subred"
|
216 |
|
217 |
+
#: restricted_site_access.php:740
|
218 |
+
#, fuzzy
|
219 |
+
msgid "Add My Current IP Address"
|
|
|
|
|
|
|
|
|
|
|
220 |
msgstr "añadir mi dirección IP actual"
|
221 |
|
222 |
+
#: restricted_site_access.php:742
|
223 |
msgid "To manage IP addresses, you must use a JavaScript enabled browser."
|
224 |
+
msgstr ""
|
225 |
+
"Para administrar las direcciones IP, debe utilizar un buscador compatible "
|
226 |
+
"con JavaScript."
|
227 |
|
228 |
+
#: restricted_site_access.php:753
|
229 |
+
msgid "Access to this site is restricted."
|
230 |
+
msgstr "El acceso a este sitio está restringido."
|
231 |
|
232 |
+
#: restricted_site_access.php:791
|
233 |
+
msgid ""
|
234 |
+
"Send restricted visitor to same path (relative URL) at the new web address"
|
235 |
+
msgstr ""
|
236 |
+
"Enviar visitante restringido a mismo camino (URL relativa) en la nueva "
|
237 |
+
"dirección web"
|
238 |
+
|
239 |
+
#: restricted_site_access.php:807
|
240 |
msgid "301 Permanent"
|
241 |
msgstr "301 Permanente"
|
242 |
|
243 |
+
#: restricted_site_access.php:808
|
244 |
msgid "302 Undefined"
|
245 |
msgstr "302 Indefinido"
|
246 |
|
247 |
+
#: restricted_site_access.php:809
|
248 |
msgid "307 Temporary"
|
249 |
msgstr "307 Temporario"
|
250 |
|
251 |
+
#: restricted_site_access.php:826
|
252 |
+
msgid "Select a page"
|
253 |
+
msgstr ""
|
254 |
+
|
255 |
+
#: restricted_site_access.php:878
|
256 |
+
msgid "Settings"
|
257 |
+
msgstr "Configuración"
|
258 |
+
|
259 |
+
#. Plugin Name of the plugin/theme
|
260 |
+
#, fuzzy
|
261 |
+
msgid "Restricted Site Access"
|
262 |
+
msgstr "Página nota restringido"
|
263 |
|
264 |
+
#. Plugin URI of the plugin/theme
|
265 |
+
msgid "http://10up.com/plugins/restricted-site-access-wordpress/"
|
266 |
+
msgstr ""
|
267 |
|
268 |
+
#. Description of the plugin/theme
|
269 |
+
msgid ""
|
270 |
+
"<strong>Limit access your site</strong> to visitors who are logged in or "
|
271 |
+
"accessing the site from a set of specific IP addresses. Send restricted "
|
272 |
+
"visitors to the log in page, redirect them, or display a message or page. "
|
273 |
+
"<strong>Powerful control over redirection</strong>, including <strong>SEO "
|
274 |
+
"friendly redirect headers</strong>. Great solution for Extranets, publicly "
|
275 |
+
"hosted Intranets, or parallel development sites."
|
276 |
+
msgstr ""
|
277 |
|
278 |
+
#. Author of the plugin/theme
|
279 |
+
msgid "Jake Goldman, 10up, Oomph"
|
280 |
+
msgstr ""
|
281 |
|
282 |
+
#. Author URI of the plugin/theme
|
283 |
+
msgid "http://10up.com"
|
284 |
+
msgstr ""
|
285 |
+
|
286 |
+
#: restricted_site_access.php:125
|
287 |
+
#, fuzzy
|
288 |
+
msgctxt "default restriction message"
|
289 |
+
msgid "Access to this site is restricted."
|
290 |
+
msgstr "El acceso a este sitio está restringido."
|
291 |
+
|
292 |
+
#: restricted_site_access.php:600
|
293 |
+
#, fuzzy
|
294 |
+
msgctxt "help topic"
|
295 |
+
msgid "Handle restricted visitors"
|
296 |
+
msgstr "Manejar visitantes restringido"
|
297 |
+
|
298 |
+
#: restricted_site_access.php:606
|
299 |
+
#, fuzzy
|
300 |
+
msgctxt "help topic"
|
301 |
msgid "Allowed IP addresses"
|
302 |
msgstr "Direcciones IP permitidas"
|
303 |
|
304 |
+
#: restricted_site_access.php:618
|
305 |
+
#, fuzzy
|
306 |
+
msgctxt "help topic"
|
307 |
+
msgid "Redirect web address"
|
308 |
+
msgstr "Reorientar dirección web"
|
309 |
|
310 |
+
#: restricted_site_access.php:624
|
311 |
+
#, fuzzy
|
312 |
+
msgctxt "help topic"
|
313 |
+
msgid "Redirect to the same path"
|
314 |
+
msgstr "Redirigir a mismo camino"
|
315 |
|
316 |
+
#: restricted_site_access.php:630
|
317 |
+
#, fuzzy
|
318 |
+
msgctxt "help topic"
|
319 |
+
msgid "Redirection status code"
|
320 |
+
msgstr "Redirección código de estatus"
|
321 |
|
322 |
+
#: restricted_site_access.php:636
|
323 |
+
#, fuzzy
|
324 |
+
msgctxt "help screen title"
|
325 |
+
msgid "Restricted Site Acccess"
|
326 |
+
msgstr "Página nota restringido"
|
327 |
|
328 |
+
#: restricted_site_access.php:726 restricted_site_access.php:731
|
329 |
+
#, fuzzy
|
330 |
+
msgctxt "remove IP address action"
|
331 |
+
msgid "Remove"
|
332 |
+
msgstr "eliminar"
|
333 |
|
334 |
+
#~ msgid "Click \"Save Changes\" to save this IP address."
|
335 |
+
#~ msgstr "Clic en \"Guardar cambios\" para guardar esta dirección IP."
|
|
|
336 |
|
337 |
+
#~ msgid "confirm removal"
|
338 |
+
#~ msgstr "confirmar eliminación"
|
|
|
339 |
|
340 |
+
#~ msgid "cancel"
|
341 |
+
#~ msgstr "cancelar"
|
|
|
342 |
|
343 |
+
#~ msgid "Show them a specific WordPress page I've created"
|
344 |
+
#~ msgstr "Muéstrales una determinada página de WordPress que he creado"
|
345 |
+
|
346 |
+
#~ msgid "help"
|
347 |
+
#~ msgstr "ayuda"
|
348 |
+
|
349 |
+
#~ msgid "HTTP status code sent to browser"
|
350 |
+
#~ msgstr "Código de estado HTTP envía al navegador"
|
351 |
+
|
352 |
+
#~ msgid "is a plug-in by"
|
353 |
+
#~ msgstr "es un plug-in de"
|
354 |
+
|
355 |
+
#~ msgid ""
|
356 |
+
#~ "that allows you to restrict access to logged in users and a set of IP "
|
357 |
+
#~ "addresses."
|
358 |
+
#~ msgstr ""
|
359 |
+
#~ "que le permite restringir el acceso a usuarios registrados y un conjunto "
|
360 |
+
#~ "de direcciones IP."
|
361 |
+
|
362 |
+
#~ msgid "handy calculator"
|
363 |
+
#~ msgstr "práctica calculadora"
|
364 |
|
365 |
+
#~ msgid "Redirection Options"
|
366 |
+
#~ msgstr "Opciones de Redirección"
|
localization/restricted-site-access.pot
ADDED
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2017 Jake Goldman, 10up, Oomph
|
2 |
+
# This file is distributed under the GPLv2 or later.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Restricted Site Access 6.0\n"
|
6 |
+
"Report-Msgid-Bugs-To: "
|
7 |
+
"https://wordpress.org/support/plugin/restricted_site_access\n"
|
8 |
+
"POT-Creation-Date: 2016-03-29 01:22:24+00:00\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=utf-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
|
13 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
+
"X-Generator: grunt-wp-i18n 0.5.4\n"
|
16 |
+
|
17 |
+
#: restricted_site_access.php:121 restricted_site_access.php:372
|
18 |
+
msgid "Handle restricted visitors"
|
19 |
+
msgstr ""
|
20 |
+
|
21 |
+
#: restricted_site_access.php:126 restricted_site_access.php:404
|
22 |
+
msgid "Restriction message"
|
23 |
+
msgstr ""
|
24 |
+
|
25 |
+
#: restricted_site_access.php:131 restricted_site_access.php:380
|
26 |
+
msgid "Redirect web address"
|
27 |
+
msgstr ""
|
28 |
+
|
29 |
+
#: restricted_site_access.php:141 restricted_site_access.php:396
|
30 |
+
msgid "Redirection status code"
|
31 |
+
msgstr ""
|
32 |
+
|
33 |
+
#: restricted_site_access.php:146
|
34 |
+
msgid "Restricted notice page"
|
35 |
+
msgstr ""
|
36 |
+
|
37 |
+
#: restricted_site_access.php:151 restricted_site_access.php:412
|
38 |
+
msgid "Unrestricted IP addresses"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: restricted_site_access.php:333
|
42 |
+
msgid "Restricted Site Access Settings"
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: restricted_site_access.php:336 restricted_site_access.php:339
|
46 |
+
msgid "Mode"
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#: restricted_site_access.php:340
|
50 |
+
msgid "<strong>Default</strong> to the settings below when creating a new site"
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: restricted_site_access.php:341
|
54 |
+
msgid "<strong>Enforce</strong> the settings below across all sites"
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: restricted_site_access.php:346 restricted_site_access.php:356
|
58 |
+
msgid "Site Visibility"
|
59 |
+
msgstr ""
|
60 |
+
|
61 |
+
#: restricted_site_access.php:358
|
62 |
+
msgid "Allow search engines to index this site"
|
63 |
+
msgstr ""
|
64 |
+
|
65 |
+
#: restricted_site_access.php:360
|
66 |
+
msgid "Discourage search engines from indexing this site"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: restricted_site_access.php:361
|
70 |
+
msgid ""
|
71 |
+
"Note: Neither of these options blocks access to your site — it is up to "
|
72 |
+
"search engines to honor your request."
|
73 |
+
msgstr ""
|
74 |
+
|
75 |
+
#: restricted_site_access.php:364 restricted_site_access.php:650
|
76 |
+
msgid "Restrict site access to visitors who are logged in or allowed by IP address"
|
77 |
+
msgstr ""
|
78 |
+
|
79 |
+
#: restricted_site_access.php:388
|
80 |
+
msgid "Redirect to same path"
|
81 |
+
msgstr ""
|
82 |
+
|
83 |
+
#: restricted_site_access.php:462
|
84 |
+
msgid "Public access to this site has been restricted."
|
85 |
+
msgstr ""
|
86 |
+
|
87 |
+
#: restricted_site_access.php:476
|
88 |
+
msgid "Restricted Site Access plug-in is blocking public access to this site."
|
89 |
+
msgstr ""
|
90 |
+
|
91 |
+
#: restricted_site_access.php:532
|
92 |
+
msgid ""
|
93 |
+
"Network visibility settings are currently enforced across all blogs on the "
|
94 |
+
"network."
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: restricted_site_access.php:542
|
98 |
+
msgid ""
|
99 |
+
"Please select the page you want to show restricted visitors. If no page is "
|
100 |
+
"selected, WordPress will simply show a general restriction message."
|
101 |
+
msgstr ""
|
102 |
+
|
103 |
+
#: restricted_site_access.php:544
|
104 |
+
msgid ""
|
105 |
+
"Please enter the web address you would like to redirect restricted visitors "
|
106 |
+
"to. If no address is entered, visitors will be redirected to the login "
|
107 |
+
"screen."
|
108 |
+
msgstr ""
|
109 |
+
|
110 |
+
#: restricted_site_access.php:583
|
111 |
+
msgid ""
|
112 |
+
"Page caching appears to be enabled. Restricted Site Access may not work as "
|
113 |
+
"expected. <a "
|
114 |
+
"href=\"https://wordpress.org/plugins/restricted-site-access/#faq\">Learn "
|
115 |
+
"more</a>."
|
116 |
+
msgstr ""
|
117 |
+
|
118 |
+
#: restricted_site_access.php:601
|
119 |
+
msgid "Choose the method for handling visitors to your site that are restricted."
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: restricted_site_access.php:607
|
123 |
+
msgid ""
|
124 |
+
"enter a single IP address (for example, 192.168.1.105) or an IP range using "
|
125 |
+
"a network prefix (for example, 10.0.0.1/24). Enter your addresses carefully!"
|
126 |
+
msgstr ""
|
127 |
+
|
128 |
+
#: restricted_site_access.php:611
|
129 |
+
msgid "Here is a handy calculator to check your prefix."
|
130 |
+
msgstr ""
|
131 |
+
|
132 |
+
#: restricted_site_access.php:613
|
133 |
+
msgid ""
|
134 |
+
"The redirection fields are only used when \"Handle restricted visitors\" is "
|
135 |
+
"set to \"Redirect them to a specified web address\"."
|
136 |
+
msgstr ""
|
137 |
+
|
138 |
+
#: restricted_site_access.php:619
|
139 |
+
msgid "The web address of the site you want the visitor redirected to."
|
140 |
+
msgstr ""
|
141 |
+
|
142 |
+
#: restricted_site_access.php:625
|
143 |
+
msgid ""
|
144 |
+
"redirect the visitor to the same path (URI) entered at this site. Typically "
|
145 |
+
"used when there are two, very similar sites at different public web "
|
146 |
+
"addresses; for instance, a parallel development server accessible on the "
|
147 |
+
"Internet but not intended for the public."
|
148 |
+
msgstr ""
|
149 |
+
|
150 |
+
#: restricted_site_access.php:631
|
151 |
+
msgid ""
|
152 |
+
"Redirect status codes can provide certain visitors, particularly search "
|
153 |
+
"engines, more information about the nature of the redirect. A 301 redirect "
|
154 |
+
"tells search engines that a page has moved permanently to the new location. "
|
155 |
+
"307 indicates a temporary redirect. 302 is an undefined redirect."
|
156 |
+
msgstr ""
|
157 |
+
|
158 |
+
#: restricted_site_access.php:700
|
159 |
+
msgid "Send them to the WordPress login screen"
|
160 |
+
msgstr ""
|
161 |
+
|
162 |
+
#: restricted_site_access.php:703
|
163 |
+
msgid "Redirect them to a specified web address"
|
164 |
+
msgstr ""
|
165 |
+
|
166 |
+
#: restricted_site_access.php:706
|
167 |
+
msgid "Show them a simple message"
|
168 |
+
msgstr ""
|
169 |
+
|
170 |
+
#: restricted_site_access.php:711
|
171 |
+
msgid "Show them a page"
|
172 |
+
msgstr ""
|
173 |
+
|
174 |
+
#: restricted_site_access.php:737
|
175 |
+
msgid "Add"
|
176 |
+
msgstr ""
|
177 |
+
|
178 |
+
#: restricted_site_access.php:738
|
179 |
+
msgid "Enter a single IP address or a range using a subnet prefix"
|
180 |
+
msgstr ""
|
181 |
+
|
182 |
+
#: restricted_site_access.php:740
|
183 |
+
msgid "Add My Current IP Address"
|
184 |
+
msgstr ""
|
185 |
+
|
186 |
+
#: restricted_site_access.php:742
|
187 |
+
msgid "To manage IP addresses, you must use a JavaScript enabled browser."
|
188 |
+
msgstr ""
|
189 |
+
|
190 |
+
#: restricted_site_access.php:753
|
191 |
+
msgid "Access to this site is restricted."
|
192 |
+
msgstr ""
|
193 |
+
|
194 |
+
#: restricted_site_access.php:791
|
195 |
+
msgid "Send restricted visitor to same path (relative URL) at the new web address"
|
196 |
+
msgstr ""
|
197 |
+
|
198 |
+
#: restricted_site_access.php:807
|
199 |
+
msgid "301 Permanent"
|
200 |
+
msgstr ""
|
201 |
+
|
202 |
+
#: restricted_site_access.php:808
|
203 |
+
msgid "302 Undefined"
|
204 |
+
msgstr ""
|
205 |
+
|
206 |
+
#: restricted_site_access.php:809
|
207 |
+
msgid "307 Temporary"
|
208 |
+
msgstr ""
|
209 |
+
|
210 |
+
#: restricted_site_access.php:826
|
211 |
+
msgid "Select a page"
|
212 |
+
msgstr ""
|
213 |
+
|
214 |
+
#: restricted_site_access.php:878
|
215 |
+
msgid "Settings"
|
216 |
+
msgstr ""
|
217 |
+
|
218 |
+
#. Plugin Name of the plugin/theme
|
219 |
+
msgid "Restricted Site Access"
|
220 |
+
msgstr ""
|
221 |
+
|
222 |
+
#. Plugin URI of the plugin/theme
|
223 |
+
msgid "http://10up.com/plugins/restricted-site-access-wordpress/"
|
224 |
+
msgstr ""
|
225 |
+
|
226 |
+
#. Description of the plugin/theme
|
227 |
+
msgid ""
|
228 |
+
"<strong>Limit access your site</strong> to visitors who are logged in or "
|
229 |
+
"accessing the site from a set of specific IP addresses. Send restricted "
|
230 |
+
"visitors to the log in page, redirect them, or display a message or page. "
|
231 |
+
"<strong>Powerful control over redirection</strong>, including <strong>SEO "
|
232 |
+
"friendly redirect headers</strong>. Great solution for Extranets, publicly "
|
233 |
+
"hosted Intranets, or parallel development sites."
|
234 |
+
msgstr ""
|
235 |
+
|
236 |
+
#. Author of the plugin/theme
|
237 |
+
msgid "Jake Goldman, 10up, Oomph"
|
238 |
+
msgstr ""
|
239 |
+
|
240 |
+
#. Author URI of the plugin/theme
|
241 |
+
msgid "http://10up.com"
|
242 |
+
msgstr ""
|
243 |
+
|
244 |
+
#: restricted_site_access.php:125
|
245 |
+
msgctxt "default restriction message"
|
246 |
+
msgid "Access to this site is restricted."
|
247 |
+
msgstr ""
|
248 |
+
|
249 |
+
#: restricted_site_access.php:600
|
250 |
+
msgctxt "help topic"
|
251 |
+
msgid "Handle restricted visitors"
|
252 |
+
msgstr ""
|
253 |
+
|
254 |
+
#: restricted_site_access.php:606
|
255 |
+
msgctxt "help topic"
|
256 |
+
msgid "Allowed IP addresses"
|
257 |
+
msgstr ""
|
258 |
+
|
259 |
+
#: restricted_site_access.php:618
|
260 |
+
msgctxt "help topic"
|
261 |
+
msgid "Redirect web address"
|
262 |
+
msgstr ""
|
263 |
+
|
264 |
+
#: restricted_site_access.php:624
|
265 |
+
msgctxt "help topic"
|
266 |
+
msgid "Redirect to the same path"
|
267 |
+
msgstr ""
|
268 |
+
|
269 |
+
#: restricted_site_access.php:630
|
270 |
+
msgctxt "help topic"
|
271 |
+
msgid "Redirection status code"
|
272 |
+
msgstr ""
|
273 |
+
|
274 |
+
#: restricted_site_access.php:636
|
275 |
+
msgctxt "help screen title"
|
276 |
+
msgid "Restricted Site Acccess"
|
277 |
+
msgstr ""
|
278 |
+
|
279 |
+
#: restricted_site_access.php:726 restricted_site_access.php:731
|
280 |
+
msgctxt "remove IP address action"
|
281 |
+
msgid "Remove"
|
282 |
+
msgstr ""
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Restricted Site Access ===
|
2 |
-
Contributors: jakemgold, rcbth, 10up, thinkoomph
|
3 |
Donate link: http://10up.com/plugins/restricted-site-access-wordpress/
|
4 |
Tags: privacy, restricted, restrict, privacy, limited, permissions, security, block
|
5 |
Requires at least: 3.5
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag:
|
8 |
|
9 |
Limit access to visitors who are logged in or allowed by IP addresses. Includes many options for handling blocked visitors.
|
10 |
|
@@ -12,7 +12,7 @@ Limit access to visitors who are logged in or allowed by IP addresses. Includes
|
|
12 |
|
13 |
Limit access your site to visitors who are logged in or accessing the site from a set of specified IP addresses. Send restricted visitors to the log in page, redirect them, or display a message or page. A great solution for Extranets, publicly hosted Intranets, or parallel development / staging sites.
|
14 |
|
15 |
-
Adds a number of new configuration options to the Reading settings panel. From
|
16 |
|
17 |
1. Enable or disable site restriction
|
18 |
1. Change the restriction behavior: send to login, redirect, display a message, display a page
|
@@ -61,6 +61,10 @@ Visitors that are not logged in or allowed by IP address will not be able to bro
|
|
61 |
|
62 |
Restricted Site Access is not meant to be a top secret data safe, but simply a reliable and convenient way to handle unwanted visitors.
|
63 |
|
|
|
|
|
|
|
|
|
64 |
== Screenshots ==
|
65 |
|
66 |
1. Screenshot of settings panel with simple Restricted Site Access option (send to login page).
|
@@ -69,6 +73,13 @@ Restricted Site Access is not meant to be a top secret data safe, but simply a r
|
|
69 |
|
70 |
== Changelog ==
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
= 5.1 =
|
73 |
* Under the hood refactoring and clean up for performance and maintainability.
|
74 |
* Small visual refinements to the settings panel.
|
@@ -140,4 +151,4 @@ Restricted Site Access is not meant to be a top secret data safe, but simply a r
|
|
140 |
Drops support for versions of WordPress prior to 3.5.
|
141 |
|
142 |
= 4.0 =
|
143 |
-
This update improves performance, refines the user interface, and adds support for showing restricted visitors a specific page. Please be advised that this udpate is specifically designed for WordPress 3.2+, and like WordPress 3.2, <strong>no longer supports PHP < 5.2.4</strong>.
|
1 |
=== Restricted Site Access ===
|
2 |
+
Contributors: jakemgold, rcbth, 10up, thinkoomph, tlovett1
|
3 |
Donate link: http://10up.com/plugins/restricted-site-access-wordpress/
|
4 |
Tags: privacy, restricted, restrict, privacy, limited, permissions, security, block
|
5 |
Requires at least: 3.5
|
6 |
+
Tested up to: 4.9
|
7 |
+
Stable tag: trunk
|
8 |
|
9 |
Limit access to visitors who are logged in or allowed by IP addresses. Includes many options for handling blocked visitors.
|
10 |
|
12 |
|
13 |
Limit access your site to visitors who are logged in or accessing the site from a set of specified IP addresses. Send restricted visitors to the log in page, redirect them, or display a message or page. A great solution for Extranets, publicly hosted Intranets, or parallel development / staging sites.
|
14 |
|
15 |
+
Adds a number of new configuration options to the Reading settings panel as well as the Network Settings panel in multisite. From these panels you can:
|
16 |
|
17 |
1. Enable or disable site restriction
|
18 |
1. Change the restriction behavior: send to login, redirect, display a message, display a page
|
61 |
|
62 |
Restricted Site Access is not meant to be a top secret data safe, but simply a reliable and convenient way to handle unwanted visitors.
|
63 |
|
64 |
+
= I received a warning about page caching. What does it mean? =
|
65 |
+
|
66 |
+
Page caching plugins often hook into WordPress to quickly serve the last cached output of a page before we can check to see if a visitor’s access should be restricted. Not all page caching plugins behave the same way, but several solutions - including external solutions we might not detect - can cause restricted pages to be publicly served regardless of your settings.
|
67 |
+
|
68 |
== Screenshots ==
|
69 |
|
70 |
1. Screenshot of settings panel with simple Restricted Site Access option (send to login page).
|
73 |
|
74 |
== Changelog ==
|
75 |
|
76 |
+
= 6.0 =
|
77 |
+
* Use Grunt to manage assets.
|
78 |
+
* Network settings added for management of entire network visibility settings.
|
79 |
+
* Display warning if page caching is enabled.
|
80 |
+
|
81 |
+
__Note: There is currently an edge case bug affecting IP whitelisting. This bug is on the docket to be fixed shortly.__
|
82 |
+
|
83 |
= 5.1 =
|
84 |
* Under the hood refactoring and clean up for performance and maintainability.
|
85 |
* Small visual refinements to the settings panel.
|
151 |
Drops support for versions of WordPress prior to 3.5.
|
152 |
|
153 |
= 4.0 =
|
154 |
+
This update improves performance, refines the user interface, and adds support for showing restricted visitors a specific page. Please be advised that this udpate is specifically designed for WordPress 3.2+, and like WordPress 3.2, <strong>no longer supports PHP < 5.2.4</strong>.
|
restricted-site-access.dev.js
DELETED
@@ -1,146 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* 10up
|
3 |
-
* http://10up.com
|
4 |
-
*
|
5 |
-
* Copyright (c) 2013 10up, jakemgold
|
6 |
-
* Licensed under the GPLv2+ license.
|
7 |
-
*/
|
8 |
-
(function (window, $) {
|
9 |
-
|
10 |
-
'use strict';
|
11 |
-
var document = window.document;
|
12 |
-
|
13 |
-
var Cache = {
|
14 |
-
add_btn : '',
|
15 |
-
new_ip : '',
|
16 |
-
ip_list_wrap : '',
|
17 |
-
empty_ip : '',
|
18 |
-
restrict_radio : '',
|
19 |
-
table : '',
|
20 |
-
redirect_choice : '',
|
21 |
-
message_choice : '',
|
22 |
-
page_choice : '',
|
23 |
-
redirect_fields : '',
|
24 |
-
message_field : '',
|
25 |
-
page_field : ''
|
26 |
-
};
|
27 |
-
|
28 |
-
function init() {
|
29 |
-
|
30 |
-
Cache.add_btn = $( document.getElementById('addip') );
|
31 |
-
Cache.new_ip = document.getElementById('newip');
|
32 |
-
Cache.ip_list_wrap = document.getElementById('ip_list');
|
33 |
-
Cache.empty_ip = $( document.getElementById('ip_list_empty') );
|
34 |
-
Cache.restrict_radio = document.getElementById('blog-restricted');
|
35 |
-
Cache.table = $( document.getElementById('rsa-send-to-login') ).closest('table');
|
36 |
-
Cache.redirect_choice = document.getElementById('rsa-redirect-visitor');
|
37 |
-
Cache.message_choice = document.getElementById('rsa-display-message');
|
38 |
-
Cache.page_choice = document.getElementById('rsa-unblocked-page');
|
39 |
-
Cache.redirect_fields = $( document.querySelectorAll('.rsa_redirect_field') ).closest('tr');
|
40 |
-
Cache.message_field = $( document.getElementById('rsa_message') ).closest('tr');
|
41 |
-
Cache.page_field = $( document.getElementById('rsa_page') ).closest('tr');
|
42 |
-
|
43 |
-
if ( ! document.getElementById('blog-restricted').checked ) {
|
44 |
-
Cache.table.hide();
|
45 |
-
}
|
46 |
-
|
47 |
-
if ( ! document.getElementById('rsa-redirect-visitor').checked ) {
|
48 |
-
Cache.redirect_fields.hide();
|
49 |
-
}
|
50 |
-
|
51 |
-
if ( ! document.getElementById('rsa-display-message').checked ) {
|
52 |
-
Cache.message_field.hide();
|
53 |
-
}
|
54 |
-
|
55 |
-
if ( ! document.getElementById('rsa-unblocked-page').checked ) {
|
56 |
-
Cache.page_field.hide();
|
57 |
-
}
|
58 |
-
|
59 |
-
$( document.querySelectorAll('#rsa_handle_fields input') ).on('change',function(){
|
60 |
-
|
61 |
-
if ( Cache.redirect_choice.checked ) {
|
62 |
-
Cache.redirect_fields.show();
|
63 |
-
} else {
|
64 |
-
Cache.redirect_fields.hide();
|
65 |
-
}
|
66 |
-
|
67 |
-
if ( Cache.message_choice.checked ) {
|
68 |
-
Cache.message_field.show();
|
69 |
-
} else {
|
70 |
-
Cache.message_field.hide();
|
71 |
-
}
|
72 |
-
|
73 |
-
if ( Cache.page_choice.checked ) {
|
74 |
-
Cache.page_field.show();
|
75 |
-
} else {
|
76 |
-
Cache.page_field.hide();
|
77 |
-
}
|
78 |
-
|
79 |
-
});
|
80 |
-
|
81 |
-
$( document.querySelectorAll('.option-site-visibility input') ).on('change',function(){
|
82 |
-
if ( Cache.restrict_radio.checked ) {
|
83 |
-
Cache.table.show();
|
84 |
-
} else {
|
85 |
-
Cache.table.hide();
|
86 |
-
}
|
87 |
-
});
|
88 |
-
|
89 |
-
Cache.add_btn.on('click',function(){
|
90 |
-
add_ip( Cache.new_ip.value );
|
91 |
-
});
|
92 |
-
|
93 |
-
var myip_btn = document.getElementById('rsa_myip');
|
94 |
-
if ( null !== myip_btn ) {
|
95 |
-
$(myip_btn).on('click',function(){
|
96 |
-
add_ip( $(this).data('myip') );
|
97 |
-
});
|
98 |
-
}
|
99 |
-
|
100 |
-
$(Cache.ip_list_wrap).on('click', '.remove_btn', function(){
|
101 |
-
$( this.parentNode ).slideUp( 250, function(){ $(this).remove(); } );
|
102 |
-
});
|
103 |
-
|
104 |
-
}
|
105 |
-
|
106 |
-
function add_ip( ip ) {
|
107 |
-
if ( $.trim( ip ) == '' ) {
|
108 |
-
return false;
|
109 |
-
}
|
110 |
-
|
111 |
-
var shake_speed = 600;
|
112 |
-
|
113 |
-
Cache.add_btn.attr('disabled', 'disabled');
|
114 |
-
var ip_list = $( document.querySelectorAll('#ip_list input') );
|
115 |
-
|
116 |
-
for ( var i = 0, l = ip_list.length; i < ip_list.length; i++ ) {
|
117 |
-
if( ip_list[i].value == ip ) {
|
118 |
-
$( ip_list[i] ).parent().effect( 'shake', shake_speed );
|
119 |
-
Cache.add_btn.removeAttr('disabled');
|
120 |
-
return false;
|
121 |
-
}
|
122 |
-
}
|
123 |
-
|
124 |
-
jQuery.post( ajaxurl, { action: 'rsa_ip_check', 'ip_address': ip }, function(response) {
|
125 |
-
if ( response ) {
|
126 |
-
$( Cache.new_ip.parentNode ).effect( 'shake', shake_speed );
|
127 |
-
Cache.add_btn.removeAttr('disabled');
|
128 |
-
return false;
|
129 |
-
} else {
|
130 |
-
var new_ip = Cache.empty_ip.clone().appendTo(Cache.ip_list_wrap);
|
131 |
-
new_ip.children('input').val(ip);
|
132 |
-
new_ip.removeAttr('id').slideDown(250);
|
133 |
-
|
134 |
-
if ( ip == Cache.new_ip.value ) {
|
135 |
-
$(Cache.new_ip).val('');
|
136 |
-
}
|
137 |
-
Cache.add_btn.removeAttr('disabled');
|
138 |
-
|
139 |
-
return true;
|
140 |
-
}
|
141 |
-
} );
|
142 |
-
}
|
143 |
-
|
144 |
-
init();
|
145 |
-
|
146 |
-
})(window,jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
restricted-site-access.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
(function(e,t){"use strict";function i(){r.add_btn=t(n.getElementById("addip"));r.new_ip=n.getElementById("newip");r.ip_list_wrap=n.getElementById("ip_list");r.empty_ip=t(n.getElementById("ip_list_empty"));r.restrict_radio=n.getElementById("blog-restricted");r.table=t(n.getElementById("rsa-send-to-login")).closest("table");r.redirect_choice=n.getElementById("rsa-redirect-visitor");r.message_choice=n.getElementById("rsa-display-message");r.page_choice=n.getElementById("rsa-unblocked-page");r.redirect_fields=t(n.querySelectorAll(".rsa_redirect_field")).closest("tr");r.message_field=t(n.getElementById("rsa_message")).closest("tr");r.page_field=t(n.getElementById("rsa_page")).closest("tr");if(!n.getElementById("blog-restricted").checked){r.table.hide()}if(!n.getElementById("rsa-redirect-visitor").checked){r.redirect_fields.hide()}if(!n.getElementById("rsa-display-message").checked){r.message_field.hide()}if(!n.getElementById("rsa-unblocked-page").checked){r.page_field.hide()}t(n.querySelectorAll("#rsa_handle_fields input")).on("change",function(){if(r.redirect_choice.checked){r.redirect_fields.show()}else{r.redirect_fields.hide()}if(r.message_choice.checked){r.message_field.show()}else{r.message_field.hide()}if(r.page_choice.checked){r.page_field.show()}else{r.page_field.hide()}});t(n.querySelectorAll(".option-site-visibility input")).on("change",function(){if(r.restrict_radio.checked){r.table.show()}else{r.table.hide()}});r.add_btn.on("click",function(){s(r.new_ip.value)});var e=n.getElementById("rsa_myip");if(null!==e){t(e).on("click",function(){s(t(this).data("myip"))})}t(r.ip_list_wrap).on("click",".remove_btn",function(){t(this.parentNode).slideUp(250,function(){t(this).remove()})})}function s(e){if(t.trim(e)==""){return false}var i=600;r.add_btn.attr("disabled","disabled");var s=t(n.querySelectorAll("#ip_list input"));for(var o=0,u=s.length;o<s.length;o++){if(s[o].value==e){t(s[o]).parent().effect("shake",i);r.add_btn.removeAttr("disabled");return false}}jQuery.post(ajaxurl,{action:"rsa_ip_check",ip_address:e},function(n){if(n){t(r.new_ip.parentNode).effect("shake",i);r.add_btn.removeAttr("disabled");return false}else{var s=r.empty_ip.clone().appendTo(r.ip_list_wrap);s.children("input").val(e);s.removeAttr("id").slideDown(250);if(e==r.new_ip.value){t(r.new_ip).val("")}r.add_btn.removeAttr("disabled");return true}})}var n=e.document;var r={add_btn:"",new_ip:"",ip_list_wrap:"",empty_ip:"",restrict_radio:"",table:"",redirect_choice:"",message_choice:"",page_choice:"",redirect_fields:"",message_field:"",page_field:""};i()})(window,jQuery)
|
|
restricted_site_access.php
CHANGED
@@ -1,55 +1,22 @@
|
|
1 |
<?php
|
2 |
/**
|
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 |
-
Author: Jake Goldman, 10up, Oomph
|
8 |
-
Author URI: http://10up.com
|
9 |
-
License: GPLv2 or later
|
10 |
-
*/
|
|
|
|
|
11 |
|
12 |
class Restricted_Site_Access {
|
13 |
-
|
14 |
-
private static $
|
15 |
private static $settings_page = 'reading';
|
16 |
-
|
17 |
-
|
18 |
-
'default' => 1,
|
19 |
-
'label' => 'Handle restricted visitors',
|
20 |
-
'field' => 'settings_field_handling',
|
21 |
-
),
|
22 |
-
'message' => array(
|
23 |
-
'default' => 'Access to this site is restricted.',
|
24 |
-
'label' => 'Restriction message',
|
25 |
-
'field' => 'settings_field_message',
|
26 |
-
),
|
27 |
-
'redirect_url' => array(
|
28 |
-
'default' => '',
|
29 |
-
'label' => 'Redirect web address',
|
30 |
-
'field' => 'settings_field_redirect',
|
31 |
-
),
|
32 |
-
'redirect_path' => array(
|
33 |
-
'default' => 0,
|
34 |
-
'label' => 'Redirect to same path',
|
35 |
-
'field' => 'settings_field_redirect_path',
|
36 |
-
),
|
37 |
-
'head_code' => array(
|
38 |
-
'default' => 302,
|
39 |
-
'label' => 'Redirection status code',
|
40 |
-
'field' => 'settings_field_redirect_code',
|
41 |
-
),
|
42 |
-
'page' => array(
|
43 |
-
'default' => 0,
|
44 |
-
'label' => 'Restricted notice page',
|
45 |
-
'field' => 'settings_field_rsa_page',
|
46 |
-
),
|
47 |
-
'allowed' => array(
|
48 |
-
'default' => array(),
|
49 |
-
'label' => 'Unrestricted IP addresses',
|
50 |
-
'field' => 'settings_field_allowed',
|
51 |
-
),
|
52 |
-
);
|
53 |
|
54 |
/**
|
55 |
* Handles initializing this class and returning the singleton instance after it's been cached.
|
@@ -63,6 +30,7 @@ class Restricted_Site_Access {
|
|
63 |
if ( null === $instance ) {
|
64 |
$instance = new self();
|
65 |
self::_add_actions();
|
|
|
66 |
}
|
67 |
|
68 |
return $instance;
|
@@ -71,14 +39,15 @@ class Restricted_Site_Access {
|
|
71 |
/**
|
72 |
* An empty constructor
|
73 |
*/
|
74 |
-
public function __construct() {
|
|
|
75 |
|
76 |
/**
|
77 |
* Handles registering hooks that initialize this plugin.
|
78 |
*/
|
79 |
public static function _add_actions() {
|
80 |
self::$basename = plugin_basename( __FILE__ );
|
81 |
-
|
82 |
add_action( 'parse_request', array( __CLASS__, 'restrict_access' ), 1 );
|
83 |
add_action( 'admin_init', array( __CLASS__, 'admin_init' ), 1 );
|
84 |
add_action( 'plugins_loaded', array( __CLASS__, 'load_textdomain' ) );
|
@@ -86,6 +55,53 @@ class Restricted_Site_Access {
|
|
86 |
|
87 |
add_action( 'activate_' . self::$basename, array( __CLASS__, 'activation' ) );
|
88 |
add_action( 'deactivate_' . self::$basename, array( __CLASS__, 'deactivation' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
|
91 |
/**
|
@@ -95,21 +111,80 @@ class Restricted_Site_Access {
|
|
95 |
load_plugin_textdomain( 'restricted-site-access', false, dirname( self::$basename ) . '/localization/' );
|
96 |
}
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
/**
|
99 |
* populate the option with defaults
|
100 |
*/
|
101 |
-
private static function
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
104 |
}
|
105 |
|
106 |
-
//
|
107 |
-
self::$rsa_options = (array) get_option( 'rsa_options' );
|
108 |
foreach( self::$fields as $field_name => $field_details ) {
|
109 |
-
if ( ! isset(
|
110 |
-
|
111 |
}
|
112 |
}
|
|
|
|
|
113 |
}
|
114 |
|
115 |
/**
|
@@ -118,30 +193,46 @@ class Restricted_Site_Access {
|
|
118 |
* @param array $wp WordPress request
|
119 |
*/
|
120 |
public static function restrict_access( $wp ) {
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
if ( apply_filters( 'restricted_site_access_is_restricted', $is_restricted, $wp ) === false ) {
|
125 |
return;
|
126 |
}
|
127 |
|
128 |
-
self::set_option_defaults();
|
129 |
-
|
130 |
// check for the allow list, if its empty block everything
|
131 |
-
if ( !empty( self::$rsa_options['allowed'] ) && is_array( self::$rsa_options['allowed'] ) ) {
|
132 |
-
$remote_ip = $_SERVER['REMOTE_ADDR']; //save the remote ip
|
133 |
if ( strpos( $remote_ip, '.' ) ) {
|
134 |
-
$remote_ip = str_replace( '::ffff:', '', $remote_ip ); //handle dual-stack addresses
|
135 |
}
|
136 |
-
$remote_ip = inet_pton( $remote_ip ); //parse the remote ip
|
137 |
-
|
138 |
// iterate through the allow list
|
139 |
-
foreach( self::$rsa_options['allowed'] as $line ) {
|
140 |
list( $ip, $mask ) = explode( '/', $line . '/128' ); // get the ip and mask from the list
|
141 |
-
|
142 |
-
$mask = str_repeat( 'f', $mask >> 2 ); //render the mask as bits, similar to info on the php.net man page discussion for inet_pton
|
143 |
-
|
144 |
-
switch( $mask % 4 ) {
|
145 |
case 1:
|
146 |
$mask .= '8';
|
147 |
break;
|
@@ -152,49 +243,50 @@ class Restricted_Site_Access {
|
|
152 |
$mask .= 'e';
|
153 |
break;
|
154 |
}
|
155 |
-
|
156 |
$mask = pack( 'H*', $mask );
|
157 |
-
|
158 |
// check if the masked versions match
|
159 |
if ( ( inet_pton( $ip ) & $mask ) == ( $remote_ip & $mask ) ) {
|
160 |
return;
|
161 |
}
|
162 |
}
|
163 |
}
|
164 |
-
|
165 |
$rsa_restrict_approach = apply_filters( 'restricted_site_access_approach', self::$rsa_options['approach'] );
|
166 |
do_action( 'restrict_site_access_handling', $rsa_restrict_approach, $wp ); // allow users to hook handling
|
167 |
-
|
168 |
-
switch( $rsa_restrict_approach ) {
|
169 |
case 4:
|
170 |
-
if ( !empty( self::$rsa_options['page'] ) && ( $page_id = get_post_field( 'ID', self::$rsa_options['page'] ) ) ) {
|
171 |
unset( $wp->query_vars );
|
172 |
$wp->query_vars['page_id'] = $page_id;
|
173 |
return;
|
174 |
}
|
175 |
-
|
176 |
case 3:
|
177 |
$message = __( self::$rsa_options['message'], 'restricted-site-access' );
|
178 |
$message .= "\n<!-- protected by Restricted Site Access http://10up.com/plugins/restricted-site-access-wordpress/ -->";
|
179 |
$message = apply_filters( 'restricted_site_access_message', $message, $wp );
|
180 |
-
wp_die( $message, get_bloginfo( 'name' ) . ' - Site Access Restricted' );
|
181 |
-
|
182 |
case 2:
|
183 |
if ( ! empty( self::$rsa_options['redirect_url'] ) ) {
|
184 |
-
if( ! empty( self::$rsa_options['redirect_path'] ) ) {
|
185 |
self::$rsa_options['redirect_url'] = untrailingslashit( self::$rsa_options['redirect_url'] ) . $_SERVER['REQUEST_URI'];
|
186 |
}
|
187 |
break;
|
188 |
}
|
189 |
-
|
190 |
default:
|
191 |
-
self::$rsa_options['
|
192 |
$current_path = empty( $_SERVER['REQUEST_URI'] ) ? home_url() : $_SERVER['REQUEST_URI'];
|
193 |
self::$rsa_options['redirect_url'] = wp_login_url( $current_path );
|
194 |
}
|
195 |
|
196 |
$redirect_url = apply_filters( 'restricted_site_access_redirect_url', self::$rsa_options['redirect_url'], $wp );
|
197 |
-
$redirect_code = apply_filters( 'restricted_site_access_head', self::$rsa_options['
|
|
|
198 |
wp_redirect( $redirect_url, $redirect_code );
|
199 |
die;
|
200 |
}
|
@@ -206,21 +298,156 @@ class Restricted_Site_Access {
|
|
206 |
// customize privacy message
|
207 |
add_filter( 'privacy_on_link_text', array( __CLASS__, 'privacy_on_link_text' ) );
|
208 |
add_filter( 'privacy_on_link_title', array( __CLASS__, 'privacy_on_link_title' ) );
|
209 |
-
|
210 |
// customize privacy page
|
211 |
add_action( 'load-options-' . self::$settings_page . '.php', array( __CLASS__, 'load_options_page' ) );
|
212 |
-
|
213 |
// add new choice for blog privacy
|
214 |
add_action( 'blog_privacy_selector', array( __CLASS__, 'blog_privacy_selector' ) );
|
215 |
-
|
216 |
// settings for restricted site access
|
217 |
register_setting( self::$settings_page, 'rsa_options', array( __CLASS__, 'sanitize_options' ) ); // array of fundamental options including ID and caching info
|
218 |
add_settings_section( 'restricted-site-access', '', '__return_empty_string', self::$settings_page );
|
219 |
foreach ( self::$fields as $field_name => $field_data ) {
|
220 |
add_settings_field( $field_name, __( $field_data['label'], 'restricted-site-access' ), array( __CLASS__, $field_data['field'] ), self::$settings_page, 'restricted-site-access' );
|
221 |
}
|
222 |
-
|
223 |
add_filter( 'plugin_action_links_' . self::$basename, array( __CLASS__, 'plugin_action_links' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
}
|
225 |
|
226 |
/**
|
@@ -251,35 +478,112 @@ class Restricted_Site_Access {
|
|
251 |
return $text;
|
252 |
}
|
253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
/**
|
255 |
* Loads needed scripts and assets on the Reading page
|
256 |
*/
|
257 |
public static function load_options_page() {
|
258 |
-
|
259 |
-
wp_enqueue_script( 'restricted-site-access', plugin_dir_url( __FILE__ ) . 'restricted-site-access' . $dev . '.js', array('jquery-effects-shake'), '5.1', true );
|
260 |
|
261 |
add_action( 'admin_notices', array( __CLASS__, 'admin_notice' ) );
|
262 |
add_action( 'admin_head', array( __CLASS__, 'admin_head' ) );
|
263 |
|
264 |
-
self::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
}
|
266 |
|
267 |
/**
|
268 |
* Customize admin notices to ensure user completes restriction setup properly
|
269 |
*/
|
270 |
public static function admin_notice() {
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
if ( empty( self::$rsa_options['approach'] ) ) {
|
272 |
return;
|
273 |
}
|
274 |
-
|
275 |
if ( 4 == self::$rsa_options['approach'] && empty( self::$rsa_options['page'] ) ) {
|
276 |
$message = __( 'Please select the page you want to show restricted visitors. If no page is selected, WordPress will simply show a general restriction message.', 'restricted-site-access' );
|
277 |
} elseif ( 2 == self::$rsa_options['approach'] && empty( self::$rsa_options['redirect_url'] ) ) {
|
278 |
$message = __( 'Please enter the web address you would like to redirect restricted visitors to. If no address is entered, visitors will be redirected to the login screen.', 'restricted-site-access' );
|
279 |
}
|
280 |
-
|
281 |
if ( isset( $message ) ) {
|
282 |
-
echo '<div class="error"><p><strong>' . $message . '</strong></p></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
}
|
284 |
}
|
285 |
|
@@ -287,18 +591,50 @@ class Restricted_Site_Access {
|
|
287 |
* Add restricted access help tab to screen
|
288 |
*/
|
289 |
public static function admin_head() {
|
290 |
-
$screen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
$screen->add_help_tab( array(
|
292 |
'id' => 'restricted-site-access',
|
293 |
-
'title' =>
|
294 |
-
'content' =>
|
295 |
-
<p><strong>' . __('Handle restricted visitors','restricted-site-access') . '</strong> - ' . __('choose the method for handling visitors to your site that are restricted.','restricted-site-access') . '</p>
|
296 |
-
<p><strong>' . __('Allowed IP addresses','restricted-site-access') . '</strong> - ' . __('enter a single IP address (for example, 192.168.1.105) or an IP range using a network prefix (for example, 10.0.0.1/24). Enter your addresses carefully! Here\'s a','restricted-site-access') . ' <a href="http://www.csgnetwork.com/ipinfocalc.html" target="_blank">' . __('handy calculator','restricted-site-access') . '</a> ' . __('to check your prefix.','restricted-site-access') . '</p>
|
297 |
-
<p>' . __('The redirection fields are only used when "Handle restricted visitors" is set to "Redirect them to a specified web address".','restricted-site-access') . '</p>
|
298 |
-
<p><strong>' . __('Redirect web address','restricted-site-access') . '</strong> - ' . __('the web address of the site you want the visitor redirected to.','restricted-site-access') . '</p>
|
299 |
-
<p><strong>' . __('Redirect to same path','restricted-site-access') . '</strong> - ' . __('redirect the visitor to the same path (URI) entered at this site. Typically used when there are two, very similar sites at different public web addresses; for instance, a parallel development server accessible on the Internet but not intended for the public.','restricted-site-access') . '</p>
|
300 |
-
<p><strong>' . __('Redirection status code','restricted-site-access') . '</strong> - ' . __('redirect status codes can provide certain visitors, particularly search engines, more information about the nature of the redirect. A 301 redirect tells search engines that a page has moved permanently to the new location. 307 indicates a temporary redirect. 302 is an undefined redirect.','restricted-site-access') . '</p>
|
301 |
-
',
|
302 |
) );
|
303 |
}
|
304 |
|
@@ -306,10 +642,12 @@ class Restricted_Site_Access {
|
|
306 |
* Add a new choice to the privacy selector
|
307 |
*/
|
308 |
public static function blog_privacy_selector() {
|
|
|
|
|
309 |
?>
|
310 |
<p>
|
311 |
-
<input id="blog-restricted" type="radio" name="blog_public" value="2" <?php checked(
|
312 |
-
<label for="blog-restricted"><?php
|
313 |
</p>
|
314 |
<?php
|
315 |
}
|
@@ -332,18 +670,18 @@ class Restricted_Site_Access {
|
|
332 |
|
333 |
$new_input['redirect_path'] = empty( $input['redirect_path'] ) ? 0 : 1;
|
334 |
$new_input['head_code'] = in_array( (int) $input['head_code'], array( 301, 302, 307 ) ) ? (int) $input['head_code'] : self::$fields['head_code']['default'];
|
335 |
-
$new_input['redirect_url'] = empty( $input['redirect_url'] ) ? '' : esc_url_raw( $input['redirect_url'], array('http','https') );
|
336 |
$new_input['page'] = empty( $input['page'] ) ? 0 : (int) $input['page'];
|
337 |
|
338 |
$new_input['allowed'] = array();
|
339 |
-
if ( !empty( $input['allowed'] ) && is_array( $input['allowed'] ) ) {
|
340 |
-
foreach( $input['allowed'] as $ip_address ) {
|
341 |
if ( self::is_ip( $ip_address ) ) {
|
342 |
$new_input['allowed'][] = $ip_address;
|
343 |
}
|
344 |
}
|
345 |
}
|
346 |
-
|
347 |
return $new_input;
|
348 |
}
|
349 |
|
@@ -352,23 +690,26 @@ class Restricted_Site_Access {
|
|
352 |
*
|
353 |
* @param $args
|
354 |
*/
|
355 |
-
public static function settings_field_handling( $args ) {
|
356 |
if ( ! isset( self::$rsa_options['approach'] ) ) {
|
357 |
self::$rsa_options['approach'] = 1;
|
358 |
}
|
359 |
?>
|
360 |
<fieldset id="rsa_handle_fields">
|
361 |
<input id="rsa-send-to-login" name="rsa_options[approach]" type="radio" value="1" <?php checked( self::$rsa_options['approach'], 1 ); ?> />
|
362 |
-
<label for="rsa-send-to-login"><?php
|
363 |
<br />
|
364 |
<input id="rsa-redirect-visitor" name="rsa_options[approach]" type="radio" value="2" <?php checked( self::$rsa_options['approach'], 2 ); ?> />
|
365 |
-
<label for="rsa-redirect-visitor"><?php
|
366 |
<br />
|
367 |
<input id="rsa-display-message" name="rsa_options[approach]" type="radio" value="3" <?php checked( self::$rsa_options['approach'], 3 ); ?> />
|
368 |
-
<label for="rsa-display-message"><?php
|
369 |
-
|
370 |
-
|
371 |
-
|
|
|
|
|
|
|
372 |
</fieldset>
|
373 |
<?php
|
374 |
}
|
@@ -378,27 +719,27 @@ class Restricted_Site_Access {
|
|
378 |
*
|
379 |
* @param $args
|
380 |
*/
|
381 |
-
public static function settings_field_allowed( $args ) {
|
382 |
?>
|
383 |
<div class="hide-if-no-js">
|
384 |
<div id="ip_list">
|
385 |
-
<div id="ip_list_empty" style="display: none;"><input type="text" name="rsa_options[allowed][]" value="" readonly="true" /> <a href="#remove" class="remove_btn"><?php
|
386 |
<?php
|
387 |
$ips = (array) self::$rsa_options['allowed'];
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
}
|
392 |
}
|
|
|
393 |
?>
|
394 |
</div>
|
395 |
<div>
|
396 |
<input type="text" name="newip" id="newip" /> <input class="button" type="button" id="addip" value="<?php _e( 'Add' ); ?>" />
|
397 |
-
<p class="description" style="display: inline;"><label for="newip"><?php
|
398 |
-
|
399 |
-
<?php if ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { ?><input class="button" type="button" id="rsa_myip" value="<?php
|
400 |
</div>
|
401 |
-
<p class="hide-if-js"><strong><?php
|
402 |
<?php
|
403 |
}
|
404 |
|
@@ -407,7 +748,7 @@ class Restricted_Site_Access {
|
|
407 |
*
|
408 |
* @param $args
|
409 |
*/
|
410 |
-
public static function settings_field_message( $args ) {
|
411 |
if ( empty( self::$rsa_options['message'] ) ) {
|
412 |
self::$rsa_options['message'] = __( 'Access to this site is restricted.', 'restricted-site-access' );
|
413 |
}
|
@@ -425,7 +766,7 @@ class Restricted_Site_Access {
|
|
425 |
*
|
426 |
* @param $args
|
427 |
*/
|
428 |
-
public static function settings_field_redirect( $args ) {
|
429 |
if ( ! isset( self::$rsa_options['redirect_url'] ) ) {
|
430 |
self::$rsa_options['redirect_url'] = '';
|
431 |
}
|
@@ -439,7 +780,7 @@ class Restricted_Site_Access {
|
|
439 |
*
|
440 |
* @param $args
|
441 |
*/
|
442 |
-
public static function settings_field_redirect_path( $args ) {
|
443 |
if ( ! isset( self::$rsa_options['redirect_path'] ) ) {
|
444 |
self::$rsa_options['redirect_path'] = 0;
|
445 |
}
|
@@ -447,7 +788,7 @@ class Restricted_Site_Access {
|
|
447 |
<fieldset><legend class="screen-reader-text"><span><?php _e( self::$rsa_options['redirect_path']['label'], 'restricted-site-access' ); ?></span></legend>
|
448 |
<label for="redirect_path">
|
449 |
<input type="checkbox" name="rsa_options[redirect_path]" value="1" id="redirect_path" class="rsa_redirect_field" <?php checked( self::$rsa_options['redirect_path'] ); ?> />
|
450 |
-
<?php
|
451 |
</fieldset>
|
452 |
<?php
|
453 |
}
|
@@ -457,15 +798,15 @@ class Restricted_Site_Access {
|
|
457 |
*
|
458 |
* @param $args
|
459 |
*/
|
460 |
-
public static function settings_field_redirect_code( $args ) {
|
461 |
if ( empty( self::$rsa_options['head_code'] ) ) {
|
462 |
self::$rsa_options['head_code'] = 302;
|
463 |
}
|
464 |
?>
|
465 |
<select name="rsa_options[head_code]" id="redirect_code" class="rsa_redirect_field">
|
466 |
-
<option value="301" <?php selected( self::$rsa_options['head_code'], 301 ); ?>><?php
|
467 |
-
<option value="302" <?php selected( self::$rsa_options['head_code'], 302 ); ?>><?php
|
468 |
-
<option value="307" <?php selected( self::$rsa_options['head_code'], 307 ); ?>><?php
|
469 |
</select>
|
470 |
<?php
|
471 |
}
|
@@ -475,16 +816,16 @@ class Restricted_Site_Access {
|
|
475 |
*
|
476 |
* @param $args
|
477 |
*/
|
478 |
-
public static function settings_field_rsa_page( $args ) {
|
479 |
if ( ! isset( self::$rsa_options['page'] ) ) {
|
480 |
self::$rsa_options['page'] = 0;
|
481 |
}
|
482 |
|
483 |
-
wp_dropdown_pages(array(
|
484 |
'selected' => self::$rsa_options['page'],
|
485 |
-
'show_option_none' => 'Select a page',
|
486 |
'name' => 'rsa_options[page]',
|
487 |
-
'id' => 'rsa_page'
|
488 |
));
|
489 |
}
|
490 |
|
@@ -492,7 +833,7 @@ class Restricted_Site_Access {
|
|
492 |
* Validate IP address entry on demand (AJAX)
|
493 |
*/
|
494 |
public static function ajax_rsa_ip_check() {
|
495 |
-
if ( empty( $_POST['ip_address'] ) || !self::is_ip( stripslashes( $_POST['ip_address'] ) ) ) {
|
496 |
die( '1' );
|
497 |
}
|
498 |
die;
|
@@ -509,14 +850,14 @@ class Restricted_Site_Access {
|
|
509 |
// very basic validation of ranges
|
510 |
if ( strpos( $ip_address, '/' ) ) {
|
511 |
$ip_parts = explode( '/', $ip_address );
|
512 |
-
if ( empty( $ip_parts[1] ) || !is_numeric( $ip_parts[1] ) || strlen( $ip_parts[1] ) > 3 ) {
|
513 |
return false;
|
514 |
}
|
515 |
$ip_address = $ip_parts[0];
|
516 |
}
|
517 |
|
518 |
// confirm IP part is a valid IPv6 or IPv4 IP
|
519 |
-
if ( empty( $ip_address ) || !inet_pton( stripslashes( $ip_address ) ) ) {
|
520 |
return false;
|
521 |
}
|
522 |
|
@@ -531,17 +872,22 @@ class Restricted_Site_Access {
|
|
531 |
* @return array
|
532 |
*/
|
533 |
public static function plugin_action_links( $links ) {
|
534 |
-
$links[] =
|
535 |
-
|
|
|
|
|
|
|
|
|
|
|
536 |
}
|
537 |
-
|
538 |
/**
|
539 |
* activation of plugin: upgrades old versions, immediately sets privacy
|
540 |
*/
|
541 |
public static function activation() {
|
542 |
update_option( 'blog_public', 2 );
|
543 |
}
|
544 |
-
|
545 |
/**
|
546 |
* restore privacy option to default value upon deactivating
|
547 |
*/
|
@@ -550,45 +896,81 @@ class Restricted_Site_Access {
|
|
550 |
update_option( 'blog_public', 1 );
|
551 |
}
|
552 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
}
|
554 |
|
|
|
|
|
555 |
Restricted_Site_Access::get_instance();
|
556 |
|
557 |
/**
|
558 |
* Uninstall routine for the plugin
|
559 |
*/
|
560 |
function restricted_site_access_uninstall() {
|
561 |
-
if (
|
562 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
}
|
564 |
-
delete_option('rsa_options');
|
565 |
}
|
566 |
|
567 |
register_uninstall_hook( __FILE__, 'restricted_site_access_uninstall' );
|
568 |
|
569 |
if ( ! function_exists( 'inet_pton' ) ) :
|
570 |
|
571 |
-
/**
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
function inet_pton($ip) {
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
}
|
593 |
|
594 |
-
endif;
|
1 |
<?php
|
2 |
/**
|
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 |
+
|
16 |
+
private static $basename, $rsa_options;
|
17 |
private static $settings_page = 'reading';
|
18 |
+
|
19 |
+
private static $fields;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
/**
|
22 |
* Handles initializing this class and returning the singleton instance after it's been cached.
|
30 |
if ( null === $instance ) {
|
31 |
$instance = new self();
|
32 |
self::_add_actions();
|
33 |
+
self::populate_fields_array();
|
34 |
}
|
35 |
|
36 |
return $instance;
|
39 |
/**
|
40 |
* An empty constructor
|
41 |
*/
|
42 |
+
public function __construct() {
|
43 |
+
/* Purposely do nothing here */ }
|
44 |
|
45 |
/**
|
46 |
* Handles registering hooks that initialize this plugin.
|
47 |
*/
|
48 |
public static function _add_actions() {
|
49 |
self::$basename = plugin_basename( __FILE__ );
|
50 |
+
|
51 |
add_action( 'parse_request', array( __CLASS__, 'restrict_access' ), 1 );
|
52 |
add_action( 'admin_init', array( __CLASS__, 'admin_init' ), 1 );
|
53 |
add_action( 'plugins_loaded', array( __CLASS__, 'load_textdomain' ) );
|
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' ) );
|
61 |
+
}
|
62 |
+
|
63 |
+
public static function ajax_notice_dismiss() {
|
64 |
+
if ( ! check_ajax_referer( 'rsa_admin_nonce', 'nonce', false ) ) {
|
65 |
+
wp_send_json_error();
|
66 |
+
exit;
|
67 |
+
}
|
68 |
+
|
69 |
+
if ( RSA_IS_NETWORK ) {
|
70 |
+
if ( ! is_super_admin() ) {
|
71 |
+
wp_send_json_error();
|
72 |
+
exit;
|
73 |
+
}
|
74 |
+
} else {
|
75 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
76 |
+
wp_send_json_error();
|
77 |
+
exit;
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
if ( RSA_IS_NETWORK ) {
|
82 |
+
update_site_option( 'rsa_hide_page_cache_notice', true );
|
83 |
+
} else {
|
84 |
+
update_option( 'rsa_hide_page_cache_notice', true );
|
85 |
+
}
|
86 |
+
|
87 |
+
wp_send_json_success();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Set RSA defaults for new site
|
92 |
+
*/
|
93 |
+
public static function set_defaults( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
|
94 |
+
if ( 'enforce' === self::get_network_mode() ) {
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
+
$network_options = self::get_options( true );
|
99 |
+
$blog_public = get_site_option( 'blog_public', 2 );
|
100 |
+
|
101 |
+
switch_to_blog( $blog_id );
|
102 |
+
update_option( 'rsa_options', self::sanitize_options( $network_options ) );
|
103 |
+
update_option( 'blog_public', (int) $blog_public );
|
104 |
+
restore_current_blog();
|
105 |
}
|
106 |
|
107 |
/**
|
111 |
load_plugin_textdomain( 'restricted-site-access', false, dirname( self::$basename ) . '/localization/' );
|
112 |
}
|
113 |
|
114 |
+
/**
|
115 |
+
* Populate Restricted_Site_Access::$fields with internationalization-ready field information.
|
116 |
+
*/
|
117 |
+
protected static function populate_fields_array() {
|
118 |
+
self::$fields = array(
|
119 |
+
'approach' => array(
|
120 |
+
'default' => 1,
|
121 |
+
'label' => __( 'Handle restricted visitors', 'restricted-site-access' ),
|
122 |
+
'field' => 'settings_field_handling',
|
123 |
+
),
|
124 |
+
'message' => array(
|
125 |
+
'default' => _x( 'Access to this site is restricted.', 'default restriction message', 'restricted-site-access' ),
|
126 |
+
'label' => __( 'Restriction message', 'restricted-site-access' ),
|
127 |
+
'field' => 'settings_field_message',
|
128 |
+
),
|
129 |
+
'redirect_url' => array(
|
130 |
+
'default' => '',
|
131 |
+
'label' => __( 'Redirect web address', 'restricted-site-access' ),
|
132 |
+
'field' => 'settings_field_redirect',
|
133 |
+
),
|
134 |
+
'redirect_path' => array(
|
135 |
+
'default' => 0,
|
136 |
+
'label' => 'Redirect to same path',
|
137 |
+
'field' => 'settings_field_redirect_path',
|
138 |
+
),
|
139 |
+
'head_code' => array(
|
140 |
+
'default' => 302,
|
141 |
+
'label' => __( 'Redirection status code', 'restricted-site-access' ),
|
142 |
+
'field' => 'settings_field_redirect_code',
|
143 |
+
),
|
144 |
+
'page' => array(
|
145 |
+
'default' => 0,
|
146 |
+
'label' => __( 'Restricted notice page', 'restricted-site-access' ),
|
147 |
+
'field' => 'settings_field_rsa_page',
|
148 |
+
),
|
149 |
+
'allowed' => array(
|
150 |
+
'default' => array(),
|
151 |
+
'label' => __( 'Unrestricted IP addresses', 'restricted-site-access' ),
|
152 |
+
'field' => 'settings_field_allowed',
|
153 |
+
),
|
154 |
+
);
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Get current plugin network mode
|
159 |
+
*/
|
160 |
+
private static function get_network_mode() {
|
161 |
+
if ( RSA_IS_NETWORK ){
|
162 |
+
return get_site_option( 'rsa_mode', 'default' );
|
163 |
+
}
|
164 |
+
|
165 |
+
return 'default';
|
166 |
+
}
|
167 |
+
|
168 |
/**
|
169 |
* populate the option with defaults
|
170 |
*/
|
171 |
+
private static function get_options( $network = false ) {
|
172 |
+
$options = array();
|
173 |
+
|
174 |
+
if ( $network ) {
|
175 |
+
$options = get_site_option( 'rsa_options' );
|
176 |
+
} else {
|
177 |
+
$options = get_option( 'rsa_options' );
|
178 |
}
|
179 |
|
180 |
+
// Fill in defaults where values aren't set
|
|
|
181 |
foreach( self::$fields as $field_name => $field_details ) {
|
182 |
+
if ( ! isset( $options[ $field_name ] ) ) {
|
183 |
+
$options[ $field_name ] = $field_details['default'];
|
184 |
}
|
185 |
}
|
186 |
+
|
187 |
+
return $options;
|
188 |
}
|
189 |
|
190 |
/**
|
193 |
* @param array $wp WordPress request
|
194 |
*/
|
195 |
public static function restrict_access( $wp ) {
|
196 |
+
if ( empty( $wp->query_vars['rest_route'] ) ) {
|
197 |
+
remove_action( 'parse_request', array( __CLASS__, 'restrict_access' ), 1 ); // only need it the first time
|
198 |
+
}
|
199 |
+
|
200 |
+
self::$rsa_options = self::get_options();
|
201 |
+
$mode = self::get_network_mode();
|
202 |
+
|
203 |
+
if ( RSA_IS_NETWORK ) {
|
204 |
+
if ( 'enforce' === $mode ) {
|
205 |
+
self::$rsa_options = self::get_options( true );
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
$blog_public = get_option( 'blog_public', 2 );
|
210 |
+
|
211 |
+
//If rsa_mode==enforce we override the rsa_options
|
212 |
+
if( RSA_IS_NETWORK && 'enforce' === $mode ) {
|
213 |
+
$blog_public = get_site_option( 'blog_public', 2 );
|
214 |
+
}
|
215 |
+
|
216 |
+
$is_restricted = !( is_admin() || is_user_logged_in() || 2 != $blog_public || ( defined( 'WP_INSTALLING' ) && isset( $_GET['key'] ) ) );
|
217 |
if ( apply_filters( 'restricted_site_access_is_restricted', $is_restricted, $wp ) === false ) {
|
218 |
return;
|
219 |
}
|
220 |
|
|
|
|
|
221 |
// check for the allow list, if its empty block everything
|
222 |
+
if ( ! empty( self::$rsa_options['allowed'] ) && is_array( self::$rsa_options['allowed'] ) ) {
|
223 |
+
$remote_ip = $_SERVER['REMOTE_ADDR']; // save the remote ip
|
224 |
if ( strpos( $remote_ip, '.' ) ) {
|
225 |
+
$remote_ip = str_replace( '::ffff:', '', $remote_ip ); // handle dual-stack addresses
|
226 |
}
|
227 |
+
$remote_ip = inet_pton( $remote_ip ); // parse the remote ip
|
228 |
+
|
229 |
// iterate through the allow list
|
230 |
+
foreach ( self::$rsa_options['allowed'] as $line ) {
|
231 |
list( $ip, $mask ) = explode( '/', $line . '/128' ); // get the ip and mask from the list
|
232 |
+
|
233 |
+
$mask = str_repeat( 'f', $mask >> 2 ); // render the mask as bits, similar to info on the php.net man page discussion for inet_pton
|
234 |
+
|
235 |
+
switch ( $mask % 4 ) {
|
236 |
case 1:
|
237 |
$mask .= '8';
|
238 |
break;
|
243 |
$mask .= 'e';
|
244 |
break;
|
245 |
}
|
246 |
+
|
247 |
$mask = pack( 'H*', $mask );
|
248 |
+
|
249 |
// check if the masked versions match
|
250 |
if ( ( inet_pton( $ip ) & $mask ) == ( $remote_ip & $mask ) ) {
|
251 |
return;
|
252 |
}
|
253 |
}
|
254 |
}
|
255 |
+
|
256 |
$rsa_restrict_approach = apply_filters( 'restricted_site_access_approach', self::$rsa_options['approach'] );
|
257 |
do_action( 'restrict_site_access_handling', $rsa_restrict_approach, $wp ); // allow users to hook handling
|
258 |
+
|
259 |
+
switch ( $rsa_restrict_approach ) {
|
260 |
case 4:
|
261 |
+
if ( ! empty( self::$rsa_options['page'] ) && ( $page_id = get_post_field( 'ID', self::$rsa_options['page'] ) ) ) {
|
262 |
unset( $wp->query_vars );
|
263 |
$wp->query_vars['page_id'] = $page_id;
|
264 |
return;
|
265 |
}
|
266 |
+
|
267 |
case 3:
|
268 |
$message = __( self::$rsa_options['message'], 'restricted-site-access' );
|
269 |
$message .= "\n<!-- protected by Restricted Site Access http://10up.com/plugins/restricted-site-access-wordpress/ -->";
|
270 |
$message = apply_filters( 'restricted_site_access_message', $message, $wp );
|
271 |
+
wp_die( $message, get_bloginfo( 'name' ) . ' - Site Access Restricted', array( 'response' => 403 ) );
|
272 |
+
|
273 |
case 2:
|
274 |
if ( ! empty( self::$rsa_options['redirect_url'] ) ) {
|
275 |
+
if ( ! empty( self::$rsa_options['redirect_path'] ) ) {
|
276 |
self::$rsa_options['redirect_url'] = untrailingslashit( self::$rsa_options['redirect_url'] ) . $_SERVER['REQUEST_URI'];
|
277 |
}
|
278 |
break;
|
279 |
}
|
280 |
+
|
281 |
default:
|
282 |
+
self::$rsa_options['head_code'] = 302;
|
283 |
$current_path = empty( $_SERVER['REQUEST_URI'] ) ? home_url() : $_SERVER['REQUEST_URI'];
|
284 |
self::$rsa_options['redirect_url'] = wp_login_url( $current_path );
|
285 |
}
|
286 |
|
287 |
$redirect_url = apply_filters( 'restricted_site_access_redirect_url', self::$rsa_options['redirect_url'], $wp );
|
288 |
+
$redirect_code = apply_filters( 'restricted_site_access_head', self::$rsa_options['head_code'], $wp );
|
289 |
+
|
290 |
wp_redirect( $redirect_url, $redirect_code );
|
291 |
die;
|
292 |
}
|
298 |
// customize privacy message
|
299 |
add_filter( 'privacy_on_link_text', array( __CLASS__, 'privacy_on_link_text' ) );
|
300 |
add_filter( 'privacy_on_link_title', array( __CLASS__, 'privacy_on_link_title' ) );
|
301 |
+
|
302 |
// customize privacy page
|
303 |
add_action( 'load-options-' . self::$settings_page . '.php', array( __CLASS__, 'load_options_page' ) );
|
304 |
+
|
305 |
// add new choice for blog privacy
|
306 |
add_action( 'blog_privacy_selector', array( __CLASS__, 'blog_privacy_selector' ) );
|
307 |
+
|
308 |
// settings for restricted site access
|
309 |
register_setting( self::$settings_page, 'rsa_options', array( __CLASS__, 'sanitize_options' ) ); // array of fundamental options including ID and caching info
|
310 |
add_settings_section( 'restricted-site-access', '', '__return_empty_string', self::$settings_page );
|
311 |
foreach ( self::$fields as $field_name => $field_data ) {
|
312 |
add_settings_field( $field_name, __( $field_data['label'], 'restricted-site-access' ), array( __CLASS__, $field_data['field'] ), self::$settings_page, 'restricted-site-access' );
|
313 |
}
|
314 |
+
|
315 |
add_filter( 'plugin_action_links_' . self::$basename, array( __CLASS__, 'plugin_action_links' ) );
|
316 |
+
|
317 |
+
//This is for Network Site Settings
|
318 |
+
if ( RSA_IS_NETWORK && is_network_admin() ) {
|
319 |
+
add_action( 'load-settings.php', array( __CLASS__, 'load_network_settings_page' ) );
|
320 |
+
add_action( 'network_admin_notices', array( __CLASS__, 'page_cache_notice' ) );
|
321 |
+
|
322 |
+
}
|
323 |
+
|
324 |
+
add_action( 'admin_notices', array( __CLASS__, 'page_cache_notice' ) );
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Show RSA Settings in Network Settings
|
329 |
+
*/
|
330 |
+
public static function show_network_settings() {
|
331 |
+
$mode = self::get_network_mode();
|
332 |
+
?>
|
333 |
+
<h2><?php _e( 'Restricted Site Access Settings', 'restricted-site-access' ); ?></h2>
|
334 |
+
<table id="restricted-site-access-mode" class="option-site-visibility form-table">
|
335 |
+
<tr>
|
336 |
+
<th scope="row"><?php _e( 'Mode', 'restricted-site-access' ) ?></th>
|
337 |
+
<td>
|
338 |
+
<fieldset>
|
339 |
+
<legend class="screen-reader-text"><?php _e( 'Mode', 'restricted-site-access' ) ?></legend>
|
340 |
+
<label><input name="rsa_mode" type="radio" id="rsa-mode-default" value="default"<?php checked( $mode, 'default') ?> /> <?php _e( '<strong>Default</strong> to the settings below when creating a new site', 'restricted-site-access' ); ?></label><br />
|
341 |
+
<label><input name="rsa_mode" type="radio" id="rsa-mode-enforce" value="enforce"<?php checked( $mode, 'enforce') ?> /> <?php _e( '<strong>Enforce</strong> the settings below across all sites', 'restricted-site-access' ); ?></label><br />
|
342 |
+
</fieldset>
|
343 |
+
</td>
|
344 |
+
</tr>
|
345 |
+
<tr>
|
346 |
+
<th scope="row"><?php _e( 'Site Visibility', 'restricted-site-access' ) ?></th>
|
347 |
+
<?php
|
348 |
+
$blog_public = get_site_option( 'blog_public' );
|
349 |
+
|
350 |
+
if ( false === $blog_public ) {
|
351 |
+
$blog_public = 1;
|
352 |
+
}
|
353 |
+
?>
|
354 |
+
<td>
|
355 |
+
<fieldset>
|
356 |
+
<legend class="screen-reader-text"><span><?php _e( 'Site Visibility', 'restricted-site-access' ) ?></span></legend>
|
357 |
+
<input id="blog-public" type="radio" name="blog_public" value="1" <?php checked( $blog_public, '1') ?>>
|
358 |
+
<label for="blog-public"><?php _e( 'Allow search engines to index this site', 'restricted-site-access' ) ?></label><br>
|
359 |
+
<input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked( $blog_public, '0') ?>>
|
360 |
+
<label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site', 'restricted-site-access' ) ?></label>
|
361 |
+
<p class="description"><?php _e( 'Note: Neither of these options blocks access to your site — it is up to search engines to honor your request.', 'restricted-site-access' ) ?></p>
|
362 |
+
<p>
|
363 |
+
<input id="blog-restricted" type="radio" name="blog_public" value="2" <?php checked( $blog_public, '2') ?>>
|
364 |
+
<label for="blog-restricted"><?php _e( 'Restrict site access to visitors who are logged in or allowed by IP address', 'restricted-site-access' ) ?></label>
|
365 |
+
</p>
|
366 |
+
</fieldset>
|
367 |
+
</td>
|
368 |
+
</tr>
|
369 |
+
</table>
|
370 |
+
<table id="restricted-site-access" class="form-table">
|
371 |
+
<tr>
|
372 |
+
<th scope="row"><?php _e( 'Handle restricted visitors', 'restricted-site-access' ) ?></th>
|
373 |
+
<td>
|
374 |
+
<?php
|
375 |
+
self::settings_field_handling();
|
376 |
+
?>
|
377 |
+
</td>
|
378 |
+
</tr>
|
379 |
+
<tr>
|
380 |
+
<th scope="row"><?php _e( 'Redirect web address', 'restricted-site-access' ) ?></th>
|
381 |
+
<td>
|
382 |
+
<?php
|
383 |
+
self::settings_field_redirect();
|
384 |
+
?>
|
385 |
+
</td>
|
386 |
+
</tr>
|
387 |
+
<tr>
|
388 |
+
<th scope="row"><?php _e( 'Redirect to same path', 'restricted-site-access' ) ?></th>
|
389 |
+
<td>
|
390 |
+
<?php
|
391 |
+
self::settings_field_redirect_path();
|
392 |
+
?>
|
393 |
+
</td>
|
394 |
+
</tr>
|
395 |
+
<tr>
|
396 |
+
<th scope="row"><?php _e( 'Redirection status code', 'restricted-site-access' ) ?></th>
|
397 |
+
<td>
|
398 |
+
<?php
|
399 |
+
self::settings_field_redirect_code();
|
400 |
+
?>
|
401 |
+
</td>
|
402 |
+
</tr>
|
403 |
+
<tr>
|
404 |
+
<th scope="row"><?php _e( 'Restriction message', 'restricted-site-access' ) ?></th>
|
405 |
+
<td>
|
406 |
+
<?php
|
407 |
+
self::settings_field_message();
|
408 |
+
?>
|
409 |
+
</td>
|
410 |
+
</tr>
|
411 |
+
<tr>
|
412 |
+
<th scope="row"><?php _e( 'Unrestricted IP addresses', 'restricted-site-access' ) ?></th>
|
413 |
+
<td>
|
414 |
+
<?php
|
415 |
+
self::settings_field_allowed();
|
416 |
+
?>
|
417 |
+
</td>
|
418 |
+
</tr>
|
419 |
+
</table>
|
420 |
+
|
421 |
+
<?php
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Handle Save Options for RSA Settings in Network Settings
|
426 |
+
*/
|
427 |
+
public static function save_network_settings() {
|
428 |
+
$options = array(
|
429 |
+
'rsa_mode', 'blog_public', 'rsa_options'
|
430 |
+
);
|
431 |
+
|
432 |
+
foreach ( $options as $option_name ) {
|
433 |
+
if ( ! isset( $_POST[ $option_name ] ) ){
|
434 |
+
continue;
|
435 |
+
}
|
436 |
+
|
437 |
+
switch ( $option_name ){
|
438 |
+
case 'rsa_options':
|
439 |
+
$value = self::sanitize_options( $_POST[ $option_name ] );
|
440 |
+
break;
|
441 |
+
case 'blog_public':
|
442 |
+
$value = absint( $_POST[ $option_name ] );
|
443 |
+
break;
|
444 |
+
default:
|
445 |
+
$value = sanitize_key( $_POST[ $option_name ] );
|
446 |
+
break;
|
447 |
+
}
|
448 |
+
|
449 |
+
update_site_option( $option_name, $value );
|
450 |
+
}
|
451 |
}
|
452 |
|
453 |
/**
|
478 |
return $text;
|
479 |
}
|
480 |
|
481 |
+
public static function enqueue_settings_script() {
|
482 |
+
$js_path = plugin_dir_url( __FILE__ ) . '/assets/js/settings.min.js';
|
483 |
+
|
484 |
+
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
|
485 |
+
$js_path = plugin_dir_url( __FILE__ ) . '/assets/js/src/settings.js';
|
486 |
+
}
|
487 |
+
|
488 |
+
wp_enqueue_script( 'rsa-settings', $js_path, array( 'jquery-effects-shake' ), RSA_VERSION, true );
|
489 |
+
}
|
490 |
+
|
491 |
+
public static function enqueue_admin_script() {
|
492 |
+
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
|
493 |
+
wp_enqueue_script( 'rsa-admin', plugin_dir_url( __FILE__ ) . '/assets/js/src/admin.js', array( 'jquery' ), RSA_VERSION, true );
|
494 |
+
} else {
|
495 |
+
wp_enqueue_script( 'rsa-admin', plugin_dir_url( __FILE__ ) . '/assets/js/admin.min.js', array( 'jquery' ), RSA_VERSION, true );
|
496 |
+
}
|
497 |
+
|
498 |
+
wp_localize_script( 'rsa-admin', 'rsaAdmin', array(
|
499 |
+
'nonce' => wp_create_nonce( 'rsa_admin_nonce' ),
|
500 |
+
) );
|
501 |
+
}
|
502 |
+
|
503 |
/**
|
504 |
* Loads needed scripts and assets on the Reading page
|
505 |
*/
|
506 |
public static function load_options_page() {
|
507 |
+
self::enqueue_settings_script();
|
|
|
508 |
|
509 |
add_action( 'admin_notices', array( __CLASS__, 'admin_notice' ) );
|
510 |
add_action( 'admin_head', array( __CLASS__, 'admin_head' ) );
|
511 |
|
512 |
+
self::$rsa_options = self::get_options();
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Load needed scripts and assets on Network Settings page
|
517 |
+
*/
|
518 |
+
public static function load_network_settings_page(){
|
519 |
+
self::enqueue_settings_script();
|
520 |
+
|
521 |
+
self::$rsa_options = self::get_options( true );
|
522 |
+
|
523 |
+
add_action( 'wpmu_options', array( __CLASS__, 'show_network_settings' ) );
|
524 |
+
add_action( 'update_wpmu_options', array( __CLASS__, 'save_network_settings' ) );
|
525 |
}
|
526 |
|
527 |
/**
|
528 |
* Customize admin notices to ensure user completes restriction setup properly
|
529 |
*/
|
530 |
public static function admin_notice() {
|
531 |
+
if( RSA_IS_NETWORK && 'enforce' === self::get_network_mode() ){
|
532 |
+
$rsa_mode_message = __( 'Network visibility settings are currently enforced across all blogs on the network.', 'restricted-site-access' );
|
533 |
+
echo '<div class="notice notice-warning"><p><strong>' . $rsa_mode_message . '</strong></p></div>';
|
534 |
+
return;
|
535 |
+
}
|
536 |
+
|
537 |
if ( empty( self::$rsa_options['approach'] ) ) {
|
538 |
return;
|
539 |
}
|
540 |
+
|
541 |
if ( 4 == self::$rsa_options['approach'] && empty( self::$rsa_options['page'] ) ) {
|
542 |
$message = __( 'Please select the page you want to show restricted visitors. If no page is selected, WordPress will simply show a general restriction message.', 'restricted-site-access' );
|
543 |
} elseif ( 2 == self::$rsa_options['approach'] && empty( self::$rsa_options['redirect_url'] ) ) {
|
544 |
$message = __( 'Please enter the web address you would like to redirect restricted visitors to. If no address is entered, visitors will be redirected to the login screen.', 'restricted-site-access' );
|
545 |
}
|
546 |
+
|
547 |
if ( isset( $message ) ) {
|
548 |
+
echo '<div class="notice notice-error"><p><strong>' . $message . '</strong></p></div>';
|
549 |
+
}
|
550 |
+
}
|
551 |
+
|
552 |
+
/**
|
553 |
+
* Check if the page caching is on, and notify the admin
|
554 |
+
*/
|
555 |
+
public static function page_cache_notice() {
|
556 |
+
//If WP_CACHE is on we show notification
|
557 |
+
if ( defined( 'WP_CACHE' ) && true === WP_CACHE ) {
|
558 |
+
|
559 |
+
if ( RSA_IS_NETWORK ) {
|
560 |
+
if ( get_site_option( 'rsa_hide_page_cache_notice' ) ) {
|
561 |
+
return;
|
562 |
+
}
|
563 |
+
} else {
|
564 |
+
if ( get_option( 'rsa_hide_page_cache_notice' ) ) {
|
565 |
+
return;
|
566 |
+
}
|
567 |
+
}
|
568 |
+
|
569 |
+
$mode = self::get_network_mode();
|
570 |
+
|
571 |
+
$blog_public = get_option( 'blog_public', 2 );
|
572 |
+
|
573 |
+
if ( RSA_IS_NETWORK && 'enforce' === $mode ) {
|
574 |
+
$blog_public = get_site_option( 'blog_public', 2 );
|
575 |
+
}
|
576 |
+
|
577 |
+
if ( 2 !== (int) $blog_public ) {
|
578 |
+
return;
|
579 |
+
}
|
580 |
+
?>
|
581 |
+
<div data-rsa-notice="page-cache" class="notice notice-error is-dismissible">
|
582 |
+
<p>
|
583 |
+
<strong><?php _e( 'Page caching appears to be enabled. Restricted Site Access may not work as expected. <a href="https://wordpress.org/plugins/restricted-site-access/#faq">Learn more</a>.', 'restricted-site-access' ); ?></strong>
|
584 |
+
</p>
|
585 |
+
</div>
|
586 |
+
<?php
|
587 |
}
|
588 |
}
|
589 |
|
591 |
* Add restricted access help tab to screen
|
592 |
*/
|
593 |
public static function admin_head() {
|
594 |
+
$screen = get_current_screen();
|
595 |
+
$content = array();
|
596 |
+
|
597 |
+
// Populate the tab contents.
|
598 |
+
$content[] = sprintf(
|
599 |
+
'<p><strong>%1$s</strong> - %2$s</p>',
|
600 |
+
_x( 'Handle restricted visitors', 'help topic', 'restricted-site-access' ),
|
601 |
+
__( 'Choose the method for handling visitors to your site that are restricted.', 'restricted-site-access' )
|
602 |
+
);
|
603 |
+
|
604 |
+
$content[] = sprintf(
|
605 |
+
'<p><strong>%1$s</strong> - %2$s %3$s</p><p>%4$s</p>',
|
606 |
+
_x( 'Allowed IP addresses', 'help topic', 'restricted-site-access' ),
|
607 |
+
__( 'enter a single IP address (for example, 192.168.1.105) or an IP range using a network prefix (for example, 10.0.0.1/24). Enter your addresses carefully!', 'restricted-site-access' ),
|
608 |
+
sprintf(
|
609 |
+
'<a href="http://www.csgnetwork.com/ipinfocalc.html">%s</a>',
|
610 |
+
/** translators: link to http://www.csgnetwork.com/ipinfocalc.html */
|
611 |
+
__( 'Here is a handy calculator to check your prefix.', 'restricted-site-access' )
|
612 |
+
),
|
613 |
+
__( 'The redirection fields are only used when "Handle restricted visitors" is set to "Redirect them to a specified web address".', 'restricted-site-access' )
|
614 |
+
);
|
615 |
+
|
616 |
+
$content[] = sprintf(
|
617 |
+
'<p><strong>%1$s</strong> - %2$s</p>',
|
618 |
+
_x( 'Redirect web address', 'help topic', 'restricted-site-access' ),
|
619 |
+
__( 'The web address of the site you want the visitor redirected to.', 'restricted-site-access' )
|
620 |
+
);
|
621 |
+
|
622 |
+
$content[] = sprintf(
|
623 |
+
'<p><strong>%1$s</strong> - %2$s</p>',
|
624 |
+
_x( 'Redirect to the same path', 'help topic', 'restricted-site-access' ),
|
625 |
+
__( 'redirect the visitor to the same path (URI) entered at this site. Typically used when there are two, very similar sites at different public web addresses; for instance, a parallel development server accessible on the Internet but not intended for the public.', 'restricted-site-access' )
|
626 |
+
);
|
627 |
+
|
628 |
+
$content[] = sprintf(
|
629 |
+
'<p><strong>%1$s</strong> - %2$s</p>',
|
630 |
+
_x( 'Redirection status code', 'help topic', 'restricted-site-access' ),
|
631 |
+
__( 'Redirect status codes can provide certain visitors, particularly search engines, more information about the nature of the redirect. A 301 redirect tells search engines that a page has moved permanently to the new location. 307 indicates a temporary redirect. 302 is an undefined redirect.', 'restricted-site-access' )
|
632 |
+
);
|
633 |
+
|
634 |
$screen->add_help_tab( array(
|
635 |
'id' => 'restricted-site-access',
|
636 |
+
'title' => _x( 'Restricted Site Acccess', 'help screen title', 'restricted-site-access' ),
|
637 |
+
'content' => implode( PHP_EOL, $content ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
638 |
) );
|
639 |
}
|
640 |
|
642 |
* Add a new choice to the privacy selector
|
643 |
*/
|
644 |
public static function blog_privacy_selector() {
|
645 |
+
$is_restricted = ( 2 == get_option( 'blog_public' ));
|
646 |
+
$is_restricted = apply_filters( 'restricted_site_access_is_restricted', $is_restricted );
|
647 |
?>
|
648 |
<p>
|
649 |
+
<input id="blog-restricted" type="radio" name="blog_public" value="2" <?php checked( $is_restricted ); ?> />
|
650 |
+
<label for="blog-restricted"><?php esc_html_e( 'Restrict site access to visitors who are logged in or allowed by IP address', 'restricted-site-access' ); ?></label>
|
651 |
</p>
|
652 |
<?php
|
653 |
}
|
670 |
|
671 |
$new_input['redirect_path'] = empty( $input['redirect_path'] ) ? 0 : 1;
|
672 |
$new_input['head_code'] = in_array( (int) $input['head_code'], array( 301, 302, 307 ) ) ? (int) $input['head_code'] : self::$fields['head_code']['default'];
|
673 |
+
$new_input['redirect_url'] = empty( $input['redirect_url'] ) ? '' : esc_url_raw( $input['redirect_url'], array( 'http', 'https' ) );
|
674 |
$new_input['page'] = empty( $input['page'] ) ? 0 : (int) $input['page'];
|
675 |
|
676 |
$new_input['allowed'] = array();
|
677 |
+
if ( ! empty( $input['allowed'] ) && is_array( $input['allowed'] ) ) {
|
678 |
+
foreach ( $input['allowed'] as $ip_address ) {
|
679 |
if ( self::is_ip( $ip_address ) ) {
|
680 |
$new_input['allowed'][] = $ip_address;
|
681 |
}
|
682 |
}
|
683 |
}
|
684 |
+
|
685 |
return $new_input;
|
686 |
}
|
687 |
|
690 |
*
|
691 |
* @param $args
|
692 |
*/
|
693 |
+
public static function settings_field_handling( $args = array() ) {
|
694 |
if ( ! isset( self::$rsa_options['approach'] ) ) {
|
695 |
self::$rsa_options['approach'] = 1;
|
696 |
}
|
697 |
?>
|
698 |
<fieldset id="rsa_handle_fields">
|
699 |
<input id="rsa-send-to-login" name="rsa_options[approach]" type="radio" value="1" <?php checked( self::$rsa_options['approach'], 1 ); ?> />
|
700 |
+
<label for="rsa-send-to-login"><?php esc_html_e( 'Send them to the WordPress login screen','restricted-site-access' ); ?></label>
|
701 |
<br />
|
702 |
<input id="rsa-redirect-visitor" name="rsa_options[approach]" type="radio" value="2" <?php checked( self::$rsa_options['approach'], 2 ); ?> />
|
703 |
+
<label for="rsa-redirect-visitor"><?php esc_html_e( 'Redirect them to a specified web address', 'restricted-site-access' ); ?></label>
|
704 |
<br />
|
705 |
<input id="rsa-display-message" name="rsa_options[approach]" type="radio" value="3" <?php checked( self::$rsa_options['approach'], 3 ); ?> />
|
706 |
+
<label for="rsa-display-message"><?php esc_html_e( 'Show them a simple message', 'restricted-site-access' ); ?></label>
|
707 |
+
|
708 |
+
<?php if ( ! is_network_admin() ) : ?>
|
709 |
+
<br />
|
710 |
+
<input id="rsa-unblocked-page" name="rsa_options[approach]" type="radio" value="4" <?php checked( self::$rsa_options['approach'], 4 ); ?> />
|
711 |
+
<label for="rsa-unblocked-page"><?php esc_html_e( 'Show them a page', 'restricted-site-access' ); ?></label>
|
712 |
+
<?php endif; ?>
|
713 |
</fieldset>
|
714 |
<?php
|
715 |
}
|
719 |
*
|
720 |
* @param $args
|
721 |
*/
|
722 |
+
public static function settings_field_allowed( $args = array() ) {
|
723 |
?>
|
724 |
<div class="hide-if-no-js">
|
725 |
<div id="ip_list">
|
726 |
+
<div id="ip_list_empty" style="display: none;"><input type="text" name="rsa_options[allowed][]" value="" readonly="true" /> <a href="#remove" class="remove_btn"><?php echo esc_html( _x( 'Remove', 'remove IP address action', 'restricted-site-access' ) ); ?></a></div>
|
727 |
<?php
|
728 |
$ips = (array) self::$rsa_options['allowed'];
|
729 |
+
foreach ( $ips as $ip ) {
|
730 |
+
if ( ! empty( $ip ) ) {
|
731 |
+
echo '<div><input type="text" name="rsa_options[allowed][]" value="' . esc_attr( $ip ) . '" readonly="true" /> <a href="#remove" class="remove_btn">' . _x( 'Remove', 'remove IP address action', 'restricted-site-access' ) . '</a></div>';
|
|
|
732 |
}
|
733 |
+
}
|
734 |
?>
|
735 |
</div>
|
736 |
<div>
|
737 |
<input type="text" name="newip" id="newip" /> <input class="button" type="button" id="addip" value="<?php _e( 'Add' ); ?>" />
|
738 |
+
<p class="description" style="display: inline;"><label for="newip"><?php esc_html_e( 'Enter a single IP address or a range using a subnet prefix', 'restricted-site-access' ); ?></label></p>
|
739 |
+
</div>
|
740 |
+
<?php if ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { ?><input class="button" type="button" id="rsa_myip" value="<?php esc_attr_e( 'Add My Current IP Address', 'restricted-site-access' ); ?>" style="margin-top: 5px;" data-myip="<?php echo esc_attr( $_SERVER['REMOTE_ADDR'] ); ?>" /><br /><?php } ?>
|
741 |
</div>
|
742 |
+
<p class="hide-if-js"><strong><?php esc_html_e( 'To manage IP addresses, you must use a JavaScript enabled browser.', 'restricted-site-access' ); ?></strong></p>
|
743 |
<?php
|
744 |
}
|
745 |
|
748 |
*
|
749 |
* @param $args
|
750 |
*/
|
751 |
+
public static function settings_field_message( $args = array() ) {
|
752 |
if ( empty( self::$rsa_options['message'] ) ) {
|
753 |
self::$rsa_options['message'] = __( 'Access to this site is restricted.', 'restricted-site-access' );
|
754 |
}
|
766 |
*
|
767 |
* @param $args
|
768 |
*/
|
769 |
+
public static function settings_field_redirect( $args = array() ) {
|
770 |
if ( ! isset( self::$rsa_options['redirect_url'] ) ) {
|
771 |
self::$rsa_options['redirect_url'] = '';
|
772 |
}
|
780 |
*
|
781 |
* @param $args
|
782 |
*/
|
783 |
+
public static function settings_field_redirect_path( $args = array() ) {
|
784 |
if ( ! isset( self::$rsa_options['redirect_path'] ) ) {
|
785 |
self::$rsa_options['redirect_path'] = 0;
|
786 |
}
|
788 |
<fieldset><legend class="screen-reader-text"><span><?php _e( self::$rsa_options['redirect_path']['label'], 'restricted-site-access' ); ?></span></legend>
|
789 |
<label for="redirect_path">
|
790 |
<input type="checkbox" name="rsa_options[redirect_path]" value="1" id="redirect_path" class="rsa_redirect_field" <?php checked( self::$rsa_options['redirect_path'] ); ?> />
|
791 |
+
<?php esc_html_e( 'Send restricted visitor to same path (relative URL) at the new web address', 'restricted-site-access' ); ?></label>
|
792 |
</fieldset>
|
793 |
<?php
|
794 |
}
|
798 |
*
|
799 |
* @param $args
|
800 |
*/
|
801 |
+
public static function settings_field_redirect_code( $args = array() ) {
|
802 |
if ( empty( self::$rsa_options['head_code'] ) ) {
|
803 |
self::$rsa_options['head_code'] = 302;
|
804 |
}
|
805 |
?>
|
806 |
<select name="rsa_options[head_code]" id="redirect_code" class="rsa_redirect_field">
|
807 |
+
<option value="301" <?php selected( self::$rsa_options['head_code'], 301 ); ?>><?php esc_html_e( '301 Permanent', 'restricted-site-access' ); ?></option>
|
808 |
+
<option value="302" <?php selected( self::$rsa_options['head_code'], 302 ); ?>><?php esc_html_e( '302 Undefined', 'restricted-site-access' ); ?></option>
|
809 |
+
<option value="307" <?php selected( self::$rsa_options['head_code'], 307 ); ?>><?php esc_html_e( '307 Temporary', 'restricted-site-access' ); ?></option>
|
810 |
</select>
|
811 |
<?php
|
812 |
}
|
816 |
*
|
817 |
* @param $args
|
818 |
*/
|
819 |
+
public static function settings_field_rsa_page( $args = array() ) {
|
820 |
if ( ! isset( self::$rsa_options['page'] ) ) {
|
821 |
self::$rsa_options['page'] = 0;
|
822 |
}
|
823 |
|
824 |
+
wp_dropdown_pages(array(
|
825 |
'selected' => self::$rsa_options['page'],
|
826 |
+
'show_option_none' => __( 'Select a page', 'restricted-site-access' ),
|
827 |
'name' => 'rsa_options[page]',
|
828 |
+
'id' => 'rsa_page',
|
829 |
));
|
830 |
}
|
831 |
|
833 |
* Validate IP address entry on demand (AJAX)
|
834 |
*/
|
835 |
public static function ajax_rsa_ip_check() {
|
836 |
+
if ( empty( $_POST['ip_address'] ) || ! self::is_ip( stripslashes( $_POST['ip_address'] ) ) ) {
|
837 |
die( '1' );
|
838 |
}
|
839 |
die;
|
850 |
// very basic validation of ranges
|
851 |
if ( strpos( $ip_address, '/' ) ) {
|
852 |
$ip_parts = explode( '/', $ip_address );
|
853 |
+
if ( empty( $ip_parts[1] ) || ! is_numeric( $ip_parts[1] ) || strlen( $ip_parts[1] ) > 3 ) {
|
854 |
return false;
|
855 |
}
|
856 |
$ip_address = $ip_parts[0];
|
857 |
}
|
858 |
|
859 |
// confirm IP part is a valid IPv6 or IPv4 IP
|
860 |
+
if ( empty( $ip_address ) || ! inet_pton( stripslashes( $ip_address ) ) ) {
|
861 |
return false;
|
862 |
}
|
863 |
|
872 |
* @return array
|
873 |
*/
|
874 |
public static function plugin_action_links( $links ) {
|
875 |
+
$links[] = sprintf(
|
876 |
+
'<a href="options-%s.php">%s</a>',
|
877 |
+
esc_attr( self::$settings_page ),
|
878 |
+
__( 'Settings', 'settings page link', 'restricted-site-access' )
|
879 |
+
);
|
880 |
+
|
881 |
+
return $links;
|
882 |
}
|
883 |
+
|
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 |
*/
|
896 |
update_option( 'blog_public', 1 );
|
897 |
}
|
898 |
}
|
899 |
+
|
900 |
+
/**
|
901 |
+
* Determine if plugin is network activated
|
902 |
+
*/
|
903 |
+
public static function is_network( $plugin ) {
|
904 |
+
|
905 |
+
$plugins = get_site_option( 'active_sitewide_plugins');
|
906 |
+
|
907 |
+
if ( is_multisite() && isset( $plugins[ $plugin ] ) ) {
|
908 |
+
return true;
|
909 |
+
}
|
910 |
+
|
911 |
+
return false;
|
912 |
+
|
913 |
+
}
|
914 |
}
|
915 |
|
916 |
+
define( 'RSA_IS_NETWORK', Restricted_Site_Access::is_network( plugin_basename( __FILE__ ) ) );
|
917 |
+
|
918 |
Restricted_Site_Access::get_instance();
|
919 |
|
920 |
/**
|
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' );
|
928 |
+
|
929 |
+
$sites = get_sites();
|
930 |
+
|
931 |
+
foreach ( $sites as $site ) {
|
932 |
+
switch_to_blog( $site->blog_id );
|
933 |
+
|
934 |
+
if ( 2 == get_option( 'blog_public' ) ) {
|
935 |
+
update_option( 'blog_public', 1 );
|
936 |
+
}
|
937 |
+
delete_option('rsa_options');
|
938 |
+
|
939 |
+
restore_current_blog();
|
940 |
+
}
|
941 |
+
} else {
|
942 |
+
if ( 2 == get_option( 'blog_public' ) ) {
|
943 |
+
update_option( 'blog_public', 1 );
|
944 |
+
}
|
945 |
+
delete_option('rsa_options');
|
946 |
}
|
|
|
947 |
}
|
948 |
|
949 |
register_uninstall_hook( __FILE__, 'restricted_site_access_uninstall' );
|
950 |
|
951 |
if ( ! function_exists( 'inet_pton' ) ) :
|
952 |
|
953 |
+
/**
|
954 |
+
* inet_pton is not included in PHP < 5.3 on Windows (WP requires PHP 5.2)
|
955 |
+
*
|
956 |
+
* @param string $ip IP Address
|
957 |
+
*
|
958 |
+
* @return array|string
|
959 |
+
*/
|
960 |
+
function inet_pton( $ip ) {
|
961 |
+
if ( strpos( $ip, '.' ) !== false ) {
|
962 |
+
// ipv4
|
963 |
+
$ip = pack( 'N',ip2long( $ip ) );
|
964 |
+
} elseif ( strpos( $ip, ':' ) !== false ) {
|
965 |
+
// ipv6
|
966 |
+
$ip = explode( ':', $ip );
|
967 |
+
$res = str_pad( '', (4 * (8 -count( $ip ))), '0000', STR_PAD_LEFT );
|
968 |
+
foreach ( $ip as $seg ) {
|
969 |
+
$res .= str_pad( $seg, 4, '0', STR_PAD_LEFT );
|
970 |
+
}
|
971 |
+
$ip = pack( 'H' . strlen( $res ), $res );
|
972 |
+
}
|
973 |
+
return $ip;
|
974 |
+
}
|
975 |
|
976 |
+
endif;
|