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

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