PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8.3
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 / controllers / FrmAddonsController.php

FrmAddonsController.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.8.3, at classes/controllers/FrmAddonsController.php

1,659 lines 43.7 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 FrmAddonsController {
7
8 /**
9 * @var string $plugin
10 */
11 protected static $plugin;
12
13 /**
14 * @return void
15 */
16 public static function menu() {
17 if ( ! current_user_can( 'activate_plugins' ) ) {
18 return;
19 }
20
21 $label = __( 'Add-Ons', 'formidable' );
22 $label = '<span style="color:#1da867">' . $label . '</span>';
23
24 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Add-Ons', 'formidable' ), $label, 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
25
26 // remove default created subpage, make the page with highest priority as default.
27 remove_submenu_page( 'formidable', 'formidable' );
28
29 if ( ! FrmAppHelper::pro_is_installed() ) {
30 add_submenu_page(
31 'formidable',
32 'Formidable | ' . __( 'Upgrade', 'formidable' ),
33 '<span class="frm-upgrade-submenu">' . __( 'Upgrade', 'formidable' ) . '</span>',
34 'frm_view_forms',
35 'formidable-pro-upgrade',
36 'FrmAddonsController::upgrade_to_pro'
37 );
38 } elseif ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) ) {
39 wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
40 exit;
41 }
42 }
43
44 /**
45 * @return void
46 */
47 public static function list_addons() {
48 FrmAppHelper::include_svg();
49 $installed_addons = apply_filters( 'frm_installed_addons', array() );
50 $license_type = '';
51
52 $addons = self::get_api_addons();
53 $errors = array();
54
55 if ( isset( $addons['error'] ) ) {
56 $api = new FrmFormApi();
57 $errors = $api->get_error_from_response( $addons );
58 $license_type = isset( $addons['error']['type'] ) ? $addons['error']['type'] : '';
59 unset( $addons['error'] );
60 }
61
62 $pro = array(
63 'pro' => array(
64 'title' => 'Formidable Forms Pro',
65 'slug' => 'formidable-pro',
66 'released' => '2011-02-05',
67 'docs' => 'knowledgebase/',
68 'excerpt' => 'Create calculators, surveys, smart forms, and data-driven applications. Build directories, real estate listings, job boards, and much more.',
69 ),
70 );
71 $addons = $pro + $addons;
72 self::prepare_addons( $addons );
73
74 $pricing = FrmAppHelper::admin_upgrade_link( 'addons' );
75
76 include( FrmAppHelper::plugin_path() . '/classes/views/addons/list.php' );
77 }
78
79 /**
80 * @return void
81 */
82 public static function license_settings() {
83 $plugins = apply_filters( 'frm_installed_addons', array() );
84 if ( empty( $plugins ) ) {
85 esc_html_e( 'There are no plugins on your site that require a license', 'formidable' );
86
87 return;
88 }
89
90 ksort( $plugins );
91
92 include( FrmAppHelper::plugin_path() . '/classes/views/addons/settings.php' );
93 }
94
95 /**
96 * @return array
97 */
98 protected static function get_api_addons() {
99 $api = new FrmFormApi();
100 $addons = $api->get_api_info();
101
102 if ( empty( $addons ) ) {
103 $addons = self::fallback_plugin_list();
104 } else {
105 foreach ( $addons as $k => $addon ) {
106 if ( empty( $addon['excerpt'] ) && $k !== 'error' ) {
107 unset( $addons[ $k ] );
108 }
109 }
110 }
111
112 return $addons;
113 }
114
115 /**
116 * If the API is unable to connect, show something on the addons page
117 *
118 * @since 3.04.03
119 * @return array
120 */
121 protected static function fallback_plugin_list() {
122 $list = array(
123 'formidable-pro' => array(
124 'title' => 'Formidable Forms Pro',
125 'link' => 'pricing/',
126 'docs' => '',
127 'excerpt' => 'Enhance your basic Formidable forms with a plethora of Pro field types and features. Create advanced forms and data-driven applications in minutes.',
128 ),
129 'mailchimp' => array(
130 'title' => 'Mailchimp Forms',
131 'excerpt' => 'Get on the path to more sales and leads in a matter of minutes. Add leads to a Mailchimp mailing list when they submit forms and update their information along with the entry.',
132 ),
133 'registration' => array(
134 'title' => 'User Registration Forms',
135 'link' => 'downloads/user-registration/',
136 'excerpt' => 'Give new users access to your site as quickly and painlessly as possible. Allow users to register, edit and be able to login to their profiles on your site from the front end in a clean, customized registration form.',
137 ),
138 'paypal' => array(
139 'title' => 'PayPal Standard Forms',
140 'link' => 'downloads/paypal-standard/',
141 'excerpt' => 'Automate your business by collecting instant payments from your clients. Collect information, calculate a total, and send them on to PayPal. Require a payment before publishing content on your site.',
142 ),
143 'stripe' => array(
144 'title' => 'Stripe Forms',
145 'docs' => 'knowledgebase/stripe/',
146 'excerpt' => 'Any Formidable forms on your site can accept credit card payments without users ever leaving your site.',
147 ),
148 'authorize-net' => array(
149 'title' => 'Authorize.net AIM Forms',
150 'link' => 'downloads/authorize-net-aim/',
151 'docs' => 'knowledgebase/authorize-net-aim/',
152 'excerpt' => 'Accept one-time payments directly on your site, using Authorize.net AIM.',
153 ),
154 'woocommerce' => array(
155 'title' => 'WooCommerce Forms',
156 'excerpt' => 'Use a Formidable form on your WooCommerce product pages.',
157 ),
158 'autoresponder' => array(
159 'title' => 'Form Action Automation',
160 'docs' => 'knowledgebase/schedule-autoresponder/',
161 'excerpt' => 'Schedule email notifications, SMS messages, and API actions.',
162 ),
163 'modal' => array(
164 'title' => 'Bootstrap Modal Forms',
165 'link' => 'downloads/bootstrap-modal/',
166 'docs' => 'knowledgebase/bootstrap-modal/',
167 'excerpt' => 'Open a view or form in a Bootstrap popup.',
168 ),
169 'bootstrap' => array(
170 'title' => 'Bootstrap Style Forms',
171 'excerpt' => 'Instantly add Bootstrap styling to all your Formidable forms.',
172 ),
173 'zapier' => array(
174 'title' => 'Zapier Forms',
175 'excerpt' => 'Connect with hundreds of different applications through Zapier. Insert a new row in a Google docs spreadsheet, post on Twitter, or add a new Dropbox file with your form.',
176 ),
177 'signature' => array(
178 'title' => 'Digital Signature Forms',
179 'excerpt' => 'Add a signature field to your form. The user may write their signature with a trackpad/mouse or just type it.',
180 ),
181 'api' => array(
182 'title' => 'Formidable Forms API',
183 'link' => 'downloads/formidable-api/',
184 'excerpt' => 'Send entry results to any other site that has a Rest API. This includes the option of sending entries from one Formidable site to another.',
185 ),
186 'twilio' => array(
187 'title' => 'Twilio SMS Forms',
188 'docs' => 'knowledgebase/twilio-add-on/',
189 'excerpt' => 'Allow users to text their votes for polls created by Formidable Forms, or send SMS notifications when entries are submitted or updated.',
190 ),
191 'views' => array(
192 'title' => 'Formidable Views',
193 'excerpt' => 'Add the power of views to your Formidable Forms to display your form submissions in listings, tables, calendars, and more.',
194 ),
195 'quiz_maker' => array(
196 'title' => 'Quiz Maker',
197 'link' => 'downloads/quiz-maker/',
198 'excerpt' => 'Make quizzes, automatically score them and show user scores.',
199 ),
200 );
201
202 $defaults = array(
203 'released' => '',
204 );
205
206 foreach ( $list as $k => $info ) {
207 $info['slug'] = $k;
208 $list[ $k ] = array_merge( $defaults, $info );
209 }
210 return $list;
211 }
212
213 /**
214 * If Pro is missing but has been authenticated, include a download URL
215 *
216 * @since 3.04.03
217 * @return string
218 */
219 public static function get_pro_download_url() {
220 $license = self::get_pro_license();
221 $api = new FrmFormApi( $license );
222 $downloads = $api->get_api_info();
223 $pro = self::get_pro_from_addons( $downloads );
224
225 return isset( $pro['url'] ) ? $pro['url'] : '';
226 }
227
228 /**
229 * @since 4.08
230 */
231 public static function get_pro_license() {
232 $pro_cred_store = 'frmpro-credentials';
233 $pro_wpmu_store = 'frmpro-wpmu-sitewide';
234 if ( is_multisite() && get_site_option( $pro_wpmu_store ) ) {
235 $creds = get_site_option( $pro_cred_store );
236 } else {
237 $creds = get_option( $pro_cred_store );
238 }
239
240 if ( empty( $creds ) || ! is_array( $creds ) || ! isset( $creds['license'] ) ) {
241 return '';
242 }
243
244 $license = $creds['license'];
245 if ( empty( $license ) ) {
246 return '';
247 }
248
249 if ( strpos( $license, '-' ) ) {
250 // this is a fix for licenses saved in the past
251 $license = strtoupper( $license );
252 }
253 return $license;
254 }
255
256 /**
257 * @since 4.08
258 *
259 * @param array $addons
260 * @return array
261 */
262 protected static function get_pro_from_addons( $addons ) {
263 return isset( $addons['93790'] ) ? $addons['93790'] : array();
264 }
265
266 /**
267 * @since 4.06
268 */
269 public static function license_type() {
270 if ( is_callable( 'FrmProAddonsController::license_type' ) ) {
271 return FrmProAddonsController::license_type();
272 }
273
274 return 'free';
275 }
276
277 /**
278 * @since 4.0.01
279 *
280 * @return bool
281 */
282 public static function is_license_expired() {
283 $version_info = self::get_primary_license_info();
284 if ( ! isset( $version_info['error'] ) ) {
285 return false;
286 }
287
288 $expires = isset( $version_info['error']['expires'] ) ? $version_info['error']['expires'] : 0;
289 if ( empty( $expires ) || $expires > time() ) {
290 return false;
291 }
292
293 $rate_limited = ! empty( $version_info['response_code'] ) && 429 === (int) $version_info['response_code'];
294 if ( $rate_limited ) {
295 // Do not return false positives for rate limited responses.
296 return false;
297 }
298
299 return $version_info['error'];
300 }
301
302 /**
303 * @since 4.08
304 *
305 * @return boolean|int false or the number of days until expiration.
306 */
307 public static function is_license_expiring() {
308 if ( is_callable( 'FrmProAddonsController::is_license_expiring' ) ) {
309 return FrmProAddonsController::is_license_expiring();
310 }
311
312 return false;
313 }
314
315 /**
316 * @since 4.08
317 * @since 6.7 This is public.
318 *
319 * @return array|false
320 */
321 public static function get_primary_license_info() {
322 $installed_addons = apply_filters( 'frm_installed_addons', array() );
323 if ( empty( $installed_addons ) || ! isset( $installed_addons['formidable_pro'] ) ) {
324 return false;
325 }
326 $installed_addons = array(
327 'formidable_pro' => $installed_addons['formidable_pro'],
328 );
329
330 return self::fill_update_addon_info( $installed_addons );
331 }
332
333 /**
334 * @since 3.04.03
335 */
336 public static function check_update( $transient ) {
337 if ( ! FrmAppHelper::pro_is_installed() ) {
338 // Don't make any changes if only Lite is installed.
339 return $transient;
340 }
341
342 if ( ! is_object( $transient ) ) {
343 $transient = new stdClass();
344 }
345
346 $installed_addons = apply_filters( 'frm_installed_addons', array() );
347 if ( empty( $installed_addons ) ) {
348 return $transient;
349 }
350
351 $version_info = self::fill_update_addon_info( $installed_addons );
352 $transient->last_checked = time();
353 $wp_plugins = self::get_plugins();
354
355 foreach ( $version_info as $id => $plugin ) {
356 $plugin = (object) $plugin;
357
358 if ( ! isset( $plugin->new_version ) || ! isset( $plugin->package ) ) {
359 continue;
360 }
361
362 $folder = $plugin->plugin;
363 if ( empty( $folder ) ) {
364 continue;
365 }
366
367 if ( ! self::is_installed( $folder ) ) {
368 // don't show an update if the plugin isn't installed
369 continue;
370 }
371
372 $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array();
373 $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0';
374 $plugin->slug = explode( '/', $folder )[0];
375
376 if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) {
377 $transient->response[ $folder ] = $plugin;
378 } else {
379 $transient->no_update[ $folder ] = $plugin;
380 }
381
382 $transient->checked[ $folder ] = $wp_version;
383
384 }//end foreach
385
386 return $transient;
387 }
388
389 /**
390 * Copy of FrmAppHelper::get_plugins.
391 * Because this gets called on "pre_set_site_transient_update_plugins" an old version of FrmAppHelper may be loaded on plugin update.
392 * This means that trying to access FrmAppHelper::get_plugins when upgrading from a Lite version before v5.5 results in a one-off error.
393 *
394 * @since 5.5.2
395 * @return array
396 */
397 protected static function get_plugins() {
398 if ( ! function_exists( 'get_plugins' ) ) {
399 require_once ABSPATH . 'wp-admin/includes/plugin.php';
400 }
401 return get_plugins();
402 }
403
404 /**
405 * Check if a plugin is installed before showing an update for it
406 *
407 * @since 3.05
408 *
409 * @param string $plugin The folder/filename.php for a plugin.
410 *
411 * @return bool - True if installed
412 */
413 protected static function is_installed( $plugin ) {
414 $all_plugins = self::get_plugins();
415 return isset( $all_plugins[ $plugin ] );
416 }
417
418 /**
419 * @since 3.04.03
420 *
421 * @param array $installed_addons
422 *
423 * @return array
424 */
425 protected static function fill_update_addon_info( $installed_addons ) {
426 $checked_licenses = array();
427 $version_info = array();
428
429 foreach ( $installed_addons as $addon ) {
430 if ( $addon->store_url !== 'https://formidableforms.com' ) {
431 // check if this is a third-party addon
432 continue;
433 }
434
435 $new_license = $addon->license;
436 if ( empty( $new_license ) || in_array( $new_license, $checked_licenses ) ) {
437 continue;
438 }
439
440 $checked_licenses[] = $new_license;
441
442 $api = new FrmFormApi( $new_license );
443 if ( empty( $version_info ) ) {
444 $version_info = $api->get_api_info();
445 continue;
446 }
447
448 $plugin = $api->get_addon_for_license( $addon, $version_info );
449 if ( empty( $plugin ) ) {
450 continue;
451 }
452
453 $download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0;
454 if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) {
455 // if this addon is using its own license, get the update url
456 $addon_info = $api->get_api_info();
457
458 $version_info[ $download_id ] = $addon_info[ $download_id ];
459 if ( isset( $addon_info['error'] ) ) {
460 $version_info[ $download_id ]['error'] = array(
461 'message' => $addon_info['error']['message'],
462 'code' => $addon_info['error']['code'],
463 );
464 }
465 }
466 }//end foreach
467
468 return $version_info;
469 }
470
471 /**
472 * Get the action link for an addon that isn't active.
473 *
474 * @since 3.06.03
475 * @param string $plugin The plugin slug.
476 * @return array
477 */
478 public static function install_link( $plugin ) {
479 $link = array();
480 $addon = self::get_addon( $plugin );
481
482 if ( $addon ) {
483 if ( $addon['status']['type'] === 'installed' && ! empty( $addon['activate_url'] ) ) {
484 $link = array(
485 'url' => $addon['plugin'],
486 'class' => 'frm-activate-addon',
487 );
488 } elseif ( isset( $addon['url'] ) && ! empty( $addon['url'] ) ) {
489 $link = array(
490 'url' => $addon['url'],
491 'class' => 'frm-install-addon',
492 );
493 } elseif ( isset( $addon['categories'] ) && ! empty( $addon['categories'] ) ) {
494 $link = array(
495 'categories' => $addon['categories'],
496 );
497 }
498
499 if ( ! empty( $link ) ) {
500 $link['status'] = $addon['status']['type'];
501 }
502 } elseif ( current_user_can( 'activate_plugins' ) && self::is_installed( 'formidable-' . $plugin . '/formidable-' . $plugin . '.php' ) ) {
503 $link = array(
504 'url' => 'formidable-' . $plugin . '/formidable-' . $plugin . '.php',
505 'class' => 'frm-activate-addon',
506 );
507 }//end if
508
509 return $link;
510 }
511
512 /**
513 * @since 4.09
514 * @param string $plugin The plugin slug.
515 * @return array|false
516 */
517 protected static function get_addon( $plugin ) {
518 $addons = self::get_api_addons();
519 self::prepare_addons( $addons );
520 foreach ( $addons as $addon ) {
521 $slug = explode( '/', $addon['plugin'] );
522 if ( $slug[0] === 'formidable-' . $plugin ) {
523 return $addon;
524 }
525 }
526 return false;
527 }
528
529 /**
530 * @since 4.09
531 * @return string
532 */
533 protected static function get_license_type() {
534 $license_type = '';
535 $addons = self::get_api_addons();
536 if ( isset( $addons['error'] ) && isset( $addons['error']['type'] ) ) {
537 $license_type = $addons['error']['type'];
538 }
539 return $license_type;
540 }
541
542 /**
543 * @since 3.04.03
544 *
545 * @param array $addons
546 * @param object $license The FrmAddon object.
547 *
548 * @return array
549 */
550 public static function get_addon_for_license( $addons, $license ) {
551 $download_id = $license->download_id;
552 $plugin = array();
553 if ( empty( $download_id ) && ! empty( $addons ) ) {
554 foreach ( $addons as $addon ) {
555 if ( strtolower( $license->plugin_name ) == strtolower( $addon['title'] ) ) {
556 return $addon;
557 }
558 }
559 } elseif ( isset( $addons[ $download_id ] ) ) {
560 $plugin = $addons[ $download_id ];
561 }
562
563 return $plugin;
564 }
565
566 /**
567 * @return void
568 */
569 protected static function prepare_addons( &$addons ) {
570 $activate_url = '';
571 if ( current_user_can( 'activate_plugins' ) ) {
572 $activate_url = add_query_arg( array( 'action' => 'activate' ), admin_url( 'plugins.php' ) );
573 }
574
575 $loop_addons = $addons;
576 foreach ( $loop_addons as $id => $addon ) {
577 if ( is_numeric( $id ) ) {
578 $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] );
579 $file_name = $addon['plugin'];
580 } else {
581 $slug = $id;
582 if ( isset( $addon['file'] ) ) {
583 $base_file = $addon['file'];
584 } else {
585 $base_file = 'formidable-' . $slug;
586 }
587 $file_name = $base_file . '/' . $base_file . '.php';
588 if ( ! isset( $addon['plugin'] ) ) {
589 $addon['plugin'] = $file_name;
590 }
591 }
592
593 $addon['installed'] = self::is_installed( $file_name );
594 if ( $addon['installed'] && 'formidable-views/formidable-views.php' === $file_name ) {
595 $active_views_version = self::get_active_views_version();
596 if ( false !== $active_views_version && $slug !== $active_views_version ) {
597 $addon['installed'] = false;
598 }
599 }
600
601 $addon['activate_url'] = '';
602
603 if ( $addon['installed'] && ! empty( $activate_url ) && ! self::is_plugin_active( $file_name, $slug ) ) {
604 $addon['activate_url'] = add_query_arg(
605 array(
606 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $file_name ),
607 'plugin' => $file_name,
608 ),
609 $activate_url
610 );
611 }
612
613 if ( ! isset( $addon['docs'] ) ) {
614 $addon['docs'] = 'knowledgebase/formidable-' . $slug . '/';
615 }
616 self::prepare_addon_link( $addon['docs'] );
617
618 if ( ! isset( $addon['link'] ) ) {
619 $addon['link'] = 'downloads/' . $slug . '/';
620 }
621 self::prepare_addon_link( $addon['link'] );
622
623 self::set_addon_status( $addon );
624 $addons[ $id ] = $addon;
625 }//end foreach
626 }
627
628 /**
629 * @return bool
630 */
631 private static function is_plugin_active( $file_name, $slug ) {
632 if ( 'formidable-views/formidable-views.php' === $file_name ) {
633 return self::get_active_views_version() === $slug;
634 }
635 return is_plugin_active( $file_name );
636 }
637
638 /**
639 * @return string|false either 'visual-views' or 'views', false if one is not found.
640 */
641 private static function get_active_views_version() {
642 if ( ! is_callable( 'FrmViewsAppHelper::plugin_version' ) ) {
643 return false;
644 }
645 $plugin_version = FrmViewsAppHelper::plugin_version();
646 return version_compare( $plugin_version, '5.0', '>=' ) ? 'visual-views' : 'views';
647 }
648
649 /**
650 * @since 3.04.02
651 *
652 * @return void
653 */
654 protected static function prepare_addon_link( &$link ) {
655 $site_url = 'https://formidableforms.com/';
656 if ( strpos( $link, 'http' ) !== 0 ) {
657 $link = $site_url . $link;
658 }
659 $link = FrmAppHelper::make_affiliate_url( $link );
660 $query_args = array(
661 'utm_source' => 'WordPress',
662 'utm_medium' => 'addons',
663 'utm_campaign' => 'liteplugin',
664 );
665 $link = add_query_arg( $query_args, $link );
666 }
667
668 /**
669 * Add the status to the addon array. Status options are:
670 * installed, active, not installed
671 *
672 * @since 3.04.02
673 *
674 * @return void
675 */
676 protected static function set_addon_status( &$addon ) {
677 if ( ! empty( $addon['activate_url'] ) ) {
678 $addon['status'] = array(
679 'type' => 'installed',
680 'label' => __( 'Installed', 'formidable' ),
681 );
682 } elseif ( $addon['installed'] ) {
683 $addon['status'] = array(
684 'type' => 'active',
685 'label' => __( 'Active', 'formidable' ),
686 );
687 } else {
688 $addon['status'] = array(
689 'type' => 'not-installed',
690 'label' => __( 'Not Installed', 'formidable' ),
691 );
692 }
693 }
694
695 /**
696 * @return void
697 */
698 public static function upgrade_to_pro() {
699 FrmAppHelper::include_svg();
700
701 $link_parts = array(
702 'medium' => 'upgrade',
703 'content' => 'button',
704 );
705
706 $features = array(
707 'Display Entries' => array(
708 array(
709 'label' => 'Display form data with virtually limitless views',
710 'link' => array(
711 'content' => 'views',
712 'param' => 'views-display-form-data',
713 ),
714 'lite' => false,
715 ),
716 array(
717 'label' => 'Generate graphs and stats based on your submitted data',
718 'link' => array(
719 'content' => 'graphs',
720 'param' => 'statistics-graphs-wordpress-forms',
721 ),
722 'lite' => false,
723 ),
724 ),
725 'Entry Management' => array(
726 array(
727 'label' => 'Import entries from a CSV',
728 'link' => array(
729 'content' => 'import-entries',
730 'param' => 'importing-exporting-wordpress-forms',
731 ),
732 'lite' => false,
733 ),
734 array(
735 'label' => 'Logged-in users can save drafts and return later',
736 'link' => array(
737 'content' => 'save-drafts',
738 'param' => 'save-drafts-wordpress-form',
739 ),
740 'lite' => false,
741 ),
742 array(
743 'label' => 'Flexibly and powerfully view, edit, and delete entries from anywhere on your site',
744 'link' => array(
745 'content' => 'front-edit',
746 'param' => 'wordpress-front-end-editing',
747 ),
748 'lite' => false,
749 ),
750 array(
751 'label' => 'View form submissions from the back-end',
752 'lite' => true,
753 ),
754 array(
755 'label' => 'Export your entries to a CSV',
756 'lite' => true,
757 ),
758 ),
759 'Form Building' => array(
760 array(
761 'label' => 'Save a calculated value into a field',
762 'link' => array(
763 'content' => 'calculations',
764 'param' => 'field-calculations-wordpress-form',
765 ),
766 'lite' => false,
767 ),
768 array(
769 'label' => 'Allow multiple file uploads',
770 'link' => array(
771 'content' => 'file-uploads',
772 'param' => 'wordpress-multi-file-upload-fields',
773 ),
774 'lite' => false,
775 ),
776 array(
777 'label' => 'Repeat sections of fields',
778 'link' => array(
779 'content' => 'repeaters',
780 'param' => 'repeatable-sections-forms',
781 ),
782 'lite' => false,
783 ),
784 array(
785 'label' => 'Hide and show fields conditionally based on other fields or the user\'s role',
786 'link' => array(
787 'content' => 'conditional-logic',
788 'param' => 'conditional-logic-wordpress-forms',
789 ),
790 'lite' => false,
791 ),
792 array(
793 'label' => 'Confirmation fields',
794 'link' => array(
795 'content' => 'confirmation-fields',
796 'param' => 'confirmation-fields-wordpress-forms',
797 ),
798 'lite' => false,
799 ),
800 array(
801 'label' => 'Multi-paged forms',
802 'link' => array(
803 'content' => 'page-breaks',
804 'param' => 'wordpress-multi-page-forms',
805 ),
806 'lite' => false,
807 ),
808 array(
809 'label' => 'Include section headings, page breaks, rich text, dates, times, scales, star ratings, sliders, toggles, dynamic fields populated from other forms, passwords, and tags in advanced forms.',
810 'lite' => false,
811 ),
812 array(
813 'label' => 'Include text, email, url, paragraph text, radio, checkbox, dropdown fields, hidden fields, user ID fields, and HTML blocks in your form.',
814 'lite' => true,
815 ),
816 array(
817 'label' => 'Drag & Drop Form building',
818 'link' => array(
819 'content' => 'drag-drop',
820 'param' => 'drag-drop-forms',
821 ),
822 'lite' => true,
823 ),
824 array(
825 'label' => 'Create forms from Templates',
826 'link' => array(
827 'content' => 'form-templates',
828 'param' => 'wordpress-form-templates',
829 ),
830 'lite' => true,
831 ),
832 array(
833 'label' => 'Import and export forms with XML',
834 'link' => array(
835 'content' => 'import',
836 'param' => 'importing-exporting-wordpress-forms',
837 ),
838 'lite' => true,
839 ),
840 array(
841 'label' => 'Use input placeholder text in your fields that clear when typing starts.',
842 'lite' => true,
843 ),
844 ),
845 'Form Actions' => array(
846 array(
847 'label' => 'Conditionally send your email notifications based on values in your form',
848 'link' => array(
849 'content' => 'conditional-emails',
850 ),
851 'lite' => false,
852 ),
853 array(
854 'label' => 'Create and edit WordPress posts or custom posts from the front-end',
855 'link' => array(
856 'content' => 'create-posts',
857 'param' => 'create-posts-pages-wordpress-forms',
858 ),
859 'lite' => false,
860 ),
861 array(
862 'label' => 'Send multiple emails and autoresponders',
863 'link' => array(
864 'content' => 'multiple-emails',
865 'param' => 'virtually-unlimited-emails',
866 ),
867 'lite' => true,
868 ),
869 ),
870 'Form Appearance' => array(
871 array(
872 'label' => 'Create Multiple styles for different forms',
873 'link' => array(
874 'content' => 'multiple-styles',
875 'param' => 'wordpress-visual-form-styler',
876 ),
877 'lite' => false,
878 ),
879 array(
880 'label' => 'Customizable layout with CSS classes',
881 'link' => array(
882 'content' => 'form-layout',
883 'param' => 'wordpress-mobile-friendly-forms',
884 ),
885 'lite' => true,
886 ),
887 array(
888 'label' => 'Customize the HTML for your forms',
889 'link' => array(
890 'content' => 'custom-html',
891 'param' => 'customizable-html-wordpress-form',
892 ),
893 'lite' => true,
894 ),
895 array(
896 'label' => 'Style your form with the Visual Form Styler',
897 'lite' => true,
898 ),
899 ),
900 );
901
902 include( FrmAppHelper::plugin_path() . '/classes/views/addons/upgrade_to_pro.php' );
903 }
904
905 /**
906 * @since 5.5.2
907 *
908 * @param string $plugin
909 * @param string $redirect
910 * @param bool $network_wide
911 * @param bool $silent
912 * @return null|WP_Error Null on success, WP_Error on invalid file.
913 */
914 protected static function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
915 if ( ! function_exists( 'activate_plugin' ) ) {
916 require_once ABSPATH . 'wp-admin/includes/plugin.php';
917 }
918 return activate_plugin( $plugin, $redirect, $network_wide, $silent );
919 }
920
921 /**
922 * Deactivate a specified plugin.
923 *
924 * @since 6.8
925 *
926 * @param string $plugin
927 * @param bool $silent
928 * @return void
929 */
930 protected static function deactivate_plugin( $plugin, $silent = false ) {
931 if ( ! function_exists( 'deactivate_plugins' ) ) {
932 require_once ABSPATH . 'wp-admin/includes/plugin.php';
933 }
934 deactivate_plugins( $plugin, $silent );
935 }
936
937 /**
938 * Uninstall a specified plugin.
939 *
940 * @since 6.8
941 *
942 * @param string $plugin
943 * @return true|WP_Error True on success, WP_Error on invalid file.
944 */
945 protected static function uninstall_plugin( $plugin ) {
946 if ( ! current_user_can( 'delete_plugins' ) ) {
947 return new WP_Error( 'uninstall_failed', __( 'Current user cannot delete plugins.', 'formidable' ) );
948 }
949
950 if ( ! function_exists( 'delete_plugins' ) ) {
951 require_once ABSPATH . 'wp-admin/includes/plugin.php';
952 }
953
954 self::deactivate_plugin( $plugin, true );
955 $result = delete_plugins( array( $plugin ) );
956
957 if ( is_wp_error( $result ) ) {
958 return $result;
959 }
960
961 return true;
962 }
963
964 /**
965 * @since 5.0.10
966 *
967 * @return string
968 */
969 protected static function get_current_plugin() {
970 if ( empty( self::$plugin ) ) {
971 self::$plugin = FrmAppHelper::get_param( 'plugin', '', 'post', 'esc_url_raw' );
972 }
973 return self::$plugin;
974 }
975
976 /**
977 * @since 4.08
978 *
979 * @return void|array
980 */
981 protected static function download_and_activate() {
982 if ( is_admin() ) {
983 FrmAppHelper::set_current_screen_and_hook_suffix();
984 }
985
986 self::maybe_show_cred_form();
987
988 $installed = self::install_addon();
989 if ( is_array( $installed ) && isset( $installed['message'] ) ) {
990 return $installed;
991 }
992 self::handle_addon_action( $installed, 'activate' );
993 }
994
995 /**
996 * @since 3.04.02
997 *
998 * @return void
999 */
1000 protected static function maybe_show_cred_form() {
1001 if ( ! function_exists( 'request_filesystem_credentials' ) ) {
1002 include_once( ABSPATH . 'wp-admin/includes/file.php' );
1003 }
1004
1005 // Start output bufferring to catch the filesystem form if credentials are needed.
1006 ob_start();
1007
1008 $show_form = false;
1009 $method = '';
1010 $url = add_query_arg( array( 'page' => 'formidable-settings' ), admin_url( 'admin.php' ) );
1011 $url = esc_url_raw( $url );
1012 $creds = request_filesystem_credentials( $url, $method, false, false, null );
1013
1014 if ( false === $creds ) {
1015 $show_form = true;
1016 } elseif ( ! WP_Filesystem( $creds ) ) {
1017 request_filesystem_credentials( $url, $method, true, false, null );
1018 $show_form = true;
1019 }
1020
1021 if ( $show_form ) {
1022 $form = ob_get_clean();
1023 $message = __( 'Sorry, your site requires FTP authentication. Please download plugins from FormidableForms.com and install them manually.', 'formidable' );
1024 $data = $form;
1025 $response = array(
1026 'success' => false,
1027 'message' => $message,
1028 'form' => $form,
1029 );
1030 wp_send_json( $response );
1031 }
1032
1033 ob_end_clean();
1034 }
1035
1036 /**
1037 * Checks if an addon download url is allowed.
1038 *
1039 * @since 6.2
1040 *
1041 * @param string $download_url
1042 *
1043 * @return bool
1044 */
1045 public static function url_is_allowed( $download_url ) {
1046 return (
1047 FrmAppHelper::validate_url_is_in_s3_bucket( $download_url, 'zip' ) || in_array( $download_url, self::allowed_external_urls(), true )
1048 );
1049 }
1050
1051 /**
1052 * We do not need any extra credentials if we have gotten this far,
1053 * so let's install the plugin.
1054 *
1055 * @since 3.04.02
1056 */
1057 protected static function install_addon() {
1058 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1059
1060 $download_url = self::get_current_plugin();
1061
1062 if ( ! self::url_is_allowed( $download_url ) ) {
1063 return array(
1064 'message' => 'Plugin URL is not valid',
1065 'success' => false,
1066 );
1067 }
1068
1069 // Create the plugin upgrader with our custom skin.
1070 $installer = new Plugin_Upgrader( new FrmInstallerSkin() );
1071 $installer->install( $download_url );
1072
1073 // Flush the cache and return the newly installed plugin basename.
1074 wp_cache_flush();
1075
1076 $plugin = $installer->plugin_info();
1077 if ( ! $plugin ) {
1078 return array(
1079 'message' => 'Plugin was not installed. ' . $installer->result,
1080 'success' => false,
1081 );
1082 }
1083 return $plugin;
1084 }
1085
1086 /**
1087 * Handle the AJAX request to activate an add-on.
1088 *
1089 * @since 6.8
1090 *
1091 * @return void
1092 */
1093 public static function ajax_activate_addon() {
1094 self::process_addon_action(
1095 function( $plugin ) {
1096 return self::handle_addon_action( $plugin, 'activate' );
1097 },
1098 array( 'FrmAddonsController', 'get_addon_activation_response' )
1099 );
1100 }
1101
1102 /**
1103 * @since 3.04.02
1104 *
1105 * @param string $installed The plugin folder name with file name.
1106 */
1107 protected static function maybe_activate_addon( $installed ) {
1108 self::ajax_activate_addon();
1109 }
1110
1111 /**
1112 * Handle the AJAX request to deactivate an add-on.
1113 *
1114 * @since 6.8
1115 *
1116 * @return void
1117 */
1118 public static function ajax_deactivate_addon() {
1119 self::process_addon_action(
1120 function( $plugin ) {
1121 return self::handle_addon_action( $plugin, 'deactivate' );
1122 }
1123 );
1124 }
1125
1126 /**
1127 * Handle the AJAX request to uninstall an add-on.
1128 *
1129 * @since 6.8
1130 *
1131 * @return void
1132 */
1133 public static function ajax_uninstall_addon() {
1134 self::process_addon_action(
1135 function( $plugin ) {
1136 return self::handle_addon_action( $plugin, 'uninstall' );
1137 }
1138 );
1139 }
1140
1141 /**
1142 * Process a specific action (activate, deactivate, uninstall) on an add-on.
1143 *
1144 * @since 6.8
1145 *
1146 * @param callable $action_callback The specific add-on action to be executed.
1147 * @param callable|null $response_callback Optional. The response handling callback. Default null.
1148 * @return void
1149 */
1150 private static function process_addon_action( $action_callback, $response_callback = null ) {
1151 self::install_addon_permissions();
1152 FrmAppHelper::set_current_screen_and_hook_suffix();
1153
1154 $plugin = FrmAppHelper::get_param( 'plugin', '', 'post', 'sanitize_text_field' );
1155 call_user_func( $action_callback, $plugin );
1156
1157 if ( is_callable( $response_callback ) ) {
1158 wp_send_json_success( call_user_func( $response_callback ) );
1159 return;
1160 }
1161
1162 wp_send_json_success();
1163 }
1164
1165 /**
1166 * Attempt to perform a specific action (activate, deactivate, uninstall) on an add-on.
1167 *
1168 * @since 6.8
1169 *
1170 * @param string $installed The plugin folder name with file name.
1171 * @param string $action The action type ('activate', 'deactivate', 'uninstall').
1172 * @return void|array
1173 */
1174 protected static function handle_addon_action( $installed, $action ) {
1175 if ( ! $installed || ! $action ) {
1176 return;
1177 }
1178
1179 $result = null;
1180 switch ( $action ) {
1181 case 'activate':
1182 $result = self::activate_plugin( $installed );
1183 break;
1184 case 'deactivate':
1185 self::deactivate_plugin( $installed );
1186 break;
1187 case 'uninstall':
1188 $result = self::uninstall_plugin( $installed );
1189 break;
1190 }
1191
1192 if ( is_wp_error( $result ) ) {
1193 // Ignore the invalid header message that shows with nested plugins.
1194 if ( $result->get_error_code() !== 'no_plugin_header' ) {
1195 if ( wp_doing_ajax() ) {
1196 wp_send_json_error( array( 'error' => $result->get_error_message() ) );
1197 }
1198 return array(
1199 'message' => $result->get_error_message(),
1200 'success' => false,
1201 );
1202 }
1203 }
1204
1205 return $result;
1206 }
1207
1208 /**
1209 * @return array
1210 */
1211 private static function get_addon_activation_response() {
1212 $activating_page = self::get_activating_page();
1213
1214 $message = $activating_page ? __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ) : __( 'Your plugin has been activated.', 'formidable' );
1215
1216 $response = array(
1217 'message' => $message,
1218 'saveAndReload' => $activating_page,
1219 );
1220
1221 return $response;
1222 }
1223
1224 /**
1225 * Return a string that reflects the page from which the addon is being activated on,
1226 * if it is from settings or form builder, otherwise return empty string.
1227 *
1228 * @return string
1229 */
1230 private static function get_activating_page() {
1231 $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' );
1232 if ( false !== strpos( $referer, 'frm_action=settings' ) ) {
1233 return 'settings';
1234 }
1235
1236 if ( false !== strpos( $referer, 'frm_action=edit' ) ) {
1237 return 'form_builder';
1238 }
1239
1240 return '';
1241 }
1242
1243 /**
1244 * Run security checks before installing
1245 *
1246 * @since 3.04.02
1247 *
1248 * @return void
1249 */
1250 protected static function install_addon_permissions() {
1251 check_ajax_referer( 'frm_ajax', 'nonce' );
1252
1253 if ( ! current_user_can( 'activate_plugins' ) || ! self::get_current_plugin() ) {
1254 echo json_encode( true );
1255 wp_die();
1256 }
1257 }
1258
1259 /**
1260 * @since 4.08
1261 *
1262 * @return string
1263 */
1264 public static function connect_link() {
1265 $auth = get_option( 'frm_connect_token' );
1266 if ( empty( $auth ) ) {
1267 $auth = hash( 'sha512', wp_rand() );
1268 update_option( 'frm_connect_token', $auth, 'no' );
1269 }
1270 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title', 'formidable-settings' );
1271 $link = 'https://formidableforms.com/api-connect/';
1272 $args = array(
1273 'v' => 2,
1274 'siteurl' => FrmAppHelper::site_url(),
1275 'url' => get_rest_url(),
1276 'inst' => (int) FrmAppHelper::pro_is_included(),
1277 'return' => $page,
1278 'token' => $auth,
1279 'l' => self::get_pro_license(),
1280 );
1281
1282 return add_query_arg( $args, $link );
1283 }
1284
1285 /**
1286 * Check the auth value for install permission.
1287 *
1288 * @since 4.08
1289 *
1290 * @return bool
1291 */
1292 public static function can_install_addon_api() {
1293 // Verify params present (auth & download link).
1294 $post_auth = FrmAppHelper::get_param( 'token', '', 'request', 'sanitize_text_field' );
1295 $post_url = FrmAppHelper::get_param( 'file_url', '', 'request', 'sanitize_text_field' );
1296
1297 // The download link is not required if already installed.
1298 $is_installed = FrmAppHelper::pro_is_included();
1299 $file_missing = ! $is_installed && empty( $post_url );
1300 if ( ! $post_auth || $file_missing ) {
1301 return false;
1302 }
1303
1304 // Verify auth.
1305 $auth = get_option( 'frm_connect_token' );
1306 if ( empty( $auth ) || ! hash_equals( $auth, $post_auth ) ) {
1307 return false;
1308 }
1309
1310 return true;
1311 }
1312
1313 /**
1314 * Install and/or activate the add-on file.
1315 *
1316 * @since 4.08
1317 *
1318 * @return array
1319 */
1320 public static function install_addon_api() {
1321 self::$plugin = FrmAppHelper::get_param( 'file_url', '', 'request', 'esc_url_raw' );
1322
1323 $error = esc_html__( 'Could not install an upgrade. Please download from formidableforms.com and install manually.', 'formidable' );
1324
1325 // Delete so cannot replay.
1326 delete_option( 'frm_connect_token' );
1327
1328 // It's already installed and active.
1329 $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
1330 if ( is_wp_error( $active ) ) {
1331 $response = self::maybe_download_and_activate();
1332 if ( is_array( $response ) ) {
1333 // The download failed.
1334 return $response;
1335 }
1336 }
1337
1338 // If empty license, save it now.
1339 if ( empty( self::get_pro_license() ) && function_exists( 'load_formidable_pro' ) ) {
1340 load_formidable_pro();
1341 $license = stripslashes( FrmAppHelper::get_param( 'key', '', 'request', 'sanitize_text_field' ) );
1342 if ( ! $license ) {
1343 return array(
1344 'success' => false,
1345 'error' => 'That site does not have a valid license key.',
1346 );
1347 }
1348
1349 $response = FrmAddon::activate_license_for_plugin( $license, 'formidable_pro' );
1350 if ( ! $response['success'] ) {
1351 // Could not activate license.
1352 return $response;
1353 }
1354 }
1355
1356 return array(
1357 'success' => true,
1358 );
1359 }
1360
1361 /**
1362 * @since 6.8.3
1363 *
1364 * @return true|array
1365 */
1366 private static function maybe_download_and_activate() {
1367 if ( ! self::$plugin ) {
1368 return array(
1369 'success' => false,
1370 'message' => __( 'The plugin download was not found.', 'formidable' ),
1371 );
1372 }
1373
1374 // Download plugin now.
1375 $response = self::download_and_activate();
1376 if ( is_array( $response ) && isset( $response['success'] ) ) {
1377 // The download failed.
1378 return $response;
1379 }
1380
1381 return true;
1382 }
1383
1384 /**
1385 * Render a conditional action button for a specified plugin
1386 *
1387 * @since 4.09
1388 *
1389 * @param string $plugin
1390 * @param array|string $upgrade_link_args
1391 * @return void
1392 */
1393 public static function conditional_action_button( $plugin, $upgrade_link_args ) {
1394 if ( is_callable( 'FrmProAddonsController::conditional_action_button' ) ) {
1395 FrmProAddonsController::conditional_action_button( $plugin, $upgrade_link_args );
1396 return;
1397 }
1398
1399 $addon = self::get_addon( $plugin );
1400 $upgrade_link = FrmAppHelper::admin_upgrade_link( $upgrade_link_args );
1401
1402 if ( ! is_array( $upgrade_link_args ) ) {
1403 // A string $upgrade_link_args is used for the utm-medium value when calling
1404 // FrmAppHelper::admin_upgrade_link above.
1405 // For self::addon_upgrade_link, we'll pass just an empty array with the link key (set below).
1406 $upgrade_link_args = array();
1407 }
1408
1409 $upgrade_link_args['link'] = $upgrade_link;
1410
1411 self::addon_upgrade_link( $addon, $upgrade_link_args );
1412 }
1413
1414 /**
1415 * Render a conditional action button for an add on
1416 *
1417 * @since 4.09.01
1418 *
1419 * @param array $atts {
1420 * Button attributes.
1421 *
1422 * @type array $addon
1423 * @type string|false $license_type
1424 * @type string $plan_required
1425 * @type string $upgrade_link
1426 * }
1427 * @return void
1428 */
1429 public static function show_conditional_action_button( $atts ) {
1430 if ( is_callable( 'FrmProAddonsController::show_conditional_action_button' ) ) {
1431 FrmProAddonsController::show_conditional_action_button( $atts );
1432 return;
1433 }
1434
1435 self::addon_upgrade_link( $atts['addon'], $atts['upgrade_link'] );
1436 }
1437
1438 /**
1439 * @since 4.09.01
1440 *
1441 * @param array|false $addon
1442 * @param string|array $upgrade_link
1443 *
1444 * @return void
1445 */
1446 protected static function addon_upgrade_link( $addon, $upgrade_link ) {
1447 $atts = is_array( $upgrade_link ) ? $upgrade_link : array();
1448 $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link;
1449
1450 if ( $addon ) {
1451 $upgrade_link .= '&utm_content=' . $addon['slug'];
1452 }
1453
1454 if ( $addon && isset( $addon['categories'] ) && in_array( 'Solution', $addon['categories'], true ) ) {
1455 // Solutions will go to a separate page.
1456 $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] );
1457 }
1458
1459 $class = ! empty( $atts['class'] ) ? $atts['class'] : '';
1460 if ( strpos( $class, 'frm-button' ) === false ) {
1461 $class .= ' frm-button-secondary frm-button-sm';
1462 }
1463 ?>
1464 <a class="install-now button <?php echo esc_attr( $class ); ?>" href="<?php echo esc_url( $upgrade_link ); ?>" target="_blank" rel="noopener" aria-label="<?php esc_attr_e( 'Upgrade Now', 'formidable' ); ?>">
1465 <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?>
1466 </a>
1467 <?php
1468 }
1469
1470 /**
1471 * @since 3.04.02
1472 *
1473 * @return void
1474 */
1475 public static function ajax_install_addon() {
1476 self::install_addon_permissions();
1477
1478 $result = self::download_and_activate();
1479 if ( isset( $result['success'] ) && ! $result['success'] ) {
1480 echo json_encode( $result );
1481 wp_die();
1482 }
1483
1484 echo json_encode( self::get_addon_activation_response() );
1485 wp_die();
1486 }
1487
1488 /**
1489 * Allowed URLs used for internal source of plugins installation.
1490 *
1491 * @since 6.3.1
1492 *
1493 * @return array
1494 */
1495 private static function allowed_external_urls() {
1496 $allowed_url_list = array(
1497 'https://downloads.wordpress.org/plugin/formidable-gravity-forms-importer.zip',
1498 'https://downloads.wordpress.org/plugin/formidable-import-pirate-forms.zip',
1499 'https://downloads.wordpress.org/plugin/wp-mail-smtp.zip',
1500 );
1501
1502 /**
1503 * List of URLs used in plugin formidable internal installation.
1504 *
1505 * @since 6.3.1
1506 *
1507 * @param array $allowed_url_list List of URLs.
1508 */
1509 $allowed_url_list = apply_filters( 'frm_allowed_external_urls', $allowed_url_list );
1510
1511 if ( ! is_array( $allowed_url_list ) ) {
1512 _doing_it_wrong( __METHOD__, 'Only an array of URLs could be used within this filter.', '6.3.1' );
1513
1514 return array();
1515 }
1516
1517 return $allowed_url_list;
1518 }
1519
1520 /**
1521 * Gets required plan for an addon.
1522 *
1523 * @since 6.4.2
1524 *
1525 * @return string Empty string if no plan is required for active license.
1526 */
1527 public static function get_addon_required_plan( $addon_id ) {
1528 $api = new FrmFormApi();
1529 $addons = $api->get_api_info();
1530
1531 if ( is_array( $addons ) && array_key_exists( $addon_id, $addons ) ) {
1532 $dates = $addons[ $addon_id ];
1533 $requires = FrmFormsHelper::get_plan_required( $dates );
1534 }
1535
1536 if ( ! isset( $requires ) || ! is_string( $requires ) ) {
1537 $requires = '';
1538 }
1539
1540 return $requires;
1541 }
1542
1543 /**
1544 * @since 4.06.02
1545 *
1546 * @deprecated 4.09.01
1547 *
1548 * @return void
1549 */
1550 public static function ajax_multiple_addons() {
1551 FrmDeprecated::ajax_multiple_addons();
1552 }
1553
1554 /**
1555 * @since 3.04.03
1556 * @deprecated 3.06
1557 * @codeCoverageIgnore
1558 * @return array
1559 */
1560 public static function error_for_license( $license ) {
1561 return FrmDeprecated::error_for_license( $license );
1562 }
1563
1564 /**
1565 * @since 3.04.03
1566 * @deprecated 3.06
1567 * @codeCoverageIgnore
1568 */
1569 public static function get_pro_updater() {
1570 return FrmDeprecated::get_pro_updater();
1571 }
1572
1573 /**
1574 * @since 3.04.03
1575 * @deprecated 3.06
1576 * @codeCoverageIgnore
1577 *
1578 * @return array
1579 */
1580 public static function get_addon_info( $license = '' ) {
1581 return FrmDeprecated::get_addon_info( $license );
1582 }
1583
1584 /**
1585 * @since 3.04.03
1586 * @deprecated 3.06
1587 * @codeCoverageIgnore
1588 *
1589 * @return string
1590 */
1591 public static function get_cache_key( $license ) {
1592 return FrmDeprecated::get_cache_key( $license );
1593 }
1594
1595 /**
1596 * @since 3.04.03
1597 *
1598 * @deprecated 3.06
1599 *
1600 * @codeCoverageIgnore
1601 *
1602 * @return void
1603 */
1604 public static function reset_cached_addons( $license = '' ) {
1605 FrmDeprecated::reset_cached_addons( $license );
1606 }
1607
1608 /**
1609 * @since 2.03.08
1610 * @deprecated 3.04.03
1611 * @codeCoverageIgnore
1612 *
1613 * @param boolean $return
1614 * @param string $package
1615 *
1616 * @return boolean
1617 */
1618 public static function add_shorten_edd_filename_filter( $return, $package ) {
1619 return FrmDeprecated::add_shorten_edd_filename_filter( $return, $package );
1620 }
1621
1622 /**
1623 * @since 2.03.08
1624 * @deprecated 3.04.03
1625 * @codeCoverageIgnore
1626 *
1627 * @param string $filename
1628 * @param string $ext
1629 *
1630 * @return string
1631 */
1632 public static function shorten_edd_filename( $filename, $ext ) {
1633 return FrmDeprecated::shorten_edd_filename( $filename, $ext );
1634 }
1635
1636 /**
1637 * @deprecated 3.04.03
1638 *
1639 * @codeCoverageIgnore
1640 *
1641 * @return void
1642 */
1643 public static function get_licenses() {
1644 FrmDeprecated::get_licenses();
1645 }
1646
1647 /**
1648 * @since 4.02.05
1649 * @deprecated 6.8.3
1650 *
1651 * @codeCoverageIgnore
1652 *
1653 * @return void
1654 */
1655 public static function connect_pro() {
1656 _deprecated_function( __METHOD__, '6.8.3' );
1657 }
1658 }
1659