PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
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/controllers/FrmAddonsController.php +413 -293 6.25.16.8 View file →
@@ -5,93 +5,15 @@
5 5
6 6 class FrmAddonsController {
7 7
8 8 /**
9 - * @var string
9 + * @var string $plugin
10 10 */
11 - const SCRIPT_HANDLE = 'frm-addons-page';
12 -
13 - /**
14 - * @var array
15 - */
16 - private static $categories = array();
17 -
18 - /**
19 - * @var string
20 - */
21 - private static $request_addon_url;
22 -
23 - /**
24 - * @var string
25 - */
26 11 protected static $plugin;
27 12
28 13 /**
29 - * @since 6.15
30 - */
31 - public static function load_admin_hooks() {
32 - add_action( 'admin_menu', self::class . '::menu', 100 );
33 - add_filter( 'pre_set_site_transient_update_plugins', self::class . '::check_update' );
34 -
35 - if ( FrmAppHelper::is_admin_page( 'formidable-addons' ) ) {
36 - self::$request_addon_url = 'https://connect.formidableforms.com/add-on-request/';
37 -
38 - add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
39 - add_filter( 'frm_show_footer_links', '__return_false' );
40 - }
41 - }
42 -
43 - /**
44 - * Enqueues the Add-Ons page scripts and styles.
45 - *
46 - * @since 6.15
47 - *
48 14 * @return void
49 15 */
50 - public static function enqueue_assets() {
51 - $plugin_url = FrmAppHelper::plugin_url();
52 - $version = FrmAppHelper::plugin_version();
53 - $js_dependencies = array(
54 - 'wp-i18n',
55 - // This prevents a console error "wp.hooks is undefined" in WP versions older than 5.7.
56 - 'wp-hooks',
57 - 'formidable_dom',
58 - );
59 -
60 - // Enqueue styles that needed.
61 - wp_enqueue_style( 'formidable-admin' );
62 - wp_enqueue_style( 'formidable-grids' );
63 -
64 - // Register and enqueue Add-Ons page style.
65 - wp_register_style( self::SCRIPT_HANDLE, $plugin_url . '/css/admin/addons-page.css', array(), $version );
66 - wp_enqueue_style( self::SCRIPT_HANDLE );
67 -
68 - // Register and enqueue Add-Ons page script.
69 - wp_register_script( self::SCRIPT_HANDLE, $plugin_url . '/js/addons-page.js', $js_dependencies, $version, true );
70 - wp_localize_script( self::SCRIPT_HANDLE, 'frmAddonsVars', self::get_js_variables() );
71 - wp_enqueue_script( self::SCRIPT_HANDLE );
72 - wp_set_script_translations( self::SCRIPT_HANDLE, 'formidable' );
73 -
74 - FrmAppHelper::dequeue_extra_global_scripts();
75 - }
76 -
77 - /**
78 - * Get the Add-Ons page JS variables as an array.
79 - *
80 - * @since 6.15
81 - *
82 - * @return array
83 - */
84 - private static function get_js_variables() {
85 - return array(
86 - 'proIsIncluded' => FrmAppHelper::pro_is_included(),
87 - 'addonRequestURL' => self::$request_addon_url,
88 - );
89 - }
90 -
91 - /**
92 - * @return void
93 - */
94 16 public static function menu() {
95 17 if ( ! current_user_can( 'activate_plugins' ) ) {
96 18 return;
97 19 }
@@ -96,9 +18,9 @@
96 18 return;
97 19 }
98 20
99 21 $label = __( 'Add-Ons', 'formidable' );
100 - $label = '<span style="color:#3FCA89">' . esc_html( $label ) . '</span>';
22 + $label = '<span style="color:#1da867">' . $label . '</span>';
101 23
102 24 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Add-Ons', 'formidable' ), $label, 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
103 25
104 26 // remove default created subpage, make the page with highest priority as default.
@@ -104,28 +26,20 @@
104 26 // remove default created subpage, make the page with highest priority as default.
105 27 remove_submenu_page( 'formidable', 'formidable' );
106 28
107 29 if ( ! FrmAppHelper::pro_is_installed() ) {
108 - $cta_text = FrmSalesApi::get_best_sale_value( 'menu_cta_text' );
109 - if ( ! $cta_text ) {
110 - $cta_text = __( 'Upgrade', 'formidable' );
111 - }
112 -
113 30 add_submenu_page(
114 31 'formidable',
115 32 'Formidable | ' . __( 'Upgrade', 'formidable' ),
116 - '<span class="frm-upgrade-submenu">' . esc_html( $cta_text ) . '</span>',
33 + '<span class="frm-upgrade-submenu">' . __( 'Upgrade', 'formidable' ) . '</span>',
117 34 'frm_view_forms',
118 35 'formidable-pro-upgrade',
119 - function () {
120 - // This function doesn't need to do anything.
121 - // The redirect is handled earlier to avoid issues with the headers being sent.
122 - }
36 + 'FrmAddonsController::upgrade_to_pro'
123 37 );
124 38 } elseif ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) ) {
125 39 wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
126 40 exit;
127 - }//end if
41 + }
128 42 }
129 43
130 44 /**
131 45 * @return void
@@ -131,31 +45,28 @@
131 45 * @return void
132 46 */
133 47 public static function list_addons() {
134 48 FrmAppHelper::include_svg();
49 + $installed_addons = apply_filters( 'frm_installed_addons', array() );
50 + $license_type = '';
135 51
136 - $view_path = FrmAppHelper::plugin_path() . '/classes/views/addons/';
137 - $installed_addons = apply_filters( 'frm_installed_addons', array() );
138 - $addons = self::get_api_addons();
139 - $errors = array();
140 - $license_type = '';
141 - $request_addon_url = self::$request_addon_url;
52 + $addons = self::get_api_addons();
53 + $errors = array();
142 54
143 55 if ( isset( $addons['error'] ) ) {
144 - $api = new FrmFormApi();
145 - $errors = $api->get_error_from_response( $addons );
146 - $license_type = $addons['error']['type'] ?? '';
56 + $api = new FrmFormApi();
57 + $errors = $api->get_error_from_response( $addons );
58 + $license_type = isset( $addons['error']['type'] ) ? $addons['error']['type'] : '';
147 59 unset( $addons['error'] );
148 60 }
149 61
150 - $pro = array(
62 + $pro = array(
151 63 'pro' => array(
152 - 'title' => 'Formidable Forms Pro',
153 - 'slug' => 'formidable-pro',
154 - 'released' => '2011-02-05',
155 - 'docs' => 'knowledgebase/',
156 - 'categories' => array( 'basic', 'plus', 'business', 'elite' ),
157 - 'excerpt' => 'Create calculators, surveys, smart forms, and data-driven applications. Build directories, real estate listings, job boards, and much more.',
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.',
158 69 ),
159 70 );
160 71 $addons = $pro + $addons;
161 72 self::prepare_addons( $addons );
@@ -161,105 +72,14 @@
161 72 self::prepare_addons( $addons );
162 73
163 74 $pricing = FrmAppHelper::admin_upgrade_link( 'addons' );
164 75
165 - self::organize_and_get_categories();
166 - $categories = self::$categories;
167 -
168 - include $view_path . 'index.php';
76 + include( FrmAppHelper::plugin_path() . '/classes/views/addons/list.php' );
169 77 }
170 78
171 79 /**
172 - * Organize and set categories.
173 - *
174 - * @since 6.15
175 - *
176 80 * @return void
177 81 */
178 - protected static function organize_and_get_categories() {
179 - unset( self::$categories['strategy11'] );
180 - ksort( self::$categories );
181 -
182 - $bottom_categories = array();
183 - $plans = FrmFormsHelper::get_license_types(
184 - array(
185 - 'include_all' => false,
186 - 'case_lower' => true,
187 - )
188 - );
189 -
190 - // Extract the elements to move
191 - foreach ( $plans as $plan ) {
192 - if ( isset( self::$categories[ $plan ] ) ) {
193 - $bottom_categories[ $plan ] = self::$categories[ $plan ];
194 - unset( self::$categories[ $plan ] );
195 - }
196 - }
197 -
198 - $special_categories = array();
199 - if ( 'elite' !== self::license_type() ) {
200 - $special_categories['available-addons'] = array(
201 - 'name' => __( 'Available', 'formidable' ),
202 - // To be assigned via JavaScript.
203 - 'count' => 0,
204 - );
205 - }
206 -
207 - $special_categories['active-addons'] = array(
208 - 'name' => __( 'Active', 'formidable' ),
209 - // To be assigned via JavaScript.
210 - 'count' => 0,
211 - );
212 -
213 - $special_categories['all-items'] = array(
214 - 'name' => __( 'All Add-Ons', 'formidable' ),
215 - // To be assigned via JavaScript.
216 - 'count' => 0,
217 - );
218 -
219 - self::$categories = array_merge(
220 - $special_categories,
221 - self::$categories,
222 - $bottom_categories
223 - );
224 - }
225 -
226 - /**
227 - * Organize and set categories.
228 - *
229 - * @since 6.15
230 - *
231 - * @param array $addon The addon array that will be modified by reference.
232 - * @return void
233 - */
234 - protected static function set_categories( &$addon ) {
235 - if ( ! isset( $addon['categories'] ) ) {
236 - return;
237 - }
238 -
239 - $addon['category-slugs'] = array();
240 -
241 - foreach ( $addon['categories'] as $category ) {
242 - $category = FrmFormsHelper::convert_legacy_package_names( $category );
243 - $category_slug = sanitize_title( $category );
244 -
245 - // Add the slug to the new array.
246 - $addon['category-slugs'][] = $category_slug;
247 -
248 - if ( ! isset( self::$categories[ $category_slug ] ) ) {
249 - self::$categories[ $category_slug ] = array(
250 - 'name' => $category,
251 - 'count' => 0,
252 - );
253 - }
254 -
255 - ++self::$categories[ $category_slug ]['count'];
256 - }
257 - }
258 -
259 - /**
260 - * @return void
261 - */
262 82 public static function license_settings() {
263 83 $plugins = apply_filters( 'frm_installed_addons', array() );
264 84 if ( empty( $plugins ) ) {
265 85 esc_html_e( 'There are no plugins on your site that require a license', 'formidable' );
@@ -268,9 +88,9 @@
268 88 }
269 89
270 90 ksort( $plugins );
271 91
272 - include FrmAppHelper::plugin_path() . '/classes/views/addons/settings.php';
92 + include( FrmAppHelper::plugin_path() . '/classes/views/addons/settings.php' );
273 93 }
274 94
275 95 /**
276 96 * @return array
@@ -292,21 +112,8 @@
292 112 return $addons;
293 113 }
294 114
295 115 /**
296 - * Retrieves the count of available addons.
297 - *
298 - * @since 6.9
299 - *
300 - * @return int Count of addons.
301 - */
302 - public static function get_addons_count() {
303 - $addons = self::get_api_addons();
304 -
305 - return count( $addons );
306 - }
307 -
308 - /**
309 116 * If the API is unable to connect, show something on the addons page
310 117 *
311 118 * @since 3.04.03
312 119 * @return array
@@ -414,9 +221,9 @@
414 221 $api = new FrmFormApi( $license );
415 222 $downloads = $api->get_api_info();
416 223 $pro = self::get_pro_from_addons( $downloads );
417 224
418 - return $pro['url'] ?? '';
225 + return isset( $pro['url'] ) ? $pro['url'] : '';
419 226 }
420 227
421 228 /**
422 229 * @since 4.08
@@ -452,9 +259,9 @@
452 259 * @param array $addons
453 260 * @return array
454 261 */
455 262 protected static function get_pro_from_addons( $addons ) {
456 - return $addons['93790'] ?? array();
263 + return isset( $addons['93790'] ) ? $addons['93790'] : array();
457 264 }
458 265
459 266 /**
460 267 * @since 4.06
@@ -468,10 +275,8 @@
468 275 }
469 276
470 277 /**
471 278 * @since 4.0.01
472 - *
473 - * @return bool
474 279 */
475 280 public static function is_license_expired() {
476 281 $version_info = self::get_primary_license_info();
477 282 if ( ! isset( $version_info['error'] ) ) {
@@ -477,20 +282,22 @@
477 282 if ( ! isset( $version_info['error'] ) ) {
478 283 return false;
479 284 }
480 285
481 - $expires = $version_info['error']['expires'] ?? 0;
482 - if ( empty( $expires ) || $expires > time() ) {
483 - return false;
484 - }
286 + return $version_info['error'];
287 + }
485 288
486 - $rate_limited = ! empty( $version_info['response_code'] ) && 429 === (int) $version_info['response_code'];
487 - if ( $rate_limited ) {
488 - // Do not return false positives for rate limited responses.
489 - return false;
289 + /**
290 + * @since 4.08
291 + *
292 + * @return boolean|int false or the number of days until expiration.
293 + */
294 + public static function is_license_expiring() {
295 + if ( is_callable( 'FrmProAddonsController::is_license_expiring' ) ) {
296 + return FrmProAddonsController::is_license_expiring();
490 297 }
491 298
492 - return $version_info['error'];
299 + return false;
493 300 }
494 301
495 302 /**
496 303 * @since 4.08
@@ -531,9 +338,9 @@
531 338 $version_info = self::fill_update_addon_info( $installed_addons );
532 339 $transient->last_checked = time();
533 340 $wp_plugins = self::get_plugins();
534 341
535 - foreach ( $version_info as $plugin ) {
342 + foreach ( $version_info as $id => $plugin ) {
536 343 $plugin = (object) $plugin;
537 344
538 345 if ( ! isset( $plugin->new_version ) || ! isset( $plugin->package ) ) {
539 346 continue;
@@ -548,10 +355,10 @@
548 355 // don't show an update if the plugin isn't installed
549 356 continue;
550 357 }
551 358
552 - $wp_plugin = $wp_plugins[ $folder ] ?? array();
553 - $wp_version = $wp_plugin['Version'] ?? '1.0';
359 + $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array();
360 + $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0';
554 361 $plugin->slug = explode( '/', $folder )[0];
555 362
556 363 if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) {
557 364 $transient->response[ $folder ] = $plugin;
@@ -629,9 +436,9 @@
629 436 if ( empty( $plugin ) ) {
630 437 continue;
631 438 }
632 439
633 - $download_id = $plugin['id'] ?? 0;
440 + $download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0;
634 441 if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) {
635 442 // if this addon is using its own license, get the update url
636 443 $addon_info = $api->get_api_info();
637 444
@@ -664,14 +471,14 @@
664 471 $link = array(
665 472 'url' => $addon['plugin'],
666 473 'class' => 'frm-activate-addon',
667 474 );
668 - } elseif ( ! empty( $addon['url'] ) ) {
475 + } elseif ( isset( $addon['url'] ) && ! empty( $addon['url'] ) ) {
669 476 $link = array(
670 477 'url' => $addon['url'],
671 478 'class' => 'frm-install-addon',
672 479 );
673 - } elseif ( ! empty( $addon['categories'] ) ) {
480 + } elseif ( isset( $addon['categories'] ) && ! empty( $addon['categories'] ) ) {
674 481 $link = array(
675 482 'categories' => $addon['categories'],
676 483 );
677 484 }
@@ -693,9 +500,9 @@
693 500 * @since 4.09
694 501 * @param string $plugin The plugin slug.
695 502 * @return array|false
696 503 */
697 - public static function get_addon( $plugin ) {
504 + protected static function get_addon( $plugin ) {
698 505 $addons = self::get_api_addons();
699 506 self::prepare_addons( $addons );
700 507 foreach ( $addons as $addon ) {
701 508 $slug = explode( '/', $addon['plugin'] );
@@ -731,9 +538,9 @@
731 538 $download_id = $license->download_id;
732 539 $plugin = array();
733 540 if ( empty( $download_id ) && ! empty( $addons ) ) {
734 541 foreach ( $addons as $addon ) {
735 - if ( strtolower( $license->plugin_name ) === strtolower( $addon['title'] ) ) {
542 + if ( strtolower( $license->plugin_name ) == strtolower( $addon['title'] ) ) {
736 543 return $addon;
737 544 }
738 545 }
739 546 } elseif ( isset( $addons[ $download_id ] ) ) {
@@ -797,13 +604,11 @@
797 604
798 605 if ( ! isset( $addon['link'] ) ) {
799 606 $addon['link'] = 'downloads/' . $slug . '/';
800 607 }
608 + self::prepare_addon_link( $addon['link'] );
801 609
802 - self::prepare_addon_link( $addon['link'] );
803 610 self::set_addon_status( $addon );
804 - self::set_categories( $addon );
805 -
806 611 $addons[ $id ] = $addon;
807 612 }//end foreach
808 613 }
809 614
@@ -817,9 +622,9 @@
817 622 return is_plugin_active( $file_name );
818 623 }
819 624
820 625 /**
821 - * @return false|string either 'visual-views' or 'views', false if one is not found.
626 + * @return string|false either 'visual-views' or 'views', false if one is not found.
822 627 */
823 628 private static function get_active_views_version() {
824 629 if ( ! is_callable( 'FrmViewsAppHelper::plugin_version' ) ) {
825 630 return false;
@@ -838,13 +643,14 @@
838 643 if ( strpos( $link, 'http' ) !== 0 ) {
839 644 $link = $site_url . $link;
840 645 }
841 646 $link = FrmAppHelper::make_affiliate_url( $link );
842 -
843 - $utm = array(
844 - 'campaign' => 'addons',
647 + $query_args = array(
648 + 'utm_source' => 'WordPress',
649 + 'utm_medium' => 'addons',
650 + 'utm_campaign' => 'liteplugin',
845 651 );
846 - $link = FrmAppHelper::maybe_add_missing_utm( $link, $utm );
652 + $link = add_query_arg( $query_args, $link );
847 653 }
848 654
849 655 /**
850 656 * Add the status to the addon array. Status options are:
@@ -873,8 +679,250 @@
873 679 }
874 680 }
875 681
876 682 /**
683 + * @return void
684 + */
685 + public static function upgrade_to_pro() {
686 + FrmAppHelper::include_svg();
687 +
688 + $link_parts = array(
689 + 'medium' => 'upgrade',
690 + 'content' => 'button',
691 + );
692 +
693 + $features = array(
694 + 'Display Entries' => array(
695 + array(
696 + 'label' => 'Display form data with virtually limitless views',
697 + 'link' => array(
698 + 'content' => 'views',
699 + 'param' => 'views-display-form-data',
700 + ),
701 + 'lite' => false,
702 + ),
703 + array(
704 + 'label' => 'Generate graphs and stats based on your submitted data',
705 + 'link' => array(
706 + 'content' => 'graphs',
707 + 'param' => 'statistics-graphs-wordpress-forms',
708 + ),
709 + 'lite' => false,
710 + ),
711 + ),
712 + 'Entry Management' => array(
713 + array(
714 + 'label' => 'Import entries from a CSV',
715 + 'link' => array(
716 + 'content' => 'import-entries',
717 + 'param' => 'importing-exporting-wordpress-forms',
718 + ),
719 + 'lite' => false,
720 + ),
721 + array(
722 + 'label' => 'Logged-in users can save drafts and return later',
723 + 'link' => array(
724 + 'content' => 'save-drafts',
725 + 'param' => 'save-drafts-wordpress-form',
726 + ),
727 + 'lite' => false,
728 + ),
729 + array(
730 + 'label' => 'Flexibly and powerfully view, edit, and delete entries from anywhere on your site',
731 + 'link' => array(
732 + 'content' => 'front-edit',
733 + 'param' => 'wordpress-front-end-editing',
734 + ),
735 + 'lite' => false,
736 + ),
737 + array(
738 + 'label' => 'View form submissions from the back-end',
739 + 'lite' => true,
740 + ),
741 + array(
742 + 'label' => 'Export your entries to a CSV',
743 + 'lite' => true,
744 + ),
745 + ),
746 + 'Form Building' => array(
747 + array(
748 + 'label' => 'Save a calculated value into a field',
749 + 'link' => array(
750 + 'content' => 'calculations',
751 + 'param' => 'field-calculations-wordpress-form',
752 + ),
753 + 'lite' => false,
754 + ),
755 + array(
756 + 'label' => 'Allow multiple file uploads',
757 + 'link' => array(
758 + 'content' => 'file-uploads',
759 + 'param' => 'wordpress-multi-file-upload-fields',
760 + ),
761 + 'lite' => false,
762 + ),
763 + array(
764 + 'label' => 'Repeat sections of fields',
765 + 'link' => array(
766 + 'content' => 'repeaters',
767 + 'param' => 'repeatable-sections-forms',
768 + ),
769 + 'lite' => false,
770 + ),
771 + array(
772 + 'label' => 'Hide and show fields conditionally based on other fields or the user\'s role',
773 + 'link' => array(
774 + 'content' => 'conditional-logic',
775 + 'param' => 'conditional-logic-wordpress-forms',
776 + ),
777 + 'lite' => false,
778 + ),
779 + array(
780 + 'label' => 'Confirmation fields',
781 + 'link' => array(
782 + 'content' => 'confirmation-fields',
783 + 'param' => 'confirmation-fields-wordpress-forms',
784 + ),
785 + 'lite' => false,
786 + ),
787 + array(
788 + 'label' => 'Multi-paged forms',
789 + 'link' => array(
790 + 'content' => 'page-breaks',
791 + 'param' => 'wordpress-multi-page-forms',
792 + ),
793 + 'lite' => false,
794 + ),
795 + array(
796 + '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.',
797 + 'lite' => false,
798 + ),
799 + array(
800 + 'label' => 'Include text, email, url, paragraph text, radio, checkbox, dropdown fields, hidden fields, user ID fields, and HTML blocks in your form.',
801 + 'lite' => true,
802 + ),
803 + array(
804 + 'label' => 'Drag & Drop Form building',
805 + 'link' => array(
806 + 'content' => 'drag-drop',
807 + 'param' => 'drag-drop-forms',
808 + ),
809 + 'lite' => true,
810 + ),
811 + array(
812 + 'label' => 'Create forms from Templates',
813 + 'link' => array(
814 + 'content' => 'form-templates',
815 + 'param' => 'wordpress-form-templates',
816 + ),
817 + 'lite' => true,
818 + ),
819 + array(
820 + 'label' => 'Import and export forms with XML',
821 + 'link' => array(
822 + 'content' => 'import',
823 + 'param' => 'importing-exporting-wordpress-forms',
824 + ),
825 + 'lite' => true,
826 + ),
827 + array(
828 + 'label' => 'Use input placeholder text in your fields that clear when typing starts.',
829 + 'lite' => true,
830 + ),
831 + ),
832 + 'Form Actions' => array(
833 + array(
834 + 'label' => 'Conditionally send your email notifications based on values in your form',
835 + 'link' => array(
836 + 'content' => 'conditional-emails',
837 + ),
838 + 'lite' => false,
839 + ),
840 + array(
841 + 'label' => 'Create and edit WordPress posts or custom posts from the front-end',
842 + 'link' => array(
843 + 'content' => 'create-posts',
844 + 'param' => 'create-posts-pages-wordpress-forms',
845 + ),
846 + 'lite' => false,
847 + ),
848 + array(
849 + 'label' => 'Send multiple emails and autoresponders',
850 + 'link' => array(
851 + 'content' => 'multiple-emails',
852 + 'param' => 'virtually-unlimited-emails',
853 + ),
854 + 'lite' => true,
855 + ),
856 + ),
857 + 'Form Appearance' => array(
858 + array(
859 + 'label' => 'Create Multiple styles for different forms',
860 + 'link' => array(
861 + 'content' => 'multiple-styles',
862 + 'param' => 'wordpress-visual-form-styler',
863 + ),
864 + 'lite' => false,
865 + ),
866 + array(
867 + 'label' => 'Customizable layout with CSS classes',
868 + 'link' => array(
869 + 'content' => 'form-layout',
870 + 'param' => 'wordpress-mobile-friendly-forms',
871 + ),
872 + 'lite' => true,
873 + ),
874 + array(
875 + 'label' => 'Customize the HTML for your forms',
876 + 'link' => array(
877 + 'content' => 'custom-html',
878 + 'param' => 'customizable-html-wordpress-form',
879 + ),
880 + 'lite' => true,
881 + ),
882 + array(
883 + 'label' => 'Style your form with the Visual Form Styler',
884 + 'lite' => true,
885 + ),
886 + ),
887 + );
888 +
889 + include( FrmAppHelper::plugin_path() . '/classes/views/addons/upgrade_to_pro.php' );
890 + }
891 +
892 + /**
893 + * Install Pro after connection with Formidable.
894 + *
895 + * @since 4.02.05
896 + *
897 + * @return void
898 + */
899 + public static function connect_pro() {
900 + FrmAppHelper::permission_check( 'install_plugins' );
901 + check_ajax_referer( 'frm_ajax', 'nonce' );
902 +
903 + $url = self::get_current_plugin();
904 + if ( FrmAppHelper::pro_is_installed() || empty( $url ) ) {
905 + wp_die();
906 + }
907 +
908 + $response = array();
909 +
910 + // It's already installed and active.
911 + $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
912 + if ( is_wp_error( $active ) ) {
913 + // The plugin was installed, but not active. Download it now.
914 + self::ajax_install_addon();
915 + } else {
916 + $response['active'] = true;
917 + $response['success'] = true;
918 + }
919 +
920 + echo json_encode( $response );
921 + wp_die();
922 + }
923 +
924 + /**
877 925 * @since 5.5.2
878 926 *
879 927 * @param string $plugin
880 928 * @param string $redirect
@@ -879,9 +927,9 @@
879 927 * @param string $plugin
880 928 * @param string $redirect
881 929 * @param bool $network_wide
882 930 * @param bool $silent
883 - * @return WP_Error|null Null on success, WP_Error on invalid file.
931 + * @return null|WP_Error Null on success, WP_Error on invalid file.
884 932 */
885 933 protected static function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
886 934 if ( ! function_exists( 'activate_plugin' ) ) {
887 935 require_once ABSPATH . 'wp-admin/includes/plugin.php';
@@ -945,10 +993,8 @@
945 993 }
946 994
947 995 /**
948 996 * @since 4.08
949 - *
950 - * @return array|void
951 997 */
952 998 protected static function download_and_activate() {
953 999 if ( is_admin() ) {
954 1000 FrmAppHelper::set_current_screen_and_hook_suffix();
@@ -969,12 +1015,12 @@
969 1015 * @return void
970 1016 */
971 1017 protected static function maybe_show_cred_form() {
972 1018 if ( ! function_exists( 'request_filesystem_credentials' ) ) {
973 - include_once ABSPATH . 'wp-admin/includes/file.php';
1019 + include_once( ABSPATH . 'wp-admin/includes/file.php' );
974 1020 }
975 1021
976 - // Start output buffering to catch the filesystem form if credentials are needed.
1022 + // Start output bufferring to catch the filesystem form if credentials are needed.
977 1023 ob_start();
978 1024
979 1025 $show_form = false;
980 1026 $method = '';
@@ -1013,9 +1059,11 @@
1013 1059 *
1014 1060 * @return bool
1015 1061 */
1016 1062 public static function url_is_allowed( $download_url ) {
1017 - return FrmAppHelper::validate_url_is_in_s3_bucket( $download_url, 'zip' ) || in_array( $download_url, self::allowed_external_urls(), true );
1063 + return (
1064 + FrmAppHelper::validate_url_is_in_s3_bucket( $download_url, 'zip' ) || in_array( $download_url, self::allowed_external_urls(), true )
1065 + );
1018 1066 }
1019 1067
1020 1068 /**
1021 1069 * We do not need any extra credentials if we have gotten this far,
@@ -1060,9 +1108,9 @@
1060 1108 * @return void
1061 1109 */
1062 1110 public static function ajax_activate_addon() {
1063 1111 self::process_addon_action(
1064 - function ( $plugin ) {
1112 + function( $plugin ) {
1065 1113 return self::handle_addon_action( $plugin, 'activate' );
1066 1114 },
1067 1115 array( 'FrmAddonsController', 'get_addon_activation_response' )
1068 1116 );
@@ -1085,9 +1133,9 @@
1085 1133 * @return void
1086 1134 */
1087 1135 public static function ajax_deactivate_addon() {
1088 1136 self::process_addon_action(
1089 - function ( $plugin ) {
1137 + function( $plugin ) {
1090 1138 return self::handle_addon_action( $plugin, 'deactivate' );
1091 1139 }
1092 1140 );
1093 1141 }
@@ -1100,9 +1148,9 @@
1100 1148 * @return void
1101 1149 */
1102 1150 public static function ajax_uninstall_addon() {
1103 1151 self::process_addon_action(
1104 - function ( $plugin ) {
1152 + function( $plugin ) {
1105 1153 return self::handle_addon_action( $plugin, 'uninstall' );
1106 1154 }
1107 1155 );
1108 1156 }
@@ -1137,9 +1185,9 @@
1137 1185 * @since 6.8
1138 1186 *
1139 1187 * @param string $installed The plugin folder name with file name.
1140 1188 * @param string $action The action type ('activate', 'deactivate', 'uninstall').
1141 - * @return array|void
1189 + * @return void|array
1142 1190 */
1143 1191 protected static function handle_addon_action( $installed, $action ) {
1144 1192 if ( ! $installed || ! $action ) {
1145 1193 return;
@@ -1235,16 +1283,13 @@
1235 1283 if ( empty( $auth ) ) {
1236 1284 $auth = hash( 'sha512', wp_rand() );
1237 1285 update_option( 'frm_connect_token', $auth, 'no' );
1238 1286 }
1239 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title', 'formidable-settings' );
1240 - $link = 'https://formidableforms.com/api-connect/';
1287 + $link = FrmAppHelper::admin_upgrade_link( 'connect', 'api-connect' );
1241 1288 $args = array(
1242 1289 'v' => 2,
1243 1290 'siteurl' => FrmAppHelper::site_url(),
1244 1291 'url' => get_rest_url(),
1245 - 'inst' => (int) FrmAppHelper::pro_is_included(),
1246 - 'return' => $page,
1247 1292 'token' => $auth,
1248 1293 'l' => self::get_pro_license(),
1249 1294 );
1250 1295
@@ -1262,12 +1307,9 @@
1262 1307 // Verify params present (auth & download link).
1263 1308 $post_auth = FrmAppHelper::get_param( 'token', '', 'request', 'sanitize_text_field' );
1264 1309 $post_url = FrmAppHelper::get_param( 'file_url', '', 'request', 'sanitize_text_field' );
1265 1310
1266 - // The download link is not required if already installed.
1267 - $is_installed = FrmAppHelper::pro_is_included();
1268 - $file_missing = ! $is_installed && empty( $post_url );
1269 - if ( ! $post_auth || $file_missing ) {
1311 + if ( ! $post_auth || ! $post_url ) {
1270 1312 return false;
1271 1313 }
1272 1314
1273 1315 // Verify auth.
@@ -1282,10 +1324,8 @@
1282 1324 /**
1283 1325 * Install and/or activate the add-on file.
1284 1326 *
1285 1327 * @since 4.08
1286 - *
1287 - * @return array
1288 1328 */
1289 1329 public static function install_addon_api() {
1290 1330 self::$plugin = FrmAppHelper::get_param( 'file_url', '', 'request', 'esc_url_raw' );
1291 1331
@@ -1296,11 +1336,11 @@
1296 1336
1297 1337 // It's already installed and active.
1298 1338 $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
1299 1339 if ( is_wp_error( $active ) ) {
1300 - $response = self::maybe_download_and_activate();
1301 - if ( is_array( $response ) ) {
1302 - // The download failed.
1340 + // Download plugin now.
1341 + $response = self::download_and_activate();
1342 + if ( is_array( $response ) && isset( $response['success'] ) ) {
1303 1343 return $response;
1304 1344 }
1305 1345 }
1306 1346
@@ -1327,31 +1367,8 @@
1327 1367 );
1328 1368 }
1329 1369
1330 1370 /**
1331 - * @since 6.8.3
1332 - *
1333 - * @return array|true
1334 - */
1335 - private static function maybe_download_and_activate() {
1336 - if ( ! self::$plugin ) {
1337 - return array(
1338 - 'success' => false,
1339 - 'message' => __( 'The plugin download was not found.', 'formidable' ),
1340 - );
1341 - }
1342 -
1343 - // Download plugin now.
1344 - $response = self::download_and_activate();
1345 - if ( is_array( $response ) && isset( $response['success'] ) ) {
1346 - // The download failed.
1347 - return $response;
1348 - }
1349 -
1350 - return true;
1351 - }
1352 -
1353 - /**
1354 1371 * Render a conditional action button for a specified plugin
1355 1372 *
1356 1373 * @since 4.09
1357 1374 *
@@ -1388,9 +1405,9 @@
1388 1405 * @param array $atts {
1389 1406 * Button attributes.
1390 1407 *
1391 1408 * @type array $addon
1392 - * @type false|string $license_type
1409 + * @type string|false $license_type
1393 1410 * @type string $plan_required
1394 1411 * @type string $upgrade_link
1395 1412 * }
1396 1413 * @return void
@@ -1407,16 +1424,15 @@
1407 1424 /**
1408 1425 * @since 4.09.01
1409 1426 *
1410 1427 * @param array|false $addon
1411 - * @param array|string $upgrade_link
1428 + * @param string|array $upgrade_link
1412 1429 *
1413 1430 * @return void
1414 1431 */
1415 - public static function addon_upgrade_link( $addon, $upgrade_link ) {
1432 + protected static function addon_upgrade_link( $addon, $upgrade_link ) {
1416 1433 $atts = is_array( $upgrade_link ) ? $upgrade_link : array();
1417 1434 $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link;
1418 - $text = ! empty( $atts['text'] ) ? $atts['text'] : __( 'Upgrade Now', 'formidable' );
1419 1435
1420 1436 if ( $addon ) {
1421 1437 $upgrade_link .= '&utm_content=' . $addon['slug'];
1422 1438 }
@@ -1431,9 +1447,9 @@
1431 1447 $class .= ' frm-button-secondary frm-button-sm';
1432 1448 }
1433 1449 ?>
1434 1450 <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' ); ?>">
1435 - <?php echo esc_html( $text ); ?>
1451 + <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?>
1436 1452 </a>
1437 1453 <?php
1438 1454 }
1439 1455
@@ -1507,6 +1523,110 @@
1507 1523 $requires = '';
1508 1524 }
1509 1525
1510 1526 return $requires;
1527 + }
1528 +
1529 + /**
1530 + * @since 4.06.02
1531 + *
1532 + * @deprecated 4.09.01
1533 + *
1534 + * @return void
1535 + */
1536 + public static function ajax_multiple_addons() {
1537 + FrmDeprecated::ajax_multiple_addons();
1538 + }
1539 +
1540 + /**
1541 + * @since 3.04.03
1542 + * @deprecated 3.06
1543 + * @codeCoverageIgnore
1544 + * @return array
1545 + */
1546 + public static function error_for_license( $license ) {
1547 + return FrmDeprecated::error_for_license( $license );
1548 + }
1549 +
1550 + /**
1551 + * @since 3.04.03
1552 + * @deprecated 3.06
1553 + * @codeCoverageIgnore
1554 + */
1555 + public static function get_pro_updater() {
1556 + return FrmDeprecated::get_pro_updater();
1557 + }
1558 +
1559 + /**
1560 + * @since 3.04.03
1561 + * @deprecated 3.06
1562 + * @codeCoverageIgnore
1563 + *
1564 + * @return array
1565 + */
1566 + public static function get_addon_info( $license = '' ) {
1567 + return FrmDeprecated::get_addon_info( $license );
1568 + }
1569 +
1570 + /**
1571 + * @since 3.04.03
1572 + * @deprecated 3.06
1573 + * @codeCoverageIgnore
1574 + *
1575 + * @return string
1576 + */
1577 + public static function get_cache_key( $license ) {
1578 + return FrmDeprecated::get_cache_key( $license );
1579 + }
1580 +
1581 + /**
1582 + * @since 3.04.03
1583 + *
1584 + * @deprecated 3.06
1585 + *
1586 + * @codeCoverageIgnore
1587 + *
1588 + * @return void
1589 + */
1590 + public static function reset_cached_addons( $license = '' ) {
1591 + FrmDeprecated::reset_cached_addons( $license );
1592 + }
1593 +
1594 + /**
1595 + * @since 2.03.08
1596 + * @deprecated 3.04.03
1597 + * @codeCoverageIgnore
1598 + *
1599 + * @param boolean $return
1600 + * @param string $package
1601 + *
1602 + * @return boolean
1603 + */
1604 + public static function add_shorten_edd_filename_filter( $return, $package ) {
1605 + return FrmDeprecated::add_shorten_edd_filename_filter( $return, $package );
1606 + }
1607 +
1608 + /**
1609 + * @since 2.03.08
1610 + * @deprecated 3.04.03
1611 + * @codeCoverageIgnore
1612 + *
1613 + * @param string $filename
1614 + * @param string $ext
1615 + *
1616 + * @return string
1617 + */
1618 + public static function shorten_edd_filename( $filename, $ext ) {
1619 + return FrmDeprecated::shorten_edd_filename( $filename, $ext );
1620 + }
1621 +
1622 + /**
1623 + * @deprecated 3.04.03
1624 + *
1625 + * @codeCoverageIgnore
1626 + *
1627 + * @return void
1628 + */
1629 + public static function get_licenses() {
1630 + FrmDeprecated::get_licenses();
1511 1631 }
1512 1632 }