PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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/helpers/FrmTipsHelper.php +144 -118 6.5.2 → trunk View file →
@@ -26,10 +26,10 @@
26 26 * Shows tip.
27 27 *
28 28 * @since 6.0
29 29 *
30 - * @param array $tip {
31 - * Tip args
30 + * @param array $tip {
31 + * Tip args.
32 32 *
33 33 * @type array $link Tip link data. See the first parameter of {@see FrmAppHelper::admin_upgrade_link()} for more details.
34 34 * @type string $page The based link of the tip. If this is empty, `https://formidableforms.com/lite-upgrade/` will
35 35 * be used. Otherwise, `https://formidableforms.com/{$page}` will be used.
@@ -35,8 +35,9 @@
35 35 * be used. Otherwise, `https://formidableforms.com/{$page}` will be used.
36 36 * @type string $tip Tip text.
37 37 * @type string $call Call to action text.
38 38 * }
39 + *
39 40 * @param string $html
40 41 *
41 42 * @return void
42 43 */
@@ -46,10 +47,10 @@
46 47 'class' => 'frm-mt-0',
47 48 );
48 49 $tip = array_merge( $defaults, $tip );
49 50
50 - if ( isset( $tip['link'] ) && ! isset( $tip['link']['medium'] ) ) {
51 - $tip['link']['medium'] = 'tip';
51 + if ( isset( $tip['link'] ) && ! isset( $tip['link']['medium'] ) && ! isset( $tip['link']['campaign'] ) ) {
52 + $tip['link']['campaign'] = 'tip';
52 53 }
53 54
54 55 if ( 'p' === $html ) {
55 56 echo '<p class="frmcenter ' . esc_attr( $tip['class'] ) . '">';
@@ -54,27 +55,25 @@
54 55 if ( 'p' === $html ) {
55 56 echo '<p class="frmcenter ' . esc_attr( $tip['class'] ) . '">';
56 57 }
57 58
58 - $link = empty( $tip['link'] ) ? $tip['page'] : FrmAppHelper::admin_upgrade_link( $tip['link'], $tip['page'] );
59 + $link = self::get_tip_link( $tip );
60 + // phpcs:disable Generic.WhiteSpace.ScopeIndent
59 61 ?>
60 - <a href="<?php echo esc_url( $link ); ?>" <?php echo empty( $tip['link'] ) ? '' : 'target="_blank"'; ?> class="frm_pro_tip">
61 - <?php FrmAppHelper::icon_by_class( 'frmfont frm_lightning', array( 'aria-hidden' => 'true' ) ); ?>
62 + <a href="<?php echo esc_url( $link ); ?>" <?php echo ! empty( $tip['link'] ) ? 'target="_blank"' : ''; ?> class="frm_pro_tip frm-gradient">
63 + <span class="frm-tip-badge"><?php esc_html_e( 'PRO TIP', 'formidable' ); ?></span>
62 64
63 65 <?php if ( isset( $tip['call'] ) ) { ?>
64 66 <span class="frm-tip-info">
65 67 <?php echo esc_html( $tip['tip'] ); ?>
66 68 </span>
67 - <span class="frm-tip-cta">
68 - <?php echo esc_html( $tip['call'] ); ?>
69 - </span>
70 - <?php } else { ?>
71 - <span class="frm-tip-cta">
72 - <?php echo esc_html( $tip['tip'] ); ?>
73 - </span>
74 69 <?php } ?>
70 + <span class="frm-tip-cta">
71 + <?php echo esc_html( $tip['call'] ? $tip['call'] : $tip['tip'] ); ?>
72 + </span>
75 73 </a>
76 74 <?php
75 + // phpcs:enable Generic.WhiteSpace.ScopeIndent
77 76
78 77 if ( 'p' === $html ) {
79 78 echo '</p>';
80 79 }
@@ -80,8 +79,33 @@
80 79 }
81 80 }
82 81
83 82 /**
83 + * @since 6.21
84 + *
85 + * @param array $tip
86 + *
87 + * @return string
88 + */
89 + private static function get_tip_link( $tip ) {
90 + if ( empty( $tip['tip'] ) ) {
91 + return $tip['page'];
92 + }
93 +
94 + $cta_link = FrmSalesApi::get_best_sale_value( 'pro_tip_cta_link' );
95 +
96 + if ( $cta_link ) {
97 + if ( is_array( $tip['link'] ) ) {
98 + return FrmAppHelper::maybe_add_missing_utm( $cta_link, $tip['link'] );
99 + }
100 +
101 + return $cta_link;
102 + }
103 +
104 + return FrmAppHelper::admin_upgrade_link( $tip['link'], $tip['page'] );
105 + }
106 +
107 + /**
84 108 * Use the correct label for the license.
85 109 *
86 110 * @since 6.5.1
87 111 *
@@ -87,8 +111,14 @@
87 111 *
88 112 * @return string
89 113 */
90 114 private static function cta_label() {
115 + $cta_text = FrmSalesApi::get_best_sale_value( 'pro_tip_cta_text' );
116 +
117 + if ( $cta_text ) {
118 + return $cta_text;
119 + }
120 +
91 121 return FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro.', 'formidable' );
92 122 }
93 123
94 124 /**
@@ -94,9 +124,9 @@
94 124 /**
95 125 * @return array
96 126 */
97 127 public static function get_builder_tip() {
98 - $tips = array(
128 + return array(
99 129 array(
100 130 'link' => array(
101 131 'content' => 'conditional-logic',
102 132 'param' => 'conditional-logic-wordpress-forms',
@@ -108,10 +138,10 @@
108 138 'link' => array(
109 139 'content' => 'confirmation-fields',
110 140 'param' => 'confirmation-fields-wordpress-forms',
111 141 ),
112 - 'tip' => __( 'Want to stop losing leads from email typos?', 'formidable' ),
113 - 'call' => __( 'Add email confirmation fields.', 'formidable' ),
142 + 'tip' => __( 'Eliminate input errors with email confirmation fields.', 'formidable' ),
143 + 'call' => self::cta_label(),
114 144 ),
115 145 array(
116 146 'link' => array(
117 147 'content' => 'page-breaks',
@@ -124,17 +154,9 @@
124 154 'link' => array(
125 155 'content' => 'file-uploads',
126 156 'param' => 'wordpress-multi-file-upload-fields',
127 157 ),
128 - 'tip' => __( 'Cut down on back-and-forth with clients.', 'formidable' ),
129 - 'call' => __( 'Allow file uploads in your form.', 'formidable' ),
130 - ),
131 - array(
132 - 'link' => array(
133 - 'content' => 'calculations',
134 - 'param' => 'field-calculations-wordpress-form',
135 - ),
136 - 'tip' => __( 'Need to calculate a total?', 'formidable' ),
158 + 'tip' => __( 'Skip the follow-ups. Let users upload files.', 'formidable' ),
137 159 'call' => self::cta_label(),
138 160 ),
139 161 array(
140 162 'link' => array(
@@ -140,14 +162,12 @@
140 162 'link' => array(
141 163 'content' => 'prefill-fields',
142 164 'param' => 'auto-fill-forms',
143 165 ),
144 - 'tip' => __( 'Save time.', 'formidable' ),
145 - 'call' => __( 'Fill out forms automatically!', 'formidable' ),
166 + 'tip' => __( 'Save time with autofill forms.', 'formidable' ),
167 + 'call' => self::cta_label(),
146 168 ),
147 169 );
148 -
149 - return $tips;
150 170 }
151 171
152 172 /**
153 173 * @return array
@@ -152,16 +172,16 @@
152 172 /**
153 173 * @return array
154 174 */
155 175 public static function get_form_settings_tip() {
156 - $tips = array(
176 + return array(
157 177 array(
158 178 'link' => array(
159 179 'content' => 'front-edit-b',
160 180 'param' => 'wordpress-front-end-editing',
161 181 ),
162 - 'tip' => __( 'A site with dynamic, user-generated content is within reach.', 'formidable' ),
163 - 'call' => __( 'Add front-end editing.', 'formidable' ),
182 + 'tip' => __( 'Make your site dynamic. Enable front-end editing.', 'formidable' ),
183 + 'call' => self::cta_label(),
164 184 ),
165 185 array(
166 186 'link' => array(
167 187 'content' => 'save-drafts',
@@ -166,10 +186,10 @@
166 186 'link' => array(
167 187 'content' => 'save-drafts',
168 188 'param' => 'save-drafts-wordpress-form',
169 189 ),
170 - 'tip' => __( 'Have long forms?', 'formidable' ),
171 - 'call' => __( 'Let users save drafts and return later!', 'formidable' ),
190 + 'tip' => __( 'Long form? Let users save and finish later', 'formidable' ),
191 + 'call' => self::cta_label(),
172 192 ),
173 193 array(
174 194 'link' => array(
175 195 'content' => 'form-scheduling',
@@ -174,14 +194,12 @@
174 194 'link' => array(
175 195 'content' => 'form-scheduling',
176 196 'param' => 'schedule-forms-wordpress',
177 197 ),
178 - 'tip' => __( 'Want your form open only for a certain time period?', 'formidable' ),
179 - 'call' => __( 'Add form scheduling.', 'formidable' ),
198 + 'tip' => __( 'Limit form access with built-in scheduling.', 'formidable' ),
199 + 'call' => self::cta_label(),
180 200 ),
181 201 );
182 -
183 - return $tips;
184 202 }
185 203
186 204 /**
187 205 * @return array
@@ -186,16 +204,16 @@
186 204 /**
187 205 * @return array
188 206 */
189 207 public static function get_form_action_tip() {
190 - $tips = array(
208 + return array(
191 209 array(
192 210 'link' => array(
193 211 'content' => 'email-routing',
194 212 'param' => 'virtually-unlimited-emails',
195 213 ),
196 - 'tip' => __( 'Save time by sending the email to the right person automatically.', 'formidable' ),
197 - 'call' => __( 'Add email routing.', 'formidable' ),
214 + 'tip' => __( 'Save time — route emails to the right person automatically.', 'formidable' ),
215 + 'call' => self::cta_label(),
198 216 ),
199 217 array(
200 218 'link' => array(
201 219 'content' => 'create-posts',
@@ -216,29 +234,13 @@
216 234 'link' => array(
217 235 'content' => 'mailchimp',
218 236 'page' => 'mailchimp-tip',
219 237 ),
220 - 'tip' => __( 'Grow your business with automated email follow-up.', 'formidable' ),
221 - 'call' => __( 'Send leads straight to Mailchimp.', 'formidable' ),
238 + 'tip' => __( 'Send leads to Mailchimp for instant email follow-up.', 'formidable' ),
239 + 'call' => self::cta_label(),
222 240 ),
223 241 array(
224 242 'link' => array(
225 - 'content' => 'paypal-revenue',
226 - 'page' => 'paypal-increase-revenue-tip',
227 - ),
228 - 'tip' => __( 'Increase revenue.', 'formidable' ),
229 - 'call' => __( 'Use PayPal with this form.', 'formidable' ),
230 - ),
231 - array(
232 - 'link' => array(
233 - 'content' => 'paypal-fast',
234 - 'page' => 'paypal-save-time-tip',
235 - ),
236 - 'tip' => __( 'Get paid instantly.', 'formidable' ),
237 - 'call' => __( 'Use Paypal with this form.', 'formidable' ),
238 - ),
239 - array(
240 - 'link' => array(
241 243 'content' => 'registration',
242 244 'page' => 'registration-tip',
243 245 ),
244 246 'tip' => __( 'Automatically create user accounts.', 'formidable' ),
@@ -248,10 +250,10 @@
248 250 'link' => array(
249 251 'content' => 'profile',
250 252 'page' => 'registration-profile-editing-tip',
251 253 ),
252 - 'tip' => __( 'Need front-end profile editing?', 'formidable' ),
253 - 'call' => __( 'Add user registration.', 'formidable' ),
254 + 'tip' => __( 'Enable front-end profile editing with User Registration.', 'formidable' ),
255 + 'call' => self::cta_label(),
254 256 ),
255 257 array(
256 258 'link' => array(
257 259 'content' => 'twilio-payment',
@@ -256,10 +258,10 @@
256 258 'link' => array(
257 259 'content' => 'twilio-payment',
258 260 'page' => 'twilio-tip',
259 261 ),
260 - 'tip' => __( 'Want an SMS notification when a form is submitted or a payment received?', 'formidable' ),
261 - 'call' => __( 'Get the Twilio integration.', 'formidable' ),
262 + 'tip' => __( 'Get SMS alerts for form submissions and payments—just add Twilio.', 'formidable' ),
263 + 'call' => self::cta_label(),
262 264 ),
263 265 array(
264 266 'link' => array(
265 267 'content' => 'twilio',
@@ -264,10 +266,10 @@
264 266 'link' => array(
265 267 'content' => 'twilio',
266 268 'page' => 'twilio-send-tip',
267 269 ),
268 - 'tip' => __( 'Send an SMS message when a form is submitted.', 'formidable' ),
269 - 'call' => __( 'Get the Twilio integration.', 'formidable' ),
270 + 'tip' => __( 'Use Twilio to send SMS when forms are submitted.', 'formidable' ),
271 + 'call' => self::cta_label(),
270 272 ),
271 273 array(
272 274 'link' => array(
273 275 'content' => 'acf-tip',
@@ -272,14 +274,12 @@
272 274 'link' => array(
273 275 'content' => 'acf-tip',
274 276 'param' => 'acf-tip',
275 277 ),
276 - 'tip' => __( 'Fill Advanced Custom Fields from a form.', 'formidable' ),
277 - 'call' => __( 'Add ACF Integration', 'formidable' ),
278 + 'tip' => __( 'Fill Advanced Custom Fields automatically with form entries.', 'formidable' ),
279 + 'call' => self::cta_label(),
278 280 ),
279 281 );
280 -
281 - return $tips;
282 282 }
283 283
284 284 /**
285 285 * @return array
@@ -284,16 +284,16 @@
284 284 /**
285 285 * @return array
286 286 */
287 287 public static function get_styling_tip() {
288 - $tips = array(
288 + return array(
289 289 array(
290 290 'link' => array(
291 291 'content' => 'style',
292 292 'param' => 'wordpress-visual-form-styler',
293 293 ),
294 - 'tip' => __( 'Make your sidebar and footer forms stand out.', 'formidable' ),
295 - 'call' => __( 'Use multiple style templates.', 'formidable' ),
294 + 'tip' => __( 'Make your forms stand out with multiple style templates.', 'formidable' ),
295 + 'call' => self::cta_label(),
296 296 ),
297 297 array(
298 298 'link' => array(
299 299 'content' => 'style',
@@ -310,10 +310,8 @@
310 310 'tip' => __( 'Want to duplicate a style?', 'formidable' ),
311 311 'call' => self::cta_label(),
312 312 ),
313 313 );
314 -
315 - return $tips;
316 314 }
317 315
318 316 /**
319 317 * @return array
@@ -324,10 +322,10 @@
324 322 'link' => array(
325 323 'content' => 'entries',
326 324 'param' => 'form-entry-management-wordpress',
327 325 ),
328 - 'tip' => __( 'Want to edit form submissions?', 'formidable' ),
329 - 'call' => __( 'Add entry management.', 'formidable' ),
326 + 'tip' => __( 'Edit form entries anytime with entry management.', 'formidable' ),
327 + 'call' => self::cta_label(),
330 328 ),
331 329 array(
332 330 'link' => array(
333 331 'content' => 'entries-search',
@@ -340,15 +338,14 @@
340 338 'link' => array(
341 339 'content' => 'views',
342 340 'param' => 'views-display-form-data',
343 341 ),
344 - 'tip' => __( 'A site with dynamic, user-generated content is within reach.', 'formidable' ),
345 - 'call' => __( 'Display form data with Views.', 'formidable' ),
342 + 'tip' => __( 'Turn entries into dynamic content — no code needed.', 'formidable' ),
343 + 'call' => self::cta_label(),
346 344 ),
347 345 );
348 - $tips = array_merge( $tips, self::get_import_tip() );
349 346
350 - return $tips;
347 + return array_merge( $tips, self::get_import_tip() );
351 348 }
352 349
353 350 /**
354 351 * @return array
@@ -353,9 +350,9 @@
353 350 /**
354 351 * @return array
355 352 */
356 353 public static function get_import_tip() {
357 - $tips = array(
354 + return array(
358 355 array(
359 356 'link' => array(
360 357 'content' => 'import',
361 358 'param' => 'importing-exporting-wordpress-forms',
@@ -363,51 +360,80 @@
363 360 'tip' => __( 'Want to import entries into your forms?', 'formidable' ),
364 361 'call' => self::cta_label(),
365 362 ),
366 363 );
364 + }
367 365
368 - return $tips;
366 + /**
367 + * @param array $tips
368 + *
369 + * @return array
370 + */
371 + public static function get_random_tip( $tips ) {
372 + $count = count( $tips );
373 +
374 + if ( $count === 0 ) {
375 + return array();
376 + }
377 +
378 + $random = random_int( 0, $count - 1 );
379 + return $tips[ $random ];
369 380 }
370 381
371 382 /**
372 - * @return array
383 + * Displays a call-to-action section in the admin area.
384 + *
385 + * @since 6.7
386 + *
387 + * @param array $args {
388 + * An array of arguments to configure the call-to-action section.
389 + *
390 + * @type string $title The title of the section.
391 + * @type string $description The description of the section.
392 + * @type string $link_text The text for the link.
393 + * @type string $link_url The URL for the link.
394 + * @type string $role The required user role to view the section. Default 'administrator'.
395 + * }
396 + *
397 + * @return void
373 398 */
374 - public static function get_banner_tip() {
375 - $tips = array(
376 - array(
377 - 'link' => array(
378 - 'medium' => 'banner',
379 - 'content' => 'professional-results',
380 - ),
381 - 'tip' => __( 'Looking for more ways to get professional results?', 'formidable' ),
382 - 'call' => __( 'Take your forms to the next level.', 'formidable' ),
383 - ),
384 - array(
385 - 'link' => array(
386 - 'medium' => 'banner',
387 - 'content' => 'increase-conversions',
388 - ),
389 - 'tip' => __( 'Increase conversions in long forms.', 'formidable' ),
390 - 'call' => __( 'Add conditional logic, page breaks, and section headings.', 'formidable' ),
391 - ),
392 - array(
393 - 'link' => array(
394 - 'medium' => 'banner',
395 - 'content' => 'automate',
396 - ),
397 - 'tip' => __( 'Automate your business and increase revenue.', 'formidable' ),
398 - 'call' => __( 'Collect instant payments, and send leads to Mailchimp.', 'formidable' ),
399 - ),
399 + public static function show_admin_cta( $args ) {
400 + $role = ! empty( $args['role'] ) ? $args['role'] : 'administrator';
401 +
402 + if ( ! current_user_can( $role ) ) {
403 + // Return early if the user doesn't have the required capability.
404 + return;
405 + }
406 +
407 + $defaults = array(
408 + 'title' => '',
409 + 'description' => '',
410 + 'link_text' => '',
411 + 'link_url' => '#',
412 + 'class' => '',
413 + 'id' => '',
414 + 'target' => '_blank',
400 415 );
401 - $random = rand( 0, count( $tips ) - 1 );
402 - $tip = $tips[ $random ];
403 - $tip['num'] = $random;
404 416
405 - return $tip;
417 + $args = wp_parse_args( $args, $defaults );
418 +
419 + $attributes = array(
420 + 'class' => trim( 'frm-cta frm-flex frm-p-sm ' . $args['class'] ),
421 + );
422 +
423 + if ( $args['id'] ) {
424 + $attributes['id'] = $args['id'];
425 + }
426 +
427 + require FrmAppHelper::plugin_path() . '/classes/views/shared/admin-cta.php';
406 428 }
407 429
408 - public static function get_random_tip( $tips ) {
409 - $random = rand( 0, count( $tips ) - 1 );
410 -
411 - return $tips[ $random ];
430 + /**
431 + * @deprecated 6.21
432 + *
433 + * @return array
434 + */
435 + public static function get_banner_tip() {
436 + _deprecated_function( __METHOD__, '6.21' );
437 + return array();
412 438 }
413 439 }