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 +164 -127 6.5 → 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,12 +79,54 @@
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 + /**
108 + * Use the correct label for the license.
109 + *
110 + * @since 6.5.1
111 + *
112 + * @return string
113 + */
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 +
121 + return FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro.', 'formidable' );
122 + }
123 +
124 + /**
84 125 * @return array
85 126 */
86 127 public static function get_builder_tip() {
87 - $tips = array(
128 + return array(
88 129 array(
89 130 'link' => array(
90 131 'content' => 'conditional-logic',
91 132 'param' => 'conditional-logic-wordpress-forms',
@@ -90,9 +131,9 @@
90 131 'content' => 'conditional-logic',
91 132 'param' => 'conditional-logic-wordpress-forms',
92 133 ),
93 134 'tip' => __( 'Use conditional logic to shorten your forms and increase conversions.', 'formidable' ),
94 - 'call' => __( 'Upgrade to Pro.', 'formidable' ),
135 + 'call' => self::cta_label(),
95 136 ),
96 137 array(
97 138 'link' => array(
98 139 'content' => 'confirmation-fields',
@@ -97,10 +138,10 @@
97 138 'link' => array(
98 139 'content' => 'confirmation-fields',
99 140 'param' => 'confirmation-fields-wordpress-forms',
100 141 ),
101 - 'tip' => __( 'Want to stop losing leads from email typos?', 'formidable' ),
102 - 'call' => __( 'Add email confirmation fields.', 'formidable' ),
142 + 'tip' => __( 'Eliminate input errors with email confirmation fields.', 'formidable' ),
143 + 'call' => self::cta_label(),
103 144 ),
104 145 array(
105 146 'link' => array(
106 147 'content' => 'page-breaks',
@@ -106,9 +147,9 @@
106 147 'content' => 'page-breaks',
107 148 'param' => 'wordpress-multi-page-forms',
108 149 ),
109 150 'tip' => __( 'Use page breaks for easier forms.', 'formidable' ),
110 - 'call' => __( 'Upgrade to Pro.', 'formidable' ),
151 + 'call' => self::cta_label(),
111 152 ),
112 153 array(
113 154 'link' => array(
114 155 'content' => 'file-uploads',
@@ -113,30 +154,20 @@
113 154 'link' => array(
114 155 'content' => 'file-uploads',
115 156 'param' => 'wordpress-multi-file-upload-fields',
116 157 ),
117 - 'tip' => __( 'Cut down on back-and-forth with clients.', 'formidable' ),
118 - 'call' => __( 'Allow file uploads in your form.', 'formidable' ),
158 + 'tip' => __( 'Skip the follow-ups. Let users upload files.', 'formidable' ),
159 + 'call' => self::cta_label(),
119 160 ),
120 161 array(
121 162 'link' => array(
122 - 'content' => 'calculations',
123 - 'param' => 'field-calculations-wordpress-form',
124 - ),
125 - 'tip' => __( 'Need to calculate a total?', 'formidable' ),
126 - 'call' => __( 'Upgrade to Pro.', 'formidable' ),
127 - ),
128 - array(
129 - 'link' => array(
130 163 'content' => 'prefill-fields',
131 164 'param' => 'auto-fill-forms',
132 165 ),
133 - 'tip' => __( 'Save time.', 'formidable' ),
134 - 'call' => __( 'Fill out forms automatically!', 'formidable' ),
166 + 'tip' => __( 'Save time with autofill forms.', 'formidable' ),
167 + 'call' => self::cta_label(),
135 168 ),
136 169 );
137 -
138 - return $tips;
139 170 }
140 171
141 172 /**
142 173 * @return array
@@ -141,16 +172,16 @@
141 172 /**
142 173 * @return array
143 174 */
144 175 public static function get_form_settings_tip() {
145 - $tips = array(
176 + return array(
146 177 array(
147 178 'link' => array(
148 179 'content' => 'front-edit-b',
149 180 'param' => 'wordpress-front-end-editing',
150 181 ),
151 - 'tip' => __( 'A site with dynamic, user-generated content is within reach.', 'formidable' ),
152 - 'call' => __( 'Add front-end editing.', 'formidable' ),
182 + 'tip' => __( 'Make your site dynamic. Enable front-end editing.', 'formidable' ),
183 + 'call' => self::cta_label(),
153 184 ),
154 185 array(
155 186 'link' => array(
156 187 'content' => 'save-drafts',
@@ -155,10 +186,10 @@
155 186 'link' => array(
156 187 'content' => 'save-drafts',
157 188 'param' => 'save-drafts-wordpress-form',
158 189 ),
159 - 'tip' => __( 'Have long forms?', 'formidable' ),
160 - '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(),
161 192 ),
162 193 array(
163 194 'link' => array(
164 195 'content' => 'form-scheduling',
@@ -163,14 +194,12 @@
163 194 'link' => array(
164 195 'content' => 'form-scheduling',
165 196 'param' => 'schedule-forms-wordpress',
166 197 ),
167 - 'tip' => __( 'Want your form open only for a certain time period?', 'formidable' ),
168 - 'call' => __( 'Add form scheduling.', 'formidable' ),
198 + 'tip' => __( 'Limit form access with built-in scheduling.', 'formidable' ),
199 + 'call' => self::cta_label(),
169 200 ),
170 201 );
171 -
172 - return $tips;
173 202 }
174 203
175 204 /**
176 205 * @return array
@@ -175,16 +204,16 @@
175 204 /**
176 205 * @return array
177 206 */
178 207 public static function get_form_action_tip() {
179 - $tips = array(
208 + return array(
180 209 array(
181 210 'link' => array(
182 211 'content' => 'email-routing',
183 212 'param' => 'virtually-unlimited-emails',
184 213 ),
185 - 'tip' => __( 'Save time by sending the email to the right person automatically.', 'formidable' ),
186 - 'call' => __( 'Add email routing.', 'formidable' ),
214 + 'tip' => __( 'Save time — route emails to the right person automatically.', 'formidable' ),
215 + 'call' => self::cta_label(),
187 216 ),
188 217 array(
189 218 'link' => array(
190 219 'content' => 'create-posts',
@@ -190,9 +219,9 @@
190 219 'content' => 'create-posts',
191 220 'param' => 'create-posts-pages-wordpress-forms',
192 221 ),
193 222 'tip' => __( 'Create blog posts or pages from the front-end.', 'formidable' ),
194 - 'call' => __( 'Upgrade to Pro.', 'formidable' ),
223 + 'call' => self::cta_label(),
195 224 ),
196 225 array(
197 226 'link' => array(
198 227 'content' => 'user-submit',
@@ -198,9 +227,9 @@
198 227 'content' => 'user-submit',
199 228 'param' => 'create-posts-pages-wordpress-forms',
200 229 ),
201 230 'tip' => __( 'Let your users submit posts on the front-end.', 'formidable' ),
202 - 'call' => __( 'Upgrade to Pro.', 'formidable' ),
231 + 'call' => self::cta_label(),
203 232 ),
204 233 array(
205 234 'link' => array(
206 235 'content' => 'mailchimp',
@@ -205,29 +234,13 @@
205 234 'link' => array(
206 235 'content' => 'mailchimp',
207 236 'page' => 'mailchimp-tip',
208 237 ),
209 - 'tip' => __( 'Grow your business with automated email follow-up.', 'formidable' ),
210 - 'call' => __( 'Send leads straight to Mailchimp.', 'formidable' ),
238 + 'tip' => __( 'Send leads to Mailchimp for instant email follow-up.', 'formidable' ),
239 + 'call' => self::cta_label(),
211 240 ),
212 241 array(
213 242 'link' => array(
214 - 'content' => 'paypal-revenue',
215 - 'page' => 'paypal-increase-revenue-tip',
216 - ),
217 - 'tip' => __( 'Increase revenue.', 'formidable' ),
218 - 'call' => __( 'Use PayPal with this form.', 'formidable' ),
219 - ),
220 - array(
221 - 'link' => array(
222 - 'content' => 'paypal-fast',
223 - 'page' => 'paypal-save-time-tip',
224 - ),
225 - 'tip' => __( 'Get paid instantly.', 'formidable' ),
226 - 'call' => __( 'Use Paypal with this form.', 'formidable' ),
227 - ),
228 - array(
229 - 'link' => array(
230 243 'content' => 'registration',
231 244 'page' => 'registration-tip',
232 245 ),
233 246 'tip' => __( 'Automatically create user accounts.', 'formidable' ),
@@ -237,10 +250,10 @@
237 250 'link' => array(
238 251 'content' => 'profile',
239 252 'page' => 'registration-profile-editing-tip',
240 253 ),
241 - 'tip' => __( 'Need front-end profile editing?', 'formidable' ),
242 - 'call' => __( 'Add user registration.', 'formidable' ),
254 + 'tip' => __( 'Enable front-end profile editing with User Registration.', 'formidable' ),
255 + 'call' => self::cta_label(),
243 256 ),
244 257 array(
245 258 'link' => array(
246 259 'content' => 'twilio-payment',
@@ -245,10 +258,10 @@
245 258 'link' => array(
246 259 'content' => 'twilio-payment',
247 260 'page' => 'twilio-tip',
248 261 ),
249 - 'tip' => __( 'Want an SMS notification when a form is submitted or a payment received?', 'formidable' ),
250 - '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(),
251 264 ),
252 265 array(
253 266 'link' => array(
254 267 'content' => 'twilio',
@@ -253,10 +266,10 @@
253 266 'link' => array(
254 267 'content' => 'twilio',
255 268 'page' => 'twilio-send-tip',
256 269 ),
257 - 'tip' => __( 'Send an SMS message when a form is submitted.', 'formidable' ),
258 - 'call' => __( 'Get the Twilio integration.', 'formidable' ),
270 + 'tip' => __( 'Use Twilio to send SMS when forms are submitted.', 'formidable' ),
271 + 'call' => self::cta_label(),
259 272 ),
260 273 array(
261 274 'link' => array(
262 275 'content' => 'acf-tip',
@@ -261,14 +274,12 @@
261 274 'link' => array(
262 275 'content' => 'acf-tip',
263 276 'param' => 'acf-tip',
264 277 ),
265 - 'tip' => __( 'Fill Advanced Custom Fields from a form.', 'formidable' ),
266 - 'call' => __( 'Add ACF Integration', 'formidable' ),
278 + 'tip' => __( 'Fill Advanced Custom Fields automatically with form entries.', 'formidable' ),
279 + 'call' => self::cta_label(),
267 280 ),
268 281 );
269 -
270 - return $tips;
271 282 }
272 283
273 284 /**
274 285 * @return array
@@ -273,16 +284,16 @@
273 284 /**
274 285 * @return array
275 286 */
276 287 public static function get_styling_tip() {
277 - $tips = array(
288 + return array(
278 289 array(
279 290 'link' => array(
280 291 'content' => 'style',
281 292 'param' => 'wordpress-visual-form-styler',
282 293 ),
283 - 'tip' => __( 'Make your sidebar and footer forms stand out.', 'formidable' ),
284 - 'call' => __( 'Use multiple style templates.', 'formidable' ),
294 + 'tip' => __( 'Make your forms stand out with multiple style templates.', 'formidable' ),
295 + 'call' => self::cta_label(),
285 296 ),
286 297 array(
287 298 'link' => array(
288 299 'content' => 'style',
@@ -288,9 +299,9 @@
288 299 'content' => 'style',
289 300 'param' => 'bg-image-style-settings',
290 301 ),
291 302 'tip' => __( 'Want to add a background image?', 'formidable' ),
292 - 'call' => __( 'Upgrade to Pro.', 'formidable' ),
303 + 'call' => self::cta_label(),
293 304 ),
294 305 array(
295 306 'link' => array(
296 307 'content' => 'style',
@@ -296,13 +307,11 @@
296 307 'content' => 'style',
297 308 'param' => 'duplicate-style',
298 309 ),
299 310 'tip' => __( 'Want to duplicate a style?', 'formidable' ),
300 - 'call' => __( 'Upgrade to Pro.', 'formidable' ),
311 + 'call' => self::cta_label(),
301 312 ),
302 313 );
303 -
304 - return $tips;
305 314 }
306 315
307 316 /**
308 317 * @return array
@@ -313,10 +322,10 @@
313 322 'link' => array(
314 323 'content' => 'entries',
315 324 'param' => 'form-entry-management-wordpress',
316 325 ),
317 - 'tip' => __( 'Want to edit form submissions?', 'formidable' ),
318 - 'call' => __( 'Add entry management.', 'formidable' ),
326 + 'tip' => __( 'Edit form entries anytime with entry management.', 'formidable' ),
327 + 'call' => self::cta_label(),
319 328 ),
320 329 array(
321 330 'link' => array(
322 331 'content' => 'entries-search',
@@ -322,9 +331,9 @@
322 331 'content' => 'entries-search',
323 332 'param' => 'form-entry-management-wordpress',
324 333 ),
325 334 'tip' => __( 'Want to search submitted entries?', 'formidable' ),
326 - 'call' => __( 'Upgrade to Pro.', 'formidable' ),
335 + 'call' => self::cta_label(),
327 336 ),
328 337 array(
329 338 'link' => array(
330 339 'content' => 'views',
@@ -329,15 +338,14 @@
329 338 'link' => array(
330 339 'content' => 'views',
331 340 'param' => 'views-display-form-data',
332 341 ),
333 - 'tip' => __( 'A site with dynamic, user-generated content is within reach.', 'formidable' ),
334 - 'call' => __( 'Display form data with Views.', 'formidable' ),
342 + 'tip' => __( 'Turn entries into dynamic content — no code needed.', 'formidable' ),
343 + 'call' => self::cta_label(),
335 344 ),
336 345 );
337 - $tips = array_merge( $tips, self::get_import_tip() );
338 346
339 - return $tips;
347 + return array_merge( $tips, self::get_import_tip() );
340 348 }
341 349
342 350 /**
343 351 * @return array
@@ -342,9 +350,9 @@
342 350 /**
343 351 * @return array
344 352 */
345 353 public static function get_import_tip() {
346 - $tips = array(
354 + return array(
347 355 array(
348 356 'link' => array(
349 357 'content' => 'import',
350 358 'param' => 'importing-exporting-wordpress-forms',
@@ -349,54 +357,83 @@
349 357 'content' => 'import',
350 358 'param' => 'importing-exporting-wordpress-forms',
351 359 ),
352 360 'tip' => __( 'Want to import entries into your forms?', 'formidable' ),
353 - 'call' => __( 'Upgrade to Pro.', 'formidable' ),
361 + 'call' => self::cta_label(),
354 362 ),
355 363 );
364 + }
356 365
357 - 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 ];
358 380 }
359 381
360 382 /**
361 - * @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
362 398 */
363 - public static function get_banner_tip() {
364 - $tips = array(
365 - array(
366 - 'link' => array(
367 - 'medium' => 'banner',
368 - 'content' => 'professional-results',
369 - ),
370 - 'tip' => __( 'Looking for more ways to get professional results?', 'formidable' ),
371 - 'call' => __( 'Take your forms to the next level.', 'formidable' ),
372 - ),
373 - array(
374 - 'link' => array(
375 - 'medium' => 'banner',
376 - 'content' => 'increase-conversions',
377 - ),
378 - 'tip' => __( 'Increase conversions in long forms.', 'formidable' ),
379 - 'call' => __( 'Add conditional logic, page breaks, and section headings.', 'formidable' ),
380 - ),
381 - array(
382 - 'link' => array(
383 - 'medium' => 'banner',
384 - 'content' => 'automate',
385 - ),
386 - 'tip' => __( 'Automate your business and increase revenue.', 'formidable' ),
387 - 'call' => __( 'Collect instant payments, and send leads to Mailchimp.', 'formidable' ),
388 - ),
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',
389 415 );
390 - $random = rand( 0, count( $tips ) - 1 );
391 - $tip = $tips[ $random ];
392 - $tip['num'] = $random;
393 416
394 - 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';
395 428 }
396 429
397 - public static function get_random_tip( $tips ) {
398 - $random = rand( 0, count( $tips ) - 1 );
399 -
400 - 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();
401 438 }
402 439 }