Version Description
- Feature: WP-CLI support! Try
wp rsa
to get started. - Feature: Whitelist IPs via the
RSA_IP_WHITELIST
constant. - Feature: Use WordPress.org-provided language packs instead of bundled translations.
- Bug fix: Restrict "virtual pages" and allow them to be used as the unrestricted page, such as with BuddyPress.
- Bug fix: Hide settings properly when no published pages exist.
- Bug fix: Avoid double slashes in asset URLs that can lead to 404 errors.
Download this release
Release Info
Developer | helen |
Plugin | Restricted Site Access |
Version | 7.0.0 |
Comparing to | |
See all releases |
Code changes from version 6.2.1 to 7.0.0
- localization/restricted-site-access-es_ES.mo +0 -0
- localization/restricted-site-access-es_ES.po +0 -366
- localization/restricted-site-access.pot +0 -282
- readme.txt +29 -2
- restricted_site_access.php +114 -28
- wp-cli.php +577 -0
localization/restricted-site-access-es_ES.mo
DELETED
Binary file
|
localization/restricted-site-access-es_ES.po
DELETED
@@ -1,366 +0,0 @@
|
|
1 |
-
# Copyright (C) 2011 10up
|
2 |
-
# This file is distributed under the same license as the Restricted Site Access package.
|
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 |
-
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
localization/restricted-site-access.pot
DELETED
@@ -1,282 +0,0 @@
|
|
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 ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
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:
|
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.
|
@@ -81,6 +81,25 @@ function my_rsa_user_can_access( $access ) {
|
|
81 |
}
|
82 |
`
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
== Screenshots ==
|
85 |
|
86 |
1. Screenshot of settings panel with simple Restricted Site Access option (send to login page).
|
@@ -89,6 +108,14 @@ function my_rsa_user_can_access( $access ) {
|
|
89 |
|
90 |
== Changelog ==
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
= 6.2.1 =
|
93 |
* Bug fix: Don't redirect logged-in users viewing the site in a single site install.
|
94 |
|
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: 4.6
|
6 |
+
Tested up to: 4.9.8
|
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.
|
81 |
}
|
82 |
`
|
83 |
|
84 |
+
= Is there a way to configure this with [WP-CLI](https://make.wordpress.org/cli/)? =
|
85 |
+
|
86 |
+
As of version 7.0.0, CLI integration has been added. To see the available commands, type the following in your WordPress directory:
|
87 |
+
|
88 |
+
`
|
89 |
+
$ wp rsa
|
90 |
+
`
|
91 |
+
|
92 |
+
= How can I programatically define whitelisted IPs? =
|
93 |
+
|
94 |
+
In 7.0.0, the capacity to define a pipe delimited array of whitelisted IP addresses via constant was introduced.
|
95 |
+
|
96 |
+
In your `wp-config.php` file, you can define the following:
|
97 |
+
|
98 |
+
`
|
99 |
+
define( 'RSA_IP_WHITELIST', '192.0.0.1|192.0.0.10' );
|
100 |
+
`
|
101 |
+
|
102 |
+
|
103 |
== Screenshots ==
|
104 |
|
105 |
1. Screenshot of settings panel with simple Restricted Site Access option (send to login page).
|
108 |
|
109 |
== Changelog ==
|
110 |
|
111 |
+
= 7.0.0 =
|
112 |
+
* Feature: WP-CLI support! 🎉 Try `wp rsa` to get started.
|
113 |
+
* Feature: Whitelist IPs via the `RSA_IP_WHITELIST` constant.
|
114 |
+
* Feature: Use WordPress.org-provided language packs instead of bundled translations.
|
115 |
+
* Bug fix: Restrict "virtual pages" and allow them to be used as the unrestricted page, such as with BuddyPress.
|
116 |
+
* Bug fix: Hide settings properly when no published pages exist.
|
117 |
+
* Bug fix: Avoid double slashes in asset URLs that can lead to 404 errors.
|
118 |
+
|
119 |
= 6.2.1 =
|
120 |
* Bug fix: Don't redirect logged-in users viewing the site in a single site install.
|
121 |
|
restricted_site_access.php
CHANGED
@@ -3,13 +3,14 @@
|
|
3 |
* Plugin Name: Restricted Site Access
|
4 |
* Plugin URI: http://10up.com/plugins/restricted-site-access-wordpress/
|
5 |
* Description: <strong>Limit access your site</strong> to visitors who are logged in or accessing the site from a set of specific IP addresses. Send restricted visitors to the log in page, redirect them, or display a message or page. <strong>Powerful control over redirection</strong>, including <strong>SEO friendly redirect headers</strong>. Great solution for Extranets, publicly hosted Intranets, or parallel development sites.
|
6 |
-
* Version:
|
7 |
* Author: Jake Goldman, 10up, Oomph
|
8 |
* Author URI: http://10up.com
|
9 |
* License: GPLv2 or later
|
|
|
10 |
*/
|
11 |
|
12 |
-
define( 'RSA_VERSION', '
|
13 |
|
14 |
class Restricted_Site_Access {
|
15 |
|
@@ -50,7 +51,6 @@ class Restricted_Site_Access {
|
|
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' ) );
|
54 |
add_action( 'wp_ajax_rsa_ip_check', array( __CLASS__, 'ajax_rsa_ip_check' ) );
|
55 |
|
56 |
add_action( 'activate_' . self::$basename, array( __CLASS__, 'activation' ), 10, 1 );
|
@@ -104,13 +104,6 @@ class Restricted_Site_Access {
|
|
104 |
restore_current_blog();
|
105 |
}
|
106 |
|
107 |
-
/**
|
108 |
-
* Loads the plugin textdomain
|
109 |
-
*/
|
110 |
-
public static function load_textdomain() {
|
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 |
*/
|
@@ -168,7 +161,7 @@ class Restricted_Site_Access {
|
|
168 |
/**
|
169 |
* populate the option with defaults
|
170 |
*/
|
171 |
-
|
172 |
$options = array();
|
173 |
|
174 |
if ( $network ) {
|
@@ -267,13 +260,21 @@ class Restricted_Site_Access {
|
|
267 |
return;
|
268 |
}
|
269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
// check for the allow list, if its empty block everything
|
271 |
-
if (
|
272 |
$remote_ip = self::get_client_ip_address();
|
273 |
|
274 |
// iterate through the allow list
|
275 |
-
foreach(
|
276 |
-
if( self::ip_in_range( $remote_ip, $line ) ){
|
277 |
|
278 |
/**
|
279 |
* Fires when an ip address match occurs.
|
@@ -298,10 +299,23 @@ class Restricted_Site_Access {
|
|
298 |
|
299 |
switch ( $rsa_restrict_approach ) {
|
300 |
case 4:
|
301 |
-
if ( ! empty( self::$rsa_options['page'] )
|
302 |
-
|
303 |
-
|
304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
}
|
306 |
|
307 |
case 3:
|
@@ -349,7 +363,14 @@ class Restricted_Site_Access {
|
|
349 |
register_setting( self::$settings_page, 'rsa_options', array( __CLASS__, 'sanitize_options' ) ); // array of fundamental options including ID and caching info
|
350 |
add_settings_section( 'restricted-site-access', '', '__return_empty_string', self::$settings_page );
|
351 |
foreach ( self::$fields as $field_name => $field_data ) {
|
352 |
-
add_settings_field(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
}
|
354 |
|
355 |
add_filter( 'plugin_action_links_' . self::$basename, array( __CLASS__, 'plugin_action_links' ) );
|
@@ -519,10 +540,10 @@ class Restricted_Site_Access {
|
|
519 |
}
|
520 |
|
521 |
public static function enqueue_settings_script() {
|
522 |
-
$js_path = plugin_dir_url( __FILE__ ) . '
|
523 |
|
524 |
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
|
525 |
-
$js_path = plugin_dir_url( __FILE__ ) . '
|
526 |
}
|
527 |
|
528 |
wp_enqueue_script( 'rsa-settings', $js_path, array( 'jquery-effects-shake' ), RSA_VERSION, true );
|
@@ -530,9 +551,9 @@ class Restricted_Site_Access {
|
|
530 |
|
531 |
public static function enqueue_admin_script() {
|
532 |
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
|
533 |
-
wp_enqueue_script( 'rsa-admin', plugin_dir_url( __FILE__ ) . '
|
534 |
} else {
|
535 |
-
wp_enqueue_script( 'rsa-admin', plugin_dir_url( __FILE__ ) . '
|
536 |
}
|
537 |
|
538 |
wp_localize_script( 'rsa-admin', 'rsaAdmin', array(
|
@@ -549,6 +570,8 @@ class Restricted_Site_Access {
|
|
549 |
add_action( 'admin_notices', array( __CLASS__, 'admin_notice' ) );
|
550 |
add_action( 'admin_head', array( __CLASS__, 'admin_head' ) );
|
551 |
|
|
|
|
|
552 |
self::$rsa_options = self::get_options();
|
553 |
}
|
554 |
|
@@ -767,18 +790,32 @@ class Restricted_Site_Access {
|
|
767 |
<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>
|
768 |
<?php
|
769 |
$ips = (array) self::$rsa_options['allowed'];
|
770 |
-
|
771 |
-
|
772 |
-
|
|
|
773 |
}
|
774 |
-
}
|
775 |
?>
|
776 |
</div>
|
777 |
<div>
|
778 |
-
<input type="text" name="newip" id="newip" /> <input class="button" type="button" id="addip" value="<?php
|
779 |
<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>
|
780 |
</div>
|
781 |
<?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( self::get_client_ip_address() ); ?>" /><br /><?php } ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
782 |
</div>
|
783 |
<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>
|
784 |
<?php
|
@@ -870,6 +907,25 @@ class Restricted_Site_Access {
|
|
870 |
));
|
871 |
}
|
872 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
873 |
/**
|
874 |
* Validate IP address entry on demand (AJAX)
|
875 |
*/
|
@@ -905,6 +961,32 @@ class Restricted_Site_Access {
|
|
905 |
return true;
|
906 |
}
|
907 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
908 |
/**
|
909 |
* Add settings link directing user to privacy page on plug-in page
|
910 |
*
|
@@ -1030,6 +1112,10 @@ define( 'RSA_IS_NETWORK', Restricted_Site_Access::is_network( plugin_basename( _
|
|
1030 |
|
1031 |
Restricted_Site_Access::get_instance();
|
1032 |
|
|
|
|
|
|
|
|
|
1033 |
/**
|
1034 |
* Uninstall routine for the plugin
|
1035 |
*/
|
3 |
* Plugin Name: Restricted Site Access
|
4 |
* Plugin URI: http://10up.com/plugins/restricted-site-access-wordpress/
|
5 |
* Description: <strong>Limit access your site</strong> to visitors who are logged in or accessing the site from a set of specific IP addresses. Send restricted visitors to the log in page, redirect them, or display a message or page. <strong>Powerful control over redirection</strong>, including <strong>SEO friendly redirect headers</strong>. Great solution for Extranets, publicly hosted Intranets, or parallel development sites.
|
6 |
+
* Version: 7.0.0
|
7 |
* Author: Jake Goldman, 10up, Oomph
|
8 |
* Author URI: http://10up.com
|
9 |
* License: GPLv2 or later
|
10 |
+
* Text Domain: restricted-site-access
|
11 |
*/
|
12 |
|
13 |
+
define( 'RSA_VERSION', '7.0.0' );
|
14 |
|
15 |
class Restricted_Site_Access {
|
16 |
|
51 |
|
52 |
add_action( 'parse_request', array( __CLASS__, 'restrict_access' ), 1 );
|
53 |
add_action( 'admin_init', array( __CLASS__, 'admin_init' ), 1 );
|
|
|
54 |
add_action( 'wp_ajax_rsa_ip_check', array( __CLASS__, 'ajax_rsa_ip_check' ) );
|
55 |
|
56 |
add_action( 'activate_' . self::$basename, array( __CLASS__, 'activation' ), 10, 1 );
|
104 |
restore_current_blog();
|
105 |
}
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
/**
|
108 |
* Populate Restricted_Site_Access::$fields with internationalization-ready field information.
|
109 |
*/
|
161 |
/**
|
162 |
* populate the option with defaults
|
163 |
*/
|
164 |
+
public static function get_options( $network = false ) {
|
165 |
$options = array();
|
166 |
|
167 |
if ( $network ) {
|
260 |
return;
|
261 |
}
|
262 |
|
263 |
+
$allowed_ips = self::get_config_ips();
|
264 |
+
if (
|
265 |
+
! empty( self::$rsa_options['allowed'] ) &&
|
266 |
+
is_array( self::$rsa_options['allowed'] )
|
267 |
+
) {
|
268 |
+
$allowed_ips = array_merge( $allowed_ips, self::$rsa_options['allowed'] );
|
269 |
+
}
|
270 |
+
|
271 |
// check for the allow list, if its empty block everything
|
272 |
+
if ( count( $allowed_ips ) > 0 ) {
|
273 |
$remote_ip = self::get_client_ip_address();
|
274 |
|
275 |
// iterate through the allow list
|
276 |
+
foreach( $allowed_ips as $line ) {
|
277 |
+
if ( self::ip_in_range( $remote_ip, $line ) ) {
|
278 |
|
279 |
/**
|
280 |
* Fires when an ip address match occurs.
|
299 |
|
300 |
switch ( $rsa_restrict_approach ) {
|
301 |
case 4:
|
302 |
+
if ( ! empty( self::$rsa_options['page'] ) ) {
|
303 |
+
$page = get_post( self::$rsa_options['page'] );
|
304 |
+
|
305 |
+
// If the selected page isn't found, fall back to default values.
|
306 |
+
if ( ! $page ) {
|
307 |
+
self::$rsa_options['head_code'] = 302;
|
308 |
+
$current_path = empty( $_SERVER['REQUEST_URI'] ) ? home_url() : $_SERVER['REQUEST_URI'];
|
309 |
+
self::$rsa_options['redirect_url'] = wp_login_url( $current_path );
|
310 |
+
}
|
311 |
+
|
312 |
+
// Prevents infinite loops.
|
313 |
+
if ( ! isset( $wp->query_vars['pagename'] ) || $wp->query_vars['pagename'] !== $page->post_name ) {
|
314 |
+
self::$rsa_options['redirect_url'] = get_permalink( $page->ID );
|
315 |
+
break;
|
316 |
+
} else {
|
317 |
+
return;
|
318 |
+
}
|
319 |
}
|
320 |
|
321 |
case 3:
|
363 |
register_setting( self::$settings_page, 'rsa_options', array( __CLASS__, 'sanitize_options' ) ); // array of fundamental options including ID and caching info
|
364 |
add_settings_section( 'restricted-site-access', '', '__return_empty_string', self::$settings_page );
|
365 |
foreach ( self::$fields as $field_name => $field_data ) {
|
366 |
+
add_settings_field(
|
367 |
+
$field_name,
|
368 |
+
$field_data['label'],
|
369 |
+
array( __CLASS__, $field_data['field'] ),
|
370 |
+
self::$settings_page,
|
371 |
+
'restricted-site-access',
|
372 |
+
array( 'class' => 'rsa-setting rsa-setting_' . esc_attr( $field_data['field'] ) )
|
373 |
+
);
|
374 |
}
|
375 |
|
376 |
add_filter( 'plugin_action_links_' . self::$basename, array( __CLASS__, 'plugin_action_links' ) );
|
540 |
}
|
541 |
|
542 |
public static function enqueue_settings_script() {
|
543 |
+
$js_path = plugin_dir_url( __FILE__ ) . 'assets/js/settings.min.js';
|
544 |
|
545 |
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
|
546 |
+
$js_path = plugin_dir_url( __FILE__ ) . 'assets/js/src/settings.js';
|
547 |
}
|
548 |
|
549 |
wp_enqueue_script( 'rsa-settings', $js_path, array( 'jquery-effects-shake' ), RSA_VERSION, true );
|
551 |
|
552 |
public static function enqueue_admin_script() {
|
553 |
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
|
554 |
+
wp_enqueue_script( 'rsa-admin', plugin_dir_url( __FILE__ ) . 'assets/js/src/admin.js', array( 'jquery' ), RSA_VERSION, true );
|
555 |
} else {
|
556 |
+
wp_enqueue_script( 'rsa-admin', plugin_dir_url( __FILE__ ) . 'assets/js/admin.min.js', array( 'jquery' ), RSA_VERSION, true );
|
557 |
}
|
558 |
|
559 |
wp_localize_script( 'rsa-admin', 'rsaAdmin', array(
|
570 |
add_action( 'admin_notices', array( __CLASS__, 'admin_notice' ) );
|
571 |
add_action( 'admin_head', array( __CLASS__, 'admin_head' ) );
|
572 |
|
573 |
+
add_filter( 'wp_dropdown_pages', array( __CLASS__, 'filter_page_dropdown' ), 10, 2 );
|
574 |
+
|
575 |
self::$rsa_options = self::get_options();
|
576 |
}
|
577 |
|
790 |
<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>
|
791 |
<?php
|
792 |
$ips = (array) self::$rsa_options['allowed'];
|
793 |
+
foreach ( $ips as $ip ) {
|
794 |
+
if ( ! empty( $ip ) ) {
|
795 |
+
echo '<div><input type="text" name="rsa_options[allowed][]" value="' . esc_attr( $ip ) . '" readonly="true" /> <a href="#remove" class="remove_btn">' . esc_html_x( 'Remove', 'remove IP address action', 'restricted-site-access' ) . '</a></div>';
|
796 |
+
}
|
797 |
}
|
|
|
798 |
?>
|
799 |
</div>
|
800 |
<div>
|
801 |
+
<input type="text" name="newip" id="newip" /> <input class="button" type="button" id="addip" value="<?php esc_attr_e( 'Add' ); ?>" />
|
802 |
<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>
|
803 |
</div>
|
804 |
<?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( self::get_client_ip_address() ); ?>" /><br /><?php } ?>
|
805 |
+
<div class="config_ips" style="margin-top: 10px;">
|
806 |
+
<p class="description">
|
807 |
+
<?php esc_html_e( 'IP addresses set by configuration', 'restricted-site-access' ); ?>
|
808 |
+
</p>
|
809 |
+
<?php
|
810 |
+
$config_ips = self::get_config_ips();
|
811 |
+
foreach ( $config_ips as $ip ) {
|
812 |
+
printf(
|
813 |
+
'<div><input type="text" value="%1$s" disabled="true" /></div>',
|
814 |
+
esc_attr( $ip )
|
815 |
+
);
|
816 |
+
}
|
817 |
+
?>
|
818 |
+
</div>
|
819 |
</div>
|
820 |
<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>
|
821 |
<?php
|
907 |
));
|
908 |
}
|
909 |
|
910 |
+
/**
|
911 |
+
* Filters the page dropdown to display text if no pages are found.
|
912 |
+
*
|
913 |
+
* @param string $html The HTML to be output by wp_dropdown_pages.
|
914 |
+
* @param array $args Array of arguments for wp_dropdown_pages.
|
915 |
+
* @return string Dropdown HTML, or text saying no pages are found.
|
916 |
+
*/
|
917 |
+
public static function filter_page_dropdown( $html, $args ) {
|
918 |
+
if ( '' !== $html || 'rsa_page' !== $args['id'] ) {
|
919 |
+
return $html;
|
920 |
+
}
|
921 |
+
|
922 |
+
return sprintf(
|
923 |
+
'<p class="description" id="%2$s">%1$s</p>',
|
924 |
+
esc_html__( 'No published pages found.', 'restricted-site-access' ),
|
925 |
+
esc_attr( $args['id'] )
|
926 |
+
);
|
927 |
+
}
|
928 |
+
|
929 |
/**
|
930 |
* Validate IP address entry on demand (AJAX)
|
931 |
*/
|
961 |
return true;
|
962 |
}
|
963 |
|
964 |
+
/**
|
965 |
+
* Gets an array of valid IP addresses from constant.
|
966 |
+
*
|
967 |
+
* @return array
|
968 |
+
*/
|
969 |
+
public static function get_config_ips() {
|
970 |
+
if ( ! defined( 'RSA_IP_WHITELIST' ) || ! RSA_IP_WHITELIST ) {
|
971 |
+
return array();
|
972 |
+
}
|
973 |
+
|
974 |
+
if ( ! is_string( RSA_IP_WHITELIST ) ) {
|
975 |
+
return array();
|
976 |
+
}
|
977 |
+
|
978 |
+
// Filter out valid IPs from configured ones.
|
979 |
+
$raw_ips = explode( '|', RSA_IP_WHITELIST );
|
980 |
+
$valid_ips = array();
|
981 |
+
foreach ( $raw_ips as $ip ) {
|
982 |
+
$trimmed = trim( $ip );
|
983 |
+
if ( self::is_ip( $trimmed ) ) {
|
984 |
+
$valid_ips[] = $trimmed;
|
985 |
+
}
|
986 |
+
}
|
987 |
+
return $valid_ips;
|
988 |
+
}
|
989 |
+
|
990 |
/**
|
991 |
* Add settings link directing user to privacy page on plug-in page
|
992 |
*
|
1112 |
|
1113 |
Restricted_Site_Access::get_instance();
|
1114 |
|
1115 |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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Manages the Restricted Site Access plugin settings.
|
5 |
+
*
|
6 |
+
* ## EXAMPLES
|
7 |
+
*
|
8 |
+
* # Restricts site access.
|
9 |
+
* $ wp rsa set-mode login
|
10 |
+
* Success: Redirecting visitors to login screen.
|
11 |
+
*
|
12 |
+
* # Whitelists IP addresses.
|
13 |
+
* $ wp rsa ip-add 192.0.0.1
|
14 |
+
* Success: Added 192.0.0.1 to the whitelist.
|
15 |
+
*/
|
16 |
+
class Restricted_Site_Access_CLI extends WP_CLI_Command {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Stored command positional arguments.
|
20 |
+
* @var array
|
21 |
+
*/
|
22 |
+
private $args;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Stored command associative arguments.
|
26 |
+
* @var array
|
27 |
+
*/
|
28 |
+
private $assoc_args;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Whether the command is operating on the network or a single site.
|
32 |
+
* @var bool
|
33 |
+
*/
|
34 |
+
private $is_network = false;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Sets how the site is restricted.
|
38 |
+
*
|
39 |
+
* ## OPTIONS
|
40 |
+
*
|
41 |
+
* <mode>
|
42 |
+
* : What mode to set the plugin to.
|
43 |
+
* ---
|
44 |
+
* options:
|
45 |
+
* - disable
|
46 |
+
* - login
|
47 |
+
* - redirect
|
48 |
+
* - message
|
49 |
+
* - page
|
50 |
+
* ---
|
51 |
+
*
|
52 |
+
* [--redirect=<url>]
|
53 |
+
* : What URL to redirect visitors to in case of the redirect mode.
|
54 |
+
*
|
55 |
+
* [--same-path]
|
56 |
+
* : Preserve the path in case of the redirect mode.
|
57 |
+
*
|
58 |
+
* [--status-code=<code>]
|
59 |
+
* : What status code to use, in case of the redirect mode.
|
60 |
+
* ---
|
61 |
+
* options:
|
62 |
+
* - 301
|
63 |
+
* - 302
|
64 |
+
* - 307
|
65 |
+
* default: 302
|
66 |
+
* ---
|
67 |
+
*
|
68 |
+
* [--text=<text>]
|
69 |
+
* : What message to display in case of message mode.
|
70 |
+
*
|
71 |
+
* [--page=<page-id>]
|
72 |
+
* : What page ID to display in case of page mode.
|
73 |
+
*
|
74 |
+
* [--network]
|
75 |
+
* : Multisite only. Sets this configuration for the network.
|
76 |
+
*
|
77 |
+
* ## EXAMPLES
|
78 |
+
*
|
79 |
+
* # Disables site restriction.
|
80 |
+
* $ wp rsa set-mode disable
|
81 |
+
* Success: Site restrictions disabled.
|
82 |
+
*
|
83 |
+
* # Redirects site visitors to a URL.
|
84 |
+
* $ wp rsa set-mode redirect --url=http://example.com
|
85 |
+
* Success: Site redirecting visitors to "http://example.com".
|
86 |
+
*
|
87 |
+
* # Shows site visitors a message.
|
88 |
+
* $ wp rsa set-mode message --text="None shall pass!"
|
89 |
+
* Success: Site message set.
|
90 |
+
*
|
91 |
+
* # Shows site visitors a page.
|
92 |
+
* wp rsa set-mode page --page=123
|
93 |
+
* Success: Site showing visitors page "Welcome".
|
94 |
+
*
|
95 |
+
* @subcommand set-mode
|
96 |
+
* @alias mode
|
97 |
+
*
|
98 |
+
* @param array $args Array with single value of what mode to set.
|
99 |
+
* @param array $assoc_args Array with optional flags described above.
|
100 |
+
* @return void
|
101 |
+
*/
|
102 |
+
public function set_mode( $args, $assoc_args ) {
|
103 |
+
// We don't need to validate the mode, as WP-CLI ensures that's correct.
|
104 |
+
$mode = $args[0];
|
105 |
+
|
106 |
+
// Sets up and gets options.
|
107 |
+
$this->setup( $args, $assoc_args );
|
108 |
+
$options = $this->get_options();
|
109 |
+
|
110 |
+
// Gets the current setting.
|
111 |
+
$blog_public = (int) get_option( 'blog_public', 2 );
|
112 |
+
if ( $this->is_network ) {
|
113 |
+
$blog_public = (int) get_site_option( 'blog_public', 2 );
|
114 |
+
}
|
115 |
+
|
116 |
+
// Handles disabling the plugin.
|
117 |
+
if ( 'disable' === $mode ) {
|
118 |
+
if ( 2 !== $blog_public ) {
|
119 |
+
WP_CLI::success( sprintf(
|
120 |
+
__( '%s already not under restricted access.', 'restricted-site-access' ),
|
121 |
+
$this->update_text()
|
122 |
+
) );
|
123 |
+
return;
|
124 |
+
}
|
125 |
+
|
126 |
+
if ( $this->is_network ) {
|
127 |
+
update_site_option( 'blog_public', 1 );
|
128 |
+
} else {
|
129 |
+
update_option( 'blog_public', 1 );
|
130 |
+
}
|
131 |
+
|
132 |
+
WP_CLI::success( sprintf(
|
133 |
+
__( '%s restrictions disabled.', 'restricted-site-access' ) ),
|
134 |
+
$this->update_text()
|
135 |
+
);
|
136 |
+
return; // Exit.
|
137 |
+
}
|
138 |
+
|
139 |
+
// Enables RSA if it's not already enabled.
|
140 |
+
if ( 2 !== $blog_public ) {
|
141 |
+
if ( $this->is_network ) {
|
142 |
+
update_site_option( 'blog_public', 2 );
|
143 |
+
WP_CLI::debug( 'Enabled RSA on network.' );
|
144 |
+
} else {
|
145 |
+
update_option( 'blog_public', 2 );
|
146 |
+
WP_CLI::debug( 'Enabled RSA.' );
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
// Login mode. Simple!
|
151 |
+
if ( 'login' === $mode ) {
|
152 |
+
$options['approach'] = 1;
|
153 |
+
|
154 |
+
} else if ( 'redirect' === $mode ) {
|
155 |
+
$url = WP_CLI\Utils\get_flag_value( $assoc_args, 'redirect' );
|
156 |
+
if ( ! $url ) {
|
157 |
+
WP_CLI::error( __( 'Redirect URL required.', 'restricted-site-access' ) );
|
158 |
+
}
|
159 |
+
|
160 |
+
// Let WP-CLI validate the status code.
|
161 |
+
$options = array_merge( $options, array(
|
162 |
+
'approach' => 2,
|
163 |
+
'redirect_url' => $url,
|
164 |
+
'head_code' => WP_CLI\Utils\get_flag_value( $assoc_args, 'status-code' ),
|
165 |
+
'redirect_path' => (int) WP_CLI\Utils\get_flag_value( $assoc_args, 'same-path', 0 ),
|
166 |
+
) );
|
167 |
+
|
168 |
+
// End redirect mode.
|
169 |
+
} else if ( 'message' === $mode ) {
|
170 |
+
// Set default for message text.
|
171 |
+
$message = WP_CLI\Utils\get_flag_value( $assoc_args, 'text' );
|
172 |
+
if ( ! $message ) {
|
173 |
+
$message = __( 'Access to this site is restricted.', 'restricted-site-access' );
|
174 |
+
}
|
175 |
+
$options['approach'] = 3;
|
176 |
+
$options['message'] = $message;
|
177 |
+
|
178 |
+
// End message mode.
|
179 |
+
} else if ( 'page' === $mode ) {
|
180 |
+
// Validate page ID passed.
|
181 |
+
$page_id = (int) WP_CLI\Utils\get_flag_value( $assoc_args, 'page' );
|
182 |
+
if ( ! $page_id ) {
|
183 |
+
WP_CLI::error( __( 'Page required.', 'restricted-site-access' ) );
|
184 |
+
}
|
185 |
+
$page = get_post( $page_id );
|
186 |
+
if ( ! $page || 'page' !== $page->post_type ) {
|
187 |
+
WP_CLI::error( __( 'Page is invalid.', 'restricted-site-access' ) );
|
188 |
+
}
|
189 |
+
|
190 |
+
$options['approach'] = 4;
|
191 |
+
$options['page'] = $page_id;
|
192 |
+
// End page mode.
|
193 |
+
}
|
194 |
+
|
195 |
+
$updated_options = $this->update_options( $options );
|
196 |
+
|
197 |
+
// Send update messages.
|
198 |
+
$success_msg = '';
|
199 |
+
switch ( $mode ) {
|
200 |
+
case 'login' :
|
201 |
+
$success_msg = __( '%s redirecting visitors to login.', 'restricted-site-access' );
|
202 |
+
break;
|
203 |
+
case 'redirect' :
|
204 |
+
$success_msg = sprintf(
|
205 |
+
__( '%%s redirecting visitors to "%s"', 'restricted-site-access' ),
|
206 |
+
$updated_options['redirect_url']
|
207 |
+
);
|
208 |
+
break;
|
209 |
+
case 'message' :
|
210 |
+
$success_msg = __( '%s showing message to visitors.', 'restricted-site-access' );
|
211 |
+
break;
|
212 |
+
case 'page' :
|
213 |
+
$success_msg = sprintf(
|
214 |
+
__( '%%s showing visitors page "%s"', 'restricted-site-access' ),
|
215 |
+
get_the_title( $page )
|
216 |
+
);
|
217 |
+
break;
|
218 |
+
default :
|
219 |
+
$success_msg = __( '%s settings updated.', 'restricted-site-access' );
|
220 |
+
}
|
221 |
+
|
222 |
+
WP_CLI::success( sprintf(
|
223 |
+
$success_msg,
|
224 |
+
$this->update_text()
|
225 |
+
) );
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Sets the network mode.
|
230 |
+
*
|
231 |
+
* ## OPTIONS
|
232 |
+
*
|
233 |
+
* <mode>
|
234 |
+
* : Mode to set network.
|
235 |
+
* ---
|
236 |
+
* default: default
|
237 |
+
* options:
|
238 |
+
* - default
|
239 |
+
* - enforce
|
240 |
+
* ---
|
241 |
+
*
|
242 |
+
* ## EXAMPLES
|
243 |
+
*
|
244 |
+
* # Sets the multisite to enforce mode.
|
245 |
+
* $ wp rsa set-network-mode enforce
|
246 |
+
* Success: Set network mode to enforced.
|
247 |
+
*
|
248 |
+
* @subcommand set-network-mode
|
249 |
+
*
|
250 |
+
* @param array $args Array with single value of what mode to set.
|
251 |
+
* @param array $assoc_args Associative arguments. Not used.
|
252 |
+
*/
|
253 |
+
public function set_network_mode( $args, $assoc_args ) {
|
254 |
+
if ( ! RSA_IS_NETWORK ) {
|
255 |
+
WP_CLI::error( __( 'Cannot set network mode when plugin not activated on network.', 'restricted-site-access' ) );
|
256 |
+
}
|
257 |
+
|
258 |
+
// We don't need to validate the mode, as WP-CLI ensures that's correct.
|
259 |
+
$new_mode = $args[0];
|
260 |
+
$current_mode = get_site_option( 'rsa_mode', 'default' );
|
261 |
+
|
262 |
+
// Sets mode and shows message.
|
263 |
+
if ( $new_mode === $current_mode ) {
|
264 |
+
WP_CLI::warning( sprintf(
|
265 |
+
__( 'Mode is already set to %s.', 'restricted-site-access' ),
|
266 |
+
$current_mode
|
267 |
+
) );
|
268 |
+
} else {
|
269 |
+
update_site_option( 'rsa_mode', sanitize_key( $new_mode ) );
|
270 |
+
WP_CLI::success( sprintf(
|
271 |
+
__( 'Set network mode to %s.', 'restricted-site-access' ),
|
272 |
+
$new_mode
|
273 |
+
) );
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Lists current IP whitelist.
|
279 |
+
*
|
280 |
+
* ## OPTIONS
|
281 |
+
*
|
282 |
+
* [--exclude-config]
|
283 |
+
* : Don't include IPs from the configuration file.
|
284 |
+
*
|
285 |
+
* [--format=<format>]
|
286 |
+
* : Render output in a particular format.
|
287 |
+
* ---
|
288 |
+
* default: table
|
289 |
+
* options:
|
290 |
+
* - table
|
291 |
+
* - csv
|
292 |
+
* - json
|
293 |
+
* - yaml
|
294 |
+
* ---
|
295 |
+
*
|
296 |
+
* [--network]
|
297 |
+
* : Multisite only. Sets configuration for the network as a whole.
|
298 |
+
*
|
299 |
+
* ## EXAMPLES
|
300 |
+
*
|
301 |
+
* # Outputs currently whitelisted IPs in CSV format.
|
302 |
+
* $ wp rsa ip-list --format=csv
|
303 |
+
* 192.0.0.1,10.10.0.0
|
304 |
+
*
|
305 |
+
* @subcommand ip-list
|
306 |
+
*
|
307 |
+
* @param array $args Positional arguments. Not used.
|
308 |
+
* @param array $assoc_args Array with format value.
|
309 |
+
*/
|
310 |
+
public function ip_list( $args, $assoc_args ) {
|
311 |
+
$this->setup( $args, $assoc_args );
|
312 |
+
|
313 |
+
$no_config = WP_CLI\Utils\get_flag_value( $assoc_args, 'exclude-config', false );
|
314 |
+
$ips = $this->get_current_ips( ! $no_config );
|
315 |
+
$items = array();
|
316 |
+
|
317 |
+
if ( 0 === count( $ips ) ) {
|
318 |
+
WP_CLI::line( __( 'No IP addresses configured.', 'restricted-site-access' ) );
|
319 |
+
return;
|
320 |
+
}
|
321 |
+
|
322 |
+
foreach ( $ips as $ip ) {
|
323 |
+
$items[] = compact( 'ip' );
|
324 |
+
}
|
325 |
+
|
326 |
+
$format = WP_CLI\Utils\get_flag_value( $assoc_args, 'format', 'table' );
|
327 |
+
WP_CLI\Utils\format_items( $format, $items, array( 'ip' ) );
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Adds one or more IP addresses to the whitelist.
|
332 |
+
*
|
333 |
+
* ## OPTIONS
|
334 |
+
*
|
335 |
+
* <ip>...
|
336 |
+
* : List of IP addresses to add to the whitelist.
|
337 |
+
*
|
338 |
+
* [--network]
|
339 |
+
* : Multisite only. Sets configuration for the network as a whole.
|
340 |
+
*
|
341 |
+
* ## EXAMPLES
|
342 |
+
*
|
343 |
+
* # Adds 192.0.0.1 to IP whitelist.
|
344 |
+
* $ wp rsa ip-add 192.0.0.1
|
345 |
+
* Success: Added 192.0.0.1 to site whitelist.
|
346 |
+
*
|
347 |
+
* @subcommand ip-add
|
348 |
+
*
|
349 |
+
* @param array $args List of IPs to whitelist.
|
350 |
+
* @param array $assoc_args Optional flags.
|
351 |
+
*/
|
352 |
+
public function ip_add( $args, $assoc_args ) {
|
353 |
+
$this->setup( $args, $assoc_args );
|
354 |
+
|
355 |
+
// Validate the IP addresses.
|
356 |
+
$valid_ips = array_filter( $args, [ 'Restricted_Site_Access', 'is_ip' ] );
|
357 |
+
if ( 0 === count( $valid_ips ) ) {
|
358 |
+
WP_CLI::error( __( 'No valid IP addresses provided.', 'restricted-site-access' ) );
|
359 |
+
}
|
360 |
+
|
361 |
+
// Get the new IPs.
|
362 |
+
$current_ips = $this->get_current_ips();
|
363 |
+
$new_ips = array_diff( $valid_ips, $current_ips );
|
364 |
+
|
365 |
+
if ( 0 === count( $new_ips ) ) {
|
366 |
+
// Only show a warning as this may be an automated process.
|
367 |
+
WP_CLI::warning( sprintf(
|
368 |
+
__( 'Provided IPs are already on %s whitelist.', 'restricted-site-access' ),
|
369 |
+
$this->update_text( false )
|
370 |
+
) );
|
371 |
+
return;
|
372 |
+
}
|
373 |
+
|
374 |
+
// Updates the option.
|
375 |
+
$options['allowed'] = array_merge( $this->get_current_ips( false ), $new_ips );
|
376 |
+
$new_options = $this->update_options( $options );
|
377 |
+
|
378 |
+
WP_CLI::success( sprintf(
|
379 |
+
__( 'Added %1$s to %2$s whitelist.', 'restricted-site-access' ),
|
380 |
+
implode( ', ', $new_ips ),
|
381 |
+
$this->update_text( false )
|
382 |
+
) );
|
383 |
+
|
384 |
+
WP_CLI::debug( sprintf(
|
385 |
+
__( 'Current %2$s whitelisted IPs are: %1$s', 'restricted-site-access' ),
|
386 |
+
implode( ', ', $new_options['allowed'] ),
|
387 |
+
$this->update_text( false )
|
388 |
+
) );
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Removes one or more IP addresses from the whitelist.
|
393 |
+
*
|
394 |
+
* ## OPTIONS
|
395 |
+
*
|
396 |
+
* <ip>...
|
397 |
+
* : List of IP addresses to remove from the whitelist.
|
398 |
+
*
|
399 |
+
* [--network]
|
400 |
+
* : Multisite only. Sets configuration for the network as a whole.
|
401 |
+
*
|
402 |
+
* ## EXAMPLES
|
403 |
+
*
|
404 |
+
* # Removes IP address from whitelist.
|
405 |
+
* $ wp rsa ip-remove 192.0.0.1
|
406 |
+
* Success: Removed 192.0.0.1 from whitelist.
|
407 |
+
*
|
408 |
+
* @subcommand ip-remove
|
409 |
+
*
|
410 |
+
* @param array $args List of IPs to blacklist.
|
411 |
+
* @param array $assoc_args Optional flags.
|
412 |
+
*/
|
413 |
+
public function ip_remove( $args, $assoc_args ) {
|
414 |
+
$this->setup( $args, $assoc_args );
|
415 |
+
|
416 |
+
// Validate the IP addresses.
|
417 |
+
$valid_ips = array_filter( $args, [ 'Restricted_Site_Access', 'is_ip' ] );
|
418 |
+
if ( 0 === count( $valid_ips ) ) {
|
419 |
+
WP_CLI::error( __( 'No valid IP addresses provided.', 'restricted-site-access' ) );
|
420 |
+
}
|
421 |
+
|
422 |
+
// Get the IPs to remove.
|
423 |
+
$current_ips = $this->get_current_ips( false );
|
424 |
+
$removed_ips = array_intersect( $valid_ips, $current_ips );
|
425 |
+
|
426 |
+
if ( 0 === count( $removed_ips ) ) {
|
427 |
+
// Only show warning as this may be an automated process.
|
428 |
+
WP_CLI::warning( sprintf(
|
429 |
+
__( 'Provided IPs are not on %s whitelist.', 'restricted-site-access' ),
|
430 |
+
$this->update_text( false )
|
431 |
+
) );
|
432 |
+
return;
|
433 |
+
}
|
434 |
+
|
435 |
+
// Updates the option.
|
436 |
+
$options['allowed'] = array_diff( $current_ips, $removed_ips );
|
437 |
+
$new_options = $this->update_options( $options );
|
438 |
+
|
439 |
+
WP_CLI::success( sprintf(
|
440 |
+
__( 'Removed IPs %1$s from %2$s whitelist.', 'restricted-site-access' ),
|
441 |
+
implode( ', ', $removed_ips ),
|
442 |
+
$this->update_text( false )
|
443 |
+
) );
|
444 |
+
|
445 |
+
WP_CLI::debug( sprintf(
|
446 |
+
__( 'Current %2$s whitelisted IPs are: %1$s', 'restricted-site-access' ),
|
447 |
+
implode( ', ', $new_options['allowed'] ),
|
448 |
+
$this->update_text( false )
|
449 |
+
) );
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Sets list of IPs to whitelist. Overwrites current settings.
|
454 |
+
*
|
455 |
+
* ## OPTIONS
|
456 |
+
*
|
457 |
+
* <ip>...
|
458 |
+
* : List of IP addresses to whitelist.
|
459 |
+
*
|
460 |
+
* [--network]
|
461 |
+
* : Multisite only. Sets configuration for the network as a whole.
|
462 |
+
*
|
463 |
+
* ## EXAMPLES
|
464 |
+
*
|
465 |
+
* # Sets IP whitelist to 192.0.0.1.
|
466 |
+
* $ wp rsa ip-set 192.0.0.1
|
467 |
+
* Success: Updated site IP whitelist to 192.0.0.1.
|
468 |
+
*
|
469 |
+
* @subcommand ip-set
|
470 |
+
*
|
471 |
+
* @param array $args List of IPs to set.
|
472 |
+
* @param array $assoc_args Optional flags.
|
473 |
+
*/
|
474 |
+
public function ip_set( $args, $assoc_args ) {
|
475 |
+
$this->setup( $args, $assoc_args );
|
476 |
+
|
477 |
+
// Validate the IP addresses.
|
478 |
+
$valid_ips = array_filter( $args, [ 'Restricted_Site_Access', 'is_ip' ] );
|
479 |
+
if ( 0 === count( $valid_ips ) ) {
|
480 |
+
WP_CLI::error( __( 'No valid IP addresses provided.', 'restricted-site-access' ) );
|
481 |
+
}
|
482 |
+
|
483 |
+
// Updates the option.
|
484 |
+
$options['allowed'] = $valid_ips;
|
485 |
+
$new_options = $this->update_options( $options );
|
486 |
+
|
487 |
+
WP_CLI::success( sprintf(
|
488 |
+
__( 'Set %2$s IP whitelist to %1$s.', 'restricted-site-access' ),
|
489 |
+
implode( ', ', $new_options['allowed'] ),
|
490 |
+
$this->update_text( false )
|
491 |
+
) );
|
492 |
+
}
|
493 |
+
|
494 |
+
/**
|
495 |
+
* Sets up the instance correctly.
|
496 |
+
*
|
497 |
+
* @param array $args Array with positional arguments.
|
498 |
+
* @param array $assoc_args Array with associative arguments.
|
499 |
+
* @return void
|
500 |
+
*/
|
501 |
+
private function setup( $args = [], $assoc_args = [] ) {
|
502 |
+
$this->args = $args;
|
503 |
+
$this->assoc_args = $assoc_args;
|
504 |
+
|
505 |
+
$is_network = WP_CLI\Utils\get_flag_value( $assoc_args, 'network', false );
|
506 |
+
if ( $is_network && ! RSA_IS_NETWORK ) {
|
507 |
+
WP_CLI::error( __( 'Cannot get network settings when plugin not activated on network.', 'restricted-site-access' ) );
|
508 |
+
}
|
509 |
+
|
510 |
+
$this->is_network = (bool) $is_network;
|
511 |
+
}
|
512 |
+
|
513 |
+
/**
|
514 |
+
* Gets plugin options, either from the network or specified site.
|
515 |
+
*
|
516 |
+
* @return array Array of options from database.
|
517 |
+
*/
|
518 |
+
private function get_options() {
|
519 |
+
return Restricted_Site_Access::get_options( $this->is_network );
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Gets all current IPs, optionally including config IPs.
|
524 |
+
*
|
525 |
+
* @param bool $include_config Whether to include the config file IPs. Default true.
|
526 |
+
* @return array
|
527 |
+
*/
|
528 |
+
private function get_current_ips( $include_config = true ) {
|
529 |
+
$options = $this->get_options();
|
530 |
+
$current_ips = empty( $options['allowed'] ) ? array() : $options['allowed'];
|
531 |
+
$config_ips = array();
|
532 |
+
|
533 |
+
if ( $include_config ) {
|
534 |
+
$config_ips = Restricted_Site_Access::get_config_ips();
|
535 |
+
}
|
536 |
+
|
537 |
+
return array_unique( array_merge( $current_ips, $config_ips ) );
|
538 |
+
}
|
539 |
+
|
540 |
+
/**
|
541 |
+
* Updates options, potentially on the site.
|
542 |
+
*
|
543 |
+
* @param array $new_options Array of unsanitized options to save.
|
544 |
+
* @return array The newly set options.
|
545 |
+
*/
|
546 |
+
private function update_options( $new_options ) {
|
547 |
+
$options = wp_parse_args( $new_options, $this->get_options() );
|
548 |
+
$sanitized_options = Restricted_Site_Access::sanitize_options( $options );
|
549 |
+
if ( $this->is_network ) {
|
550 |
+
update_site_option( 'rsa_options', $sanitized_options );
|
551 |
+
} else {
|
552 |
+
update_option( 'rsa_options', $sanitized_options );
|
553 |
+
}
|
554 |
+
|
555 |
+
return $this->get_options();
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
* Text used to indicate whether the user is updating a site or the network.
|
560 |
+
*
|
561 |
+
* @param bool $capitalize Whether to capitalize the text or not.
|
562 |
+
* @return string
|
563 |
+
*/
|
564 |
+
private function update_text( $capitalize = true ) {
|
565 |
+
$text = _x( 'Site', 'update type', 'restricted-site-access' );
|
566 |
+
if ( $this->is_network ) {
|
567 |
+
$text = _x( 'Network', 'update type', 'restricted-site-access' );
|
568 |
+
}
|
569 |
+
|
570 |
+
if ( $capitalize ) {
|
571 |
+
return $text;
|
572 |
+
}
|
573 |
+
return strtolower( $text );
|
574 |
+
}
|
575 |
+
}
|
576 |
+
|
577 |
+
WP_CLI::add_command( 'rsa', 'Restricted_Site_Access_CLI' );
|