Version Description
- 2017/05/14
- Added missing functions for compatibility with WordPress < 4.4.
Download this release
Release Info
Developer | GregLone |
Plugin | Move Login |
Version | 2.5.1 |
Comparing to | |
See all releases |
Code changes from version 2.4.3 to 2.5.1
- inc/functions/compat.php +130 -0
- inc/functions/deprecated.php +98 -0
- inc/functions/rewrite.php +0 -23
- inc/functions/settings-page.php +4 -4
- inc/functions/utilities.php +52 -0
- inc/redirections-and-dies.php +54 -57
- languages/sf-move-login-fr_FR.mo +0 -0
- languages/sf-move-login-fr_FR.po +31 -15
- readme.txt +11 -1
- sf-move-login.php +3 -2
inc/functions/compat.php
CHANGED
@@ -77,3 +77,133 @@ if ( ! function_exists( 'wp_is_writable' ) ) :
|
|
77 |
return @is_writable( $path );
|
78 |
}
|
79 |
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
return @is_writable( $path );
|
78 |
}
|
79 |
endif;
|
80 |
+
|
81 |
+
|
82 |
+
if ( ! function_exists( 'wp_parse_url' ) ) :
|
83 |
+
/**
|
84 |
+
* A wrapper for PHP's parse_url() function that handles consistency in the return
|
85 |
+
* values across PHP versions.
|
86 |
+
*
|
87 |
+
* PHP 5.4.7 expanded parse_url()'s ability to handle non-absolute url's, including
|
88 |
+
* schemeless and relative url's with :// in the path. This function works around
|
89 |
+
* those limitations providing a standard output on PHP 5.2~5.4+.
|
90 |
+
*
|
91 |
+
* Secondly, across various PHP versions, schemeless URLs starting containing a ":"
|
92 |
+
* in the query are being handled inconsistently. This function works around those
|
93 |
+
* differences as well.
|
94 |
+
*
|
95 |
+
* Error suppression is used as prior to PHP 5.3.3, an E_WARNING would be generated
|
96 |
+
* when URL parsing failed.
|
97 |
+
*
|
98 |
+
* @since 2.5.1
|
99 |
+
* @since WP 4.4.0
|
100 |
+
* @since WP 4.7.0 The $component parameter was added for parity with PHP's parse_url().
|
101 |
+
*
|
102 |
+
* @param (string) $url The URL to parse.
|
103 |
+
* @param (int) $component The specific component to retrieve. Use one of the PHP
|
104 |
+
* predefined constants to specify which one.
|
105 |
+
* Defaults to -1 (= return all parts as an array).
|
106 |
+
* @see http://php.net/manual/en/function.parse-url.php
|
107 |
+
*
|
108 |
+
* @return (mixed) False on parse failure; Array of URL components on success;
|
109 |
+
* When a specific component has been requested: null if the component
|
110 |
+
* doesn't exist in the given URL; a sting or - in the case of
|
111 |
+
* PHP_URL_PORT - integer when it does. See parse_url()'s return values.
|
112 |
+
*/
|
113 |
+
function wp_parse_url( $url, $component = -1 ) {
|
114 |
+
$to_unset = array();
|
115 |
+
$url = strval( $url );
|
116 |
+
|
117 |
+
if ( '//' === substr( $url, 0, 2 ) ) {
|
118 |
+
$to_unset[] = 'scheme';
|
119 |
+
$url = 'placeholder:' . $url;
|
120 |
+
} elseif ( '/' === substr( $url, 0, 1 ) ) {
|
121 |
+
$to_unset[] = 'scheme';
|
122 |
+
$to_unset[] = 'host';
|
123 |
+
$url = 'placeholder://placeholder' . $url;
|
124 |
+
}
|
125 |
+
|
126 |
+
$parts = @parse_url( $url );
|
127 |
+
|
128 |
+
if ( false === $parts ) {
|
129 |
+
// Parsing failure.
|
130 |
+
return $parts;
|
131 |
+
}
|
132 |
+
|
133 |
+
// Remove the placeholder values.
|
134 |
+
if ( $to_unset ) {
|
135 |
+
foreach ( $to_unset as $key ) {
|
136 |
+
unset( $parts[ $key ] );
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
return _get_component_from_parsed_url_array( $parts, $component );
|
141 |
+
}
|
142 |
+
endif;
|
143 |
+
|
144 |
+
|
145 |
+
if ( ! function_exists( '_get_component_from_parsed_url_array' ) ) :
|
146 |
+
/**
|
147 |
+
* Retrieve a specific component from a parsed URL array.
|
148 |
+
*
|
149 |
+
* @since 2.5.1
|
150 |
+
* @since WP 4.7.0
|
151 |
+
*
|
152 |
+
* @param (array|false) $url_parts The parsed URL. Can be false if the URL failed to parse.
|
153 |
+
* @param (int) $component The specific component to retrieve. Use one of the PHP
|
154 |
+
* predefined constants to specify which one.
|
155 |
+
* Defaults to -1 (= return all parts as an array).
|
156 |
+
* @see http://php.net/manual/en/function.parse-url.php
|
157 |
+
*
|
158 |
+
* @return (mixed) False on parse failure; Array of URL components on success;
|
159 |
+
* When a specific component has been requested: null if the component
|
160 |
+
* doesn't exist in the given URL; a sting or - in the case of
|
161 |
+
* PHP_URL_PORT - integer when it does. See parse_url()'s return values.
|
162 |
+
*/
|
163 |
+
function _get_component_from_parsed_url_array( $url_parts, $component = -1 ) {
|
164 |
+
if ( -1 === $component ) {
|
165 |
+
return $url_parts;
|
166 |
+
}
|
167 |
+
|
168 |
+
$key = _wp_translate_php_url_constant_to_key( $component );
|
169 |
+
|
170 |
+
if ( false !== $key && is_array( $url_parts ) && isset( $url_parts[ $key ] ) ) {
|
171 |
+
return $url_parts[ $key ];
|
172 |
+
} else {
|
173 |
+
return null;
|
174 |
+
}
|
175 |
+
}
|
176 |
+
endif;
|
177 |
+
|
178 |
+
|
179 |
+
if ( ! function_exists( '_wp_translate_php_url_constant_to_key' ) ) :
|
180 |
+
/**
|
181 |
+
* Translate a PHP_URL_* constant to the named array keys PHP uses.
|
182 |
+
*
|
183 |
+
* @since 2.5.1
|
184 |
+
* @since WP 4.7.0
|
185 |
+
* @see http://php.net/manual/en/url.constants.php
|
186 |
+
*
|
187 |
+
* @param (int) $constant PHP_URL_* constant.
|
188 |
+
*
|
189 |
+
* @return (string|bool) The named key or false.
|
190 |
+
*/
|
191 |
+
function _wp_translate_php_url_constant_to_key( $constant ) {
|
192 |
+
$translation = array(
|
193 |
+
PHP_URL_SCHEME => 'scheme',
|
194 |
+
PHP_URL_HOST => 'host',
|
195 |
+
PHP_URL_PORT => 'port',
|
196 |
+
PHP_URL_USER => 'user',
|
197 |
+
PHP_URL_PASS => 'pass',
|
198 |
+
PHP_URL_PATH => 'path',
|
199 |
+
PHP_URL_QUERY => 'query',
|
200 |
+
PHP_URL_FRAGMENT => 'fragment',
|
201 |
+
);
|
202 |
+
|
203 |
+
if ( isset( $translation[ $constant ] ) ) {
|
204 |
+
return $translation[ $constant ];
|
205 |
+
} else {
|
206 |
+
return false;
|
207 |
+
}
|
208 |
+
}
|
209 |
+
endif;
|
inc/functions/deprecated.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
die( 'Cheatin\' uh?' );
|
4 |
+
}
|
5 |
+
|
6 |
+
|
7 |
+
/**
|
8 |
+
* When a logged out user tries to access the admin area, deny access.
|
9 |
+
* Does nothing if the user is logged in.
|
10 |
+
* `admin-post.php` and `admin-ajax.php` are white listed.
|
11 |
+
*
|
12 |
+
* @since 2.5 Deprecated. Was hooked on 'after_setup_theme'.
|
13 |
+
*/
|
14 |
+
function sfml_maybe_deny_admin_redirect() {
|
15 |
+
global $pagenow;
|
16 |
+
|
17 |
+
_deprecated_function( __FUNCTION__, '2.5', 'sfml_maybe_deny_login_redirect' );
|
18 |
+
|
19 |
+
// If it's not the administration area, or if it's an ajax call, no need to go further.
|
20 |
+
if ( ! ( is_admin() && ! ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ( 'admin-post.php' === $pagenow && ! empty( $_REQUEST['action'] ) ) ) ) ) {
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
if ( is_user_admin() ) {
|
25 |
+
$scheme = 'logged_in';
|
26 |
+
} else {
|
27 |
+
/** This filter is documented in wp-includes/pluggable.php */
|
28 |
+
$scheme = apply_filters( 'auth_redirect_scheme', '' );
|
29 |
+
}
|
30 |
+
|
31 |
+
if ( wp_validate_auth_cookie( '', $scheme ) ) {
|
32 |
+
return;
|
33 |
+
}
|
34 |
+
|
35 |
+
// Nice try. But no.
|
36 |
+
sfml_deny_login_redirect();
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* When a logged out user tries to access `wp-signup.php` or `wp-register.php`, deny access.
|
42 |
+
* Does nothing if the user is logged in.
|
43 |
+
* Does nothing in multisite.
|
44 |
+
*
|
45 |
+
* @since 2.5 Deprecated. Was hooked on 'register_url'.
|
46 |
+
*
|
47 |
+
* @param (string) $url The URL.
|
48 |
+
*
|
49 |
+
* @return (string) The same URL.
|
50 |
+
*/
|
51 |
+
function sfml_maybe_die_on_signup_page( $url ) {
|
52 |
+
_deprecated_function( __FUNCTION__, '2.5', 'sfml_maybe_deny_login_redirect' );
|
53 |
+
|
54 |
+
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
|
55 |
+
return $url;
|
56 |
+
}
|
57 |
+
if ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-signup.php' ) && false === strpos( $_SERVER['REQUEST_URI'], '/wp-register.php' ) ) {
|
58 |
+
return $url;
|
59 |
+
}
|
60 |
+
if ( is_multisite() || is_user_logged_in() ) {
|
61 |
+
return $url;
|
62 |
+
}
|
63 |
+
|
64 |
+
// Nope!
|
65 |
+
sfml_deny_login_redirect();
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Perform the action set for redirections to login page: die or redirect.
|
71 |
+
*
|
72 |
+
* @since 2.5 Deprecated.
|
73 |
+
*/
|
74 |
+
function sfml_deny_login_redirect() {
|
75 |
+
_deprecated_function( __FUNCTION__, '2.5', 'sfml_maybe_deny_login_redirect' );
|
76 |
+
|
77 |
+
/**
|
78 |
+
* If you want to trigger a custom action (redirect, message, die...), add it here.
|
79 |
+
* Don't forget to exit/die.
|
80 |
+
*/
|
81 |
+
do_action( 'sfml_wp_admin_error' );
|
82 |
+
|
83 |
+
$do = sfml_get_deny_admin_access();
|
84 |
+
|
85 |
+
switch ( $do ) {
|
86 |
+
case 1:
|
87 |
+
wp_die( __( 'Cheatin’ uh?' ), __( 'Nope :)', 'sf-move-login' ), array( 'response' => 403 ) );
|
88 |
+
case 2:
|
89 |
+
$redirect = $GLOBALS['wp_rewrite']->using_permalinks() ? home_url( '404' ) : add_query_arg( 'p', '404', home_url() );
|
90 |
+
/** This filter is documented in inc/redirections-and-dies.php */
|
91 |
+
$redirect = apply_filters( 'sfml_404_error_page', $redirect );
|
92 |
+
wp_redirect( esc_url_raw( user_trailingslashit( $redirect ) ) );
|
93 |
+
exit;
|
94 |
+
case 3:
|
95 |
+
wp_redirect( esc_url_raw( user_trailingslashit( home_url() ) ) );
|
96 |
+
exit;
|
97 |
+
}
|
98 |
+
}
|
inc/functions/rewrite.php
CHANGED
@@ -82,29 +82,6 @@ function sfml_write_rules( $rules = null ) {
|
|
82 |
}
|
83 |
|
84 |
|
85 |
-
/**
|
86 |
-
* Is WP a MultiSite and a subfolder install?
|
87 |
-
*
|
88 |
-
* @return (bool)
|
89 |
-
*/
|
90 |
-
function sfml_is_subfolder_install() {
|
91 |
-
global $wpdb;
|
92 |
-
static $subfolder_install;
|
93 |
-
|
94 |
-
if ( ! isset( $subfolder_install ) ) {
|
95 |
-
if ( is_multisite() ) {
|
96 |
-
$subfolder_install = ! is_subdomain_install();
|
97 |
-
} elseif ( ! is_null( $wpdb->sitemeta ) ) {
|
98 |
-
$subfolder_install = ! $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
|
99 |
-
} else {
|
100 |
-
$subfolder_install = false;
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
return $subfolder_install;
|
105 |
-
}
|
106 |
-
|
107 |
-
|
108 |
/**
|
109 |
* Get infos for the rewrite rules.
|
110 |
* The main concern is about directories.
|
82 |
}
|
83 |
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
/**
|
86 |
* Get infos for the rewrite rules.
|
87 |
* The main concern is about directories.
|
inc/functions/settings-page.php
CHANGED
@@ -61,14 +61,14 @@ function sfml_settings_fields() {
|
|
61 |
2 => __( 'Redirect to a «Page not found» error page', 'sf-move-login' ),
|
62 |
3 => __( 'Redirect to the home page', 'sf-move-login' ),
|
63 |
),
|
64 |
-
'label' => '<strong>' . __( 'When a
|
65 |
)
|
66 |
);
|
67 |
|
68 |
-
// Deny
|
69 |
add_settings_field(
|
70 |
'deny_admin_access',
|
71 |
-
|
72 |
'sfml_radio_field',
|
73 |
SFML_Options::OPTION_PAGE,
|
74 |
'access',
|
@@ -82,7 +82,7 @@ function sfml_settings_fields() {
|
|
82 |
2 => __( 'Redirect to a «Page not found» error page', 'sf-move-login' ),
|
83 |
3 => __( 'Redirect to the home page', 'sf-move-login' ),
|
84 |
),
|
85 |
-
'label' => '<strong>' . __( '
|
86 |
)
|
87 |
);
|
88 |
}
|
61 |
2 => __( 'Redirect to a «Page not found» error page', 'sf-move-login' ),
|
62 |
3 => __( 'Redirect to the home page', 'sf-move-login' ),
|
63 |
),
|
64 |
+
'label' => '<strong>' . __( 'When a logged out user attempts to access the old login page.', 'sf-move-login' ) . '</strong>',
|
65 |
)
|
66 |
);
|
67 |
|
68 |
+
// Deny redirect to the login page.
|
69 |
add_settings_field(
|
70 |
'deny_admin_access',
|
71 |
+
_x( 'Redirects', 'noun', 'sf-move-login' ),
|
72 |
'sfml_radio_field',
|
73 |
SFML_Options::OPTION_PAGE,
|
74 |
'access',
|
82 |
2 => __( 'Redirect to a «Page not found» error page', 'sf-move-login' ),
|
83 |
3 => __( 'Redirect to the home page', 'sf-move-login' ),
|
84 |
),
|
85 |
+
'label' => '<strong>' . __( 'Instead of redirecting a logged out user to the new login page:', 'sf-move-login' ) . '</strong>',
|
86 |
)
|
87 |
);
|
88 |
}
|
inc/functions/utilities.php
CHANGED
@@ -227,6 +227,58 @@ function sfml_get_wp_directory() {
|
|
227 |
}
|
228 |
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
/**
|
231 |
* Build a string for html attributes (means: separated by a space).
|
232 |
* Example:
|
227 |
}
|
228 |
|
229 |
|
230 |
+
/**
|
231 |
+
* Is WP a MultiSite and a subfolder install?
|
232 |
+
*
|
233 |
+
* @since 2.5 Moved to global scope.
|
234 |
+
*
|
235 |
+
* @return (bool)
|
236 |
+
*/
|
237 |
+
function sfml_is_subfolder_install() {
|
238 |
+
global $wpdb;
|
239 |
+
static $subfolder_install;
|
240 |
+
|
241 |
+
if ( ! isset( $subfolder_install ) ) {
|
242 |
+
if ( is_multisite() ) {
|
243 |
+
$subfolder_install = ! is_subdomain_install();
|
244 |
+
} elseif ( ! is_null( $wpdb->sitemeta ) ) {
|
245 |
+
$subfolder_install = ! $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
|
246 |
+
} else {
|
247 |
+
$subfolder_install = false;
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
return $subfolder_install;
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Get the site main URL. Will be the same for any site of a network, and for any lang of a multilang site.
|
257 |
+
*
|
258 |
+
* @since 2.5
|
259 |
+
*
|
260 |
+
* @return (string) The URL.
|
261 |
+
*/
|
262 |
+
function sfml_get_main_url() {
|
263 |
+
$current_network = false;
|
264 |
+
|
265 |
+
if ( function_exists( 'get_network' ) ) {
|
266 |
+
$current_network = get_network();
|
267 |
+
} elseif ( function_exists( 'get_current_site' ) ) {
|
268 |
+
$current_network = get_current_site();
|
269 |
+
}
|
270 |
+
|
271 |
+
if ( ! $current_network ) {
|
272 |
+
return get_option( 'siteurl' );
|
273 |
+
}
|
274 |
+
|
275 |
+
$scheme = is_ssl() ? 'https' : 'http';
|
276 |
+
$main_url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
|
277 |
+
|
278 |
+
return untrailingslashit( $main_url );
|
279 |
+
}
|
280 |
+
|
281 |
+
|
282 |
/**
|
283 |
* Build a string for html attributes (means: separated by a space).
|
284 |
* Example:
|
inc/redirections-and-dies.php
CHANGED
@@ -98,7 +98,7 @@ function sfml_deny_login_access() {
|
|
98 |
|
99 |
switch ( $do ) {
|
100 |
case 2:
|
101 |
-
$redirect =
|
102 |
/**
|
103 |
* Filter the 404 page URL.
|
104 |
*
|
@@ -120,84 +120,81 @@ function sfml_deny_login_access() {
|
|
120 |
/* !DO NOT REDIRECT TO THE NEW LOGIN PAGE ======================================================= */
|
121 |
/*------------------------------------------------------------------------------------------------*/
|
122 |
|
123 |
-
|
124 |
/**
|
125 |
-
*
|
|
|
126 |
* Does nothing if the user is logged in.
|
127 |
-
*
|
|
|
|
|
|
|
|
|
|
|
128 |
*/
|
129 |
-
function
|
130 |
-
|
131 |
-
|
132 |
-
if ( ! ( is_admin() && ! ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ( 'admin-post.php' === $pagenow && ! empty( $_REQUEST['action'] ) ) ) ) ) {
|
133 |
-
return;
|
134 |
}
|
135 |
|
136 |
-
|
137 |
-
|
138 |
-
} else {
|
139 |
-
/** This filter is documented in wp-includes/pluggable.php */
|
140 |
-
$scheme = apply_filters( 'auth_redirect_scheme', '' );
|
141 |
-
}
|
142 |
|
143 |
-
if (
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
* When a logged out user tries to access `wp-signup.php` or `wp-register.php`, deny access.
|
155 |
-
* Does nothing if the user is logged in.
|
156 |
-
* Does nothing in multisite.
|
157 |
-
*
|
158 |
-
* @param (string) $url The URL.
|
159 |
-
*
|
160 |
-
* @return (string) The same URL.
|
161 |
-
*/
|
162 |
-
function sfml_maybe_die_on_signup_page( $url ) {
|
163 |
-
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
|
164 |
-
return $url;
|
165 |
-
}
|
166 |
-
if ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-signup.php' ) && false === strpos( $_SERVER['REQUEST_URI'], '/wp-register.php' ) ) {
|
167 |
-
return $url;
|
168 |
}
|
169 |
-
if ( is_multisite() || is_user_logged_in() ) {
|
170 |
-
return $url;
|
171 |
-
}
|
172 |
-
|
173 |
-
// Nope!
|
174 |
-
sfml_deny_login_redirect();
|
175 |
-
}
|
176 |
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Perform the action set for redirections to login page: die or redirect.
|
180 |
-
*/
|
181 |
-
function sfml_deny_login_redirect() {
|
182 |
/**
|
183 |
* If you want to trigger a custom action (redirect, message, die...), add it here.
|
184 |
-
*
|
|
|
|
|
|
|
185 |
*/
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
$do = sfml_get_deny_admin_access();
|
189 |
|
190 |
switch ( $do ) {
|
191 |
case 1:
|
192 |
-
|
|
|
193 |
case 2:
|
194 |
-
$redirect =
|
195 |
/** This filter is documented in inc/redirections-and-dies.php */
|
196 |
$redirect = apply_filters( 'sfml_404_error_page', $redirect );
|
197 |
-
|
198 |
-
exit;
|
199 |
case 3:
|
200 |
-
|
201 |
-
exit;
|
202 |
}
|
203 |
}
|
98 |
|
99 |
switch ( $do ) {
|
100 |
case 2:
|
101 |
+
$redirect = home_url( '404' );
|
102 |
/**
|
103 |
* Filter the 404 page URL.
|
104 |
*
|
120 |
/* !DO NOT REDIRECT TO THE NEW LOGIN PAGE ======================================================= */
|
121 |
/*------------------------------------------------------------------------------------------------*/
|
122 |
|
123 |
+
add_filter( 'wp_redirect', 'sfml_maybe_deny_login_redirect', 1 );
|
124 |
/**
|
125 |
+
* Filters the redirect location.
|
126 |
+
* When a logged out user is being redirected to the new login page, deny access.
|
127 |
* Does nothing if the user is logged in.
|
128 |
+
*
|
129 |
+
* @since 2.5
|
130 |
+
*
|
131 |
+
* @param (string) $location The path to redirect to.
|
132 |
+
*
|
133 |
+
* @return (string)
|
134 |
*/
|
135 |
+
function sfml_maybe_deny_login_redirect( $location ) {
|
136 |
+
if ( is_user_logged_in() ) {
|
137 |
+
return $location;
|
|
|
|
|
138 |
}
|
139 |
|
140 |
+
$slugs = sfml_get_slugs();
|
141 |
+
$wp_dir = sfml_get_wp_directory();
|
|
|
|
|
|
|
|
|
142 |
|
143 |
+
if ( sfml_is_subfolder_install() ) {
|
144 |
+
$base = wp_parse_url( trailingslashit( sfml_get_main_url() ) );
|
145 |
+
$base = ltrim( $base['path'], '/' );
|
146 |
+
$base .= $wp_dir ? '[_0-9a-zA-Z-]+/' : '([_0-9a-zA-Z-]+/)?';
|
147 |
+
} else {
|
148 |
+
$base = wp_parse_url( trailingslashit( get_option( 'home' ) ) );
|
149 |
+
$base = ltrim( $base['path'], '/' );
|
150 |
+
$base .= $wp_dir ? ltrim( $wp_dir, '/' ) : '';
|
151 |
}
|
152 |
|
153 |
+
$regex = '^' . $base . '(' . implode( '|', $slugs ) . ')$';
|
154 |
+
$parsed = wp_parse_url( $location );
|
155 |
+
$parsed = ! empty( $parsed['path'] ) ? $parsed['path'] : '';
|
156 |
+
$parsed = trim( $parsed, '/' );
|
157 |
|
158 |
+
if ( ! preg_match( "@{$regex}@", $parsed ) ) {
|
159 |
+
return $location;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
+
$redirect = false;
|
|
|
|
|
|
|
|
|
163 |
/**
|
164 |
* If you want to trigger a custom action (redirect, message, die...), add it here.
|
165 |
+
*
|
166 |
+
* @since 2.5
|
167 |
+
*
|
168 |
+
* @param (string|bool) $redirect A custom URL to redirect to. Default is false.
|
169 |
*/
|
170 |
+
$redirect = apply_filters( 'sfml_login_redirect_location', $redirect );
|
171 |
+
|
172 |
+
if ( $redirect ) {
|
173 |
+
return esc_url_raw( $redirect );
|
174 |
+
}
|
175 |
+
|
176 |
+
if ( function_exists( 'do_action_deprecated' ) ) {
|
177 |
+
do_action_deprecated( 'sfml_wp_admin_error', array(), '2.5', 'sfml_login_redirect_location' );
|
178 |
+
} else {
|
179 |
+
/**
|
180 |
+
* If you want to trigger a custom action (redirect, message, die...), add it here.
|
181 |
+
* Don't forget to exit/die.
|
182 |
+
*/
|
183 |
+
do_action( 'sfml_wp_admin_error' );
|
184 |
+
}
|
185 |
|
186 |
$do = sfml_get_deny_admin_access();
|
187 |
|
188 |
switch ( $do ) {
|
189 |
case 1:
|
190 |
+
sfml_lang_init();
|
191 |
+
wp_die( __( 'Cheatin’ uh?', 'sf-move-login' ), __( 'Nope :)', 'sf-move-login' ), array( 'response' => 403 ) );
|
192 |
case 2:
|
193 |
+
$redirect = home_url( '404' );
|
194 |
/** This filter is documented in inc/redirections-and-dies.php */
|
195 |
$redirect = apply_filters( 'sfml_404_error_page', $redirect );
|
196 |
+
return esc_url_raw( user_trailingslashit( $redirect ) );
|
|
|
197 |
case 3:
|
198 |
+
return esc_url_raw( user_trailingslashit( home_url() ) );
|
|
|
199 |
}
|
200 |
}
|
languages/sf-move-login-fr_FR.mo
CHANGED
Binary file
|
languages/sf-move-login-fr_FR.po
CHANGED
@@ -4,8 +4,8 @@ msgid ""
|
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: Move Login 2.4.3\n"
|
6 |
"Report-Msgid-Bugs-To: Grégory Viguier <i18n@screenfeed.fr>\n"
|
7 |
-
"POT-Creation-Date: 2017-
|
8 |
-
"PO-Revision-Date: 2017-
|
9 |
"Last-Translator: WP Media <contact@secupress.me>\n"
|
10 |
"Language-Team: French (France)\n"
|
11 |
"Language: fr_FR\n"
|
@@ -86,6 +86,11 @@ msgstr ""
|
|
86 |
"règles de réécriture. %3$s fonctionne mais ne pourra pas le faire "
|
87 |
"correctement tant que vous ne vous serez pas occupé de ces règles."
|
88 |
|
|
|
|
|
|
|
|
|
|
|
89 |
#. Translators: %s is an URL slug name.
|
90 |
#: inc/classes/class-sfml-options.php:389
|
91 |
#, php-format
|
@@ -98,6 +103,11 @@ msgstr[1] "Les identifiants %s sont interdits."
|
|
98 |
msgid "The links can't have the same slugs."
|
99 |
msgstr "Les liens ne peuvent pas avoir les mêmes identifiants."
|
100 |
|
|
|
|
|
|
|
|
|
|
|
101 |
#: inc/functions/settings-page.php:19
|
102 |
msgid "Choose your new URLs"
|
103 |
msgstr "Choisissez vos nouvelles adresses"
|
@@ -125,14 +135,15 @@ msgid "Redirect to the home page"
|
|
125 |
msgstr "Rediriger vers la page d’accueil"
|
126 |
|
127 |
#: inc/functions/settings-page.php:64
|
128 |
-
msgid "When a
|
129 |
msgstr ""
|
130 |
-
"
|
131 |
-
"
|
132 |
|
133 |
#: inc/functions/settings-page.php:71
|
134 |
-
|
135 |
-
|
|
|
136 |
|
137 |
#: inc/functions/settings-page.php:80
|
138 |
msgid "Do nothing, redirect to the new login page (not recommended)"
|
@@ -140,10 +151,10 @@ msgstr ""
|
|
140 |
"Ne rien faire, rediriger vers la nouvelle page de connexion (non recommandé)"
|
141 |
|
142 |
#: inc/functions/settings-page.php:85
|
143 |
-
msgid "
|
144 |
msgstr ""
|
145 |
-
"
|
146 |
-
"
|
147 |
|
148 |
#. Translators: %s is an option value.
|
149 |
#: inc/functions/settings-page.php:167 inc/functions/settings-page.php:210
|
@@ -195,15 +206,20 @@ msgstr ""
|
|
195 |
msgid "No no no, the login form is not here."
|
196 |
msgstr "Non non non, le formulaire de connexion ne se trouve pas ici."
|
197 |
|
198 |
-
#: inc/redirections-and-dies.php:114 inc/redirections-and-dies.php:192
|
199 |
-
msgid "Nope :)"
|
200 |
-
msgstr "Raté :)"
|
201 |
-
|
202 |
#. Translators: Description of the plugin/theme
|
203 |
-
#: sf-move-login.php:
|
204 |
msgid "Change your login URL."
|
205 |
msgstr "Changez l’url de votre page de connexion."
|
206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
#~ msgid ""
|
208 |
#~ "It seems your server does not use <i>Apache</i>, <i>Nginx</i>, nor "
|
209 |
#~ "<i>IIS7</i>. <strong>Move Login</strong> won't work."
|
4 |
msgstr ""
|
5 |
"Project-Id-Version: Move Login 2.4.3\n"
|
6 |
"Report-Msgid-Bugs-To: Grégory Viguier <i18n@screenfeed.fr>\n"
|
7 |
+
"POT-Creation-Date: 2017-05-09 22:18+0200\n"
|
8 |
+
"PO-Revision-Date: 2017-05-09 22:24+0200\n"
|
9 |
"Last-Translator: WP Media <contact@secupress.me>\n"
|
10 |
"Language-Team: French (France)\n"
|
11 |
"Language: fr_FR\n"
|
86 |
"règles de réécriture. %3$s fonctionne mais ne pourra pas le faire "
|
87 |
"correctement tant que vous ne vous serez pas occupé de ces règles."
|
88 |
|
89 |
+
#: inc/admin.php:152 inc/functions/deprecated.php:87
|
90 |
+
#: inc/redirections-and-dies.php:190
|
91 |
+
msgid "Cheatin’ uh?"
|
92 |
+
msgstr "Alors, on triche ?"
|
93 |
+
|
94 |
#. Translators: %s is an URL slug name.
|
95 |
#: inc/classes/class-sfml-options.php:389
|
96 |
#, php-format
|
103 |
msgid "The links can't have the same slugs."
|
104 |
msgstr "Les liens ne peuvent pas avoir les mêmes identifiants."
|
105 |
|
106 |
+
#: inc/functions/deprecated.php:87 inc/redirections-and-dies.php:114
|
107 |
+
#: inc/redirections-and-dies.php:190
|
108 |
+
msgid "Nope :)"
|
109 |
+
msgstr "Raté :)"
|
110 |
+
|
111 |
#: inc/functions/settings-page.php:19
|
112 |
msgid "Choose your new URLs"
|
113 |
msgstr "Choisissez vos nouvelles adresses"
|
135 |
msgstr "Rediriger vers la page d’accueil"
|
136 |
|
137 |
#: inc/functions/settings-page.php:64
|
138 |
+
msgid "When a logged out user attempts to access the old login page."
|
139 |
msgstr ""
|
140 |
+
"Quand un utilisateur non connecté tente d'accéder à l'ancienne page de "
|
141 |
+
"connexion."
|
142 |
|
143 |
#: inc/functions/settings-page.php:71
|
144 |
+
msgctxt "noun"
|
145 |
+
msgid "Redirects"
|
146 |
+
msgstr "Redirections"
|
147 |
|
148 |
#: inc/functions/settings-page.php:80
|
149 |
msgid "Do nothing, redirect to the new login page (not recommended)"
|
151 |
"Ne rien faire, rediriger vers la nouvelle page de connexion (non recommandé)"
|
152 |
|
153 |
#: inc/functions/settings-page.php:85
|
154 |
+
msgid "Instead of redirecting a logged out user to the new login page:"
|
155 |
msgstr ""
|
156 |
+
"Plutôt que de rediriger un utilisateur non connecté vers la nouvelle page de "
|
157 |
+
"connexion :"
|
158 |
|
159 |
#. Translators: %s is an option value.
|
160 |
#: inc/functions/settings-page.php:167 inc/functions/settings-page.php:210
|
206 |
msgid "No no no, the login form is not here."
|
207 |
msgstr "Non non non, le formulaire de connexion ne se trouve pas ici."
|
208 |
|
|
|
|
|
|
|
|
|
209 |
#. Translators: Description of the plugin/theme
|
210 |
+
#: sf-move-login.php:92
|
211 |
msgid "Change your login URL."
|
212 |
msgstr "Changez l’url de votre page de connexion."
|
213 |
|
214 |
+
#~ msgid "Administration area"
|
215 |
+
#~ msgstr "Zone d'administration"
|
216 |
+
|
217 |
+
#~ msgid ""
|
218 |
+
#~ "When a not connected user attempts to access the administration area."
|
219 |
+
#~ msgstr ""
|
220 |
+
#~ "Lorsqu’un utilisateur non connecté tente d’accéder à la zone "
|
221 |
+
#~ "d’administration."
|
222 |
+
|
223 |
#~ msgid ""
|
224 |
#~ "It seems your server does not use <i>Apache</i>, <i>Nginx</i>, nor "
|
225 |
#~ "<i>IIS7</i>. <strong>Move Login</strong> won't work."
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Contributors: GregLone, SecuPress, juliobox
|
4 |
Tags: login, logout, url, security
|
5 |
Requires at least: 3.1
|
6 |
-
Tested up to: 4.7.
|
7 |
Stable tag: trunk
|
8 |
License: GPLv3
|
9 |
License URI: https://www.screenfeed.fr/gpl-v3.txt
|
@@ -67,6 +67,16 @@ Eventually, try the [WordPress support forum](https://wordpress.org/support/plug
|
|
67 |
|
68 |
== Changelog ==
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
= 2.4.3 =
|
71 |
|
72 |
* 2017/03/26
|
3 |
Contributors: GregLone, SecuPress, juliobox
|
4 |
Tags: login, logout, url, security
|
5 |
Requires at least: 3.1
|
6 |
+
Tested up to: 4.7.4
|
7 |
Stable tag: trunk
|
8 |
License: GPLv3
|
9 |
License URI: https://www.screenfeed.fr/gpl-v3.txt
|
67 |
|
68 |
== Changelog ==
|
69 |
|
70 |
+
= 2.5.1 =
|
71 |
+
|
72 |
+
* 2017/05/14
|
73 |
+
* Added missing functions for compatibility with WordPress < 4.4.
|
74 |
+
|
75 |
+
= 2.5 =
|
76 |
+
|
77 |
+
* 2017/05/09
|
78 |
+
* Some files from WordPress core were still able to redirect a logged out user to the new login URL. Now Move Login filters every redirection to prevent it.
|
79 |
+
|
80 |
= 2.4.3 =
|
81 |
|
82 |
* 2017/03/26
|
sf-move-login.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: SF Move Login
|
4 |
* Plugin URI: https://www.screenfeed.fr/plugin-wp/move-login/
|
5 |
* Description: Change your login URL.
|
6 |
-
* Version: 2.
|
7 |
* Author: Grégory Viguier
|
8 |
* Author URI: https://www.screenfeed.fr/
|
9 |
* License: GPLv3
|
@@ -25,7 +25,7 @@ if ( empty( $GLOBALS['wp_version'] ) || version_compare( $GLOBALS['wp_version'],
|
|
25 |
/* !CONSTANTS =================================================================================== */
|
26 |
/*------------------------------------------------------------------------------------------------*/
|
27 |
|
28 |
-
define( 'SFML_VERSION', '2.
|
29 |
define( 'SFML_FILE', __FILE__ );
|
30 |
define( 'SFML_PLUGIN_BASENAME', plugin_basename( SFML_FILE ) );
|
31 |
define( 'SFML_PLUGIN_DIR', plugin_dir_path( SFML_FILE ) );
|
@@ -62,6 +62,7 @@ function sfml_init() {
|
|
62 |
return;
|
63 |
}
|
64 |
|
|
|
65 |
include_once( SFML_PLUGIN_DIR . 'inc/url-filters.php' );
|
66 |
include_once( SFML_PLUGIN_DIR . 'inc/redirections-and-dies.php' );
|
67 |
}
|
3 |
* Plugin Name: SF Move Login
|
4 |
* Plugin URI: https://www.screenfeed.fr/plugin-wp/move-login/
|
5 |
* Description: Change your login URL.
|
6 |
+
* Version: 2.5.1
|
7 |
* Author: Grégory Viguier
|
8 |
* Author URI: https://www.screenfeed.fr/
|
9 |
* License: GPLv3
|
25 |
/* !CONSTANTS =================================================================================== */
|
26 |
/*------------------------------------------------------------------------------------------------*/
|
27 |
|
28 |
+
define( 'SFML_VERSION', '2.5.1' );
|
29 |
define( 'SFML_FILE', __FILE__ );
|
30 |
define( 'SFML_PLUGIN_BASENAME', plugin_basename( SFML_FILE ) );
|
31 |
define( 'SFML_PLUGIN_DIR', plugin_dir_path( SFML_FILE ) );
|
62 |
return;
|
63 |
}
|
64 |
|
65 |
+
include_once( SFML_PLUGIN_DIR . 'inc/functions/deprecated.php' );
|
66 |
include_once( SFML_PLUGIN_DIR . 'inc/url-filters.php' );
|
67 |
include_once( SFML_PLUGIN_DIR . 'inc/redirections-and-dies.php' );
|
68 |
}
|