PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.8.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.8.3
4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 340 releases
profile-builder / admin / review.php

review.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.8.3, at admin/review.php

133 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WPPB_Review_Request {
4
5 // Number of days to wait until review request is displayed
6 public $delay = 7;
7 public $wppb_review_cron_hook = 'wppb_review_check';
8 public $notificationId = 'wppb_review_request';
9 public $query_arg = 'wppb_dismiss_admin_notification';
10
11 public function __construct() {
12 $wppb_review_request_status = get_option( 'wppb_review_request_status', 'not_found' );
13
14 // Initialize the option that keeps track of the number of days elapsed
15 if ( $wppb_review_request_status === 'not_found' || !is_numeric( $wppb_review_request_status ) ) {
16 update_option( 'wppb_review_request_status', 0 );
17 }
18
19 // Handle the cron
20 if ( $wppb_review_request_status <= $this->delay ) {
21 if ( !wp_next_scheduled( $this->wppb_review_cron_hook ) ) {
22 wp_schedule_event( time(), 'daily', $this->wppb_review_cron_hook );
23 }
24
25 if ( !has_action( $this->wppb_review_cron_hook ) ) {
26 add_action( $this->wppb_review_cron_hook, array( $this, 'check_for_registration_shortcode' ) );
27 }
28 } else if ( wp_next_scheduled( $this->wppb_review_cron_hook ) ){
29 wp_clear_scheduled_hook( $this->wppb_review_cron_hook );
30 }
31
32 // Admin notice requesting review
33 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
34 add_action( 'admin_init', array( $this, 'dismiss_notification' ) );
35 // Footer text requesting review
36 add_filter('admin_footer_text', array( $this, 'admin_footer_rate_us' ) );
37 }
38
39 // Function that looks for the PB registration form shortcode and counts the number of days elapsed
40 public function check_for_registration_shortcode() {
41 global $wpdb;
42
43 $query = "SELECT ID, post_title, guid FROM ".$wpdb->posts." WHERE post_content LIKE '%[wppb-register%' AND post_status = 'publish'";
44
45 if ( !empty( $wpdb->get_results( $query ) ) ) {
46 $wppb_review_request_status = get_option( 'wppb_review_request_status', 'not_found' );
47
48 if ( $wppb_review_request_status !== 'not_found' && is_numeric( $wppb_review_request_status ) ) {
49 update_option( 'wppb_review_request_status', $wppb_review_request_status + 1 );
50 } else {
51 update_option( 'wppb_review_request_status', 1 );
52 }
53 }
54 }
55
56 // Function that displays the notice
57 public function admin_notices() {
58 $wppb_review_request_status = get_option( 'wppb_review_request_status' );
59
60 if ( is_numeric( $wppb_review_request_status ) && $wppb_review_request_status > $this->delay ) {
61 global $current_user;
62 global $pagenow;
63
64 $user_id = $current_user->ID;
65
66 if ( current_user_can( 'manage_options' ) ) {
67 // Check that the user hasn't already dismissed the message
68 if ( !get_user_meta( $user_id, $this->notificationId . '_dismiss_notification' ) ) {
69 do_action( $this->notificationId . '_before_notification_displayed', $current_user, $pagenow );
70 ?>
71 <div class="wppb-review-notice wppb-notice notice is-dismissible">
72 <p style="margin-top: 16px; font-size: 15px;">
73 <?php esc_html_e("Hello! Seems like you've been using Profile Builder to create front-end user forms. That's awesome!", 'profile-builder'); ?>
74 <br/>
75 <?php esc_html_e("If you can spare a few moments to rate it on WordPress.org, it would help us a lot (and boost my motivation).", 'profile-builder'); ?>
76 </p>
77 <p>
78 <?php esc_html_e("~ Paul, developer of Profile Builder", 'profile-builder'); ?>
79 </p>
80 <p></p>
81 <p>
82 <a href="https://wordpress.org/support/plugin/profile-builder/reviews/?filter=5#new-post"
83 target="_blank" rel="noopener" class="button-primary" style="margin-right: 20px">
84 <?php esc_html_e('Ok, I will gladly help!', 'profile-builder'); ?>
85 </a>
86 <a href="<?php echo esc_url( add_query_arg(array($this->query_arg => $this->notificationId)) ) ?>"
87 class="button-secondary">
88 <?php esc_html_e('No, thanks.', 'profile-builder'); ?>
89 </a>
90 </p>
91 <a href="<?php echo esc_url( add_query_arg(array($this->query_arg => $this->notificationId)) ) ?>"
92 type="button" class="notice-dismiss" style="text-decoration: none;">
93 <span class="screen-reader-text">
94 <?php esc_html_e('Dismiss this notice.', 'profile-builder'); ?>
95 </span>
96 </a>
97 </div>
98 <?php
99 do_action( $this->notificationId . '_after_notification_displayed', $current_user, $pagenow );
100 }
101 }
102 }
103 }
104
105 // Function that saves the notification dismissal to the user meta
106 public function dismiss_notification() {
107 global $current_user;
108
109 $user_id = $current_user->ID;
110
111 // If user clicks to ignore the notice, add that to their user meta
112 if ( isset( $_GET[$this->query_arg] ) && $this->notificationId === $_GET[$this->query_arg] ) {
113 do_action( $this->notificationId.'_before_notification_dismissed', $current_user );
114 add_user_meta($user_id, $this->notificationId . '_dismiss_notification', 'true', true);
115 do_action( $this->notificationId.'_after_notification_dismissed', $current_user );
116 }
117 }
118
119 // Function that adds admin footer text for encouraging users to leave a review of the plugin on wordpress.org
120 function admin_footer_rate_us( $footer_text ) {
121 global $current_screen;
122
123 if ( $current_screen->parent_base == 'profile-builder' ){
124 $rate_text = sprintf( __( 'If you enjoy using <strong> %1$s </strong> please <a href="%2$s" target="_blank">rate us on WordPress.org</a>. More happy users means more features, less bugs and better support for everyone. ', 'profile-builder' ),
125 PROFILE_BUILDER,
126 'https://wordpress.org/support/view/plugin-reviews/profile-builder?filter=5#postform'
127 );
128 return '<span id="footer-thankyou">' .$rate_text . '</span>';
129 } else {
130 return $footer_text;
131 }
132 }
133 }