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

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