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

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

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