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

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