PluginProbe
LoginPress | wp-login Custom Login Page Customizer / 3.0.0
LoginPress | wp-login Custom Login Page Customizer v3.0.0
6.2.5 6.2.4 6.2.3 6.2.2 6.2.1 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.3 1.0.4 All 118 releases
loginpress / include / compatibility.php

compatibility.php in LoginPress | wp-login Custom Login Page Customizer 3.0.0, at include/compatibility.php

454 lines 12.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * This is a LoginPress Compatibility to make it compatible for older versions.
5 *
6 * @since 1.0.22
7 * @version 3.0.0
8 */
9
10
11 /**
12 * Run a compatibility check on 1.0.21 and change the settings.
13 *
14 */
15 add_action( 'init', 'loginpress_upgrade_1_0_22', 1 );
16
17
18 /**
19 * loginpress_upgrade_1_0_22
20 * Remove element 'login_with_email' from loginpress_setting array that was defined in 1.0.21
21 * and update 'login_order' in loginpress_setting for compatibility.
22 *
23 * @since 1.0.22
24 * @return array update loginpress_setting
25 */
26 function loginpress_upgrade_1_0_22() {
27
28 $loginpress_setting = get_option( 'loginpress_setting' );
29 $login_with_email = isset( $loginpress_setting['login_with_email'] ) ? $loginpress_setting['login_with_email'] : '';
30
31 if ( isset( $loginpress_setting['login_with_email'] ) ) {
32
33 if( 'on' == $login_with_email ) {
34
35 $loginpress_setting['login_order'] = 'email';
36 unset( $loginpress_setting['login_with_email'] );
37 update_option( 'loginpress_setting', $loginpress_setting );
38 } else if ( 'off' == $login_with_email ) {
39
40 $loginpress_setting['login_order'] = 'default';
41 unset( $loginpress_setting['login_with_email'] );
42 update_option( 'loginpress_setting', $loginpress_setting );
43 }
44 }
45 }
46
47 if ( ! class_exists( 'LoginPress_Compatibility' ) ) :
48
49 /**
50 * LoginPress compatibility Class is used to make LoginPress compatible with other plugins.
51 * Remove conflict.
52 * Add CSS Support.
53 * @since 1.0.3
54 * @version 1.3.2
55 */
56 class LoginPress_Compatibility {
57
58 /**
59 * Variable that Check for LoginPress Key.
60 *
61 * @var string
62 * @since 1.3.2
63 */
64 public $loginpress_key;
65
66 public function __construct() {
67 $this->loginpress_key = get_option( 'loginpress_customization' );
68 $this->dependencies();
69 }
70
71 public function dependencies() {
72
73 add_action( 'wp_print_scripts', array( $this, 'dequeue_conflicted_script' ), 100 );
74 add_action( 'login_headerurl', array( $this, 'remove_conflicted_action' ) );
75 add_action( 'init', array( $this, 'enqueue_loginpress_compatibility_script') );
76
77 /*************************************
78 WebArx Compatibility Fix // v1.2.3
79 *************************************/
80 add_filter( 'wp_redirect', array( $this, 'wp_redirect_remove_filter' ), 9 );
81 add_filter( 'site_url', array( $this, 'site_url_remove_filter' ) , 9 );
82 add_filter( 'network_site_url', array( $this, 'network_site_url_remove_filter' ), 9 );
83 add_action( 'plugins_loaded', array( $this, 'plugins_loaded_remove_action' ), 10 );
84 add_action( 'wp_loaded', array( $this, 'wp_loaded_remove_action' ), 9 );
85 add_action( 'init', array( $this, 'init_remove_action' ), 9 );
86
87 /**
88 * Login page Compatibility Fix.
89 *
90 * @since v1.3.2
91 */
92 add_action( 'login_enqueue_scripts', array( $this, 'dequeue_login_page_conflicting_scripts' ), 99 );
93
94 /**
95 * Oxygen Builder Compatibility Fix.
96 *
97 * @since v1.4.0
98 */
99 add_filter( 'template_include', array( $this, 'template_include_ob' ), 100 );
100
101 /**
102 * All In One WP Security & Firewall Compatibility Fix.
103 *
104 * @since 1.4.0
105 */
106 add_action( 'init', array( $this, 'aiowps_login_init_remove_action' ) );
107 }
108
109 /**
110 * Dequeue login page styles.
111 *
112 * @since 1.3.2
113 * @version 1.4.3
114 */
115 function dequeue_login_page_conflicting_scripts() {
116
117 /**
118 * Dequeue thrive theme login page styles.
119 *
120 * @since 1.3.2
121 */
122 wp_dequeue_style( 'thrive-custom-login' );
123 wp_dequeue_script( 'thrive-custom-login' );
124
125 /**
126 * Dequeue listing-pro theme login page styles.
127 *
128 * @since 1.4.3
129 */
130 wp_dequeue_style( 'listable-custom-login' );
131
132 /**
133 * PCI Compliance
134 *
135 * @since 1.7.2
136 */
137 $loginpress_setting = get_option( 'loginpress_setting' );
138 $pci_compliance = isset( $loginpress_setting['enable_pci_compliance'] ) ? $loginpress_setting['enable_pci_compliance'] : 'off';
139
140 if ( $pci_compliance !== 'off' ) {
141
142 echo '<script>document.addEventListener("DOMContentLoaded", function() {
143 var inputs = document.querySelectorAll("input[type=text]");
144 for (var i = 0; i < inputs.length; i++) {
145 inputs[i].setAttribute("autocomplete", "off");
146 }
147 });</script>';
148 echo '<script>document.addEventListener("DOMContentLoaded", function() {
149 var inputs = document.querySelectorAll("input[type=password]");
150 for (var i = 0; i < inputs.length; i++) {
151 inputs[i].setAttribute("autocomplete", "off");
152 }
153 });</script>';
154 echo '<script>document.addEventListener("DOMContentLoaded", function() {
155 var inputs = document.querySelectorAll("input[type=email]");
156 for (var i = 0; i < inputs.length; i++) {
157 inputs[i].setAttribute("autocomplete", "off");
158 }
159 });</script>';
160 }
161 }
162
163 /**
164 * Override the oxygen template with loginpress on login customizer screen.
165 *
166 * @since 1.4.0
167 */
168 public function template_include_ob( $template ) {
169
170 // Safely exit if methods not defined yet
171 if ( ! function_exists( 'is_customize_preview' ) || ! function_exists( 'wp_get_referer' ) ) {
172 return $template;
173 }
174
175 if ( is_customize_preview() && $template == ABSPATH . 'wp-content/plugins/oxygen/component-framework//oxygen-main-template.php' && ( false !== strpos( wp_get_referer(), 'autofocus[panel]=loginpress_panel' ) ) ) {
176 return ABSPATH . 'wp-content/plugins/loginpress/include/template-loginpress.php';
177 }
178
179 return $template;
180 }
181
182 /**
183 * WebArx Compatibility Fix.
184 *
185 * @since 1.2.3
186 * @param string $location The currrent location.
187 * @return string $location Modified currrent location.
188 */
189 public function wp_redirect_remove_filter( $location ) {
190
191 if ( class_exists( 'Webarx' ) ) {
192
193 if ( ! function_exists( 'is_user_logged_in' ) ) {
194 return $location;
195 }
196
197 $webarx_login = get_option( 'webarx_mv_wp_login' );
198 $user_logged_in = is_user_logged_in();
199
200 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
201 remove_filter( 'wp_redirect', array( webarx()->hide_login, 'wp_redirect' ) );
202 }
203 }
204 return $location;
205 }
206
207 /**
208 * WebArx Compatibility Fix for site URL removal.
209 *
210 * @since 1.2.3
211 * @param string $url The URL.
212 * @return string $url Modfied URL.
213 */
214 public function site_url_remove_filter( $url ) {
215 if ( class_exists( 'Webarx' ) ) {
216
217 if ( ! function_exists( 'is_user_logged_in' ) ) {
218 return $url;
219 }
220
221 $webarx_login = get_option( 'webarx_mv_wp_login' );
222 $user_logged_in = is_user_logged_in();
223
224 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
225 remove_filter('site_url', array( webarx()->hide_login, 'site_url' ) ) ;
226 }
227 }
228 return $url;
229 }
230
231 /**
232 * WebArx Compatibility Fix for multi-site URL removal.
233 *
234 * @since 1.2.3
235 * @param string $url The URL.
236 * @return string $url Modfied URL.
237 */
238 public function network_site_url_remove_filter( $url ) {
239 if ( class_exists( 'Webarx' ) ) {
240
241 if ( ! function_exists( 'is_user_logged_in' ) ) {
242 return $url;
243 }
244
245 $webarx_login = get_option( 'webarx_mv_wp_login' );
246 $user_logged_in = is_user_logged_in();
247
248 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
249 remove_filter('network_site_url', array( webarx()->hide_login, 'network_site_url' ) ) ;
250 }
251 }
252 return $url;
253 }
254
255 /**
256 * WebArx Compatibility Fix for multi-site URL removal.
257 *
258 * @since 1.2.3
259 */
260 public function plugins_loaded_remove_action() {
261 if ( class_exists( 'Webarx' ) ) {
262
263 if ( ! function_exists( 'is_user_logged_in' ) ) {
264 return;
265 }
266
267 $webarx_login = get_option( 'webarx_mv_wp_login' );
268 $user_logged_in = is_user_logged_in();
269
270 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
271 remove_action( 'plugins_loaded', array( webarx()->hide_login, 'plugins_loaded' ), 9999 ) ;
272 }
273 }
274 }
275 /**
276 * Remove wp_loaded action hook.
277 *
278 * @since 1.2.3
279 */
280 public function wp_loaded_remove_action() {
281 if ( class_exists( 'Webarx' ) ) {
282
283 if ( ! function_exists( 'is_user_logged_in' ) ) {
284 return $url;
285 }
286
287 $webarx_login = get_option( 'webarx_mv_wp_login' );
288 $user_logged_in = is_user_logged_in();
289
290 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
291 remove_action( 'wp_loaded', array( webarx()->hide_login, 'wp_loaded' ) );
292 }
293 }
294 }
295 /**
296 * Remove init action hook.
297 *
298 * @since 1.2.3
299 */
300 public function init_remove_action() {
301 if ( class_exists( 'Webarx' ) ) {
302
303 if ( ! function_exists( 'is_user_logged_in' ) ) {
304 return $url;
305 }
306
307 $webarx_login = get_option( 'webarx_mv_wp_login' );
308 $user_logged_in = is_user_logged_in();
309
310 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
311 remove_action( 'init', array( webarx()->hide_login, 'denyRequestsToWpLogin' ) ) ;
312 }
313 }
314 }
315
316
317 /**
318 * Remove login security check in customizer screen only.
319 * No need for this check as the user is already logged in and using customizer.
320 *
321 * @since 1.4.0
322 */
323 public function aiowps_login_init_remove_action() {
324 if ( ! is_customize_preview() )
325 return;
326
327 if ( ! class_exists( 'AIO_WP_Security' ) )
328 return;
329
330 global $aio_wp_security;
331
332 if( ! is_a( $aio_wp_security, 'AIO_WP_Security' ) )
333 return;
334
335 if( remove_action( 'wp_loaded', array( $aio_wp_security, 'aiowps_wp_loaded_handler' ) ) ) {
336 add_filter( 'option_aio_wp_security_configs', array( $this, 'aiowps_filter_options' ) );
337 }
338 }
339
340 /**
341 * Filter options aio_wp_security_configs.
342 *
343 * @since 1.4.0
344 */
345 public function aiowps_filter_options( $option ) {
346
347 unset( $option['aiowps_enable_rename_login_page'] );
348 return $option;
349 }
350
351 /**
352 * Enqueue LoginPress CSS on Password_Protected plugin.
353 *
354 * @return void
355 */
356 public function enqueue_loginpress_compatibility_script() {
357
358 /**
359 * Enqueue LoginPress CSS on Password_Protected plugin.
360 *
361 * Hooked to the password_protected_login_head action,
362 * Head URL & Title on logo as well.
363 *
364 * so that it is after the script was enqueued.
365 * @since 1.0.3
366 * @version 1.3.2
367 */
368 if ( class_exists( 'Password_Protected' ) ) {
369 add_action( 'password_protected_login_head', array( $this, 'enqueue_loginpress_script' ) );
370 add_filter( 'password_protected_login_headerurl', array( $this, 'password_protected_login_headerurl_cb' ) );
371 add_filter( 'password_protected_login_headertitle', array( $this, 'password_protected_login_headertitle_cb' ) );
372 }
373 }
374
375 /**
376 * Enqueue the Divi Login script.
377 *
378 * @since 1.0.3
379 */
380 public function dequeue_conflicted_script() {
381
382 /**
383 * Dequeue the Divi Login script.
384 *
385 * Hooked to the wp_print_scripts action, with a late priority (100),
386 * so that it is after the script was enqueued.
387 * @since 1.0.3
388 */
389 if ( class_exists( 'ET_Divi_100_Custom_Login_Page_Config' ) ) {
390 wp_dequeue_style( 'custom-login-pages' );
391 wp_dequeue_script( 'custom-login-pages-icon-font' );
392 wp_dequeue_script( 'custom-login-pages-scripts' );
393 }
394 }
395
396 /**
397 * Remove the Divi login_footer hook 'print_styles'.
398 *
399 * @since 1.0.3
400 */
401 public function remove_conflicted_action() {
402
403 /**
404 * Remove the Divi login_footer hook 'print_styles'
405 * So that conflict is removed.
406 *
407 * @since 1.0.3
408 */
409 if ( class_exists( 'ET_Divi_100_Custom_Login_Page_Config' ) ) {
410
411 remove_action( 'login_footer', array( ET_Divi_100_Custom_Login_Page::instance(), 'print_styles' ) );
412 }
413 }
414
415 /**
416 * Include LoginPress CSS for Support with other plugins.
417 *
418 * @since 1.0.3
419 */
420 public function enqueue_loginpress_script() {
421
422 include( LOGINPRESS_DIR_PATH . 'css/style-presets.php' );
423 include( LOGINPRESS_DIR_PATH . 'css/style-login.php' );
424 }
425
426 /**
427 * Password protected plugin compatibility with logo url.
428 *
429 * @since 1.3.1
430 * @version 1.3.2
431 */
432 public function password_protected_login_headerurl_cb() {
433
434 $logo_url = $this->loginpress_key && isset( $this->loginpress_key['customize_logo_hover'] ) && ! empty( $this->loginpress_key['customize_logo_hover'] ) ? $this->loginpress_key['customize_logo_hover'] : home_url( '/' );
435
436 return $logo_url;
437 }
438
439 /**
440 * Password protected plugin compatibility with logo title.
441 *
442 * @since 1.3.2
443 */
444 public function password_protected_login_headertitle_cb() {
445
446 $logo_title = $this->loginpress_key && isset( $this->loginpress_key['customize_logo_hover_title'] ) && ! empty( $this->loginpress_key['customize_logo_hover_title'] ) ? $this->loginpress_key['customize_logo_hover_title'] : get_bloginfo( 'name' );
447
448 return $logo_title;
449 }
450 }
451 endif;
452
453 new LoginPress_Compatibility;
454