PluginProbe
LoginPress | wp-login Custom Login Page Customizer / 1.5.11
LoginPress | wp-login Custom Login Page Customizer v1.5.11
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 1.5.11, at loginpress.php

626 lines 19.4 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 - Customizing the WordPress Login Screen.
4 * Plugin URI: https://loginpress.pro/?utm_source=loginpress-lite&utm_medium=plugin-inside&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/">WPBrigade</a> which allows you to completely change the layout of login, register and forgot password forms.
6 * Version: 1.5.11
7 * Author: WPBrigade
8 * Author URI: https://WPBrigade.com/
9 * Text Domain: loginpress
10 * Domain Path: /languages
11 *
12 * @package loginpress
13 * @category Core
14 * @author WPBrigade
15 */
16
17
18 if ( ! class_exists( 'LoginPress' ) ) :
19
20 final class LoginPress {
21
22 /**
23 * @var string
24 */
25 public $version = '1.5.11';
26
27 /**
28 * @var The single instance of the class
29 * @since 1.0.0
30 */
31 protected static $_instance = null;
32
33 /**
34 * @var WP_Session session
35 */
36 public $session = null;
37
38 /**
39 * @var WP_Query $query
40 */
41 public $query = null;
42
43 /**s
44 * @var WP_Countries $countries
45 */
46 public $countries = null;
47
48 /* * * * * * * * * *
49 * Class constructor
50 * * * * * * * * * */
51 public function __construct() {
52
53 $this->define_constants();
54 $this->includes();
55 $this->_hooks();
56
57 }
58
59 /**
60 * Define LoginPress Constants
61 */
62 private function define_constants() {
63
64 $this->define( 'LOGINPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
65 $this->define( 'LOGINPRESS_DIR_PATH', plugin_dir_path( __FILE__ ) );
66 $this->define( 'LOGINPRESS_DIR_URL', plugin_dir_url( __FILE__ ) );
67 $this->define( 'LOGINPRESS_ROOT_PATH', dirname( __FILE__ ) . '/' );
68 $this->define( 'LOGINPRESS_ROOT_FILE', __FILE__ );
69 $this->define( 'LOGINPRESS_VERSION', $this->version );
70 $this->define( 'LOGINPRESS_FEEDBACK_SERVER', 'https://wpbrigade.com/' );
71 }
72
73 /**
74 * Include required core files used in admin and on the frontend.
75 * @version 1.1.7
76 */
77
78 public function includes() {
79
80 include_once( LOGINPRESS_DIR_PATH . 'include/compatibility.php' );
81 include_once( LOGINPRESS_DIR_PATH . 'custom.php' );
82 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-setup.php' );
83 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-ajax.php' );
84 // include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-filter-plugin.php' );
85 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-developer-hooks.php' );
86 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-notifications.php' );
87 if ( is_multisite() ) {
88 require_once( LOGINPRESS_DIR_PATH . 'include/class-loginpress-theme-template.php' );
89 }
90
91 $loginpress_setting = get_option( 'loginpress_setting' );
92
93 $loginpress_privacy_policy = isset( $loginpress_setting['enable_privacy_policy'] ) ? $loginpress_setting['enable_privacy_policy'] : 'off';
94 if ( 'off' != $loginpress_privacy_policy ) {
95 include_once( LOGINPRESS_DIR_PATH . 'include/privacy-policy.php' );
96 }
97
98 $login_with_email = isset( $loginpress_setting['login_order'] ) ? $loginpress_setting['login_order'] : 'default';
99 if ( 'default' != $login_with_email ) {
100 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-login-order.php' );
101 new LoginPress_Login_Order();
102 }
103
104 $enable_reg_pass_field = isset( $loginpress_setting['enable_reg_pass_field'] ) ? $loginpress_setting['enable_reg_pass_field'] : 'off';
105 if ( 'off' != $enable_reg_pass_field ) {
106 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-custom-password.php' );
107 new LoginPresss_Custom_Password();
108 }
109
110 }
111
112 /**
113 * Hook into actions and filters
114 * @since 1.0.0
115 * @version 1.2.2
116 */
117 private function _hooks() {
118
119 add_action( 'admin_menu', array( $this, 'register_options_page' ) );
120 add_action( 'plugins_loaded', array( $this, 'textdomain' ) );
121 add_filter( 'plugin_row_meta', array( $this, '_row_meta'), 10, 2 );
122 add_action( 'admin_enqueue_scripts', array( $this, '_admin_scripts' ) );
123 add_action( 'admin_footer', array( $this, 'add_deactive_modal' ) );
124 add_action( 'plugin_action_links', array( $this, 'loginpress_action_links' ), 10, 2 );
125 add_action( 'admin_init', array( $this, 'redirect_optin' ) );
126 add_filter( 'auth_cookie_expiration', array( $this, '_change_auth_cookie_expiration' ), 10, 3 );
127 //add_filter( 'plugins_api', array( $this, 'get_addon_info_' ) , 100, 3 );
128 if ( is_multisite() ) {
129 add_action( 'admin_init', array( $this, 'redirect_loginpress_edit_page' ) );
130 add_action( 'admin_init', array( $this, 'check_loginpress_page' ) );
131 }
132
133 }
134
135 /**
136 * Redirect to Optin page.
137 *
138 * @since 1.0.15
139 */
140 function redirect_optin() {
141
142 // delete_option( '_loginpress_optin' );
143
144 if ( isset( $_POST['loginpress-submit-optout'] ) ) {
145
146 update_option( '_loginpress_optin', 'no' );
147 $this->_send_data( array(
148 'action' => 'Skip',
149 ) );
150
151 } elseif ( isset( $_POST['loginpress-submit-optin'] ) ) {
152
153 update_option( '_loginpress_optin', 'yes' );
154 $fields = array(
155 'action' => 'Activate',
156 'track_mailchimp' => 'yes'
157 );
158 $this->_send_data( $fields );
159
160 } elseif ( ! get_option( '_loginpress_optin' ) && isset( $_GET['page'] ) && ( $_GET['page'] === 'loginpress-settings' || $_GET['page'] === 'loginpress' || $_GET['page'] === 'abw' ) ) {
161
162 /**
163 * XSS Attack vector found and fixed.
164 *
165 * @since 1.5.11
166 */
167 $page_redirect = $_GET['page'] === 'loginpress' ? 'loginpress' : 'loginpress-settings';
168 wp_redirect( admin_url('admin.php?page=loginpress-optin&redirect-page=' . $page_redirect) );
169 exit;
170 } elseif ( get_option( '_loginpress_optin' ) && ( get_option( '_loginpress_optin' ) == 'yes' || get_option( '_loginpress_optin' ) == 'no' ) && isset( $_GET['page'] ) && $_GET['page'] === 'loginpress-optin' ) {
171 wp_redirect( admin_url( 'admin.php?page=loginpress-settings' ) );
172 exit;
173 }
174 }
175
176
177 /**
178 * Main Instance
179 *
180 * @since 1.0.0
181 * @static
182 * @see loginPress_loader()
183 * @return Main instance
184 */
185 public static function instance() {
186 if ( is_null( self::$_instance ) ) {
187 self::$_instance = new self();
188 }
189 return self::$_instance;
190 }
191
192
193 /**
194 * Load Languages
195 * @since 1.0.0
196 */
197 public function textdomain() {
198
199 $plugin_dir = dirname( plugin_basename( __FILE__ ) ) ;
200 load_plugin_textdomain( 'loginpress', false, $plugin_dir . '/languages/' );
201 }
202
203 /**
204 * Define constant if not already set
205 * @param string $name
206 * @param string|bool $value
207 */
208 private function define( $name, $value ) {
209 if ( ! defined( $name ) ) {
210 define( $name, $value );
211 }
212 }
213
214 /**
215 * Init WPBrigade when WordPress Initialises.
216 */
217 public function init() {
218 // Before init action
219 }
220
221 /**
222 * Create LoginPress Page Template.
223 *
224 * @since 1.1.3
225 */
226 public function check_loginpress_page() {
227
228 // Retrieve the LoginPress admin page option, that was created during the activation process.
229 $option = $this->get_loginpress_page();
230
231 include LOGINPRESS_DIR_PATH . 'include/create-loginpress-page.php';
232 // Retrieve the status of the page, if the option is available.
233 if ( $option ) {
234 $page = get_post( $option );
235 $status = $page->post_status;
236 } else {
237 $status = null;
238 }
239
240 // Check the status of the page. Let's fix it, if the page is missing or in the trash.
241 if ( empty( $status ) || 'trash' === $status ) {
242 new LoginPress_Page_Create();
243 }
244 }
245
246 /**
247 * function for redirect the LoginPress page on editing.
248 *
249 * @since 1.1.3
250 */
251 public function redirect_loginpress_edit_page() {
252 global $pagenow;
253
254 $page = $this->get_loginpress_page();
255
256 if ( ! $page ) {
257 return;
258 }
259
260 $page_url = get_permalink( $page );
261 $page_id = get_post( $page );
262 $page_id = $page->ID;
263
264 // Generate the redirect url.
265 $url = add_query_arg(
266 array(
267 'autofocus[section]' => 'loginpress_panel',
268 'url' => rawurlencode( $page_url ),
269 ),
270 admin_url( 'customize.php' )
271 );
272
273 /* Check current admin page. */
274 if ( $pagenow == 'post.php' && isset( $_GET['post'] ) && $_GET['post'] == $page_id ) {
275 wp_safe_redirect( $url );
276 }
277 }
278
279 /**
280 * Add new page in Apperance to customize Login Page
281 */
282 public function register_options_page() {
283
284 add_submenu_page( null, __( 'Activate', 'loginpress' ), __( 'Activate', 'loginpress' ), 'manage_options', 'loginpress-optin', array( $this, 'render_optin' ) );
285
286 add_theme_page( __( 'LoginPress', 'loginpress' ), __( 'LoginPress', 'loginpress' ), 'manage_options', "abw", '__return_null' );
287 }
288
289
290 /**
291 * Show Opt-in Page.
292 *
293 * @since 1.0.15
294 */
295 function render_optin() {
296 include LOGINPRESS_DIR_PATH . 'include/loginpress-optin-form.php';
297 }
298
299 /**
300 * Wrapper function to send data.
301 * @param [arrays] $args.
302 *
303 * @since 1.0.15
304 * @version 1.0.23
305 */
306 function _send_data( $args ) {
307
308 $cuurent_user = wp_get_current_user();
309 $fields = array(
310 'email' => get_option( 'admin_email' ),
311 'website' => get_site_url(),
312 'action' => '',
313 'reason' => '',
314 'reason_detail' => '',
315 'display_name' => $cuurent_user->display_name,
316 'blog_language' => get_bloginfo( 'language' ),
317 'wordpress_version' => get_bloginfo( 'version' ),
318 'php_version' => PHP_VERSION,
319 'plugin_version' => LOGINPRESS_VERSION,
320 'plugin_name' => 'LoginPress Free',
321 );
322
323 $args = array_merge( $fields, $args );
324 $response = wp_remote_post( LOGINPRESS_FEEDBACK_SERVER, array(
325 'method' => 'POST',
326 'timeout' => 5,
327 'httpversion' => '1.0',
328 'blocking' => true,
329 'headers' => array(),
330 'body' => $args,
331 ) );
332
333 // echo '<pre>'; print_r( $args ); echo '</pre>';
334
335 }
336
337 /**
338 * Session Expiration
339 *
340 * @since 1.0.18
341 * @version 1.3.2
342 */
343 function _change_auth_cookie_expiration( $expiration, $user_id, $remember ) {
344
345 $loginpress_setting = get_option( 'loginpress_setting' );
346 $_expiration = isset( $loginpress_setting['session_expiration'] ) ? intval( $loginpress_setting['session_expiration'] ) : '';
347
348 /**
349 * return the WordPress default $expiration time if LoginPress Session Expiration time set 0 or empty.
350 * @since 1.0.18
351 */
352 if ( empty( $_expiration ) || '0' == $_expiration ) {
353 return $expiration;
354 }
355
356 /**
357 * $filter_role Use filter `loginpress_exclude_role_session` for return the role.
358 * By default it's false and $expiration time will apply on all user.
359 *
360 * @return string/array role name.
361 * @since 1.3.2
362 */
363 $filter_role = apply_filters( 'loginpress_exclude_role_session', false );
364
365 if ( $filter_role ) {
366 $user_roles = get_userdata( $user_id )->roles;
367
368 // if $filter_role is array, return the default $expiration for each defined role.
369 if ( is_array( $filter_role ) ) {
370 foreach ( $filter_role as $role ) {
371 if ( in_array( $role, $user_roles ) ) {
372 return $expiration;
373 }
374 }
375 } else if ( in_array( $filter_role, $user_roles ) ) {
376 return $expiration;
377 }
378 }
379
380 // Convert Duration (minutes) of the expiration period in seconds.
381 $expiration = $_expiration * 60;
382
383 return $expiration;
384 }
385
386 /**
387 * Load JS or CSS files at admin side and enqueue them
388 * @param string tell you the Page ID
389 * @return void
390 */
391 function _admin_scripts( $hook ) {
392
393 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' ) {
394
395 wp_enqueue_style( 'loginpress_stlye', plugins_url( 'css/style.css', __FILE__ ), array(), LOGINPRESS_VERSION );
396 wp_enqueue_script( 'loginpress_js', plugins_url( 'js/admin-custom.js', __FILE__ ), array(), LOGINPRESS_VERSION );
397
398 // Array for localize.
399 $loginpress_localize = array(
400 'plugin_url' => plugins_url(),
401 );
402
403 wp_localize_script( 'loginpress_js', 'loginpress_script', $loginpress_localize );
404 }
405
406 }
407
408 /**
409 * Add rating icon on plugins page.
410 *
411 * @since 1.0.9
412 * @version 1.1.22
413 */
414
415 public function _row_meta( $meta_fields, $file ) {
416
417 if ( $file != 'loginpress/loginpress.php' ) {
418
419 return $meta_fields;
420 }
421
422 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>";
423
424 $plugin_rate = "https://wordpress.org/support/plugin/loginpress/reviews/?rate=5#new-post";
425 $plugin_filter = "https://wordpress.org/support/plugin/loginpress/reviews/?filter=5";
426 $svg_xmlns = "https://www.w3.org/2000/svg";
427 $svg_icon = '';
428
429 for ( $i = 0; $i < 5; $i++ ) {
430 $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>";
431 }
432
433 // Set icon for thumbsup.
434 $meta_fields[] = '<a href="' . esc_url( $plugin_filter ) . '" target="_blank"><span class="dashicons dashicons-thumbs-up"></span>' . __( 'Vote!', 'loginpress' ) . '</a>';
435
436 // Set icon for 5-star reviews. v1.1.22
437 $meta_fields[] = "<a href='" . esc_url( $plugin_rate ) . "' target='_blank' title='" . esc_html__( 'Rate', 'loginpress' ) . "'><i class='loginpress-rate-stars'>" . $svg_icon . "</i></a>";
438
439 return $meta_fields;
440 }
441
442 /**
443 * Add deactivate modal layout.
444 */
445 function add_deactive_modal() {
446 global $pagenow;
447
448 if ( 'plugins.php' !== $pagenow ) {
449 return;
450 }
451
452 include LOGINPRESS_DIR_PATH . 'include/deactivate_modal.php';
453 include LOGINPRESS_DIR_PATH . 'include/loginpress-optout-form.php';
454 }
455
456 /**
457 * Plugin activation
458 *
459 * @since 1.0.15
460 * @version 1.0.22
461 */
462 static function plugin_activation() {
463
464 $loginpress_key = get_option( 'loginpress_customization' );
465 $loginpress_setting = get_option( 'loginpress_setting' );
466
467 // Create a key 'loginpress_customization' with empty array.
468 if ( ! $loginpress_key ) {
469 update_option( 'loginpress_customization', array() );
470 }
471
472 // Create a key 'loginpress_setting' with empty array.
473 if ( ! $loginpress_setting ) {
474 update_option( 'loginpress_setting', array() );
475 }
476 }
477
478 static function plugin_uninstallation() {
479
480 $email = get_option( 'admin_email' );
481
482 $fields = array(
483 'email' => $email,
484 'website' => get_site_url(),
485 'action' => 'Uninstall',
486 'reason' => '',
487 'reason_detail' => '',
488 'blog_language' => get_bloginfo( 'language' ),
489 'wordpress_version' => get_bloginfo( 'version' ),
490 'php_version' => PHP_VERSION,
491 'plugin_version' => LOGINPRESS_VERSION,
492 'plugin_name' => 'LoginPress Free',
493 );
494
495 $response = wp_remote_post( LOGINPRESS_FEEDBACK_SERVER, array(
496 'method' => 'POST',
497 'timeout' => 5,
498 'httpversion' => '1.0',
499 'blocking' => false,
500 'headers' => array(),
501 'body' => $fields,
502 ) );
503
504 }
505
506
507
508 /**
509 * Pull the LoginPress page from options.
510 *
511 * @access public
512 * @since 1.1.3
513 * @version 1.1.7
514 */
515 public function get_loginpress_page() {
516
517 $loginpress_setting = get_option( 'loginpress_setting', array() );
518 if ( ! is_array( $loginpress_setting ) && empty( $loginpress_setting ) ) {
519 $loginpress_setting = array();
520 }
521 $page = array_key_exists( 'loginpress_page', $loginpress_setting ) ? get_post( $loginpress_setting['loginpress_page'] ) : false;
522
523 return $page;
524 }
525
526
527 /**
528 * Add a link to the settings page to the plugins list
529 *
530 * @since 1.0.11
531 */
532 public function loginpress_action_links( $links, $file ) {
533
534 static $this_plugin;
535
536 if ( empty( $this_plugin ) ) {
537
538 $this_plugin = 'loginpress/loginpress.php';
539 }
540
541 if ( $file == $this_plugin ) {
542
543 $settings_link = sprintf( esc_html__( '%1$s Settings %2$s | %3$s Customize %4$s', 'loginpress' ), '<a href="' . admin_url( 'admin.php?page=loginpress-settings' ) . '">', '</a>', '<a href="' . admin_url( 'admin.php?page=loginpress' ) . '">', '</a>' );
544
545
546 if( 'yes' == get_option( '_loginpress_optin' ) ){
547 $settings_link .= sprintf( esc_html__( ' | %1$s Opt Out %2$s ', 'loginpress'), '<a class="opt-out" href="' . admin_url( 'admin.php?page=loginpress-settings' ) . '">', '</a>' );
548 } else {
549 $settings_link .= sprintf( esc_html__( ' | %1$s Opt In %2$s ', 'loginpress'), '<a href="' . admin_url( 'admin.php?page=loginpress-optin&redirect-page=' .'loginpress-settings' ) . '">', '</a>' );
550 }
551
552 array_unshift( $links, $settings_link );
553
554 if ( ! has_action( 'loginpress_pro_add_template' ) ) :
555 $pro_link = sprintf( esc_html__( '%1$s %3$s Upgrade Pro %4$s %2$s', 'loginpress' ), '<a href="https://wpbrigade.com/wordpress/plugins/loginpress-pro/?utm_source=loginpress-lite&utm_medium=plugin-action-link&utm_campaign=pro-upgrade" target="_blank">', '</a>', '<span class="loginpress-dasboard-pro-link">', '</span>' );
556 array_push( $links, $pro_link );
557 endif;
558 }
559
560 return $links;
561 }
562
563 // function get_addon_info_( $api, $action, $args ) {
564
565 // if ( $action == 'plugin_information' && empty( $api ) && ( ! empty( $_GET['lgp'] ) ) ) {
566
567 // $raw_response = wp_remote_post( 'https://wpbrigade.com/loginpress-api/search.php', array(
568 // 'body' => array(
569 // 'slug' => $args->slug
570 // ) )
571 // );
572
573 // if ( is_wp_error( $raw_response ) || $raw_response['response']['code'] != 200 ) {
574 // return false;
575 // }
576
577 // $plugin = unserialize( $raw_response['body'] );
578
579 // $api = new stdClass();
580 // $api->name = $plugin['title'];
581 // $api->version = $plugin['version'];
582 // $api->download_link = $plugin['download_url'];
583 // $api->tested = '10.0';
584
585 // }
586
587 // return $api;
588 // }
589 } // End Of Class.
590 endif;
591
592
593 /**
594 * Returns the main instance of WP to prevent the need to use globals.
595 *
596 * @since 1.0.0
597 * @return LoginPress
598 */
599 function loginPress_loader() {
600 return LoginPress::instance();
601 }
602
603 // Call the function
604 loginPress_loader();
605
606 /**
607 * Create the Object of Custom Login Entites and Settings.
608 *
609 * @since 1.0.0
610 */
611 new LoginPress_Entities();
612 new LoginPress_Settings();
613
614 /**
615 * Create the Object of Remote Notification.
616 *
617 * @since 1.0.9
618 */
619 if (!class_exists('TAV_Remote_Notification_Client')) {
620 require( LOGINPRESS_ROOT_PATH . 'include/class-remote-notification-client.php' );
621 }
622 $notification = new TAV_Remote_Notification_Client( 125, '16765c0902705d62', 'https://wpbrigade.com?post_type=notification' );
623
624 register_activation_hook( __FILE__, array( 'LoginPress', 'plugin_activation' ) );
625 register_uninstall_hook( __FILE__, array( 'LoginPress', 'plugin_uninstallation' ) );
626