PluginProbe
LoginPress | wp-login Custom Login Page Customizer / 6.1.2
LoginPress | wp-login Custom Login Page Customizer v6.1.2
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 / loginpress.php

loginpress.php in LoginPress | wp-login Custom Login Page Customizer 6.1.2, at loginpress.php

801 lines 25.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Plugin Name: LoginPress
4 * Plugin URI: https://loginpress.pro?utm_source=loginpress-lite&utm_medium=plugin-header&utm_campaign=pro-upgrade&utm_content=plugin-uri
5 * Description: LoginPress is the best <code>wp-login</code> Login Page Customizer plugin by <a href="https://wpbrigade.com/?utm_source=loginpress-lite&utm_medium=plugins&utm_campaign=wpbrigade-home&utm_content=WPBrigade-text-link">WPBrigade</a> which allows you to completely change the layout of login, register and forgot password forms.
6 * Version: 6.1.2
7 * Author: LoginPress
8 * Author URI: https://loginpress.pro?utm_source=loginpress-lite&utm_medium=plugin-header&utm_campaign=pro-upgrade&utm_content=author-uri
9 * Text Domain: loginpress
10 * Domain Path: /languages
11 * Requires at least: 4.0
12 * Tested up to: 6.9
13 * License: GPLv2 or later
14 * GitHub Plugin URI: https://github.com/WPBrigade/loginpress
15 *
16 * @package loginpress
17 * @category Core
18 * @author WPBrigade
19 *
20 * phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed
21 */
22
23 // Define constants for PHPStan.
24 if ( ! defined( 'LOGINPRESS_PLUGIN_BASENAME' ) ) {
25 define( 'LOGINPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
26 }
27 if ( ! defined( 'LOGINPRESS_DIR_PATH' ) ) {
28 define( 'LOGINPRESS_DIR_PATH', plugin_dir_path( __FILE__ ) );
29 }
30 if ( ! defined( 'LOGINPRESS_DIR_URL' ) ) {
31 define( 'LOGINPRESS_DIR_URL', plugin_dir_url( __FILE__ ) );
32 }
33 if ( ! defined( 'LOGINPRESS_ROOT_PATH' ) ) {
34 define( 'LOGINPRESS_ROOT_PATH', __DIR__ . '/' );
35 }
36 if ( ! defined( 'LOGINPRESS_ROOT_FILE' ) ) {
37 define( 'LOGINPRESS_ROOT_FILE', __FILE__ );
38 }
39 if ( ! defined( 'LOGINPRESS_VERSION' ) ) {
40 define( 'LOGINPRESS_VERSION', '6.1.2' );
41 }
42 if ( ! defined( 'LOGINPRESS_FEEDBACK_SERVER' ) ) {
43 define( 'LOGINPRESS_FEEDBACK_SERVER', 'https://wpbrigade.com/' );
44 }
45 if ( ! defined( 'LOGINPRESS_REST_NAMESPACE' ) ) {
46 define( 'LOGINPRESS_REST_NAMESPACE', 'loginpress/v1' );
47 }
48
49
50 if ( ! function_exists( 'loginpress_wpb53407382' ) ) {
51 /**
52 * Create a helper function for easy SDK access.
53 *
54 * @return mixed
55 */
56 function loginpress_wpb53407382() {
57 global $loginpress_wpb53407382;
58
59 if ( ! isset( $loginpress_wpb53407382 ) ) {
60 /**
61 * Include Telemetry SDK.
62 *
63 * @var mixed $loginpress_wpb53407382
64 * @phpstan-ignore-next-line
65 */
66 require_once __DIR__ . '/lib/wpb-sdk/start.php';
67
68 /**
69 * Initialize WPB SDK.
70 *
71 * @phpstan-ignore-next-line
72 */
73 $loginpress_wpb53407382 = wpb_dynamic_init(
74 array(
75 'id' => '6',
76 'slug' => 'loginpress',
77 'type' => 'plugin',
78 'public_key' => '1|4aOA8EuyIN4pi2miMvC23LLpnHbBZFNki9R9pVmwd673d3c8',
79 'secret_key' => 'sk_b36c525848fee035',
80 'is_premium' => false,
81 'has_addons' => false,
82 'has_paid_plans' => false,
83 'menu' => array(
84 'slug' => 'loginpress',
85 'account' => false,
86 'support' => false,
87 ),
88 'settings' => array(
89 'loginpress_customization' => '',
90 'loginpress_setting' => '',
91 'loginpress_addon_active_time' => '',
92 'loginpress_addon_dismiss_1' => '',
93 'loginpress_review_dismiss' => '',
94 'loginpress_active_time' => '',
95 '_loginpress_optin' => '',
96 'loginpress_friday_sale_active_time' => '',
97 'loginpress_friday_sale_dismiss' => '',
98 'loginpress_friday_21_sale_dismiss' => '',
99 ),
100 )
101 );
102 }
103
104 return $loginpress_wpb53407382;
105 }
106
107 // Init Telemetry.
108 loginpress_wpb53407382();
109 // Signal that SDK was initiated.
110 do_action( 'loginpress_wpb53407382_loaded' );
111 }
112
113 if ( ! class_exists( 'LoginPress' ) ) :
114 // REST endpoints moved into a trait to keep main file slimmer.
115 require_once plugin_dir_path( __FILE__ ) . 'classes/traits/loginpress-rest-trait.php';
116
117 /**
118 * LoginPress Main Class
119 *
120 * Main LoginPress plugin class.
121 *
122 * @package LoginPress
123 * @since 1.0.0
124 * @version 6.1.1
125 */
126 final class LoginPress {
127 use LoginPress_Rest_Trait;
128
129 /**
130 * Plugin version number.
131 *
132 * @var string Current version of the LoginPress plugin.
133 */
134 public $version = '6.1.1';
135
136 /**
137 * The single instance of the LoginPress class.
138 *
139 * @var LoginPress|null Singleton instance of the LoginPress class.
140 * @since 1.0.0
141 *
142 * phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
143 */
144 protected static ?LoginPress $_instance = null;
145
146 /**
147 * Session data storage.
148 *
149 * @var mixed WordPress session data or null if not set.
150 */
151 public $session = null;
152
153 /**
154 * Database query object.
155 *
156 * @var mixed WordPress database query object or null if not set.
157 */
158 public $query = null;
159
160 /**
161 * Countries data for forms.
162 *
163 * @var mixed Array of countries data or null if not loaded.
164 */
165 public $countries = null;
166
167 /**
168 * Class Constructor.
169 *
170 * @since 1.0.0
171 * @version 6.0.0
172 * @return void
173 */
174 public function __construct() {
175 $this->define_constants();
176 $this->includes();
177 $this->_hooks();
178 }
179
180 /**
181 * Define LoginPress Constants.
182 *
183 * @return void
184 */
185 private function define_constants() {
186
187 $this->define( 'LOGINPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
188 $this->define( 'LOGINPRESS_DIR_PATH', plugin_dir_path( __FILE__ ) );
189 $this->define( 'LOGINPRESS_DIR_URL', plugin_dir_url( __FILE__ ) );
190 $this->define( 'LOGINPRESS_ROOT_PATH', __DIR__ . '/' );
191 $this->define( 'LOGINPRESS_ROOT_FILE', __FILE__ );
192 $this->define( 'LOGINPRESS_VERSION', $this->version );
193 $this->define( 'LOGINPRESS_FEEDBACK_SERVER', 'https://wpbrigade.com/' );
194 $this->define( 'LOGINPRESS_REST_NAMESPACE', 'loginpress/v1' );
195 }
196
197 /**
198 * Include required core files used in admin and on the frontend.
199 *
200 * @since 1.0.0
201 * @version 3.0.0
202 * @return void
203 */
204 public function includes() {
205
206 include_once LOGINPRESS_DIR_PATH . 'include/class-loginpress-compatibility.php';
207 include_once LOGINPRESS_DIR_PATH . 'include/class-loginpress-domains.php';
208 include_once LOGINPRESS_DIR_PATH . 'classes/customizer/class-loginpress-customizer.php';
209 include_once LOGINPRESS_DIR_PATH . 'classes/class-loginpress-setup.php';
210 include_once LOGINPRESS_DIR_PATH . 'classes/class-loginpress-ajax.php';
211 include_once LOGINPRESS_DIR_PATH . 'classes/class-loginpress-developer-hooks.php';
212 include_once LOGINPRESS_DIR_PATH . 'classes/class-loginpress-notifications.php';
213 include_once LOGINPRESS_DIR_PATH . 'include/loginpress-utilities.php';
214 if ( is_multisite() ) {
215 require_once LOGINPRESS_DIR_PATH . 'include/class-loginpress-theme-template.php';
216 }
217
218 $loginpress_setting = get_option( 'loginpress_setting' );
219
220 $loginpress_privacy_policy = isset( $loginpress_setting['enable_privacy_policy'] ) ? $loginpress_setting['enable_privacy_policy'] : 'off';
221 if ( 'off' !== $loginpress_privacy_policy ) {
222 include_once LOGINPRESS_DIR_PATH . 'include/privacy-policy.php';
223 }
224
225 $login_with_email = isset( $loginpress_setting['login_order'] ) ? $loginpress_setting['login_order'] : 'default';
226 if ( 'default' !== $login_with_email ) {
227 include_once LOGINPRESS_DIR_PATH . 'classes/class-loginpress-login-order.php';
228 new LoginPress_Login_Order();
229 }
230
231 $enable_reg_pass_field = isset( $loginpress_setting['enable_reg_pass_field'] ) ? $loginpress_setting['enable_reg_pass_field'] : 'off';
232 if ( 'off' !== $enable_reg_pass_field ) {
233 include_once LOGINPRESS_DIR_PATH . 'classes/class-loginpress-custom-password.php';
234 new LoginPress_Custom_Password();
235 include_once LOGINPRESS_DIR_PATH . 'classes/class-loginpress-password-strength.php';
236 new LoginPress_Password_Strength();
237 }
238 $loginpress_password_reset_time_limit = isset( $loginpress_setting['loginpress_password_reset_time_limit'] ) ? $loginpress_setting['loginpress_password_reset_time_limit'] : 'off';
239 if ( 'off' !== $loginpress_password_reset_time_limit ) {
240 include_once LOGINPRESS_DIR_PATH . 'classes/class-loginpress-force-password-reset.php';
241 new LoginPress_Force_Password_Reset();
242 }
243 }
244
245 /**
246 * Hook into actions and filters
247 *
248 * @since 1.0.0
249 * @version 3.0.0
250 * @return void
251 *
252 * phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
253 */
254 private function _hooks() {
255 add_action( 'rest_api_init', array( $this, 'loginpress_register_routes' ) );
256 add_action( 'admin_menu', array( $this, 'register_options_page' ) );
257 add_action( 'init', array( $this, 'textdomain' ) );
258 add_filter( 'plugin_row_meta', array( $this, '_row_meta' ), 10, 2 );
259 add_action( 'admin_enqueue_scripts', array( $this, '_admin_scripts' ) );
260 add_action( 'admin_footer', array( $this, 'add_deactivate_modal' ) );
261 add_filter( 'plugin_action_links', array( $this, 'loginpress_action_links' ), 10, 2 );
262 add_action( 'admin_init', array( $this, 'redirect_optin' ) );
263 add_filter( 'auth_cookie_expiration', array( $this, '_change_auth_cookie_expiration' ), 10, 3 );
264 add_action( 'wp_wpb_sdk_after_uninstall', array( $this, 'plugin_uninstallation' ) );
265 if ( is_multisite() ) {
266 add_action( 'admin_init', array( $this, 'redirect_loginpress_edit_page' ) );
267 add_action( 'admin_init', array( $this, 'check_loginpress_page' ) );
268 // Makes sure the plugin is defined before trying to use it.
269 if ( ! function_exists( 'is_plugin_active_for_network' ) || ! function_exists( 'is_plugin_active' ) ) {
270 /**
271 * Include plugin functions.
272 *
273 * @phpstan-ignore-next-line
274 */
275 require_once ABSPATH . '/wp-admin/includes/plugin.php';
276 if ( is_plugin_active_for_network( 'wordpress-seo/wp-seo.php' ) ) {
277 /**
278 * This filters the ID of the page/post which you want to remove from the sitemap XML.
279 *
280 * @since 1.5.14
281 *
282 * @documentation https://developer.yoast.com/features/xml-sitemaps/api/
283 */
284 add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'loginpress_exclude_from_sitemap' ) );
285 }
286 }
287 }
288 }
289
290 /**
291 * Callback function to exclude LoginPress page from sitemap.
292 *
293 * @return array<int>|false Exclude page/s or post/s.
294 * @since 1.5.14
295 * @version 1.6.3
296 */
297 public function loginpress_exclude_from_sitemap() {
298
299 $page = get_page_by_path( 'loginpress' );
300 if ( is_object( $page ) ) {
301 // This is used as a filter callback, so we need to return the array
302 // even though the action expects void return.
303 return array( $page->ID );
304 }
305 return false;
306 }
307
308 /**
309 * Redirect to Optin page.
310 *
311 * @since 1.0.15
312 * @return void
313 */
314 public function redirect_optin() {
315 /**
316 * Fix the Broken Access Control (BAC) security fix.
317 *
318 * @since 1.6.3
319 */
320 if ( current_user_can( 'manage_options' ) ) {
321 if ( isset( $_POST['loginpress-submit-optout'] ) ) {
322 if ( ! isset( $_POST['loginpress_submit_optin_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['loginpress_submit_optin_nonce'] ) ), 'loginpress_submit_optin_nonce' ) ) {
323 return;
324 }
325 update_option( '_loginpress_optin', 'no' );
326 // Retrieve WPB SDK existing option and set user_skip.
327 $sdk_data = json_decode( get_option( 'wpb_sdk_loginpress' ), true );
328 $sdk_data['user_skip'] = '1';
329 $sdk_data_json = wp_json_encode( $sdk_data );
330 update_option( 'wpb_sdk_loginpress', $sdk_data_json );
331 } elseif ( isset( $_POST['loginpress-submit-optin'] ) ) {
332 if ( ! isset( $_POST['loginpress_submit_optin_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['loginpress_submit_optin_nonce'] ) ), 'loginpress_submit_optin_nonce' ) ) {
333 return;
334 }
335 update_option( '_loginpress_optin', 'yes' );
336 // WPB SDK OPT IN OPTIONS.
337 $sdk_data = array(
338 'communication' => '1',
339 'diagnostic_info' => '1',
340 'extensions' => '1',
341 'user_skip' => '0',
342 );
343 $sdk_data_json = wp_json_encode( $sdk_data );
344 update_option( 'wpb_sdk_loginpress', $sdk_data_json );
345 } elseif ( ! get_option( '_loginpress_optin' ) && isset( $_GET['page'] ) && ( 'loginpress-settings' === $_GET['page'] || 'loginpress' === $_GET['page'] || 'abw' === $_GET['page'] ) ) {
346 /**
347 * XSS Attack vector found and fixed.
348 *
349 * @since 1.5.11
350 */
351 $page_redirect = 'loginpress' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ? 'loginpress' : 'loginpress-settings';
352 wp_safe_redirect( admin_url( 'admin.php?page=loginpress-optin&redirect-page=' . $page_redirect ) );
353 exit;
354 } elseif ( get_option( '_loginpress_optin' ) && ( get_option( '_loginpress_optin' ) === 'yes' ) && isset( $_GET['page'] ) && 'loginpress-optin' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) {
355 wp_safe_redirect( admin_url( 'admin.php?page=loginpress-settings' ) );
356 exit;
357 }
358 }
359 }
360
361 /**
362 * Main Instance.
363 *
364 * @since 1.0.0
365 * @static
366 * @see loginpress_loader()
367 * @return LoginPress instance
368 */
369 public static function instance() {
370 if ( is_null( self::$_instance ) ) {
371 self::$_instance = new self();
372 }
373 return self::$_instance;
374 }
375
376 /**
377 * Load Languages.
378 *
379 * @since 1.0.0
380 * @return void
381 */
382 public function textdomain() {
383
384 $plugin_dir = dirname( plugin_basename( __FILE__ ) );
385 load_plugin_textdomain( 'loginpress', false, $plugin_dir . '/languages/' );
386 }
387
388 /**
389 * Define constant if not already set.
390 *
391 * @param string $name The constant name to define.
392 * @param string|bool $value The constant value to set.
393 * @return void
394 */
395 private function define( $name, $value ) {
396 if ( ! defined( $name ) ) {
397 define( $name, $value );
398 }
399 }
400
401 /**
402 * Init WPBrigade when WordPress Initializes.
403 *
404 * @return void
405 */
406 public function init() {
407 // Before init action.
408 }
409
410 /**
411 * Create LoginPress Page Template.
412 *
413 * @since 1.1.3
414 * @return void
415 */
416 public function check_loginpress_page() {
417
418 // Retrieve the LoginPress admin page option, that was created during the activation process.
419 $option = $this->get_loginpress_page();
420
421 include LOGINPRESS_DIR_PATH . 'include/class-loginpress-page-create.php';
422 // Retrieve the status of the page, if the option is available.
423 if ( $option ) {
424 $page = get_post( $option );
425 $status = $page ? $page->post_status : null;
426 } else {
427 $status = null;
428 }
429
430 // Check the status of the page. Let's fix it, if the page is missing or in the trash.
431 if ( empty( $status ) || 'trash' === $status ) {
432 new LoginPress_Page_Create();
433 }
434 }
435
436 /**
437 * Function for redirect the LoginPress page on editing.
438 *
439 * @since 1.1.3
440 * @return void
441 */
442 public function redirect_loginpress_edit_page() {
443 global $pagenow;
444
445 $page = $this->get_loginpress_page();
446
447 if ( ! $page ) {
448 return;
449 }
450
451 $page_url = get_permalink( $page );
452 $page_id = $page->ID;
453
454 // Generate the redirect url.
455 $url = add_query_arg(
456 array(
457 'autofocus[section]' => 'loginpress_panel',
458 'url' => rawurlencode( $page_url ? $page_url : '' ),
459 ),
460 admin_url( 'customize.php' )
461 );
462
463 // Check current admin page.
464 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- GET parameter for admin page check.
465 if ( 'post.php' === $pagenow && isset( $_GET['post'] ) && absint( $_GET['post'] ) === $page_id ) {
466 wp_safe_redirect( $url );
467 }
468 }
469
470 /**
471 * Add new page in Appearance to customize Login Page.
472 *
473 * @version 3.0.0
474 * @return void
475 */
476 public function register_options_page() {
477
478 add_submenu_page( 'LoginPress', __( 'Activate', 'loginpress' ), __( 'Activate', 'loginpress' ), 'manage_options', 'loginpress-optin', array( $this, 'render_optin' ) );
479
480 add_theme_page( __( 'LoginPress', 'loginpress' ), __( 'LoginPress', 'loginpress' ), 'manage_options', 'abw', '__return_null' );
481 }
482
483
484 /**
485 * Show Opt-in Page.
486 *
487 * @since 1.0.15
488 * @return void
489 */
490 public function render_optin() {
491 include LOGINPRESS_DIR_PATH . 'include/loginpress-optin-form.php';
492 }
493
494 /**
495 * Session Expiration.
496 *
497 * @since 1.0.18
498 * @version 1.3.2
499 * @param int $expiration Default expiration time in seconds.
500 * @param int $user_id The user ID.
501 * @param bool $remember Whether to remember the user.
502 * @return int Modified expiration time in seconds.
503 *
504 * phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
505 * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
506 */
507 public function _change_auth_cookie_expiration( $expiration, $user_id, $remember ) {
508 $loginpress_setting = get_option( 'loginpress_setting' );
509 $expiration_time = isset( $loginpress_setting['session_expiration'] ) ? absint( $loginpress_setting['session_expiration'] ) : 0;
510
511 /**
512 * Return the WordPress default $expiration time if LoginPress Session Expiration time set 0 or empty.
513 *
514 * @since 1.0.18
515 */
516 // @phpstan-ignore-next-line
517 if ( empty( $expiration_time ) || '0' === $expiration_time ) {
518 return $expiration;
519 }
520
521 /**
522 * $filter_role Use filter `loginpress_exclude_role_session` for return the role.
523 * By default it's false and $expiration time will apply on all user.
524 *
525 * @return string|array|false role name.
526 * @since 1.3.2
527 */
528 $filter_role = apply_filters( 'loginpress_exclude_role_session', false );
529
530 if ( $filter_role ) {
531 $user_data = get_userdata( $user_id );
532 if ( ! $user_data ) {
533 return $expiration;
534 }
535 $user_roles = $user_data->roles;
536
537 // if $filter_role is array, return the default $expiration for each defined role.
538 if ( is_array( $filter_role ) ) {
539 foreach ( $filter_role as $role ) {
540 if ( in_array( $role, $user_roles, true ) ) {
541 return $expiration;
542 }
543 }
544 } elseif ( in_array( $filter_role, $user_roles, true ) ) {
545 return $expiration;
546 }
547 }
548
549 // Convert Duration (minutes) of the expiration period in seconds.
550 $expiration = $expiration_time * 60;
551
552 return $expiration;
553 }
554
555 /**
556 * Load JS or CSS files at admin side and enqueue them.
557 *
558 * @param string $hook The current admin page hook identifier.
559 * @return void
560 * @version 3.0.0
561 *
562 * phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
563 */
564 public function _admin_scripts( $hook ) {
565 if ( 'toplevel_page_loginpress-settings' === $hook ) {
566 wp_enqueue_script( 'youtube-api', 'https://www.youtube.com/iframe_api', array(), LOGINPRESS_VERSION, true );
567
568 $js_code = '
569 var ytPlayers = {};
570
571 function onYouTubeIframeAPIReady() {
572 var iframes = document.querySelectorAll("iframe.loginPress-feature-video");
573
574 Array.prototype.forEach.call(iframes, function(iframe) {
575 // Assign a unique ID if not present
576 if (!iframe.id) {
577 iframe.id = "yt-player-" + Math.random().toString(36).substring(2, 15);
578 }
579
580 var id = iframe.id;
581
582 ytPlayers[id] = new YT.Player(id, {
583 events: {
584 "onStateChange": function(event) {
585 handleStateChange(event, id);
586 }
587 }
588 });
589 });
590 }
591
592 function handleStateChange(event, currentId) {
593 if (event.data === YT.PlayerState.PLAYING) {
594 for (var id in ytPlayers) {
595 if (ytPlayers.hasOwnProperty(id) && id !== currentId) {
596 var player = ytPlayers[id];
597 if (typeof player.pauseVideo === "function") {
598 player.pauseVideo();
599 }
600 }
601 }
602 }
603 }
604 ';
605
606 wp_add_inline_script( 'youtube-api', $js_code );
607 }
608
609 $should_load = ( 'toplevel_page_loginpress-settings' === $hook || 'loginpress_page_loginpress-addons' === $hook || 'loginpress_page_loginpress-help' === $hook || 'loginpress_page_loginpress-import-export' === $hook || 'loginpress_page_loginpress-license' === $hook || 'admin_page_loginpress-optin' === $hook );
610
611 if ( version_compare( LOGINPRESS_VERSION, '6.0.0', '>=' ) ) {
612 if ( $should_load || 'users.php' == $hook ) { // phpcs:ignore
613 // Register script first with all parameters.
614 wp_register_script( 'loginpress-react-settings', LOGINPRESS_DIR_URL . 'build/index.js', array( 'wp-element', 'wp-i18n', 'wp-api-fetch' ), LOGINPRESS_VERSION, true );
615
616 // Enqueue the registered script.
617 wp_enqueue_script( 'loginpress-react-settings' );
618 wp_enqueue_style( 'loginpress_style_react', plugins_url( 'build/index.css', __FILE__ ), array(), LOGINPRESS_VERSION );
619
620 // Set translations.
621 wp_set_script_translations( 'loginpress-react-settings', 'loginpress', LOGINPRESS_DIR_PATH . 'languages' );
622
623 // Localize script data.
624 $is_pro_active = false;
625 if ( is_plugin_active( 'loginpress-pro/loginpress-pro.php' ) ) {
626 $is_pro_active = true;
627 }
628 $languages = ! empty( get_available_languages() );
629
630 wp_localize_script(
631 'loginpress-react-settings',
632 'loginpressReactData',
633 array(
634 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
635 'isProActive' => $is_pro_active,
636 'wp_login_url' => wp_login_url(),
637 'language_switcher' => $languages,
638 )
639 );
640 }
641 }
642
643 if ( $should_load ) {
644 wp_enqueue_style( 'loginpress_style', plugins_url( 'css/style.css', __FILE__ ), array(), LOGINPRESS_VERSION );
645 wp_enqueue_script( 'loginpress_js', plugins_url( 'js/admin-custom.js', __FILE__ ), array(), LOGINPRESS_VERSION, false );
646
647 // Array for localize.
648 $loginpress_localize = array(
649 'plugin_url' => plugins_url(),
650 'localize_translations' => array(
651 _x( 'Name', 'Login Redirect Roles', 'loginpress' ),
652 ),
653 'help_nonce' => wp_create_nonce( 'loginpress-log-nonce' ),
654
655 );
656
657 wp_localize_script( 'loginpress_js', 'loginpress_script', $loginpress_localize );
658 }
659 wp_enqueue_script( 'lp_outside_plugin_admin', plugins_url( 'js/outside-plugin-admin.js', __FILE__ ), array(), LOGINPRESS_VERSION, false );
660 }
661
662 /**
663 * Add rating icon on plugins page.
664 *
665 * @since 1.0.9
666 * @version 1.1.22
667 * @param array<string> $meta_fields Array of existing meta fields.
668 * @param string $file Plugin file path.
669 * @return array<string> Modified meta fields array.
670 *
671 * phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
672 */
673 public function _row_meta( $meta_fields, $file ) {
674
675 if ( 'loginpress/loginpress.php' !== $file ) {
676 return $meta_fields;
677 }
678
679 echo '<style>.loginpress-rate-stars { display: inline-block; color: #ffb900; position: relative; top: 3px; }.loginpress-rate-stars svg{ fill:#ffb900; } .loginpress-rate-stars svg:hover{ fill:#ffb900 } .loginpress-rate-stars svg:hover ~ svg{ fill:none; } </style>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
680
681 $plugin_rate = 'https://wordpress.org/support/plugin/loginpress/reviews/?rate=5#rate-response';
682 $plugin_filter = 'https://wordpress.org/support/plugin/loginpress/reviews/?filter=5';
683 $svg_xmlns = 'https://www.w3.org/2000/svg';
684 $svg_icon = '';
685
686 for ( $i = 0; $i < 5; $i++ ) {
687 $svg_icon .= "<svg xmlns='" . esc_url( $svg_xmlns ) . "' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>";
688 }
689
690 // Set icon for thumbs up.
691 $meta_fields[] = '<a href="' . esc_url( $plugin_filter ) . '" target="_blank"><span class="dashicons dashicons-thumbs-up"></span>' . esc_html__( 'Vote!', 'loginpress' ) . '</a>';
692
693 // Set icon for 5-star reviews, v1.1.22.
694 $meta_fields[] = "<a href='" . esc_url( $plugin_rate ) . "' target='_blank' title='" . esc_html__( 'Rate', 'loginpress' ) . "'><i class='loginpress-rate-stars'>" . $svg_icon . '</i></a>';
695
696 return $meta_fields;
697 }
698
699 /**
700 * Add deactivate modal layout.
701 *
702 * @return void
703 */
704 public function add_deactivate_modal() {
705 global $pagenow;
706
707 if ( 'plugins.php' !== $pagenow ) {
708 return;
709 }
710
711 include LOGINPRESS_DIR_PATH . 'include/loginpress-optout-form.php';
712 }
713
714 /**
715 * Plugin activation.
716 *
717 * @since 1.0.15
718 * @version 1.0.22
719 * @return void
720 */
721 public static function plugin_activation() {
722
723 $loginpress_key = get_option( 'loginpress_customization' );
724 $loginpress_setting = get_option( 'loginpress_setting' );
725
726 // Create a key 'loginpress_customization' with empty array.
727 if ( ! $loginpress_key ) {
728 update_option( 'loginpress_customization', array() );
729 }
730
731 // Create a key 'loginpress_setting' with empty array.
732 if ( ! $loginpress_setting ) {
733 update_option( 'loginpress_setting', array() );
734 }
735 }
736
737 /**
738 * Plugin uninstallation.
739 *
740 * @return void
741 */
742 public function plugin_uninstallation() {
743 include_once LOGINPRESS_DIR_PATH . 'include/uninstall.php';
744 }
745
746
747 /**
748 * Pull the LoginPress page from options.
749 *
750 * @access public
751 * @since 1.1.3
752 * @version 1.1.7
753 * @return mixed
754 */
755 public function get_loginpress_page() {
756
757 $loginpress_setting = get_option( 'loginpress_setting', array() );
758 if ( ! is_array( $loginpress_setting ) && empty( $loginpress_setting ) ) {
759 $loginpress_setting = array();
760 }
761 $page = array_key_exists( 'loginpress_page', $loginpress_setting ) ? get_post( $loginpress_setting['loginpress_page'] ) : false;
762
763 return $page;
764 }
765 } // End Of Class.
766 endif;
767
768
769 /**
770 * Returns the main instance of WP to prevent the need to use globals.
771 *
772 * @since 1.0.0
773 * @return LoginPress
774 */
775 function loginpress_loader() {
776 return LoginPress::instance();
777 }
778
779 // Call the function.
780 loginpress_loader();
781
782 /**
783 * Create the Object of Custom Login Entities and Settings.
784 *
785 * @since 1.0.0
786 */
787 new LoginPress_Customizer();
788 new LoginPress_Settings();
789
790 /**
791 * Create the Object of Remote Notification.
792 *
793 * @since 1.0.9
794 */
795 if ( ! class_exists( 'TAV_Remote_Notification_Client' ) ) {
796 require LOGINPRESS_ROOT_PATH . 'include/class-remote-notification-client.php';
797 }
798 $notification = new TAV_Remote_Notification_Client( 125, '16765c0902705d62', 'https://wpbrigade.com?post_type=notification' );
799
800 register_activation_hook( __FILE__, array( 'LoginPress', 'plugin_activation' ) );
801