PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.14
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.14
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 +268 -212 6.25.16.14 View file →
@@ -7,91 +7,13 @@
7 7
8 8 /**
9 9 * @var string
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 56 $api = new FrmFormApi();
145 57 $errors = $api->get_error_from_response( $addons );
146 - $license_type = $addons['error']['type'] ?? '';
58 + $license_type = isset( $addons['error']['type'] ) ? $addons['error']['type'] : '';
147 59 unset( $addons['error'] );
148 60 }
149 61
150 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' );
@@ -414,9 +234,9 @@
414 234 $api = new FrmFormApi( $license );
415 235 $downloads = $api->get_api_info();
416 236 $pro = self::get_pro_from_addons( $downloads );
417 237
418 - return $pro['url'] ?? '';
238 + return isset( $pro['url'] ) ? $pro['url'] : '';
419 239 }
420 240
421 241 /**
422 242 * @since 4.08
@@ -452,9 +272,9 @@
452 272 * @param array $addons
453 273 * @return array
454 274 */
455 275 protected static function get_pro_from_addons( $addons ) {
456 - return $addons['93790'] ?? array();
276 + return isset( $addons['93790'] ) ? $addons['93790'] : array();
457 277 }
458 278
459 279 /**
460 280 * @since 4.06
@@ -477,9 +297,9 @@
477 297 if ( ! isset( $version_info['error'] ) ) {
478 298 return false;
479 299 }
480 300
481 - $expires = $version_info['error']['expires'] ?? 0;
301 + $expires = isset( $version_info['error']['expires'] ) ? $version_info['error']['expires'] : 0;
482 302 if ( empty( $expires ) || $expires > time() ) {
483 303 return false;
484 304 }
485 305
@@ -548,10 +368,10 @@
548 368 // don't show an update if the plugin isn't installed
549 369 continue;
550 370 }
551 371
552 - $wp_plugin = $wp_plugins[ $folder ] ?? array();
553 - $wp_version = $wp_plugin['Version'] ?? '1.0';
372 + $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array();
373 + $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0';
554 374 $plugin->slug = explode( '/', $folder )[0];
555 375
556 376 if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) {
557 377 $transient->response[ $folder ] = $plugin;
@@ -629,9 +449,9 @@
629 449 if ( empty( $plugin ) ) {
630 450 continue;
631 451 }
632 452
633 - $download_id = $plugin['id'] ?? 0;
453 + $download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0;
634 454 if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) {
635 455 // if this addon is using its own license, get the update url
636 456 $addon_info = $api->get_api_info();
637 457
@@ -797,13 +617,11 @@
797 617
798 618 if ( ! isset( $addon['link'] ) ) {
799 619 $addon['link'] = 'downloads/' . $slug . '/';
800 620 }
621 + self::prepare_addon_link( $addon['link'] );
801 622
802 - self::prepare_addon_link( $addon['link'] );
803 623 self::set_addon_status( $addon );
804 - self::set_categories( $addon );
805 -
806 624 $addons[ $id ] = $addon;
807 625 }//end foreach
808 626 }
809 627
@@ -838,13 +656,14 @@
838 656 if ( strpos( $link, 'http' ) !== 0 ) {
839 657 $link = $site_url . $link;
840 658 }
841 659 $link = FrmAppHelper::make_affiliate_url( $link );
842 -
843 - $utm = array(
844 - 'campaign' => 'addons',
660 + $query_args = array(
661 + 'utm_source' => 'WordPress',
662 + 'utm_medium' => 'addons',
663 + 'utm_campaign' => 'liteplugin',
845 664 );
846 - $link = FrmAppHelper::maybe_add_missing_utm( $link, $utm );
665 + $link = add_query_arg( $query_args, $link );
847 666 }
848 667
849 668 /**
850 669 * Add the status to the addon array. Status options are:
@@ -873,8 +692,218 @@
873 692 }
874 693 }
875 694
876 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 + /**
877 906 * @since 5.5.2
878 907 *
879 908 * @param string $plugin
880 909 * @param string $redirect
@@ -972,9 +1001,9 @@
972 1001 if ( ! function_exists( 'request_filesystem_credentials' ) ) {
973 1002 include_once ABSPATH . 'wp-admin/includes/file.php';
974 1003 }
975 1004
976 - // Start output buffering to catch the filesystem form if credentials are needed.
1005 + // Start output bufferring to catch the filesystem form if credentials are needed.
977 1006 ob_start();
978 1007
979 1008 $show_form = false;
980 1009 $method = '';
@@ -1411,12 +1440,11 @@
1411 1440 * @param array|string $upgrade_link
1412 1441 *
1413 1442 * @return void
1414 1443 */
1415 - public static function addon_upgrade_link( $addon, $upgrade_link ) {
1444 + protected static function addon_upgrade_link( $addon, $upgrade_link ) {
1416 1445 $atts = is_array( $upgrade_link ) ? $upgrade_link : array();
1417 1446 $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link;
1418 - $text = ! empty( $atts['text'] ) ? $atts['text'] : __( 'Upgrade Now', 'formidable' );
1419 1447
1420 1448 if ( $addon ) {
1421 1449 $upgrade_link .= '&utm_content=' . $addon['slug'];
1422 1450 }
@@ -1431,9 +1459,9 @@
1431 1459 $class .= ' frm-button-secondary frm-button-sm';
1432 1460 }
1433 1461 ?>
1434 1462 <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 ); ?>
1463 + <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?>
1436 1464 </a>
1437 1465 <?php
1438 1466 }
1439 1467
@@ -1507,6 +1535,34 @@
1507 1535 $requires = '';
1508 1536 }
1509 1537
1510 1538 return $requires;
1539 + }
1540 +
1541 + /**
1542 + * @since 4.02.05
1543 + * @deprecated 6.8.3
1544 + *
1545 + * @codeCoverageIgnore
1546 + *
1547 + * @return void
1548 + */
1549 + public static function connect_pro() {
1550 + _deprecated_function( __METHOD__, '6.8.3' );
1551 + }
1552 +
1553 + /**
1554 + * @since 4.08
1555 + * @deprecated 6.11.1
1556 + *
1557 + * @return bool|int false or the number of days until expiration.
1558 + */
1559 + public static function is_license_expiring() {
1560 + _deprecated_function( __METHOD__, '6.11.1', 'FrmProAddonsController::is_license_expiring' );
1561 +
1562 + if ( is_callable( 'FrmProAddonsController::is_license_expiring' ) ) {
1563 + return FrmProAddonsController::is_license_expiring();
1564 + }
1565 +
1566 + return false;
1511 1567 }
1512 1568 }