PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.26
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.26
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
formidable / classes / helpers / FrmTipsHelper.php

FrmTipsHelper.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.26, at classes/helpers/FrmTipsHelper.php

471 lines 11.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 class FrmTipsHelper {
7
8 /**
9 * @param string $callback
10 * @param string $html
11 *
12 * @return void
13 */
14 public static function pro_tip( $callback, $html = '' ) {
15 if ( FrmAppHelper::pro_is_installed() ) {
16 return;
17 }
18
19 $tips = self::$callback();
20 $tip = self::get_random_tip( $tips );
21
22 self::show_tip( $tip, $html );
23 }
24
25 /**
26 * Shows tip.
27 *
28 * @since 6.0
29 *
30 * @param array $tip {
31 * Tip args.
32 *
33 * @type array $link Tip link data. See the first parameter of {@see FrmAppHelper::admin_upgrade_link()} for more details.
34 * @type string $page The based link of the tip. If this is empty, `https://formidableforms.com/lite-upgrade/` will
35 * be used. Otherwise, `https://formidableforms.com/{$page}` will be used.
36 * @type string $tip Tip text.
37 * @type string $call Call to action text.
38 * }
39 *
40 * @param string $html
41 *
42 * @return void
43 */
44 public static function show_tip( $tip, $html = '' ) {
45 $defaults = array(
46 'page' => '',
47 'class' => 'frm-mt-0',
48 );
49 $tip = array_merge( $defaults, $tip );
50
51 if ( isset( $tip['link'] ) && ! isset( $tip['link']['medium'] ) ) {
52 $tip['link']['medium'] = 'tip';
53 }
54
55 if ( 'p' === $html ) {
56 echo '<p class="frmcenter ' . esc_attr( $tip['class'] ) . '">';
57 }
58
59 $link = self::get_tip_link( $tip );
60 ?>
61 <a href="<?php echo esc_url( $link ); ?>" <?php echo empty( $tip['link'] ) ? '' : 'target="_blank"'; ?> class="frm_pro_tip frm-gradient">
62 <span class="frm-tip-badge"><?php esc_html_e( 'PRO TIP', 'formidable' ); ?></span>
63
64 <?php if ( isset( $tip['call'] ) ) { ?>
65 <span class="frm-tip-info">
66 <?php echo esc_html( $tip['tip'] ); ?>
67 </span>
68 <?php } ?>
69 <span class="frm-tip-cta">
70 <?php echo esc_html( $tip['call'] ? $tip['call'] : $tip['tip'] ); ?>
71 </span>
72 </a>
73 <?php
74
75 if ( 'p' === $html ) {
76 echo '</p>';
77 }
78 }
79
80 /**
81 * @since 6.21
82 *
83 * @param array $tip
84 *
85 * @return string
86 */
87 private static function get_tip_link( $tip ) {
88 if ( empty( $tip['tip'] ) ) {
89 return $tip['page'];
90 }
91
92 $cta_link = FrmSalesApi::get_best_sale_value( 'pro_tip_cta_link' );
93
94 if ( $cta_link ) {
95 if ( is_array( $tip['link'] ) ) {
96 $cta_link = FrmAppHelper::maybe_add_missing_utm( $cta_link, $tip['link'] );
97 }
98 return $cta_link;
99 }
100
101 return FrmAppHelper::admin_upgrade_link( $tip['link'], $tip['page'] );
102 }
103
104 /**
105 * Use the correct label for the license.
106 *
107 * @since 6.5.1
108 *
109 * @return string
110 */
111 private static function cta_label() {
112 $cta_text = FrmSalesApi::get_best_sale_value( 'pro_tip_cta_text' );
113
114 if ( $cta_text ) {
115 return $cta_text;
116 }
117 return FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro.', 'formidable' );
118 }
119
120 /**
121 * @return array
122 */
123 public static function get_builder_tip() {
124 $tips = array(
125 array(
126 'link' => array(
127 'content' => 'conditional-logic',
128 'param' => 'conditional-logic-wordpress-forms',
129 ),
130 'tip' => __( 'Use conditional logic to shorten your forms and increase conversions.', 'formidable' ),
131 'call' => self::cta_label(),
132 ),
133 array(
134 'link' => array(
135 'content' => 'confirmation-fields',
136 'param' => 'confirmation-fields-wordpress-forms',
137 ),
138 'tip' => __( 'Eliminate input errors with email confirmation fields.', 'formidable' ),
139 'call' => self::cta_label(),
140 ),
141 array(
142 'link' => array(
143 'content' => 'page-breaks',
144 'param' => 'wordpress-multi-page-forms',
145 ),
146 'tip' => __( 'Use page breaks for easier forms.', 'formidable' ),
147 'call' => self::cta_label(),
148 ),
149 array(
150 'link' => array(
151 'content' => 'file-uploads',
152 'param' => 'wordpress-multi-file-upload-fields',
153 ),
154 'tip' => __( 'Skip the follow-ups. Let users upload files.', 'formidable' ),
155 'call' => self::cta_label(),
156 ),
157 array(
158 'link' => array(
159 'content' => 'calculations',
160 'param' => 'field-calculations-wordpress-form',
161 ),
162 'tip' => __( 'Need to calculate a total?', 'formidable' ),
163 'call' => self::cta_label(),
164 ),
165 array(
166 'link' => array(
167 'content' => 'prefill-fields',
168 'param' => 'auto-fill-forms',
169 ),
170 'tip' => __( 'Save time with autofill forms.', 'formidable' ),
171 'call' => self::cta_label(),
172 ),
173 );
174
175 return $tips;
176 }
177
178 /**
179 * @return array
180 */
181 public static function get_form_settings_tip() {
182 $tips = array(
183 array(
184 'link' => array(
185 'content' => 'front-edit-b',
186 'param' => 'wordpress-front-end-editing',
187 ),
188 'tip' => __( 'Make your site dynamic. Enable front-end editing.', 'formidable' ),
189 'call' => self::cta_label(),
190 ),
191 array(
192 'link' => array(
193 'content' => 'save-drafts',
194 'param' => 'save-drafts-wordpress-form',
195 ),
196 'tip' => __( 'Long form? Let users save and finish later', 'formidable' ),
197 'call' => self::cta_label(),
198 ),
199 array(
200 'link' => array(
201 'content' => 'form-scheduling',
202 'param' => 'schedule-forms-wordpress',
203 ),
204 'tip' => __( 'Limit form access with built-in scheduling.', 'formidable' ),
205 'call' => self::cta_label(),
206 ),
207 );
208
209 return $tips;
210 }
211
212 /**
213 * @return array
214 */
215 public static function get_form_action_tip() {
216 $tips = array(
217 array(
218 'link' => array(
219 'content' => 'email-routing',
220 'param' => 'virtually-unlimited-emails',
221 ),
222 'tip' => __( 'Save time — route emails to the right person automatically.', 'formidable' ),
223 'call' => self::cta_label(),
224 ),
225 array(
226 'link' => array(
227 'content' => 'create-posts',
228 'param' => 'create-posts-pages-wordpress-forms',
229 ),
230 'tip' => __( 'Create blog posts or pages from the front-end.', 'formidable' ),
231 'call' => self::cta_label(),
232 ),
233 array(
234 'link' => array(
235 'content' => 'user-submit',
236 'param' => 'create-posts-pages-wordpress-forms',
237 ),
238 'tip' => __( 'Let your users submit posts on the front-end.', 'formidable' ),
239 'call' => self::cta_label(),
240 ),
241 array(
242 'link' => array(
243 'content' => 'mailchimp',
244 'page' => 'mailchimp-tip',
245 ),
246 'tip' => __( 'Send leads to Mailchimp for instant email follow-up.', 'formidable' ),
247 'call' => self::cta_label(),
248 ),
249 array(
250 'link' => array(
251 'content' => 'paypal-revenue',
252 'page' => 'paypal-increase-revenue-tip',
253 ),
254 'tip' => __( 'Accept PayPal payments and grow your sales.', 'formidable' ),
255 'call' => self::cta_label(),
256 ),
257 array(
258 'link' => array(
259 'content' => 'paypal-fast',
260 'page' => 'paypal-save-time-tip',
261 ),
262 'tip' => __( 'Accept payments now with PayPal integration.', 'formidable' ),
263 'call' => self::cta_label(),
264 ),
265 array(
266 'link' => array(
267 'content' => 'registration',
268 'page' => 'registration-tip',
269 ),
270 'tip' => __( 'Automatically create user accounts.', 'formidable' ),
271 'call' => __( 'Upgrade to boost your site membership.', 'formidable' ),
272 ),
273 array(
274 'link' => array(
275 'content' => 'profile',
276 'page' => 'registration-profile-editing-tip',
277 ),
278 'tip' => __( 'Enable front-end profile editing with User Registration.', 'formidable' ),
279 'call' => self::cta_label(),
280 ),
281 array(
282 'link' => array(
283 'content' => 'twilio-payment',
284 'page' => 'twilio-tip',
285 ),
286 'tip' => __( 'Get SMS alerts for form submissions and payments—just add Twilio.', 'formidable' ),
287 'call' => self::cta_label(),
288 ),
289 array(
290 'link' => array(
291 'content' => 'twilio',
292 'page' => 'twilio-send-tip',
293 ),
294 'tip' => __( 'Use Twilio to send SMS when forms are submitted.', 'formidable' ),
295 'call' => self::cta_label(),
296 ),
297 array(
298 'link' => array(
299 'content' => 'acf-tip',
300 'param' => 'acf-tip',
301 ),
302 'tip' => __( 'Fill Advanced Custom Fields automatically with form entries.', 'formidable' ),
303 'call' => self::cta_label(),
304 ),
305 );
306
307 return $tips;
308 }
309
310 /**
311 * @return array
312 */
313 public static function get_styling_tip() {
314 $tips = array(
315 array(
316 'link' => array(
317 'content' => 'style',
318 'param' => 'wordpress-visual-form-styler',
319 ),
320 'tip' => __( 'Make your forms stand out with multiple style templates.', 'formidable' ),
321 'call' => self::cta_label(),
322 ),
323 array(
324 'link' => array(
325 'content' => 'style',
326 'param' => 'bg-image-style-settings',
327 ),
328 'tip' => __( 'Want to add a background image?', 'formidable' ),
329 'call' => self::cta_label(),
330 ),
331 array(
332 'link' => array(
333 'content' => 'style',
334 'param' => 'duplicate-style',
335 ),
336 'tip' => __( 'Want to duplicate a style?', 'formidable' ),
337 'call' => self::cta_label(),
338 ),
339 );
340
341 return $tips;
342 }
343
344 /**
345 * @return array
346 */
347 public static function get_entries_tip() {
348 $tips = array(
349 array(
350 'link' => array(
351 'content' => 'entries',
352 'param' => 'form-entry-management-wordpress',
353 ),
354 'tip' => __( 'Edit form entries anytime with entry management.', 'formidable' ),
355 'call' => self::cta_label(),
356 ),
357 array(
358 'link' => array(
359 'content' => 'entries-search',
360 'param' => 'form-entry-management-wordpress',
361 ),
362 'tip' => __( 'Want to search submitted entries?', 'formidable' ),
363 'call' => self::cta_label(),
364 ),
365 array(
366 'link' => array(
367 'content' => 'views',
368 'param' => 'views-display-form-data',
369 ),
370 'tip' => __( 'Turn entries into dynamic content — no code needed.', 'formidable' ),
371 'call' => self::cta_label(),
372 ),
373 );
374 $tips = array_merge( $tips, self::get_import_tip() );
375
376 return $tips;
377 }
378
379 /**
380 * @return array
381 */
382 public static function get_import_tip() {
383 $tips = array(
384 array(
385 'link' => array(
386 'content' => 'import',
387 'param' => 'importing-exporting-wordpress-forms',
388 ),
389 'tip' => __( 'Want to import entries into your forms?', 'formidable' ),
390 'call' => self::cta_label(),
391 ),
392 );
393
394 return $tips;
395 }
396
397 /**
398 * @param array $tips
399 *
400 * @return array
401 */
402 public static function get_random_tip( $tips ) {
403 $count = count( $tips );
404
405 if ( $count === 0 ) {
406 return array();
407 }
408
409 $random = random_int( 0, $count - 1 );
410 return $tips[ $random ];
411 }
412
413 /**
414 * Displays a call-to-action section in the admin area.
415 *
416 * @since 6.7
417 *
418 * @param array $args {
419 * An array of arguments to configure the call-to-action section.
420 *
421 * @type string $title The title of the section.
422 * @type string $description The description of the section.
423 * @type string $link_text The text for the link.
424 * @type string $link_url The URL for the link.
425 * @type string $role The required user role to view the section. Default 'administrator'.
426 * }
427 *
428 * @return void
429 */
430 public static function show_admin_cta( $args ) {
431 $role = ! empty( $args['role'] ) ? $args['role'] : 'administrator';
432
433 if ( ! current_user_can( $role ) ) {
434 // Return early if the user doesn't have the required capability.
435 return;
436 }
437
438 $defaults = array(
439 'title' => '',
440 'description' => '',
441 'link_text' => '',
442 'link_url' => '#',
443 'class' => '',
444 'id' => '',
445 'target' => '_blank',
446 );
447
448 $args = wp_parse_args( $args, $defaults );
449
450 $attributes = array(
451 'class' => trim( 'frm-cta frm-flex frm-p-sm ' . $args['class'] ),
452 );
453
454 if ( $args['id'] ) {
455 $attributes['id'] = $args['id'];
456 }
457
458 require FrmAppHelper::plugin_path() . '/classes/views/shared/admin-cta.php';
459 }
460
461 /**
462 * @deprecated 6.21
463 *
464 * @return array
465 */
466 public static function get_banner_tip() {
467 _deprecated_function( __METHOD__, '6.21' );
468 return array();
469 }
470 }
471