PluginProbe
LoginPress | wp-login Custom Login Page Customizer / 6.0.0
LoginPress | wp-login Custom Login Page Customizer v6.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 6.0.0, at include/compatibility.php

540 lines 15.1 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.1.1
8 */
9
10
11 /**
12 * Run a compatibility check on 1.0.21 and change the settings.
13 */
14 add_action( 'init', 'loginpress_upgrade_1_0_22', 1 );
15
16 $loginpress_preset = get_option( 'customize_presets_settings' );
17
18 if ( ( ! isset( $loginpress_preset ) || empty( $loginpress_preset ) ) ) {
19 add_action( 'init', 'loginpress_upgrade_3_0_3', 1 );
20 }
21
22 /**
23 * Select a default theme preset when user updates and no customization has been made.
24 *
25 * @since 3.0.3
26 */
27 function loginpress_upgrade_3_0_3() {
28 $loginpress_customizer = get_option( 'loginpress_customization' );
29
30 if ( empty( $loginpress_customizer ) ) {
31 update_option( 'customize_presets_settings', 'minimalist', true );
32 }
33 }
34
35 /**
36 * loginpress_upgrade_1_0_22
37 * Remove element 'login_with_email' from loginpress_setting array that was defined in 1.0.21
38 * and update 'login_order' in loginpress_setting for compatibility.
39 *
40 * @since 1.0.22
41 * @return array update loginpress_setting
42 */
43 function loginpress_upgrade_1_0_22() {
44
45 $loginpress_setting = get_option( 'loginpress_setting' );
46 $login_with_email = isset( $loginpress_setting['login_with_email'] ) ? $loginpress_setting['login_with_email'] : '';
47
48 if ( isset( $loginpress_setting['login_with_email'] ) ) {
49
50 if ( 'on' == $login_with_email ) {
51
52 $loginpress_setting['login_order'] = 'email';
53 unset( $loginpress_setting['login_with_email'] );
54 update_option( 'loginpress_setting', $loginpress_setting );
55 } elseif ( 'off' == $login_with_email ) {
56
57 $loginpress_setting['login_order'] = 'default';
58 unset( $loginpress_setting['login_with_email'] );
59 update_option( 'loginpress_setting', $loginpress_setting );
60 }
61 }
62 }
63
64 if ( ! class_exists( 'LoginPress_Compatibility' ) ) :
65
66 /**
67 * LoginPress compatibility Class is used to make LoginPress compatible with other plugins.
68 * Remove conflict.
69 * Add CSS Support.
70 *
71 * @since 1.0.3
72 * @version 1.3.2
73 */
74 class LoginPress_Compatibility {
75
76 /**
77 * Variable that Check for LoginPress Key.
78 *
79 * @var string
80 * @since 1.3.2
81 */
82 public $loginpress_key;
83
84 public function __construct() {
85 $this->loginpress_key = get_option( 'loginpress_customization' );
86 $this->dependencies();
87 }
88
89 public function dependencies() {
90
91 add_action( 'wp_print_scripts', array( $this, 'dequeue_conflicted_script' ), 100 );
92 add_action( 'login_headerurl', array( $this, 'remove_conflicted_action' ) );
93 add_action( 'init', array( $this, 'enqueue_loginpress_compatibility_script' ) );
94
95 /*************************************
96 WebArx Compatibility Fix // v1.2.3
97 */
98 add_action( 'plugins_loaded', array( $this, 'plugins_loaded_remove_action' ), 10 );
99 add_action( 'init', array( $this, 'loginpress_webarx_compatibility' ), 9 );
100
101 /**
102 * Login page Compatibility Fix.
103 *
104 * @since v1.3.2
105 */
106 add_action( 'login_enqueue_scripts', array( $this, 'dequeue_login_page_conflicting_scripts' ), 99 );
107
108 /**
109 * Oxygen Builder Compatibility Fix.
110 *
111 * @since v1.4.0
112 */
113 add_filter( 'template_include', array( $this, 'template_include_ob' ), 100 );
114
115 /**
116 * All In One WP Security & Firewall Compatibility Fix.
117 *
118 * @since 1.4.0
119 */
120 add_action( 'init', array( $this, 'aiowps_login_init_remove_action' ) );
121
122 /**
123 * BuddyBoss theme Compatibility with login page Fix.
124 *
125 * @since 3.0.9
126 */
127 add_action( 'login_head', array( $this, 'lp_remove_filter_buddyboss' ) );
128
129 /**
130 * WPS Hide Login Fix.
131 *
132 * @version 3.0.8
133 */
134 add_filter( 'whl_logged_in_redirect', array( $this, 'wps_hide_login_compatibility' ), 10, 3 );
135 add_filter( 'wps_hide_login_before_redirect', array( $this, 'wps_hide_login_redirect' ) );
136 }
137
138 /**
139 * Dequeue login page styles.
140 *
141 * @since 1.3.2
142 * @version 1.4.3
143 */
144 function dequeue_login_page_conflicting_scripts() {
145
146 /**
147 * Dequeue thrive theme login page styles.
148 *
149 * @since 1.3.2
150 */
151 wp_dequeue_style( 'thrive-custom-login' );
152 wp_dequeue_script( 'thrive-custom-login' );
153
154 /**
155 * Dequeue listing-pro theme login page styles.
156 *
157 * @since 1.4.3
158 */
159 wp_dequeue_style( 'listable-custom-login' );
160
161 /**
162 * PCI Compliance
163 *
164 * @since 1.7.2
165 */
166 $loginpress_setting = get_option( 'loginpress_setting' );
167 $pci_compliance = isset( $loginpress_setting['enable_pci_compliance'] ) ? $loginpress_setting['enable_pci_compliance'] : 'off';
168
169 if ( $pci_compliance !== 'off' ) {
170
171 echo '<script>document.addEventListener("DOMContentLoaded", function() {
172 var inputs = document.querySelectorAll("input[type=text]");
173 for (var i = 0; i < inputs.length; i++) {
174 inputs[i].setAttribute("autocomplete", "off");
175 }
176 });</script>';
177 echo '<script>document.addEventListener("DOMContentLoaded", function() {
178 var inputs = document.querySelectorAll("input[type=password]");
179 for (var i = 0; i < inputs.length; i++) {
180 inputs[i].setAttribute("autocomplete", "off");
181 }
182 });</script>';
183 echo '<script>document.addEventListener("DOMContentLoaded", function() {
184 var inputs = document.querySelectorAll("input[type=email]");
185 for (var i = 0; i < inputs.length; i++) {
186 inputs[i].setAttribute("autocomplete", "off");
187 }
188 });</script>';
189 }
190 }
191
192 /**
193 * Override the oxygen template with loginpress on login customizer screen.
194 *
195 * @since 1.4.0
196 */
197 public function template_include_ob( $template ) {
198
199 // Safely exit if methods not defined yet
200 if ( ! function_exists( 'is_customize_preview' ) || ! function_exists( 'wp_get_referer' ) ) {
201 return $template;
202 }
203
204 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' ) ) ) {
205 return ABSPATH . 'wp-content/plugins/loginpress/include/template-loginpress.php';
206 }
207
208 return $template;
209 }
210
211 /**
212 * BuddyBoss theme Compatibility Fix for login page logo.
213 *
214 * @since 3.0.9
215 */
216 public function lp_remove_filter_buddyboss() {
217 $active_theme = get_template();
218 if ( isset( $active_theme ) && 'buddyboss-theme' === $active_theme ) {
219 remove_filter( 'login_headerurl', 'change_wp_login_url' );
220 remove_filter( 'login_headertext', 'change_wp_login_title' );
221 }
222 }
223
224 /**
225 * To check the WebARX hooks if class exist.
226 *
227 * @since 3.1.1
228 */
229 public function loginpress_webarx_compatibility() {
230 if ( class_exists( 'Webarx' ) ) {
231 $this->init_remove_action();
232 add_filter( 'wp_redirect', array( $this, 'wp_redirect_remove_filter' ), 9 );
233 add_filter( 'site_url', array( $this, 'site_url_remove_filter' ), 9 );
234 add_filter( 'network_site_url', array( $this, 'network_site_url_remove_filter' ), 9 );
235 add_action( 'wp_loaded', array( $this, 'wp_loaded_remove_action' ), 9 );
236 }
237 }
238
239 /**
240 * WebArx Compatibility Fix.
241 *
242 * @param string $location The current location.
243 * @return string $location Modified current location.
244 *
245 * @since 1.2.3
246 * @version 3.1.1
247 */
248 public function wp_redirect_remove_filter( $location ) {
249
250 if ( ! function_exists( 'is_user_logged_in' ) ) {
251 return $location;
252 }
253
254 $webarx_login = get_option( 'webarx_mv_wp_login' );
255 $user_logged_in = is_user_logged_in();
256
257 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
258 remove_filter( 'wp_redirect', array( webarx()->hide_login, 'wp_redirect' ) );
259 }
260 return $location;
261 }
262
263 /**
264 * WebArx Compatibility Fix for site URL removal.
265 *
266 * @param string $url The URL.
267 * @return string $url Modified URL.
268 *
269 * @since 1.2.3
270 * @version 3.1.1
271 */
272 public function site_url_remove_filter( $url ) {
273 if ( ! function_exists( 'is_user_logged_in' ) ) {
274 return $url;
275 }
276 $webarx_login = get_option( 'webarx_mv_wp_login' );
277 $user_logged_in = is_user_logged_in();
278 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
279 remove_filter( 'site_url', array( webarx()->hide_login, 'site_url' ) );
280 }
281 return $url;
282 }
283
284 /**
285 * WebArx Compatibility Fix for multi-site URL removal.
286 *
287 * @param string $url The URL.
288 * @return string $url Modified URL.
289 *
290 * @since 1.2.3
291 * @version 3.1.1
292 */
293 public function network_site_url_remove_filter( $url ) {
294 if ( ! function_exists( 'is_user_logged_in' ) ) {
295 return $url;
296 }
297 $webarx_login = get_option( 'webarx_mv_wp_login' );
298 $user_logged_in = is_user_logged_in();
299
300 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
301 remove_filter( 'network_site_url', array( webarx()->hide_login, 'network_site_url' ) );
302 }
303 return $url;
304 }
305
306 /**
307 * WebArx Compatibility Fix for multi-site URL removal.
308 *
309 * @since 1.2.3
310 */
311 public function plugins_loaded_remove_action() {
312 if ( class_exists( 'Webarx' ) ) {
313
314 if ( ! function_exists( 'is_user_logged_in' ) ) {
315 return;
316 }
317
318 $webarx_login = get_option( 'webarx_mv_wp_login' );
319 $user_logged_in = is_user_logged_in();
320
321 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
322 remove_action( 'plugins_loaded', array( webarx()->hide_login, 'plugins_loaded' ), 9999 );
323 }
324 }
325 }
326 /**
327 * Remove wp_loaded action hook.
328 *
329 * @since 1.2.3
330 * @version 3.1.1
331 */
332 public function wp_loaded_remove_action() {
333
334 if ( ! function_exists( 'is_user_logged_in' ) ) {
335 return $url;
336 }
337
338 $webarx_login = get_option( 'webarx_mv_wp_login' );
339 $user_logged_in = is_user_logged_in();
340
341 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
342 remove_action( 'wp_loaded', array( webarx()->hide_login, 'wp_loaded' ) );
343 }
344 }
345 /**
346 * Remove init action hook.
347 *
348 * @since 1.2.3
349 * @version 3.1.1
350 */
351 public function init_remove_action() {
352
353 if ( ! function_exists( 'is_user_logged_in' ) ) {
354 return $url;
355 }
356
357 $webarx_login = get_option( 'webarx_mv_wp_login' );
358 $user_logged_in = is_user_logged_in();
359
360 if ( ( isset( $user_logged_in ) && true === $user_logged_in ) && ( isset( $webarx_login ) && '1' === $webarx_login ) ) {
361 remove_action( 'init', array( webarx()->hide_login, 'denyRequestsToWpLogin' ) );
362 }
363 }
364
365
366 /**
367 * Remove login security check in customizer screen only.
368 * No need for this check as the user is already logged in and using customizer.
369 *
370 * @since 1.4.0
371 */
372 public function aiowps_login_init_remove_action() {
373 if ( ! is_customize_preview() ) {
374 return;
375 }
376
377 if ( ! class_exists( 'AIO_WP_Security' ) ) {
378 return;
379 }
380
381 global $aio_wp_security;
382
383 if ( ! is_a( $aio_wp_security, 'AIO_WP_Security' ) ) {
384 return;
385 }
386
387 if ( remove_action( 'wp_loaded', array( $aio_wp_security, 'aiowps_wp_loaded_handler' ) ) ) {
388 add_filter( 'option_aio_wp_security_configs', array( $this, 'aiowps_filter_options' ) );
389 }
390 }
391
392 /**
393 * Filter options aio_wp_security_configs.
394 *
395 * @since 1.4.0
396 */
397 public function aiowps_filter_options( $option ) {
398
399 unset( $option['aiowps_enable_rename_login_page'] );
400 return $option;
401 }
402
403 /**
404 * Enqueue LoginPress CSS on Password_Protected plugin.
405 *
406 * @return void
407 */
408 public function enqueue_loginpress_compatibility_script() {
409
410 /**
411 * Enqueue LoginPress CSS on Password_Protected plugin.
412 *
413 * Hooked to the password_protected_login_head action,
414 * Head URL & Title on logo as well.
415 *
416 * so that it is after the script was enqueued.
417 *
418 * @since 1.0.3
419 * @version 1.3.2
420 */
421 if ( class_exists( 'Password_Protected' ) ) {
422 add_action( 'password_protected_login_head', array( $this, 'enqueue_loginpress_script' ) );
423 add_filter( 'password_protected_login_headerurl', array( $this, 'password_protected_login_headerurl_cb' ) );
424 add_filter( 'password_protected_login_headertitle', array( $this, 'password_protected_login_headertitle_cb' ) );
425 }
426 }
427
428 /**
429 * Enqueue the Divi Login script.
430 *
431 * @since 1.0.3
432 */
433 public function dequeue_conflicted_script() {
434
435 /**
436 * Dequeue the Divi Login script.
437 *
438 * Hooked to the wp_print_scripts action, with a late priority (100),
439 * so that it is after the script was enqueued.
440 *
441 * @since 1.0.3
442 */
443 if ( class_exists( 'ET_Divi_100_Custom_Login_Page_Config' ) ) {
444 wp_dequeue_style( 'custom-login-pages' );
445 wp_dequeue_script( 'custom-login-pages-icon-font' );
446 wp_dequeue_script( 'custom-login-pages-scripts' );
447 }
448 }
449
450 /**
451 * Remove the Divi login_footer hook 'print_styles'.
452 *
453 * @since 1.0.3
454 */
455 public function remove_conflicted_action() {
456
457 /**
458 * Remove the Divi login_footer hook 'print_styles'
459 * So that conflict is removed.
460 *
461 * @since 1.0.3
462 */
463 if ( class_exists( 'ET_Divi_100_Custom_Login_Page_Config' ) ) {
464
465 remove_action( 'login_footer', array( ET_Divi_100_Custom_Login_Page::instance(), 'print_styles' ) );
466 }
467 }
468
469 /**
470 * Include LoginPress CSS for Support with other plugins.
471 *
472 * @since 1.0.3
473 */
474 public function enqueue_loginpress_script() {
475
476 include LOGINPRESS_DIR_PATH . 'css/style-presets.php';
477 include_once LOGINPRESS_DIR_PATH . 'css/style-login.php';
478 }
479
480 /**
481 * Password protected plugin compatibility with logo url.
482 *
483 * @since 1.3.1
484 * @version 1.3.2
485 */
486 public function password_protected_login_headerurl_cb() {
487
488 $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( '/' );
489
490 return $logo_url;
491 }
492
493 /**
494 * Password protected plugin compatibility with logo title.
495 *
496 * @since 1.3.2
497 */
498 public function password_protected_login_headertitle_cb() {
499
500 $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' );
501
502 return $logo_title;
503 }
504
505 /**
506 * The redirect of Hide Login compatibility with LoginPress.
507 *
508 * @version 3.0.8
509 */
510 function wps_hide_login_redirect() {
511 return wp_login_url();
512 }
513
514 /**
515 * Filters the “Go to site” link displayed in the login page footer.
516 *
517 * @param string $redirect_to The page where it will be redirected to.
518 * @param string $requested_redirect_to The requested page to redirect.
519 * @param object $user The user object.
520 * @var $user_login passes the user_login element of user to be used in wp-login
521 * @var $error passes the error element of user to be used in wp-login
522 *
523 * @since 3.0.8
524 */
525 function wps_hide_login_compatibility( $redirect_to, $requested_redirect_to, $user ) {
526 if ( ! headers_sent() ) {
527 // Create these variables to overcome couple PHP Warnings in customizer while calling wp-login.php
528 $user_login = $user->user_login;
529 $error = $user->error;
530
531 require_once ABSPATH . 'wp-login.php';
532 die();
533 }
534 return false;
535 }
536 }
537 endif;
538
539 new LoginPress_Compatibility();
540