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

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