PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
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 +270 -297 6.266.13 View file →
@@ -7,93 +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 14 * @return void
32 15 */
33 - public static function load_admin_hooks() {
34 - add_action( 'admin_menu', self::class . '::menu', 100 );
35 - add_filter( 'pre_set_site_transient_update_plugins', self::class . '::check_update' );
36 -
37 - if ( FrmAppHelper::is_admin_page( 'formidable-addons' ) ) {
38 - self::$request_addon_url = 'https://connect.formidableforms.com/add-on-request/';
39 -
40 - add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
41 - add_filter( 'frm_show_footer_links', '__return_false' );
42 - }
43 - }
44 -
45 - /**
46 - * Enqueues the Add-Ons page scripts and styles.
47 - *
48 - * @since 6.15
49 - *
50 - * @return void
51 - */
52 - public static function enqueue_assets() {
53 - $plugin_url = FrmAppHelper::plugin_url();
54 - $version = FrmAppHelper::plugin_version();
55 - $js_dependencies = array(
56 - 'wp-i18n',
57 - // This prevents a console error "wp.hooks is undefined" in WP versions older than 5.7.
58 - 'wp-hooks',
59 - 'formidable_dom',
60 - );
61 -
62 - // Enqueue styles that needed.
63 - wp_enqueue_style( 'formidable-admin' );
64 - wp_enqueue_style( 'formidable-grids' );
65 -
66 - // Register and enqueue Add-Ons page style.
67 - wp_register_style( self::SCRIPT_HANDLE, $plugin_url . '/css/admin/addons-page.css', array(), $version );
68 - wp_enqueue_style( self::SCRIPT_HANDLE );
69 -
70 - // Register and enqueue Add-Ons page script.
71 - wp_register_script( self::SCRIPT_HANDLE, $plugin_url . '/js/addons-page.js', $js_dependencies, $version, true );
72 - wp_localize_script( self::SCRIPT_HANDLE, 'frmAddonsVars', self::get_js_variables() );
73 - wp_enqueue_script( self::SCRIPT_HANDLE );
74 - wp_set_script_translations( self::SCRIPT_HANDLE, 'formidable' );
75 -
76 - FrmAppHelper::dequeue_extra_global_scripts();
77 - }
78 -
79 - /**
80 - * Get the Add-Ons page JS variables as an array.
81 - *
82 - * @since 6.15
83 - *
84 - * @return array
85 - */
86 - private static function get_js_variables() {
87 - return array(
88 - 'proIsIncluded' => FrmAppHelper::pro_is_included(),
89 - 'addonRequestURL' => self::$request_addon_url,
90 - );
91 - }
92 -
93 - /**
94 - * @return void
95 - */
96 16 public static function menu() {
97 17 if ( ! current_user_can( 'activate_plugins' ) ) {
98 18 return;
99 19 }
@@ -98,9 +18,9 @@
98 18 return;
99 19 }
100 20
101 21 $label = __( 'Add-Ons', 'formidable' );
102 - $label = '<span style="color:#3FCA89">' . esc_html( $label ) . '</span>';
22 + $label = '<span style="color:#1da867">' . $label . '</span>';
103 23
104 24 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Add-Ons', 'formidable' ), $label, 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
105 25
106 26 // remove default created subpage, make the page with highest priority as default.
@@ -106,29 +26,20 @@
106 26 // remove default created subpage, make the page with highest priority as default.
107 27 remove_submenu_page( 'formidable', 'formidable' );
108 28
109 29 if ( ! FrmAppHelper::pro_is_installed() ) {
110 - $cta_text = FrmSalesApi::get_best_sale_value( 'menu_cta_text' );
111 -
112 - if ( ! $cta_text ) {
113 - $cta_text = __( 'Upgrade', 'formidable' );
114 - }
115 -
116 30 add_submenu_page(
117 31 'formidable',
118 32 'Formidable | ' . __( 'Upgrade', 'formidable' ),
119 - '<span class="frm-upgrade-submenu">' . esc_html( $cta_text ) . '</span>',
33 + '<span class="frm-upgrade-submenu">' . __( 'Upgrade', 'formidable' ) . '</span>',
120 34 'frm_view_forms',
121 35 'formidable-pro-upgrade',
122 - function () {
123 - // This function doesn't need to do anything.
124 - // The redirect is handled earlier to avoid issues with the headers being sent.
125 - }
36 + 'FrmAddonsController::upgrade_to_pro'
126 37 );
127 38 } elseif ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) ) {
128 39 wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
129 40 exit;
130 - }//end if
41 + }
131 42 }
132 43
133 44 /**
134 45 * @return void
@@ -134,31 +45,28 @@
134 45 * @return void
135 46 */
136 47 public static function list_addons() {
137 48 FrmAppHelper::include_svg();
49 + $installed_addons = apply_filters( 'frm_installed_addons', array() );
50 + $license_type = '';
138 51
139 - $view_path = FrmAppHelper::plugin_path() . '/classes/views/addons/';
140 - $installed_addons = apply_filters( 'frm_installed_addons', array() );
141 - $addons = self::get_api_addons();
142 - $errors = array();
143 - $license_type = '';
144 - $request_addon_url = self::$request_addon_url;
52 + $addons = self::get_api_addons();
53 + $errors = array();
145 54
146 55 if ( isset( $addons['error'] ) ) {
147 56 $api = new FrmFormApi();
148 57 $errors = $api->get_error_from_response( $addons );
149 - $license_type = $addons['error']['type'] ?? '';
58 + $license_type = isset( $addons['error']['type'] ) ? $addons['error']['type'] : '';
150 59 unset( $addons['error'] );
151 60 }
152 61
153 62 $pro = array(
154 63 'pro' => array(
155 - 'title' => 'Formidable Forms Pro',
156 - 'slug' => 'formidable-pro',
157 - 'released' => '2011-02-05',
158 - 'docs' => 'knowledgebase/',
159 - 'categories' => array( 'basic', 'plus', 'business', 'elite' ),
160 - '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.',
161 69 ),
162 70 );
163 71 $addons = $pro + $addons;
164 72 self::prepare_addons( $addons );
@@ -164,110 +72,16 @@
164 72 self::prepare_addons( $addons );
165 73
166 74 $pricing = FrmAppHelper::admin_upgrade_link( 'addons' );
167 75
168 - self::organize_and_get_categories();
169 - $categories = self::$categories;
170 -
171 - include $view_path . 'index.php';
76 + include FrmAppHelper::plugin_path() . '/classes/views/addons/list.php';
172 77 }
173 78
174 79 /**
175 - * Organize and set categories.
176 - *
177 - * @since 6.15
178 - *
179 80 * @return void
180 81 */
181 - protected static function organize_and_get_categories() {
182 - unset( self::$categories['strategy11'] );
183 - ksort( self::$categories );
184 -
185 - $bottom_categories = array();
186 - $plans = FrmFormsHelper::get_license_types(
187 - array(
188 - 'include_all' => false,
189 - 'case_lower' => true,
190 - )
191 - );
192 -
193 - // Extract the elements to move
194 - foreach ( $plans as $plan ) {
195 - if ( isset( self::$categories[ $plan ] ) ) {
196 - $bottom_categories[ $plan ] = self::$categories[ $plan ];
197 - unset( self::$categories[ $plan ] );
198 - }
199 - }
200 -
201 - $special_categories = array();
202 -
203 - if ( 'elite' !== self::license_type() ) {
204 - $special_categories['available-addons'] = array(
205 - 'name' => __( 'Available', 'formidable' ),
206 - // To be assigned via JavaScript.
207 - 'count' => 0,
208 - );
209 - }
210 -
211 - $special_categories['active-addons'] = array(
212 - 'name' => __( 'Active', 'formidable' ),
213 - // To be assigned via JavaScript.
214 - 'count' => 0,
215 - );
216 -
217 - $special_categories['all-items'] = array(
218 - 'name' => __( 'All Add-Ons', 'formidable' ),
219 - // To be assigned via JavaScript.
220 - 'count' => 0,
221 - );
222 -
223 - self::$categories = array_merge(
224 - $special_categories,
225 - self::$categories,
226 - $bottom_categories
227 - );
228 - }
229 -
230 - /**
231 - * Organize and set categories.
232 - *
233 - * @since 6.15
234 - *
235 - * @param array $addon The addon array that will be modified by reference.
236 - *
237 - * @return void
238 - */
239 - protected static function set_categories( &$addon ) {
240 - if ( ! isset( $addon['categories'] ) ) {
241 - return;
242 - }
243 -
244 - $addon['category-slugs'] = array();
245 -
246 - foreach ( $addon['categories'] as $category ) {
247 - $category = FrmFormsHelper::convert_legacy_package_names( $category );
248 - $category_slug = sanitize_title( $category );
249 -
250 - // Add the slug to the new array.
251 - $addon['category-slugs'][] = $category_slug;
252 -
253 - if ( ! isset( self::$categories[ $category_slug ] ) ) {
254 - self::$categories[ $category_slug ] = array(
255 - 'name' => $category,
256 - 'count' => 0,
257 - );
258 - }
259 -
260 - ++self::$categories[ $category_slug ]['count'];
261 - }
262 - }
263 -
264 - /**
265 - * @return void
266 - */
267 82 public static function license_settings() {
268 83 $plugins = apply_filters( 'frm_installed_addons', array() );
269 -
270 84 if ( empty( $plugins ) ) {
271 85 esc_html_e( 'There are no plugins on your site that require a license', 'formidable' );
272 86
273 87 return;
@@ -314,9 +128,8 @@
314 128 /**
315 129 * If the API is unable to connect, show something on the addons page
316 130 *
317 131 * @since 3.04.03
318 - *
319 132 * @return array
320 133 */
321 134 protected static function fallback_plugin_list() {
322 135 $list = array(
@@ -413,9 +226,8 @@
413 226 /**
414 227 * If Pro is missing but has been authenticated, include a download URL
415 228 *
416 229 * @since 3.04.03
417 - *
418 230 * @return string
419 231 */
420 232 public static function get_pro_download_url() {
421 233 $license = self::get_pro_license();
@@ -422,20 +234,17 @@
422 234 $api = new FrmFormApi( $license );
423 235 $downloads = $api->get_api_info();
424 236 $pro = self::get_pro_from_addons( $downloads );
425 237
426 - return $pro['url'] ?? '';
238 + return isset( $pro['url'] ) ? $pro['url'] : '';
427 239 }
428 240
429 241 /**
430 242 * @since 4.08
431 - *
432 - * @return string
433 243 */
434 244 public static function get_pro_license() {
435 245 $pro_cred_store = 'frmpro-credentials';
436 246 $pro_wpmu_store = 'frmpro-wpmu-sitewide';
437 -
438 247 if ( is_multisite() && get_site_option( $pro_wpmu_store ) ) {
439 248 $creds = get_site_option( $pro_cred_store );
440 249 } else {
441 250 $creds = get_option( $pro_cred_store );
@@ -445,9 +254,8 @@
445 254 return '';
446 255 }
447 256
448 257 $license = $creds['license'];
449 -
450 258 if ( empty( $license ) ) {
451 259 return '';
452 260 }
453 261
@@ -461,19 +269,16 @@
461 269 /**
462 270 * @since 4.08
463 271 *
464 272 * @param array $addons
465 - *
466 273 * @return array
467 274 */
468 275 protected static function get_pro_from_addons( $addons ) {
469 - return $addons['93790'] ?? array();
276 + return isset( $addons['93790'] ) ? $addons['93790'] : array();
470 277 }
471 278
472 279 /**
473 280 * @since 4.06
474 - *
475 - * @return string
476 281 */
477 282 public static function license_type() {
478 283 if ( is_callable( 'FrmProAddonsController::license_type' ) ) {
479 284 return FrmProAddonsController::license_type();
@@ -488,21 +293,18 @@
488 293 * @return bool
489 294 */
490 295 public static function is_license_expired() {
491 296 $version_info = self::get_primary_license_info();
492 -
493 297 if ( ! isset( $version_info['error'] ) ) {
494 298 return false;
495 299 }
496 300
497 - $expires = $version_info['error']['expires'] ?? 0;
498 -
301 + $expires = isset( $version_info['error']['expires'] ) ? $version_info['error']['expires'] : 0;
499 302 if ( empty( $expires ) || $expires > time() ) {
500 303 return false;
501 304 }
502 305
503 306 $rate_limited = ! empty( $version_info['response_code'] ) && 429 === (int) $version_info['response_code'];
504 -
505 307 if ( $rate_limited ) {
506 308 // Do not return false positives for rate limited responses.
507 309 return false;
508 310 }
@@ -517,13 +319,11 @@
517 319 * @return array|false
518 320 */
519 321 public static function get_primary_license_info() {
520 322 $installed_addons = apply_filters( 'frm_installed_addons', array() );
521 -
522 323 if ( empty( $installed_addons ) || ! isset( $installed_addons['formidable_pro'] ) ) {
523 324 return false;
524 325 }
525 -
526 326 $installed_addons = array(
527 327 'formidable_pro' => $installed_addons['formidable_pro'],
528 328 );
529 329
@@ -531,12 +331,8 @@
531 331 }
532 332
533 333 /**
534 334 * @since 3.04.03
535 - *
536 - * @param mixed $transient
537 - *
538 - * @return object
539 335 */
540 336 public static function check_update( $transient ) {
541 337 if ( ! FrmAppHelper::pro_is_installed() ) {
542 338 // Don't make any changes if only Lite is installed.
@@ -547,9 +343,8 @@
547 343 $transient = new stdClass();
548 344 }
549 345
550 346 $installed_addons = apply_filters( 'frm_installed_addons', array() );
551 -
552 347 if ( empty( $installed_addons ) ) {
553 348 return $transient;
554 349 }
555 350
@@ -564,9 +359,8 @@
564 359 continue;
565 360 }
566 361
567 362 $folder = $plugin->plugin;
568 -
569 363 if ( empty( $folder ) ) {
570 364 continue;
571 365 }
572 366
@@ -574,10 +368,10 @@
574 368 // don't show an update if the plugin isn't installed
575 369 continue;
576 370 }
577 371
578 - $wp_plugin = $wp_plugins[ $folder ] ?? array();
579 - $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';
580 374 $plugin->slug = explode( '/', $folder )[0];
581 375
582 376 if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) {
583 377 $transient->response[ $folder ] = $plugin;
@@ -597,9 +391,8 @@
597 391 * Because this gets called on "pre_set_site_transient_update_plugins" an old version of FrmAppHelper may be loaded on plugin update.
598 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.
599 393 *
600 394 * @since 5.5.2
601 - *
602 395 * @return array
603 396 */
604 397 protected static function get_plugins() {
605 398 if ( ! function_exists( 'get_plugins' ) ) {
@@ -639,9 +432,8 @@
639 432 continue;
640 433 }
641 434
642 435 $new_license = $addon->license;
643 -
644 436 if ( empty( $new_license ) || in_array( $new_license, $checked_licenses ) ) {
645 437 continue;
646 438 }
647 439
@@ -647,9 +439,8 @@
647 439
648 440 $checked_licenses[] = $new_license;
649 441
650 442 $api = new FrmFormApi( $new_license );
651 -
652 443 if ( empty( $version_info ) ) {
653 444 $version_info = $api->get_api_info();
654 445 continue;
655 446 }
@@ -654,21 +445,18 @@
654 445 continue;
655 446 }
656 447
657 448 $plugin = $api->get_addon_for_license( $addon, $version_info );
658 -
659 449 if ( empty( $plugin ) ) {
660 450 continue;
661 451 }
662 452
663 - $download_id = $plugin['id'] ?? 0;
664 -
453 + $download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0;
665 454 if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) {
666 455 // if this addon is using its own license, get the update url
667 456 $addon_info = $api->get_api_info();
668 457
669 458 $version_info[ $download_id ] = $addon_info[ $download_id ];
670 -
671 459 if ( isset( $addon_info['error'] ) ) {
672 460 $version_info[ $download_id ]['error'] = array(
673 461 'message' => $addon_info['error']['message'],
674 462 'code' => $addon_info['error']['code'],
@@ -683,11 +471,9 @@
683 471 /**
684 472 * Get the action link for an addon that isn't active.
685 473 *
686 474 * @since 3.06.03
687 - *
688 475 * @param string $plugin The plugin slug.
689 - *
690 476 * @return array
691 477 */
692 478 public static function install_link( $plugin ) {
693 479 $link = array();
@@ -724,20 +510,16 @@
724 510 }
725 511
726 512 /**
727 513 * @since 4.09
728 - *
729 514 * @param string $plugin The plugin slug.
730 - *
731 515 * @return array|false
732 516 */
733 517 public static function get_addon( $plugin ) {
734 518 $addons = self::get_api_addons();
735 519 self::prepare_addons( $addons );
736 -
737 520 foreach ( $addons as $addon ) {
738 521 $slug = explode( '/', $addon['plugin'] );
739 -
740 522 if ( $slug[0] === 'formidable-' . $plugin ) {
741 523 return $addon;
742 524 }
743 525 }
@@ -745,15 +527,13 @@
745 527 }
746 528
747 529 /**
748 530 * @since 4.09
749 - *
750 531 * @return string
751 532 */
752 533 protected static function get_license_type() {
753 534 $license_type = '';
754 535 $addons = self::get_api_addons();
755 -
756 536 if ( isset( $addons['error'] ) && isset( $addons['error']['type'] ) ) {
757 537 $license_type = $addons['error']['type'];
758 538 }
759 539 return $license_type;
@@ -769,9 +549,8 @@
769 549 */
770 550 public static function get_addon_for_license( $addons, $license ) {
771 551 $download_id = $license->download_id;
772 552 $plugin = array();
773 -
774 553 if ( empty( $download_id ) && ! empty( $addons ) ) {
775 554 foreach ( $addons as $addon ) {
776 555 if ( strtolower( $license->plugin_name ) === strtolower( $addon['title'] ) ) {
777 556 return $addon;
@@ -784,21 +563,17 @@
784 563 return $plugin;
785 564 }
786 565
787 566 /**
788 - * @param array $addons
789 - *
790 567 * @return void
791 568 */
792 569 protected static function prepare_addons( &$addons ) {
793 570 $activate_url = '';
794 -
795 571 if ( current_user_can( 'activate_plugins' ) ) {
796 572 $activate_url = add_query_arg( array( 'action' => 'activate' ), admin_url( 'plugins.php' ) );
797 573 }
798 574
799 575 $loop_addons = $addons;
800 -
801 576 foreach ( $loop_addons as $id => $addon ) {
802 577 if ( is_numeric( $id ) ) {
803 578 $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] );
804 579 $file_name = $addon['plugin'];
@@ -803,17 +578,14 @@
803 578 $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] );
804 579 $file_name = $addon['plugin'];
805 580 } else {
806 581 $slug = $id;
807 -
808 582 if ( isset( $addon['file'] ) ) {
809 583 $base_file = $addon['file'];
810 584 } else {
811 585 $base_file = 'formidable-' . $slug;
812 586 }
813 -
814 587 $file_name = $base_file . '/' . $base_file . '.php';
815 -
816 588 if ( ! isset( $addon['plugin'] ) ) {
817 589 $addon['plugin'] = $file_name;
818 590 }
819 591 }
@@ -818,12 +590,10 @@
818 590 }
819 591 }
820 592
821 593 $addon['installed'] = self::is_installed( $file_name );
822 -
823 594 if ( $addon['installed'] && 'formidable-views/formidable-views.php' === $file_name ) {
824 595 $active_views_version = self::get_active_views_version();
825 -
826 596 if ( false !== $active_views_version && $slug !== $active_views_version ) {
827 597 $addon['installed'] = false;
828 598 }
829 599 }
@@ -847,21 +617,16 @@
847 617
848 618 if ( ! isset( $addon['link'] ) ) {
849 619 $addon['link'] = 'downloads/' . $slug . '/';
850 620 }
621 + self::prepare_addon_link( $addon['link'] );
851 622
852 - self::prepare_addon_link( $addon['link'] );
853 623 self::set_addon_status( $addon );
854 - self::set_categories( $addon );
855 -
856 624 $addons[ $id ] = $addon;
857 625 }//end foreach
858 626 }
859 627
860 628 /**
861 - * @param string $file_name
862 - * @param string $slug
863 - *
864 629 * @return bool
865 630 */
866 631 private static function is_plugin_active( $file_name, $slug ) {
867 632 if ( 'formidable-views/formidable-views.php' === $file_name ) {
@@ -876,9 +641,8 @@
876 641 private static function get_active_views_version() {
877 642 if ( ! is_callable( 'FrmViewsAppHelper::plugin_version' ) ) {
878 643 return false;
879 644 }
880 -
881 645 $plugin_version = FrmViewsAppHelper::plugin_version();
882 646 return version_compare( $plugin_version, '5.0', '>=' ) ? 'visual-views' : 'views';
883 647 }
884 648
@@ -884,25 +648,22 @@
884 648
885 649 /**
886 650 * @since 3.04.02
887 651 *
888 - * @param string $link
889 - *
890 652 * @return void
891 653 */
892 654 protected static function prepare_addon_link( &$link ) {
893 655 $site_url = 'https://formidableforms.com/';
894 -
895 656 if ( strpos( $link, 'http' ) !== 0 ) {
896 657 $link = $site_url . $link;
897 658 }
898 -
899 659 $link = FrmAppHelper::make_affiliate_url( $link );
900 -
901 - $utm = array(
902 - 'campaign' => 'addons',
660 + $query_args = array(
661 + 'utm_source' => 'WordPress',
662 + 'utm_medium' => 'addons',
663 + 'utm_campaign' => 'liteplugin',
903 664 );
904 - $link = FrmAppHelper::maybe_add_missing_utm( $link, $utm );
665 + $link = add_query_arg( $query_args, $link );
905 666 }
906 667
907 668 /**
908 669 * Add the status to the addon array. Status options are:
@@ -909,10 +670,8 @@
909 670 * installed, active, not installed
910 671 *
911 672 * @since 3.04.02
912 673 *
913 - * @param array $addon
914 - *
915 674 * @return void
916 675 */
917 676 protected static function set_addon_status( &$addon ) {
918 677 if ( ! empty( $addon['activate_url'] ) ) {
@@ -933,8 +692,218 @@
933 692 }
934 693 }
935 694
936 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 + /**
937 906 * @since 5.5.2
938 907 *
939 908 * @param string $plugin
940 909 * @param string $redirect
@@ -939,9 +908,8 @@
939 908 * @param string $plugin
940 909 * @param string $redirect
941 910 * @param bool $network_wide
942 911 * @param bool $silent
943 - *
944 912 * @return WP_Error|null Null on success, WP_Error on invalid file.
945 913 */
946 914 protected static function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
947 915 if ( ! function_exists( 'activate_plugin' ) ) {
@@ -956,9 +924,8 @@
956 924 * @since 6.8
957 925 *
958 926 * @param string $plugin
959 927 * @param bool $silent
960 - *
961 928 * @return void
962 929 */
963 930 protected static function deactivate_plugin( $plugin, $silent = false ) {
964 931 if ( ! function_exists( 'deactivate_plugins' ) ) {
@@ -972,9 +939,8 @@
972 939 *
973 940 * @since 6.8
974 941 *
975 942 * @param string $plugin
976 - *
977 943 * @return true|WP_Error True on success, WP_Error on invalid file.
978 944 */
979 945 protected static function uninstall_plugin( $plugin ) {
980 946 if ( ! current_user_can( 'delete_plugins' ) ) {
@@ -1019,9 +985,8 @@
1019 985
1020 986 self::maybe_show_cred_form();
1021 987
1022 988 $installed = self::install_addon();
1023 -
1024 989 if ( is_array( $installed ) && isset( $installed['message'] ) ) {
1025 990 return $installed;
1026 991 }
1027 992 self::handle_addon_action( $installed, 'activate' );
@@ -1036,9 +1001,9 @@
1036 1001 if ( ! function_exists( 'request_filesystem_credentials' ) ) {
1037 1002 include_once ABSPATH . 'wp-admin/includes/file.php';
1038 1003 }
1039 1004
1040 - // 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.
1041 1006 ob_start();
1042 1007
1043 1008 $show_form = false;
1044 1009 $method = '';
@@ -1085,10 +1050,8 @@
1085 1050 * We do not need any extra credentials if we have gotten this far,
1086 1051 * so let's install the plugin.
1087 1052 *
1088 1053 * @since 3.04.02
1089 - *
1090 - * @return array|string
1091 1054 */
1092 1055 protected static function install_addon() {
1093 1056 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1094 1057
@@ -1108,9 +1071,8 @@
1108 1071 // Flush the cache and return the newly installed plugin basename.
1109 1072 wp_cache_flush();
1110 1073
1111 1074 $plugin = $installer->plugin_info();
1112 -
1113 1075 if ( ! $plugin ) {
1114 1076 return array(
1115 1077 'message' => 'Plugin was not installed. ' . $installer->result,
1116 1078 'success' => false,
@@ -1180,9 +1142,8 @@
1180 1142 * @since 6.8
1181 1143 *
1182 1144 * @param callable $action_callback The specific add-on action to be executed.
1183 1145 * @param callable|null $response_callback Optional. The response handling callback. Default null.
1184 - *
1185 1146 * @return void
1186 1147 */
1187 1148 private static function process_addon_action( $action_callback, $response_callback = null ) {
1188 1149 self::install_addon_permissions();
@@ -1205,9 +1166,8 @@
1205 1166 * @since 6.8
1206 1167 *
1207 1168 * @param string $installed The plugin folder name with file name.
1208 1169 * @param string $action The action type ('activate', 'deactivate', 'uninstall').
1209 - *
1210 1170 * @return array|void
1211 1171 */
1212 1172 protected static function handle_addon_action( $installed, $action ) {
1213 1173 if ( ! $installed || ! $action ) {
@@ -1266,9 +1226,8 @@
1266 1226 * @return string
1267 1227 */
1268 1228 private static function get_activating_page() {
1269 1229 $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' );
1270 -
1271 1230 if ( false !== strpos( $referer, 'frm_action=settings' ) ) {
1272 1231 return 'settings';
1273 1232 }
1274 1233
@@ -1301,14 +1260,12 @@
1301 1260 * @return string
1302 1261 */
1303 1262 public static function connect_link() {
1304 1263 $auth = get_option( 'frm_connect_token' );
1305 -
1306 1264 if ( empty( $auth ) ) {
1307 1265 $auth = hash( 'sha512', wp_rand() );
1308 1266 update_option( 'frm_connect_token', $auth, 'no' );
1309 1267 }
1310 -
1311 1268 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title', 'formidable-settings' );
1312 1269 $link = 'https://formidableforms.com/api-connect/';
1313 1270 $args = array(
1314 1271 'v' => 2,
@@ -1337,9 +1294,8 @@
1337 1294
1338 1295 // The download link is not required if already installed.
1339 1296 $is_installed = FrmAppHelper::pro_is_included();
1340 1297 $file_missing = ! $is_installed && empty( $post_url );
1341 -
1342 1298 if ( ! $post_auth || $file_missing ) {
1343 1299 return false;
1344 1300 }
1345 1301
@@ -1344,9 +1300,8 @@
1344 1300 }
1345 1301
1346 1302 // Verify auth.
1347 1303 $auth = get_option( 'frm_connect_token' );
1348 -
1349 1304 if ( empty( $auth ) || ! hash_equals( $auth, $post_auth ) ) {
1350 1305 return false;
1351 1306 }
1352 1307
@@ -1362,17 +1317,17 @@
1362 1317 */
1363 1318 public static function install_addon_api() {
1364 1319 self::$plugin = FrmAppHelper::get_param( 'file_url', '', 'request', 'esc_url_raw' );
1365 1320
1321 + $error = esc_html__( 'Could not install an upgrade. Please download from formidableforms.com and install manually.', 'formidable' );
1322 +
1366 1323 // Delete so cannot replay.
1367 1324 delete_option( 'frm_connect_token' );
1368 1325
1369 1326 // It's already installed and active.
1370 1327 $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
1371 -
1372 1328 if ( is_wp_error( $active ) ) {
1373 1329 $response = self::maybe_download_and_activate();
1374 -
1375 1330 if ( is_array( $response ) ) {
1376 1331 // The download failed.
1377 1332 return $response;
1378 1333 }
@@ -1381,9 +1336,8 @@
1381 1336 // If empty license, save it now.
1382 1337 if ( empty( self::get_pro_license() ) && function_exists( 'load_formidable_pro' ) ) {
1383 1338 load_formidable_pro();
1384 1339 $license = stripslashes( FrmAppHelper::get_param( 'key', '', 'request', 'sanitize_text_field' ) );
1385 -
1386 1340 if ( ! $license ) {
1387 1341 return array(
1388 1342 'success' => false,
1389 1343 'error' => 'That site does not have a valid license key.',
@@ -1390,9 +1344,8 @@
1390 1344 );
1391 1345 }
1392 1346
1393 1347 $response = FrmAddon::activate_license_for_plugin( $license, 'formidable_pro' );
1394 -
1395 1348 if ( ! $response['success'] ) {
1396 1349 // Could not activate license.
1397 1350 return $response;
1398 1351 }
@@ -1417,9 +1370,8 @@
1417 1370 }
1418 1371
1419 1372 // Download plugin now.
1420 1373 $response = self::download_and_activate();
1421 -
1422 1374 if ( is_array( $response ) && isset( $response['success'] ) ) {
1423 1375 // The download failed.
1424 1376 return $response;
1425 1377 }
@@ -1433,9 +1385,8 @@
1433 1385 * @since 4.09
1434 1386 *
1435 1387 * @param string $plugin
1436 1388 * @param array|string $upgrade_link_args
1437 - *
1438 1389 * @return void
1439 1390 */
1440 1391 public static function conditional_action_button( $plugin, $upgrade_link_args ) {
1441 1392 if ( is_callable( 'FrmProAddonsController::conditional_action_button' ) ) {
@@ -1470,9 +1421,8 @@
1470 1421 * @type false|string $license_type
1471 1422 * @type string $plan_required
1472 1423 * @type string $upgrade_link
1473 1424 * }
1474 - *
1475 1425 * @return void
1476 1426 */
1477 1427 public static function show_conditional_action_button( $atts ) {
1478 1428 if ( is_callable( 'FrmProAddonsController::show_conditional_action_button' ) ) {
@@ -1490,12 +1440,11 @@
1490 1440 * @param array|string $upgrade_link
1491 1441 *
1492 1442 * @return void
1493 1443 */
1494 - public static function addon_upgrade_link( $addon, $upgrade_link ) {
1444 + protected static function addon_upgrade_link( $addon, $upgrade_link ) {
1495 1445 $atts = is_array( $upgrade_link ) ? $upgrade_link : array();
1496 1446 $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link;
1497 - $text = ! empty( $atts['text'] ) ? $atts['text'] : __( 'Upgrade Now', 'formidable' );
1498 1447
1499 1448 if ( $addon ) {
1500 1449 $upgrade_link .= '&utm_content=' . $addon['slug'];
1501 1450 }
@@ -1505,15 +1454,14 @@
1505 1454 $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] );
1506 1455 }
1507 1456
1508 1457 $class = ! empty( $atts['class'] ) ? $atts['class'] : '';
1509 -
1510 1458 if ( strpos( $class, 'frm-button' ) === false ) {
1511 1459 $class .= ' frm-button-secondary frm-button-sm';
1512 1460 }
1513 1461 ?>
1514 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' ); ?>">
1515 - <?php echo esc_html( $text ); ?>
1463 + <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?>
1516 1464 </a>
1517 1465 <?php
1518 1466 }
1519 1467
@@ -1525,9 +1473,8 @@
1525 1473 public static function ajax_install_addon() {
1526 1474 self::install_addon_permissions();
1527 1475
1528 1476 $result = self::download_and_activate();
1529 -
1530 1477 if ( isset( $result['success'] ) && ! $result['success'] ) {
1531 1478 echo json_encode( $result );
1532 1479 wp_die();
1533 1480 }
@@ -1572,10 +1519,8 @@
1572 1519 * Gets required plan for an addon.
1573 1520 *
1574 1521 * @since 6.4.2
1575 1522 *
1576 - * @param int|string $addon_id
1577 - *
1578 1523 * @return string Empty string if no plan is required for active license.
1579 1524 */
1580 1525 public static function get_addon_required_plan( $addon_id ) {
1581 1526 $api = new FrmFormApi();
@@ -1590,6 +1535,34 @@
1590 1535 $requires = '';
1591 1536 }
1592 1537
1593 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;
1594 1567 }
1595 1568 }