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

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

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