PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.0
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmReviews.php +25 -57 6.356.0 View file →
@@ -4,21 +4,12 @@
4 4 }
5 5
6 6 class FrmReviews {
7 7
8 - /**
9 - * @var string
10 - */
11 8 private $option_name = 'frm_reviewed';
12 9
13 - /**
14 - * @var array
15 - */
16 10 private $review_status = array();
17 11
18 - /**
19 - * @var string
20 - */
21 12 private $inbox_key = 'review';
22 13
23 14 /**
24 15 * Add admin notices as needed for reviews
@@ -23,12 +14,11 @@
23 14 /**
24 15 * Add admin notices as needed for reviews
25 16 *
26 17 * @since 3.04.03
27 - *
28 - * @return void
29 18 */
30 19 public function review_request() {
20 +
31 21 // Only show the review request to high-level users on Formidable pages
32 22 if ( ! current_user_can( 'frm_change_settings' ) || ! FrmAppHelper::is_formidable_admin() ) {
33 23 return;
34 24 }
@@ -37,16 +27,15 @@
37 27 $this->set_review_status();
38 28
39 29 // Check if it has been dismissed or if we can ask later
40 30 $dismissed = $this->review_status['dismissed'];
41 -
42 31 if ( $dismissed === 'later' && $this->review_status['asked'] < 3 ) {
43 32 $dismissed = false;
44 33 }
45 34
46 - $week_ago = $this->review_status['time'] + WEEK_IN_SECONDS <= time();
35 + $week_ago = ( $this->review_status['time'] + WEEK_IN_SECONDS ) <= time();
47 36
48 - if ( ! $dismissed && $week_ago ) {
37 + if ( empty( $dismissed ) && $week_ago ) {
49 38 $this->review();
50 39 }
51 40 }
52 41
@@ -53,10 +42,8 @@
53 42 /**
54 43 * When was the review request last dismissed?
55 44 *
56 45 * @since 3.04.03
57 - *
58 - * @return void
59 46 */
60 47 private function set_review_status() {
61 48 $user_id = get_current_user_id();
62 49 $review = get_user_meta( $user_id, $this->option_name, true );
@@ -65,9 +52,9 @@
65 52 'dismissed' => false,
66 53 'asked' => 0,
67 54 );
68 55
69 - if ( ! $review ) {
56 + if ( empty( $review ) ) {
70 57 // Set the review request to show in a week
71 58 update_user_meta( $user_id, $this->option_name, $default );
72 59 }
73 60
@@ -79,13 +66,12 @@
79 66 /**
80 67 * Maybe show review request
81 68 *
82 69 * @since 3.04.03
83 - *
84 - * @return void
85 70 */
86 71 private function review() {
87 - // Show the review request 3 times, depending on the number of entries
72 +
73 + // show the review request 3 times, depending on the number of entries
88 74 $show_intervals = array( 50, 200, 500 );
89 75 $asked = $this->review_status['asked'];
90 76
91 77 if ( ! isset( $show_intervals[ $asked ] ) ) {
@@ -97,9 +83,9 @@
97 83 $user = wp_get_current_user();
98 84
99 85 // Only show review request if the site has collected enough entries
100 86 if ( $entries < $count ) {
101 - // Check the entry count again in a week
87 + // check the entry count again in a week
102 88 $this->review_status['time'] = time();
103 89 update_user_meta( $user->ID, $this->option_name, $this->review_status );
104 90
105 91 return;
@@ -104,18 +90,24 @@
104 90
105 91 return;
106 92 }
107 93
108 - $entries = $entries <= 100 ? floor( $entries / 10 ) * 10 : floor( $entries / 50 ) * 50;
109 - $name = $user->first_name;
110 -
111 - if ( $name ) {
94 + if ( $entries <= 100 ) {
95 + // round to the nearest 10
96 + $entries = floor( $entries / 10 ) * 10;
97 + } else {
98 + // round to the nearest 50
99 + $entries = floor( $entries / 50 ) * 50;
100 + }
101 + $name = $user->first_name;
102 + if ( ! empty( $name ) ) {
112 103 $name = ' ' . $name;
113 104 }
114 105
115 106 $title = sprintf(
116 - /* translators: %1$d: number of entries */
117 - esc_html__( 'You have collected %1$d form submissions.', 'formidable' ),
107 + /* translators: %s: User name, %2$d: number of entries */
108 + esc_html__( 'Congratulations%1$s! You have collected %2$d form submissions.', 'formidable' ),
109 + esc_html( $name ),
118 110 absint( $entries )
119 111 );
120 112
121 113 $this->add_to_inbox( $title, $name, $asked );
@@ -120,20 +112,13 @@
120 112
121 113 $this->add_to_inbox( $title, $name, $asked );
122 114
123 115 // We have a candidate! Output a review message.
124 - include FrmAppHelper::plugin_path() . '/classes/views/shared/review.php';
116 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/review.php' );
125 117 }
126 118
127 - /**
128 - * @param string $title
129 - * @param string $name
130 - * @param int $asked
131 - *
132 - * @return void
133 - */
134 119 private function add_to_inbox( $title, $name, $asked ) {
135 - $message = new FrmInbox();
120 + $message = new FrmInbox();
136 121 $requests = $message->get_messages();
137 122 $key = $this->inbox_key . ( $asked ? $asked : '' );
138 123
139 124 if ( isset( $requests[ $key ] ) ) {
@@ -143,9 +128,8 @@
143 128 // Remove previous requests.
144 129 if ( $asked > 0 ) {
145 130 $message->remove( $this->inbox_key );
146 131 }
147 -
148 132 if ( $asked > 1 ) {
149 133 $message->remove( $this->inbox_key . '1' );
150 134 }
151 135
@@ -156,13 +140,13 @@
156 140
157 141 $message->add_message(
158 142 array(
159 143 'key' => $key,
160 - 'message' => __( 'If you are enjoying Formidable, could you do me a BIG favor and give us a review to help me grow my little business and boost our motivation?', 'formidable' ) . '<br/>' . // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
144 + 'message' => __( 'If you are enjoying Formidable, could you do me a BIG favor and give us a review to help me grow my little business and boost our motivation?', 'formidable' ) . '<br/>' .
161 145 '- Steph Wells<br/>' .
162 146 '<span>' . esc_html__( 'Co-Founder and CTO of Formidable Forms', 'formidable' ) . '<span>',
163 147 'subject' => str_replace( $name, '', $title ),
164 - 'cta' => '<a href="https://wordpress.org/support/plugin/formidable/reviews/?filter=5#new-post" class="frm-dismiss-review-notice frm-review-out button frm-button-secondary" data-link="yes" target="_blank" rel="noopener noreferrer">' . // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
148 + 'cta' => '<a href="https://wordpress.org/support/plugin/formidable/reviews/?filter=5#new-post" class="frm-dismiss-review-notice frm-review-out button frm-button-secondary" data-link="yes" target="_blank" rel="noopener noreferrer">' .
165 149 esc_html__( 'Ok, you deserve it', 'formidable' ) . '</a>',
166 150 'type' => 'feedback',
167 151 )
168 152 );
@@ -171,13 +155,8 @@
171 155 /**
172 156 * If there are already later requests, don't add it to the inbox again.
173 157 *
174 158 * @since 4.05.02
175 - *
176 - * @param array $requests Array of requests.
177 - * @param int $asked Number of times the review has been asked.
178 - *
179 - * @return bool
180 159 */
181 160 private function has_later_request( $requests, $asked ) {
182 161 return isset( $requests[ $this->inbox_key . ( $asked + 1 ) ] ) || isset( $requests[ $this->inbox_key . ( $asked + 2 ) ] );
183 162 }
@@ -183,10 +162,8 @@
183 162 }
184 163
185 164 /**
186 165 * @since 4.05.02
187 - *
188 - * @return array
189 166 */
190 167 private function inbox_keys() {
191 168 return array(
192 169 $this->inbox_key,
@@ -196,14 +173,11 @@
196 173 }
197 174
198 175 /**
199 176 * @since 4.05.01
200 - *
201 - * @return void
202 177 */
203 178 private function set_inbox_dismissed() {
204 179 $message = new FrmInbox();
205 -
206 180 foreach ( $this->inbox_keys() as $key ) {
207 181 $message->dismiss( $key );
208 182 }
209 183 }
@@ -209,14 +183,11 @@
209 183 }
210 184
211 185 /**
212 186 * @since 4.05.01
213 - *
214 - * @return void
215 187 */
216 188 private function set_inbox_read() {
217 189 $message = new FrmInbox();
218 -
219 190 foreach ( $this->inbox_keys() as $key ) {
220 191 $message->mark_read( $key );
221 192 }
222 193 }
@@ -224,10 +195,8 @@
224 195 /**
225 196 * Save the request to hide the review
226 197 *
227 198 * @since 3.04.03
228 - *
229 - * @return void
230 199 */
231 200 public function dismiss_review() {
232 201 FrmAppHelper::permission_check( 'frm_change_settings' );
233 202 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -233,15 +202,14 @@
233 202 check_ajax_referer( 'frm_ajax', 'nonce' );
234 203
235 204 $user_id = get_current_user_id();
236 205 $review = get_user_meta( $user_id, $this->option_name, true );
237 -
238 - if ( ! $review ) {
206 + if ( empty( $review ) ) {
239 207 $review = array();
240 208 }
241 209
242 210 if ( isset( $review['dismissed'] ) && $review['dismissed'] === 'done' ) {
243 - // If feedback was submitted, don't update it again when the review is dismissed
211 + // if feedback was submitted, don't update it again when the review is dismissed
244 212 $this->set_inbox_dismissed();
245 213 wp_die();
246 214 }
247 215