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

462 lines 11.5 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'] ) && ! isset( $tip['link']['campaign'] ) ) {
52 $tip['link']['campaign'] = '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
99 return $cta_link;
100 }
101
102 return FrmAppHelper::admin_upgrade_link( $tip['link'], $tip['page'] );
103 }
104
105 /**
106 * Use the correct label for the license.
107 *
108 * @since 6.5.1
109 *
110 * @return string
111 */
112 private static function cta_label() {
113 $cta_text = FrmSalesApi::get_best_sale_value( 'pro_tip_cta_text' );
114
115 if ( $cta_text ) {
116 return $cta_text;
117 }
118
119 return FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro.', 'formidable' );
120 }
121
122 /**
123 * @return array
124 */
125 public static function get_builder_tip() {
126 return array(
127 array(
128 'link' => array(
129 'content' => 'conditional-logic',
130 'param' => 'conditional-logic-wordpress-forms',
131 ),
132 'tip' => __( 'Use conditional logic to shorten your forms and increase conversions.', 'formidable' ),
133 'call' => self::cta_label(),
134 ),
135 array(
136 'link' => array(
137 'content' => 'confirmation-fields',
138 'param' => 'confirmation-fields-wordpress-forms',
139 ),
140 'tip' => __( 'Eliminate input errors with email confirmation fields.', 'formidable' ),
141 'call' => self::cta_label(),
142 ),
143 array(
144 'link' => array(
145 'content' => 'page-breaks',
146 'param' => 'wordpress-multi-page-forms',
147 ),
148 'tip' => __( 'Use page breaks for easier forms.', 'formidable' ),
149 'call' => self::cta_label(),
150 ),
151 array(
152 'link' => array(
153 'content' => 'file-uploads',
154 'param' => 'wordpress-multi-file-upload-fields',
155 ),
156 'tip' => __( 'Skip the follow-ups. Let users upload files.', 'formidable' ),
157 'call' => self::cta_label(),
158 ),
159 array(
160 'link' => array(
161 'content' => 'calculations',
162 'param' => 'field-calculations-wordpress-form',
163 ),
164 'tip' => __( 'Need to calculate a total?', 'formidable' ),
165 'call' => self::cta_label(),
166 ),
167 array(
168 'link' => array(
169 'content' => 'prefill-fields',
170 'param' => 'auto-fill-forms',
171 ),
172 'tip' => __( 'Save time with autofill forms.', 'formidable' ),
173 'call' => self::cta_label(),
174 ),
175 );
176 }
177
178 /**
179 * @return array
180 */
181 public static function get_form_settings_tip() {
182 return 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
210 /**
211 * @return array
212 */
213 public static function get_form_action_tip() {
214 return array(
215 array(
216 'link' => array(
217 'content' => 'email-routing',
218 'param' => 'virtually-unlimited-emails',
219 ),
220 'tip' => __( 'Save time — route emails to the right person automatically.', 'formidable' ),
221 'call' => self::cta_label(),
222 ),
223 array(
224 'link' => array(
225 'content' => 'create-posts',
226 'param' => 'create-posts-pages-wordpress-forms',
227 ),
228 'tip' => __( 'Create blog posts or pages from the front-end.', 'formidable' ),
229 'call' => self::cta_label(),
230 ),
231 array(
232 'link' => array(
233 'content' => 'user-submit',
234 'param' => 'create-posts-pages-wordpress-forms',
235 ),
236 'tip' => __( 'Let your users submit posts on the front-end.', 'formidable' ),
237 'call' => self::cta_label(),
238 ),
239 array(
240 'link' => array(
241 'content' => 'mailchimp',
242 'page' => 'mailchimp-tip',
243 ),
244 'tip' => __( 'Send leads to Mailchimp for instant email follow-up.', 'formidable' ),
245 'call' => self::cta_label(),
246 ),
247 array(
248 'link' => array(
249 'content' => 'paypal-revenue',
250 'page' => 'paypal-increase-revenue-tip',
251 ),
252 'tip' => __( 'Accept PayPal payments and grow your sales.', 'formidable' ),
253 'call' => self::cta_label(),
254 ),
255 array(
256 'link' => array(
257 'content' => 'paypal-fast',
258 'page' => 'paypal-save-time-tip',
259 ),
260 'tip' => __( 'Accept payments now with PayPal integration.', 'formidable' ),
261 'call' => self::cta_label(),
262 ),
263 array(
264 'link' => array(
265 'content' => 'registration',
266 'page' => 'registration-tip',
267 ),
268 'tip' => __( 'Automatically create user accounts.', 'formidable' ),
269 'call' => __( 'Upgrade to boost your site membership.', 'formidable' ),
270 ),
271 array(
272 'link' => array(
273 'content' => 'profile',
274 'page' => 'registration-profile-editing-tip',
275 ),
276 'tip' => __( 'Enable front-end profile editing with User Registration.', 'formidable' ),
277 'call' => self::cta_label(),
278 ),
279 array(
280 'link' => array(
281 'content' => 'twilio-payment',
282 'page' => 'twilio-tip',
283 ),
284 'tip' => __( 'Get SMS alerts for form submissions and payments—just add Twilio.', 'formidable' ),
285 'call' => self::cta_label(),
286 ),
287 array(
288 'link' => array(
289 'content' => 'twilio',
290 'page' => 'twilio-send-tip',
291 ),
292 'tip' => __( 'Use Twilio to send SMS when forms are submitted.', 'formidable' ),
293 'call' => self::cta_label(),
294 ),
295 array(
296 'link' => array(
297 'content' => 'acf-tip',
298 'param' => 'acf-tip',
299 ),
300 'tip' => __( 'Fill Advanced Custom Fields automatically with form entries.', 'formidable' ),
301 'call' => self::cta_label(),
302 ),
303 );
304 }
305
306 /**
307 * @return array
308 */
309 public static function get_styling_tip() {
310 return array(
311 array(
312 'link' => array(
313 'content' => 'style',
314 'param' => 'wordpress-visual-form-styler',
315 ),
316 'tip' => __( 'Make your forms stand out with multiple style templates.', 'formidable' ),
317 'call' => self::cta_label(),
318 ),
319 array(
320 'link' => array(
321 'content' => 'style',
322 'param' => 'bg-image-style-settings',
323 ),
324 'tip' => __( 'Want to add a background image?', 'formidable' ),
325 'call' => self::cta_label(),
326 ),
327 array(
328 'link' => array(
329 'content' => 'style',
330 'param' => 'duplicate-style',
331 ),
332 'tip' => __( 'Want to duplicate a style?', 'formidable' ),
333 'call' => self::cta_label(),
334 ),
335 );
336 }
337
338 /**
339 * @return array
340 */
341 public static function get_entries_tip() {
342 $tips = array(
343 array(
344 'link' => array(
345 'content' => 'entries',
346 'param' => 'form-entry-management-wordpress',
347 ),
348 'tip' => __( 'Edit form entries anytime with entry management.', 'formidable' ),
349 'call' => self::cta_label(),
350 ),
351 array(
352 'link' => array(
353 'content' => 'entries-search',
354 'param' => 'form-entry-management-wordpress',
355 ),
356 'tip' => __( 'Want to search submitted entries?', 'formidable' ),
357 'call' => self::cta_label(),
358 ),
359 array(
360 'link' => array(
361 'content' => 'views',
362 'param' => 'views-display-form-data',
363 ),
364 'tip' => __( 'Turn entries into dynamic content — no code needed.', 'formidable' ),
365 'call' => self::cta_label(),
366 ),
367 );
368
369 return array_merge( $tips, self::get_import_tip() );
370 }
371
372 /**
373 * @return array
374 */
375 public static function get_import_tip() {
376 return array(
377 array(
378 'link' => array(
379 'content' => 'import',
380 'param' => 'importing-exporting-wordpress-forms',
381 ),
382 'tip' => __( 'Want to import entries into your forms?', 'formidable' ),
383 'call' => self::cta_label(),
384 ),
385 );
386 }
387
388 /**
389 * @param array $tips
390 *
391 * @return array
392 */
393 public static function get_random_tip( $tips ) {
394 $count = count( $tips );
395
396 if ( $count === 0 ) {
397 return array();
398 }
399
400 $random = random_int( 0, $count - 1 );
401 return $tips[ $random ];
402 }
403
404 /**
405 * Displays a call-to-action section in the admin area.
406 *
407 * @since 6.7
408 *
409 * @param array $args {
410 * An array of arguments to configure the call-to-action section.
411 *
412 * @type string $title The title of the section.
413 * @type string $description The description of the section.
414 * @type string $link_text The text for the link.
415 * @type string $link_url The URL for the link.
416 * @type string $role The required user role to view the section. Default 'administrator'.
417 * }
418 *
419 * @return void
420 */
421 public static function show_admin_cta( $args ) {
422 $role = ! empty( $args['role'] ) ? $args['role'] : 'administrator';
423
424 if ( ! current_user_can( $role ) ) {
425 // Return early if the user doesn't have the required capability.
426 return;
427 }
428
429 $defaults = array(
430 'title' => '',
431 'description' => '',
432 'link_text' => '',
433 'link_url' => '#',
434 'class' => '',
435 'id' => '',
436 'target' => '_blank',
437 );
438
439 $args = wp_parse_args( $args, $defaults );
440
441 $attributes = array(
442 'class' => trim( 'frm-cta frm-flex frm-p-sm ' . $args['class'] ),
443 );
444
445 if ( $args['id'] ) {
446 $attributes['id'] = $args['id'];
447 }
448
449 require FrmAppHelper::plugin_path() . '/classes/views/shared/admin-cta.php';
450 }
451
452 /**
453 * @deprecated 6.21
454 *
455 * @return array
456 */
457 public static function get_banner_tip() {
458 _deprecated_function( __METHOD__, '6.21' );
459 return array();
460 }
461 }
462