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

607 lines 18.8 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
4 * Plugin URI: https://WPBrigade.com/wordpress/plugins/loginpress/
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.2.1
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.2.1';
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 * Hook into actions and filters
113 * @since 1.0.0
114 */
115 private function _hooks() {
116
117 add_action( 'admin_menu', array( $this, 'register_options_page' ) );
118 add_action( 'plugins_loaded', array( $this, 'textdomain' ) );
119 add_filter( 'plugin_row_meta', array( $this, '_row_meta'), 10, 2 );
120 add_action( 'admin_enqueue_scripts', array( $this, '_admin_scripts' ) );
121 add_action( 'admin_footer', array( $this, 'add_deactive_modal' ) );
122 add_action( 'plugin_action_links', array( $this, 'loginpress_action_links' ), 10, 2 );
123 add_action( 'admin_init', array( $this, 'redirect_optin' ) );
124 add_filter( 'auth_cookie_expiration', array( $this, '_change_auth_cookie_expiration' ), 10, 3 );
125 //add_filter( 'plugins_api', array( $this, 'get_addon_info_' ) , 100, 3 );
126 add_action( 'login_enqueue_scripts', array( $this, 'load_loginpress_assets' ) );
127 if ( is_multisite() ) {
128 add_action( 'admin_init', array( $this, 'redirect_loginpress_edit_page' ) );
129 add_action( 'admin_init', array( $this, 'check_loginpress_page' ) );
130 }
131
132 }
133
134 /**
135 * Redirect to Optin page.
136 *
137 * @since 1.0.15
138 */
139 function redirect_optin() {
140
141 // delete_option( '_loginpress_optin' );
142
143 if ( isset( $_POST['loginpress-submit-optout'] ) ) {
144
145 update_option( '_loginpress_optin', 'no' );
146 $this->_send_data( array(
147 'action' => 'Skip',
148 ) );
149
150 } elseif ( isset( $_POST['loginpress-submit-optin'] ) ) {
151
152 update_option( '_loginpress_optin', 'yes' );
153 $fields = array(
154 'action' => 'Activate',
155 'track_mailchimp' => 'yes'
156 );
157 $this->_send_data( $fields );
158
159 } elseif ( ! get_option( '_loginpress_optin' ) && isset( $_GET['page'] ) && ( $_GET['page'] === 'loginpress-settings' || $_GET['page'] === 'loginpress' || $_GET['page'] === 'abw' ) ) {
160
161 wp_redirect( admin_url('admin.php?page=loginpress-optin&redirect-page=' . $_GET['page'] ) );
162 exit;
163 } elseif ( get_option( '_loginpress_optin' ) && ( get_option( '_loginpress_optin' ) == 'yes' || get_option( '_loginpress_optin' ) == 'no' ) && isset( $_GET['page'] ) && $_GET['page'] === 'loginpress-optin' ) {
164 wp_redirect( admin_url( 'admin.php?page=loginpress-settings' ) );
165 exit;
166 }
167 }
168
169
170 /**
171 * Main Instance
172 *
173 * @since 1.0.0
174 * @static
175 * @see loginPress_loader()
176 * @return Main instance
177 */
178 public static function instance() {
179 if ( is_null( self::$_instance ) ) {
180 self::$_instance = new self();
181 }
182 return self::$_instance;
183 }
184
185
186 /**
187 * Load Languages
188 * @since 1.0.0
189 */
190 public function textdomain() {
191
192 $plugin_dir = dirname( plugin_basename( __FILE__ ) ) ;
193 load_plugin_textdomain( 'loginpress', false, $plugin_dir . '/languages/' );
194 }
195
196 /**
197 * Define constant if not already set
198 * @param string $name
199 * @param string|bool $value
200 */
201 private function define( $name, $value ) {
202 if ( ! defined( $name ) ) {
203 define( $name, $value );
204 }
205 }
206
207 /**
208 * Init WPBrigade when WordPress Initialises.
209 */
210 public function init() {
211 // Before init action
212 }
213
214 /**
215 * Create LoginPress Page Template.
216 *
217 * @since 1.1.3
218 */
219 public function check_loginpress_page() {
220
221 // Retrieve the LoginPress admin page option, that was created during the activation process.
222 $option = $this->get_loginpress_page();
223
224 include LOGINPRESS_DIR_PATH . 'include/create-loginpress-page.php';
225 // Retrieve the status of the page, if the option is available.
226 if ( $option ) {
227 $page = get_post( $option );
228 $status = $page->post_status;
229 } else {
230 $status = null;
231 }
232
233 // Check the status of the page. Let's fix it, if the page is missing or in the trash.
234 if ( empty( $status ) || 'trash' === $status ) {
235 new LoginPress_Page_Create();
236 }
237 }
238
239 /**
240 * function for redirect the LoginPress page on editing.
241 *
242 * @since 1.1.3
243 */
244 public function redirect_loginpress_edit_page() {
245 global $pagenow;
246
247 $page = $this->get_loginpress_page();
248
249 if ( ! $page ) {
250 return;
251 }
252
253 $page_url = get_permalink( $page );
254 $page_id = get_post( $page );
255 $page_id = $page->ID;
256
257 // Generate the redirect url.
258 $url = add_query_arg(
259 array(
260 'autofocus[section]' => 'loginpress_panel',
261 'url' => rawurlencode( $page_url ),
262 ),
263 admin_url( 'customize.php' )
264 );
265
266 /* Check current admin page. */
267 if ( $pagenow == 'post.php' && isset( $_GET['post'] ) && $_GET['post'] == $page_id ) {
268 wp_safe_redirect( $url );
269 }
270 }
271
272 /**
273 * Add new page in Apperance to customize Login Page
274 */
275 public function register_options_page() {
276
277 add_submenu_page( null, __( 'Activate', 'loginpress' ), __( 'Activate', 'loginpress' ), 'manage_options', 'loginpress-optin', array( $this, 'render_optin' ) );
278
279 add_theme_page( __( 'LoginPress', 'loginpress' ), __( 'LoginPress', 'loginpress' ), 'manage_options', "abw", '__return_null' );
280 }
281
282
283 /**
284 * Show Opt-in Page.
285 *
286 * @since 1.0.15
287 */
288 function render_optin() {
289 include LOGINPRESS_DIR_PATH . 'include/loginpress-optin-form.php';
290 }
291
292 /**
293 * Wrapper function to send data.
294 * @param [arrays] $args.
295 *
296 * @since 1.0.15
297 * @version 1.0.23
298 */
299 function _send_data( $args ) {
300
301 $cuurent_user = wp_get_current_user();
302 $fields = array(
303 'email' => get_option( 'admin_email' ),
304 'website' => get_site_url(),
305 'action' => '',
306 'reason' => '',
307 'reason_detail' => '',
308 'display_name' => $cuurent_user->display_name,
309 'blog_language' => get_bloginfo( 'language' ),
310 'wordpress_version' => get_bloginfo( 'version' ),
311 'php_version' => PHP_VERSION,
312 'plugin_version' => LOGINPRESS_VERSION,
313 'plugin_name' => 'LoginPress Free',
314 );
315
316 $args = array_merge( $fields, $args );
317 $response = wp_remote_post( LOGINPRESS_FEEDBACK_SERVER, array(
318 'method' => 'POST',
319 'timeout' => 5,
320 'httpversion' => '1.0',
321 'blocking' => true,
322 'headers' => array(),
323 'body' => $args,
324 ) );
325
326 // echo '<pre>'; print_r( $args ); echo '</pre>';
327
328 }
329
330 /**
331 * Load assets on login screen.
332 *
333 * @since 1.0.0
334 * @version 1.1.14
335 */
336 function load_loginpress_assets() {
337
338 wp_enqueue_script( 'loginpress-script', plugins_url( 'js/loginpress.js', __FILE__ ), array( 'jquery' ), LOGINPRESS_VERSION );
339
340 // Array for localize.
341 $loginpress_localize = array(
342 'caps_lock' => __( 'Caps Lock is on', 'loginpress' ),
343 );
344
345 wp_localize_script( 'loginpress-script', 'loginpress_script', $loginpress_localize );
346 }
347
348 /**
349 * Session Expiration
350 *
351 * @since 1.0.18
352 */
353 function _change_auth_cookie_expiration( $expiration, $user_id, $remember ) {
354
355 $loginpress_setting = get_option( 'loginpress_setting' );
356 $_expiration = isset( $loginpress_setting['session_expiration'] ) ? intval( $loginpress_setting['session_expiration'] ) : '';
357
358 if ( empty( $_expiration ) || '0' == $_expiration ) {
359 return $expiration;
360 }
361
362 $expiration = $_expiration * 60; // Convert Duration (minutes) of the expiration period in seconds.
363
364 return $expiration;
365 }
366
367 /**
368 * Load JS or CSS files at admin side and enqueue them
369 * @param string tell you the Page ID
370 * @return void
371 */
372 function _admin_scripts( $hook ) {
373
374 if( $hook == 'toplevel_page_loginpress-settings' || $hook == 'loginpress_page_loginpress-help' || $hook == 'loginpress_page_loginpress-import-export' || $hook == 'loginpress_page_loginpress-license' ) {
375
376 wp_enqueue_style( 'loginpress_stlye', plugins_url( 'css/style.css', __FILE__ ), array(), LOGINPRESS_VERSION );
377 wp_enqueue_script( 'loginpress_js', plugins_url( 'js/admin-custom.js', __FILE__ ), array(), LOGINPRESS_VERSION );
378
379 // Array for localize.
380 $loginpress_localize = array(
381 'plugin_url' => plugins_url(),
382 );
383
384 wp_localize_script( 'loginpress_js', 'loginpress_script', $loginpress_localize );
385 }
386
387 }
388
389 /**
390 * Add rating icon on plugins page.
391 *
392 * @since 1.0.9
393 * @version 1.1.22
394 */
395
396 public function _row_meta( $meta_fields, $file ) {
397
398 if ( $file != 'loginpress/loginpress.php' ) {
399
400 return $meta_fields;
401 }
402
403 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>";
404
405 $plugin_rate = "https://wordpress.org/support/plugin/loginpress/reviews/?rate=5#new-post";
406 $plugin_filter = "https://wordpress.org/support/plugin/loginpress/reviews/?filter=5";
407 $svg_xmlns = "https://www.w3.org/2000/svg";
408 $svg_icon = '';
409
410 for ( $i = 0; $i < 5; $i++ ) {
411 $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>";
412 }
413
414 // Set icon for thumbsup.
415 $meta_fields[] = '<a href="' . esc_url( $plugin_filter ) . '" target="_blank"><span class="dashicons dashicons-thumbs-up"></span>' . __( 'Vote!', 'loginpress' ) . '</a>';
416
417 // Set icon for 5-star reviews. v1.1.22
418 $meta_fields[] = "<a href='" . esc_url( $plugin_rate ) . "' target='_blank' title='" . esc_html__( 'Rate', 'loginpress' ) . "'><i class='loginpress-rate-stars'>" . $svg_icon . "</i></a>";
419
420 return $meta_fields;
421 }
422
423 /**
424 * Add deactivate modal layout.
425 */
426 function add_deactive_modal() {
427 global $pagenow;
428
429 if ( 'plugins.php' !== $pagenow ) {
430 return;
431 }
432
433 include LOGINPRESS_DIR_PATH . 'include/deactivate_modal.php';
434 include LOGINPRESS_DIR_PATH . 'include/loginpress-optout-form.php';
435 }
436
437 /**
438 * Plugin activation
439 *
440 * @since 1.0.15
441 * @version 1.0.22
442 */
443 static function plugin_activation() {
444
445 $loginpress_key = get_option( 'loginpress_customization' );
446 $loginpress_setting = get_option( 'loginpress_setting' );
447
448 // Create a key 'loginpress_customization' with empty array.
449 if ( ! $loginpress_key ) {
450 update_option( 'loginpress_customization', array() );
451 }
452
453 // Create a key 'loginpress_setting' with empty array.
454 if ( ! $loginpress_setting ) {
455 update_option( 'loginpress_setting', array() );
456 }
457 }
458
459 static function plugin_uninstallation() {
460
461 $email = get_option( 'admin_email' );
462
463 $fields = array(
464 'email' => $email,
465 'website' => get_site_url(),
466 'action' => 'Uninstall',
467 'reason' => '',
468 'reason_detail' => '',
469 'blog_language' => get_bloginfo( 'language' ),
470 'wordpress_version' => get_bloginfo( 'version' ),
471 'php_version' => PHP_VERSION,
472 'plugin_version' => LOGINPRESS_VERSION,
473 'plugin_name' => 'LoginPress Free',
474 );
475
476 $response = wp_remote_post( LOGINPRESS_FEEDBACK_SERVER, array(
477 'method' => 'POST',
478 'timeout' => 5,
479 'httpversion' => '1.0',
480 'blocking' => false,
481 'headers' => array(),
482 'body' => $fields,
483 ) );
484
485 }
486
487
488
489 /**
490 * Pull the LoginPress page from options.
491 *
492 * @access public
493 * @since 1.1.3
494 * @version 1.1.7
495 */
496 public function get_loginpress_page() {
497
498 $loginpress_setting = get_option( 'loginpress_setting', array() );
499 if ( ! is_array( $loginpress_setting ) && empty( $loginpress_setting ) ) {
500 $loginpress_setting = array();
501 }
502 $page = array_key_exists( 'loginpress_page', $loginpress_setting ) ? get_post( $loginpress_setting['loginpress_page'] ) : false;
503
504 return $page;
505 }
506
507 /**
508 * Add a link to the settings page to the plugins list
509 *
510 * @since 1.0.11
511 */
512 public function loginpress_action_links( $links, $file ) {
513
514 static $this_plugin;
515
516 if ( empty( $this_plugin ) ) {
517
518 $this_plugin = 'loginpress/loginpress.php';
519 }
520
521 if ( $file == $this_plugin ) {
522
523 $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>' );
524
525
526 if( 'yes' == get_option( '_loginpress_optin' ) ){
527 $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>' );
528 } else {
529 $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>' );
530 }
531
532 array_unshift( $links, $settings_link );
533
534 if ( ! has_action( 'loginpress_pro_add_template' ) ) :
535 $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>' );
536 array_push( $links, $pro_link );
537 endif;
538 }
539
540 return $links;
541 }
542
543 // function get_addon_info_( $api, $action, $args ) {
544
545 // if ( $action == 'plugin_information' && empty( $api ) && ( ! empty( $_GET['lgp'] ) ) ) {
546
547 // $raw_response = wp_remote_post( 'https://wpbrigade.com/loginpress-api/search.php', array(
548 // 'body' => array(
549 // 'slug' => $args->slug
550 // ) )
551 // );
552
553 // if ( is_wp_error( $raw_response ) || $raw_response['response']['code'] != 200 ) {
554 // return false;
555 // }
556
557 // $plugin = unserialize( $raw_response['body'] );
558
559 // $api = new stdClass();
560 // $api->name = $plugin['title'];
561 // $api->version = $plugin['version'];
562 // $api->download_link = $plugin['download_url'];
563 // $api->tested = '10.0';
564
565 // }
566
567 // return $api;
568 // }
569 } // End Of Class.
570 endif;
571
572
573 /**
574 * Returns the main instance of WP to prevent the need to use globals.
575 *
576 * @since 1.0.0
577 * @return LoginPress
578 */
579 function loginPress_loader() {
580 return LoginPress::instance();
581 }
582
583 // Call the function
584 loginPress_loader();
585
586 /**
587 * Create the Object of Custom Login Entites and Settings.
588 *
589 * @since 1.0.0
590 */
591 new LoginPress_Entities();
592 new LoginPress_Settings();
593
594 /**
595 * Create the Object of Remote Notification.
596 *
597 * @since 1.0.9
598 */
599 if (!class_exists('TAV_Remote_Notification_Client')) {
600 require( LOGINPRESS_ROOT_PATH . 'include/class-remote-notification-client.php' );
601 }
602 $notification = new TAV_Remote_Notification_Client( 125, '16765c0902705d62', 'https://wpbrigade.com?post_type=notification' );
603
604 register_activation_hook( __FILE__, array( 'LoginPress', 'plugin_activation' ) );
605 register_uninstall_hook( __FILE__, array( 'LoginPress', 'plugin_uninstallation' ) );
606 ?>
607