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

599 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: http://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.1.1
7 * Author: WPBrigade
8 * Author URI: http://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.1.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 */
76
77 public function includes() {
78
79 include_once( LOGINPRESS_DIR_PATH . 'include/compatibility.php' );
80 include_once( LOGINPRESS_DIR_PATH . 'custom.php' );
81 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-setup.php' );
82 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-ajax.php' );
83 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-filter-plugin.php' );
84
85 $loginpress_setting = get_option( 'loginpress_setting' );
86
87 $loginpress_privacy_policy = isset( $loginpress_setting['enable_privacy_policy'] ) ? $loginpress_setting['enable_privacy_policy'] : 'off';
88 if ( 'off' != $loginpress_privacy_policy ) {
89 include_once( LOGINPRESS_DIR_PATH . 'include/privacy-policy.php' );
90 }
91
92 $login_with_email = isset( $loginpress_setting['login_order'] ) ? $loginpress_setting['login_order'] : 'default';
93 if ( 'default' != $login_with_email ) {
94 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-login-order.php' );
95 new LoginPress_Login_Order();
96 }
97
98 $enable_reg_pass_field = isset( $loginpress_setting['enable_reg_pass_field'] ) ? $loginpress_setting['enable_reg_pass_field'] : 'off';
99 if ( 'off' != $enable_reg_pass_field ) {
100 include_once( LOGINPRESS_DIR_PATH . 'classes/class-loginpress-custom-password.php' );
101 new LoginPresss_Custom_Password();
102 }
103 }
104
105 /**
106 * Hook into actions and filters
107 * @since 1.0.0
108 */
109 private function _hooks() {
110
111 add_action( 'admin_menu', array( $this, 'register_options_page' ) );
112 add_action( 'plugins_loaded', array( $this, 'textdomain' ) );
113 add_filter( 'plugin_row_meta', array( $this, '_row_meta'), 10, 2 );
114 add_action( 'admin_enqueue_scripts', array( $this, '_admin_scripts' ) );
115 add_action( 'admin_footer', array( $this, 'add_deactive_modal' ) );
116 add_action( 'admin_init', array( $this, 'loginpress_review_notice' ) );
117 add_action( 'plugin_action_links', array( $this, 'loginpress_action_links' ), 10, 2 );
118 add_action( 'admin_init', array( $this, 'redirect_optin' ) );
119 add_filter( 'auth_cookie_expiration', array( $this, '_change_auth_cookie_expiration' ), 10, 3 );
120 //add_filter( 'plugins_api', array( $this, 'get_addon_info_' ) , 100, 3 );
121
122 }
123
124 /**
125 * Redirect to Optin page.
126 *
127 * @since 1.0.15
128 */
129 function redirect_optin() {
130
131 // delete_option( '_loginpress_optin' );
132
133 if ( isset( $_POST['loginpress-submit-optout'] ) ) {
134
135 update_option( '_loginpress_optin', 'no' );
136 $this->_send_data( array(
137 'action' => 'Skip',
138 ) );
139
140 } elseif ( isset( $_POST['loginpress-submit-optin'] ) ) {
141
142 update_option( '_loginpress_optin', 'yes' );
143 $fields = array(
144 'action' => 'Activate',
145 'track_mailchimp' => 'yes'
146 );
147 $this->_send_data( $fields );
148
149 } elseif ( ! get_option( '_loginpress_optin' ) && isset( $_GET['page'] ) && ( $_GET['page'] === 'loginpress-settings' || $_GET['page'] === 'loginpress' || $_GET['page'] === 'abw' ) ) {
150
151 wp_redirect( admin_url('admin.php?page=loginpress-optin&redirect-page=' . $_GET['page'] ) );
152 exit;
153 } elseif ( get_option( '_loginpress_optin' ) && ( get_option( '_loginpress_optin' ) == 'yes' || get_option( '_loginpress_optin' ) == 'no' ) && isset( $_GET['page'] ) && $_GET['page'] === 'loginpress-optin' ) {
154
155 wp_redirect( admin_url( 'admin.php?page=loginpress-settings' ) );
156 exit;
157 }
158 }
159
160
161 /**
162 * Main Instance
163 *
164 * @since 1.0.0
165 * @static
166 * @see loginPress_loader()
167 * @return Main instance
168 */
169 public static function instance() {
170 if ( is_null( self::$_instance ) ) {
171 self::$_instance = new self();
172 }
173 return self::$_instance;
174 }
175
176
177 /**
178 * Load Languages
179 * @since 1.0.0
180 */
181 public function textdomain() {
182
183 $plugin_dir = dirname( plugin_basename( __FILE__ ) ) ;
184 load_plugin_textdomain( 'loginpress', false, $plugin_dir . '/languages/' );
185 }
186
187 /**
188 * Define constant if not already set
189 * @param string $name
190 * @param string|bool $value
191 */
192 private function define( $name, $value ) {
193 if ( ! defined( $name ) ) {
194 define( $name, $value );
195 }
196 }
197
198 /**
199 * Init WPBrigade when WordPress Initialises.
200 */
201 public function init() {
202 // Before init action
203 }
204 /**
205 * Add new page in Apperance to customize Login Page
206 */
207 public function register_options_page() {
208
209 add_submenu_page( null, __( 'Activate', 'loginpress' ), __( 'Activate', 'loginpress' ), 'manage_options', 'loginpress-optin', array( $this, 'render_optin' ) );
210
211 add_theme_page( __( 'LoginPress', 'loginpress' ), __( 'LoginPress', 'loginpress' ), 'manage_options', "abw", '__return_null' );
212 }
213
214
215 /**
216 * Show Opt-in Page.
217 *
218 * @since 1.0.15
219 */
220 function render_optin() {
221 include LOGINPRESS_DIR_PATH . 'include/loginpress-optin-form.php';
222 }
223
224 /**
225 * Wrapper function to send data.
226 * @param [arrays] $args.
227 *
228 * @since 1.0.15
229 * @version 1.0.23
230 */
231 function _send_data( $args ) {
232
233 $cuurent_user = wp_get_current_user();
234 $fields = array(
235 'email' => get_option( 'admin_email' ),
236 'website' => get_site_url(),
237 'action' => '',
238 'reason' => '',
239 'reason_detail' => '',
240 'display_name' => $cuurent_user->display_name,
241 'blog_language' => get_bloginfo( 'language' ),
242 'wordpress_version' => get_bloginfo( 'version' ),
243 'php_version' => PHP_VERSION,
244 'plugin_version' => LOGINPRESS_VERSION,
245 'plugin_name' => 'LoginPress Free',
246 );
247
248 $args = array_merge( $fields, $args );
249 $response = wp_remote_post( LOGINPRESS_FEEDBACK_SERVER, array(
250 'method' => 'POST',
251 'timeout' => 5,
252 'httpversion' => '1.0',
253 'blocking' => true,
254 'headers' => array(),
255 'body' => $args,
256 ) );
257
258 // echo '<pre>'; print_r( $args ); echo '</pre>';
259
260 }
261
262 /**
263 * Session Expiration
264 *
265 * @since 1.0.18
266 */
267 function _change_auth_cookie_expiration( $expiration, $user_id, $remember ) {
268
269 $loginpress_setting = get_option( 'loginpress_setting' );
270 $_expiration = isset( $loginpress_setting['session_expiration'] ) ? intval( $loginpress_setting['session_expiration'] ) : '';
271
272 if ( empty( $_expiration ) || '0' == $_expiration ) {
273 return $expiration;
274 }
275
276 $expiration = $_expiration * 60; // Duration of the expiration period in seconds.
277
278 return $expiration;
279 }
280
281 /**
282 * Load JS or CSS files at admin side and enqueue them
283 * @param string tell you the Page ID
284 * @return void
285 */
286 function _admin_scripts( $hook ) {
287
288 if( $hook == 'toplevel_page_loginpress-settings' || $hook == 'loginpress_page_loginpress-help' || $hook == 'loginpress_page_loginpress-import-export' || $hook == 'loginpress_page_loginpress-license' ) {
289
290 wp_enqueue_style( 'loginpress_stlye', plugins_url( 'css/style.css', __FILE__ ), array(), LOGINPRESS_VERSION );
291 wp_enqueue_script( 'loginpress_js', plugins_url( 'js/admin-custom.js', __FILE__ ), array(), LOGINPRESS_VERSION );
292
293 // Array for localize.
294 $loginpress_localize = array(
295 'plugin_url' => plugins_url(),
296 );
297
298 wp_localize_script( 'loginpress_js', 'loginpress_script', $loginpress_localize );
299 }
300
301 }
302
303
304 public function _row_meta( $links, $file ) {
305
306 if ( strpos( $file, 'loginpress.php' ) !== false ) {
307
308 // Set link for Reviews.
309 $new_links = array('<a href="https://wordpress.org/support/plugin/loginpress/reviews/?filter=5" target="_blank"><span class="dashicons dashicons-thumbs-up"></span> ' . __( 'Vote!', 'loginpress' ) . '</a>',
310 );
311
312 $links = array_merge( $links, $new_links );
313 }
314
315 return $links;
316 }
317
318 /**
319 * Add deactivate modal layout.
320 */
321 function add_deactive_modal() {
322 global $pagenow;
323
324 if ( 'plugins.php' !== $pagenow ) {
325 return;
326 }
327
328 include LOGINPRESS_DIR_PATH . 'include/deactivate_modal.php';
329 include LOGINPRESS_DIR_PATH . 'include/loginpress-optout-form.php';
330 }
331
332 /**
333 * Plugin activation
334 *
335 * @since 1.0.15
336 * @version 1.0.22
337 */
338 static function plugin_activation() {
339
340 $loginpress_key = get_option( 'loginpress_customization' );
341 $loginpress_setting = get_option( 'loginpress_setting' );
342
343 // Create a key 'loginpress_customization' with empty array.
344 if ( ! $loginpress_key ) {
345 update_option( 'loginpress_customization', array() );
346 }
347
348 // Create a key 'loginpress_setting' with empty array.
349 if ( ! $loginpress_setting ) {
350 update_option( 'loginpress_setting', array() );
351 }
352 }
353
354 static function plugin_uninstallation() {
355
356 $email = get_option( 'admin_email' );
357
358 $fields = array(
359 'email' => $email,
360 'website' => get_site_url(),
361 'action' => 'Uninstall',
362 'reason' => '',
363 'reason_detail' => '',
364 'blog_language' => get_bloginfo( 'language' ),
365 'wordpress_version' => get_bloginfo( 'version' ),
366 'php_version' => PHP_VERSION,
367 'plugin_version' => LOGINPRESS_VERSION,
368 'plugin_name' => 'LoginPress Free',
369 );
370
371 $response = wp_remote_post( LOGINPRESS_FEEDBACK_SERVER, array(
372 'method' => 'POST',
373 'timeout' => 5,
374 'httpversion' => '1.0',
375 'blocking' => false,
376 'headers' => array(),
377 'body' => $fields,
378 ) );
379
380 }
381
382 /**
383 * Ask users to review our plugin on wordpress.org
384 *
385 * @since 1.0.11
386 * @return boolean false
387 */
388 public function loginpress_review_notice() {
389
390 $this->loginpress_review_dismissal();
391 $this->loginpress_review_pending();
392
393 $activation_time = get_site_option( 'loginpress_active_time' );
394 $review_dismissal = get_site_option( 'loginpress_review_dismiss' );
395
396 if ( 'yes' == $review_dismissal ) return;
397
398 if ( ! $activation_time ) :
399
400 $activation_time = time();
401 add_site_option( 'loginpress_active_time', $activation_time );
402 endif;
403
404 // 1296000 = 15 Days in seconds.
405 if ( time() - $activation_time > 1296000 ) :
406
407 wp_enqueue_style( 'loginpress_review_stlye', plugins_url( 'css/style-review.css', __FILE__ ), array(), LOGINPRESS_VERSION );
408 add_action( 'admin_notices' , array( $this, 'loginpress_review_notice_message' ) );
409 endif;
410
411 if ( is_multisite() ) {
412 add_action( 'admin_notices' , array( $this, 'loginpress_multisite_admin_message' ) );
413 add_action( 'network_admin_notices', array( $this, 'loginpress_multisite_admin_message' ) );
414 }
415 }
416
417 /**
418 * Multisite Admin Notice.
419 *
420 * @since 1.0.12
421 */
422 public function loginpress_multisite_admin_message() {
423
424 echo sprintf( __( '%1$s%2$sHi, LoginPress is not compatible with multisite right now. %3$s Checkout this Ticket in WordPress core %4$s %5$s%6$s', 'loginpress' ),
425 '<div class="notice notice-error is-dismissible">', '<p>', '<a href="https://core.trac.wordpress.org/ticket/40069" target="_blank">', '</a>', '</p>', '</div>' );
426 }
427
428 /**
429 * Check and Dismiss review message.
430 *
431 * @since 1.0.11
432 */
433 private function loginpress_review_dismissal() {
434
435 if ( ! is_admin() ||
436 ! current_user_can( 'manage_options' ) ||
437 ! isset( $_GET['_wpnonce'] ) ||
438 ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_wpnonce'] ) ), 'loginpress-review-nonce' ) ||
439 ! isset( $_GET['loginpress_review_dismiss'] ) ) :
440
441 return;
442 endif;
443
444 add_site_option( 'loginpress_review_dismiss', 'yes' );
445 }
446
447 /**
448 * Set time to current so review notice will popup after 14 days
449 *
450 * @since 1.0.11
451 */
452 function loginpress_review_pending() {
453
454 if ( ! is_admin() ||
455 ! current_user_can( 'manage_options' ) ||
456 ! isset( $_GET['_wpnonce'] ) ||
457 ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_wpnonce'] ) ), 'loginpress-review-nonce' ) ||
458 ! isset( $_GET['loginpress_review_later'] ) ) :
459
460 return;
461 endif;
462
463 // Reset Time to current time.
464 update_site_option( 'loginpress_active_time', time() );
465 }
466
467 /**
468 * Review notice message
469 *
470 * @since 1.0.11
471 */
472 public function loginpress_review_notice_message() {
473
474 $scheme = ( parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY ) ) ? '&' : '?';
475 $url = $_SERVER['REQUEST_URI'] . $scheme . 'loginpress_review_dismiss=yes';
476 $dismiss_url = wp_nonce_url( $url, 'loginpress-review-nonce' );
477
478 $_later_link = $_SERVER['REQUEST_URI'] . $scheme . 'loginpress_review_later=yes';
479 $later_url = wp_nonce_url( $_later_link, 'loginpress-review-nonce' );
480 ?>
481
482 <div class="loginpress-review-notice">
483 <div class="loginpress-review-thumbnail">
484 <img src="<?php echo plugins_url( 'img/thumbnail/gray-loginpress.png', __FILE__ ) ?>" alt="">
485 </div>
486 <div class="loginpress-review-text">
487 <h3><?php _e( 'Leave A Review?', 'loginpress' ) ?></h3>
488 <p><?php _e( 'We hope you\'ve enjoyed using LoginPress! Would you consider leaving us a review on WordPress.org?', 'loginpress' ) ?></p>
489 <ul class="loginpress-review-ul">
490 <li><a href="https://wordpress.org/support/view/plugin-reviews/loginpress?rate=5#postform" target="_blank"><span class="dashicons dashicons-external"></span><?php _e( 'Sure! I\'d love to!', 'loginpress' ) ?></a></li>
491 <li><a href="<?php echo $dismiss_url ?>"><span class="dashicons dashicons-smiley"></span><?php _e( 'I\'ve already left a review', 'loginpress' ) ?></a></li>
492 <li><a href="<?php echo $later_url ?>"><span class="dashicons dashicons-calendar-alt"></span><?php _e( 'Maybe Later', 'loginpress' ) ?></a></li>
493 <li><a href="<?php echo $dismiss_url ?>"><span class="dashicons dashicons-dismiss"></span><?php _e( 'Never show again', 'loginpress' ) ?></a></li></ul>
494 </div>
495 </div>
496 <?php
497 }
498
499 /**
500 * Add a link to the settings page to the plugins list
501 *
502 * @since 1.0.11
503 */
504 public function loginpress_action_links( $links, $file ) {
505
506 static $this_plugin;
507
508 if ( empty( $this_plugin ) ) {
509
510 $this_plugin = 'loginpress/loginpress.php';
511 }
512
513 if ( $file == $this_plugin ) {
514
515 $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>' );
516
517
518 if( 'yes' == get_option( '_loginpress_optin' ) ){
519 $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>' );
520 } else {
521 $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>' );
522 }
523
524 array_unshift( $links, $settings_link );
525
526 if ( ! has_action( 'loginpress_pro_add_template' ) ) :
527 $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>' );
528 array_push( $links, $pro_link );
529 endif;
530 }
531
532 return $links;
533 }
534
535 // function get_addon_info_( $api, $action, $args ) {
536
537 // if ( $action == 'plugin_information' && empty( $api ) && ( ! empty( $_GET['lgp'] ) ) ) {
538
539 // $raw_response = wp_remote_post( 'https://wpbrigade.com/loginpress-api/search.php', array(
540 // 'body' => array(
541 // 'slug' => $args->slug
542 // ) )
543 // );
544
545 // if ( is_wp_error( $raw_response ) || $raw_response['response']['code'] != 200 ) {
546 // return false;
547 // }
548
549 // $plugin = unserialize( $raw_response['body'] );
550
551 // $api = new stdClass();
552 // $api->name = $plugin['title'];
553 // $api->version = $plugin['version'];
554 // $api->download_link = $plugin['download_url'];
555 // $api->tested = '10.0';
556
557 // }
558
559 // return $api;
560 // }
561 } // End Of Class.
562 endif;
563
564
565 /**
566 * Returns the main instance of WP to prevent the need to use globals.
567 *
568 * @since 1.0.0
569 * @return LoginPress
570 */
571 function loginPress_loader() {
572 return LoginPress::instance();
573 }
574
575 // Call the function
576 loginPress_loader();
577
578 /**
579 * Create the Object of Custom Login Entites and Settings.
580 *
581 * @since 1.0.0
582 */
583 new LoginPress_Entities();
584 new LoginPress_Settings();
585
586 /**
587 * Create the Object of Remote Notification.
588 *
589 * @since 1.0.9
590 */
591 if (!class_exists('TAV_Remote_Notification_Client')) {
592 require( LOGINPRESS_ROOT_PATH . 'include/class-remote-notification-client.php' );
593 }
594 $notification = new TAV_Remote_Notification_Client( 125, '16765c0902705d62', 'http://wpbrigade.com?post_type=notification' );
595
596 register_activation_hook( __FILE__, array( 'LoginPress', 'plugin_activation' ) );
597 register_uninstall_hook( __FILE__, array( 'LoginPress', 'plugin_uninstallation' ) );
598 ?>
599