PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.15
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.15
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 +363 -251 6.306.15 View file →
@@ -26,23 +26,19 @@
26 26 protected static $plugin;
27 27
28 28 /**
29 29 * @since 6.15
30 - *
31 - * @return void
32 30 */
33 31 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' );
32 + add_action( 'admin_menu', __CLASS__ . '::menu', 100 );
33 + add_filter( 'pre_set_site_transient_update_plugins', __CLASS__ . '::check_update' );
36 34
37 - if ( ! FrmAppHelper::is_admin_page( 'formidable-addons' ) ) {
38 - return;
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', __CLASS__ . '::enqueue_assets', 15 );
39 + add_filter( 'frm_show_footer_links', '__return_false' );
39 40 }
40 -
41 - self::$request_addon_url = 'https://connect.formidableforms.com/add-on-request/';
42 -
43 - add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
44 - add_filter( 'frm_show_footer_links', '__return_false' );
45 41 }
46 42
47 43 /**
48 44 * Enqueues the Add-Ons page scripts and styles.
@@ -72,9 +68,8 @@
72 68 // Register and enqueue Add-Ons page script.
73 69 wp_register_script( self::SCRIPT_HANDLE, $plugin_url . '/js/addons-page.js', $js_dependencies, $version, true );
74 70 wp_localize_script( self::SCRIPT_HANDLE, 'frmAddonsVars', self::get_js_variables() );
75 71 wp_enqueue_script( self::SCRIPT_HANDLE );
76 - wp_set_script_translations( self::SCRIPT_HANDLE, 'formidable' );
77 72
78 73 FrmAppHelper::dequeue_extra_global_scripts();
79 74 }
80 75
@@ -100,37 +95,28 @@
100 95 return;
101 96 }
102 97
103 98 $label = __( 'Add-Ons', 'formidable' );
104 - $label = '<span style="color:#3FCA89">' . esc_html( $label ) . '</span>';
99 + $label = '<span style="color:#3FCA89">' . $label . '</span>';
105 100
106 101 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Add-Ons', 'formidable' ), $label, 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' );
107 102
108 - // Remove default created subpage, make the page with highest priority as default.
103 + // remove default created subpage, make the page with highest priority as default.
109 104 remove_submenu_page( 'formidable', 'formidable' );
110 105
111 106 if ( ! FrmAppHelper::pro_is_installed() ) {
112 - $cta_text = FrmSalesApi::get_best_sale_value( 'menu_cta_text' );
113 -
114 - if ( ! $cta_text ) {
115 - $cta_text = __( 'Upgrade', 'formidable' );
116 - }
117 -
118 107 add_submenu_page(
119 108 'formidable',
120 109 'Formidable | ' . __( 'Upgrade', 'formidable' ),
121 - '<span class="frm-upgrade-submenu">' . esc_html( $cta_text ) . '</span>',
110 + '<span class="frm-upgrade-submenu">' . __( 'Upgrade', 'formidable' ) . '</span>',
122 111 'frm_view_forms',
123 112 'formidable-pro-upgrade',
124 - function () {
125 - // This function doesn't need to do anything.
126 - // The redirect is handled earlier to avoid issues with the headers being sent.
127 - }
113 + 'FrmAddonsController::upgrade_to_pro'
128 114 );
129 115 } elseif ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) ) {
130 116 wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
131 117 exit;
132 - }//end if
118 + }
133 119 }
134 120
135 121 /**
136 122 * @return void
@@ -147,9 +133,9 @@
147 133
148 134 if ( isset( $addons['error'] ) ) {
149 135 $api = new FrmFormApi();
150 136 $errors = $api->get_error_from_response( $addons );
151 - $license_type = $addons['error']['type'] ?? '';
137 + $license_type = isset( $addons['error']['type'] ) ? $addons['error']['type'] : '';
152 138 unset( $addons['error'] );
153 139 }
154 140
155 141 $pro = array(
@@ -193,18 +179,15 @@
193 179 );
194 180
195 181 // Extract the elements to move
196 182 foreach ( $plans as $plan ) {
197 - if ( ! isset( self::$categories[ $plan ] ) ) {
198 - continue;
183 + if ( isset( self::$categories[ $plan ] ) ) {
184 + $bottom_categories[ $plan ] = self::$categories[ $plan ];
185 + unset( self::$categories[ $plan ] );
199 186 }
200 -
201 - $bottom_categories[ $plan ] = self::$categories[ $plan ];
202 - unset( self::$categories[ $plan ] );
203 187 }
204 188
205 189 $special_categories = array();
206 -
207 190 if ( 'elite' !== self::license_type() ) {
208 191 $special_categories['available-addons'] = array(
209 192 'name' => __( 'Available', 'formidable' ),
210 193 // To be assigned via JavaScript.
@@ -236,9 +219,8 @@
236 219 *
237 220 * @since 6.15
238 221 *
239 222 * @param array $addon The addon array that will be modified by reference.
240 - *
241 223 * @return void
242 224 */
243 225 protected static function set_categories( &$addon ) {
244 226 if ( ! isset( $addon['categories'] ) ) {
@@ -269,11 +251,11 @@
269 251 * @return void
270 252 */
271 253 public static function license_settings() {
272 254 $plugins = apply_filters( 'frm_installed_addons', array() );
255 + if ( empty( $plugins ) ) {
256 + esc_html_e( 'There are no plugins on your site that require a license', 'formidable' );
273 257
274 - if ( ! $plugins ) {
275 - esc_html_e( 'There are no plugins on your site that require a license', 'formidable' );
276 258 return;
277 259 }
278 260
279 261 ksort( $plugins );
@@ -287,15 +269,15 @@
287 269 protected static function get_api_addons() {
288 270 $api = new FrmFormApi();
289 271 $addons = $api->get_api_info();
290 272
291 - if ( ! $addons ) {
292 - return self::fallback_plugin_list();
293 - }
294 -
295 - foreach ( $addons as $k => $addon ) {
296 - if ( empty( $addon['excerpt'] ) && $k !== 'error' ) {
297 - unset( $addons[ $k ] );
273 + if ( empty( $addons ) ) {
274 + $addons = self::fallback_plugin_list();
275 + } else {
276 + foreach ( $addons as $k => $addon ) {
277 + if ( empty( $addon['excerpt'] ) && $k !== 'error' ) {
278 + unset( $addons[ $k ] );
279 + }
298 280 }
299 281 }
300 282
301 283 return $addons;
@@ -308,9 +290,11 @@
308 290 *
309 291 * @return int Count of addons.
310 292 */
311 293 public static function get_addons_count() {
312 - return count( self::get_api_addons() );
294 + $addons = self::get_api_addons();
295 +
296 + return count( $addons );
313 297 }
314 298
315 299 /**
316 300 * If the API is unable to connect, show something on the addons page
@@ -315,9 +299,8 @@
315 299 /**
316 300 * If the API is unable to connect, show something on the addons page
317 301 *
318 302 * @since 3.04.03
319 - *
320 303 * @return array
321 304 */
322 305 protected static function fallback_plugin_list() {
323 306 $list = array(
@@ -328,19 +311,19 @@
328 311 'excerpt' => 'Enhance your basic Formidable forms with a plethora of Pro field types and features. Create advanced forms and data-driven applications in minutes.',
329 312 ),
330 313 'mailchimp' => array(
331 314 'title' => 'Mailchimp Forms',
332 - 'excerpt' => 'Get on the path to more sales and leads in a matter of minutes. Add leads to a Mailchimp mailing list when they submit forms and update their information along with the entry.', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
315 + 'excerpt' => 'Get on the path to more sales and leads in a matter of minutes. Add leads to a Mailchimp mailing list when they submit forms and update their information along with the entry.',
333 316 ),
334 317 'registration' => array(
335 318 'title' => 'User Registration Forms',
336 319 'link' => 'downloads/user-registration/',
337 - 'excerpt' => 'Give new users access to your site as quickly and painlessly as possible. Allow users to register, edit and be able to login to their profiles on your site from the front end in a clean, customized registration form.', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
320 + 'excerpt' => 'Give new users access to your site as quickly and painlessly as possible. Allow users to register, edit and be able to login to their profiles on your site from the front end in a clean, customized registration form.',
338 321 ),
339 322 'paypal' => array(
340 323 'title' => 'PayPal Standard Forms',
341 324 'link' => 'downloads/paypal-standard/',
342 - 'excerpt' => 'Automate your business by collecting instant payments from your clients. Collect information, calculate a total, and send them on to PayPal. Require a payment before publishing content on your site.', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
325 + 'excerpt' => 'Automate your business by collecting instant payments from your clients. Collect information, calculate a total, and send them on to PayPal. Require a payment before publishing content on your site.',
343 326 ),
344 327 'stripe' => array(
345 328 'title' => 'Stripe Forms',
346 329 'docs' => 'knowledgebase/stripe/',
@@ -372,9 +355,9 @@
372 355 'excerpt' => 'Instantly add Bootstrap styling to all your Formidable forms.',
373 356 ),
374 357 'zapier' => array(
375 358 'title' => 'Zapier Forms',
376 - 'excerpt' => 'Connect with hundreds of different applications through Zapier. Insert a new row in a Google docs spreadsheet, post on Twitter, or add a new Dropbox file with your form.', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
359 + 'excerpt' => 'Connect with hundreds of different applications through Zapier. Insert a new row in a Google docs spreadsheet, post on Twitter, or add a new Dropbox file with your form.',
377 360 ),
378 361 'signature' => array(
379 362 'title' => 'Digital Signature Forms',
380 363 'excerpt' => 'Add a signature field to your form. The user may write their signature with a trackpad/mouse or just type it.',
@@ -407,9 +390,8 @@
407 390 foreach ( $list as $k => $info ) {
408 391 $info['slug'] = $k;
409 392 $list[ $k ] = array_merge( $defaults, $info );
410 393 }
411 -
412 394 return $list;
413 395 }
414 396
415 397 /**
@@ -415,28 +397,25 @@
415 397 /**
416 398 * If Pro is missing but has been authenticated, include a download URL
417 399 *
418 400 * @since 3.04.03
419 - *
420 401 * @return string
421 402 */
422 403 public static function get_pro_download_url() {
423 - $api = new FrmFormApi( self::get_pro_license() );
404 + $license = self::get_pro_license();
405 + $api = new FrmFormApi( $license );
424 406 $downloads = $api->get_api_info();
425 407 $pro = self::get_pro_from_addons( $downloads );
426 408
427 - return $pro['url'] ?? '';
409 + return isset( $pro['url'] ) ? $pro['url'] : '';
428 410 }
429 411
430 412 /**
431 413 * @since 4.08
432 - *
433 - * @return string
434 414 */
435 415 public static function get_pro_license() {
436 416 $pro_cred_store = 'frmpro-credentials';
437 417 $pro_wpmu_store = 'frmpro-wpmu-sitewide';
438 -
439 418 if ( is_multisite() && get_site_option( $pro_wpmu_store ) ) {
440 419 $creds = get_site_option( $pro_cred_store );
441 420 } else {
442 421 $creds = get_option( $pro_cred_store );
@@ -446,18 +425,16 @@
446 425 return '';
447 426 }
448 427
449 428 $license = $creds['license'];
450 -
451 - if ( ! $license ) {
429 + if ( empty( $license ) ) {
452 430 return '';
453 431 }
454 432
455 - if ( str_contains( $license, '-' ) ) {
456 - // This is a fix for licenses saved in the past
457 - return strtoupper( $license );
433 + if ( strpos( $license, '-' ) ) {
434 + // this is a fix for licenses saved in the past
435 + $license = strtoupper( $license );
458 436 }
459 -
460 437 return $license;
461 438 }
462 439
463 440 /**
@@ -463,19 +440,16 @@
463 440 /**
464 441 * @since 4.08
465 442 *
466 443 * @param array $addons
467 - *
468 444 * @return array
469 445 */
470 446 protected static function get_pro_from_addons( $addons ) {
471 - return $addons['93790'] ?? array();
447 + return isset( $addons['93790'] ) ? $addons['93790'] : array();
472 448 }
473 449
474 450 /**
475 451 * @since 4.06
476 - *
477 - * @return string
478 452 */
479 453 public static function license_type() {
480 454 if ( is_callable( 'FrmProAddonsController::license_type' ) ) {
481 455 return FrmProAddonsController::license_type();
@@ -490,21 +464,18 @@
490 464 * @return bool
491 465 */
492 466 public static function is_license_expired() {
493 467 $version_info = self::get_primary_license_info();
494 -
495 468 if ( ! isset( $version_info['error'] ) ) {
496 469 return false;
497 470 }
498 471
499 - $expires = $version_info['error']['expires'] ?? 0;
500 -
501 - if ( ! $expires || $expires > time() ) {
472 + $expires = isset( $version_info['error']['expires'] ) ? $version_info['error']['expires'] : 0;
473 + if ( empty( $expires ) || $expires > time() ) {
502 474 return false;
503 475 }
504 476
505 477 $rate_limited = ! empty( $version_info['response_code'] ) && 429 === (int) $version_info['response_code'];
506 -
507 478 if ( $rate_limited ) {
508 479 // Do not return false positives for rate limited responses.
509 480 return false;
510 481 }
@@ -519,13 +490,11 @@
519 490 * @return array|false
520 491 */
521 492 public static function get_primary_license_info() {
522 493 $installed_addons = apply_filters( 'frm_installed_addons', array() );
523 -
524 - if ( ! $installed_addons || ! isset( $installed_addons['formidable_pro'] ) ) {
494 + if ( empty( $installed_addons ) || ! isset( $installed_addons['formidable_pro'] ) ) {
525 495 return false;
526 496 }
527 -
528 497 $installed_addons = array(
529 498 'formidable_pro' => $installed_addons['formidable_pro'],
530 499 );
531 500
@@ -533,12 +502,8 @@
533 502 }
534 503
535 504 /**
536 505 * @since 3.04.03
537 - *
538 - * @param mixed $transient
539 - *
540 - * @return object
541 506 */
542 507 public static function check_update( $transient ) {
543 508 if ( ! FrmAppHelper::pro_is_installed() ) {
544 509 // Don't make any changes if only Lite is installed.
@@ -549,10 +514,9 @@
549 514 $transient = new stdClass();
550 515 }
551 516
552 517 $installed_addons = apply_filters( 'frm_installed_addons', array() );
553 -
554 - if ( ! $installed_addons ) {
518 + if ( empty( $installed_addons ) ) {
555 519 return $transient;
556 520 }
557 521
558 522 $version_info = self::fill_update_addon_info( $installed_addons );
@@ -566,20 +530,19 @@
566 530 continue;
567 531 }
568 532
569 533 $folder = $plugin->plugin;
570 -
571 - if ( ! $folder ) {
534 + if ( empty( $folder ) ) {
572 535 continue;
573 536 }
574 537
575 538 if ( ! self::is_installed( $folder ) ) {
576 - // Don't show an update if the plugin isn't installed
539 + // don't show an update if the plugin isn't installed
577 540 continue;
578 541 }
579 542
580 - $wp_plugin = $wp_plugins[ $folder ] ?? array();
581 - $wp_version = $wp_plugin['Version'] ?? '1.0';
543 + $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array();
544 + $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0';
582 545 $plugin->slug = explode( '/', $folder )[0];
583 546
584 547 if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) {
585 548 $transient->response[ $folder ] = $plugin;
@@ -587,8 +550,9 @@
587 550 $transient->no_update[ $folder ] = $plugin;
588 551 }
589 552
590 553 $transient->checked[ $folder ] = $wp_version;
554 +
591 555 }//end foreach
592 556
593 557 return $transient;
594 558 }
@@ -598,9 +562,8 @@
598 562 * Because this gets called on "pre_set_site_transient_update_plugins" an old version of FrmAppHelper may be loaded on plugin update.
599 563 * This means that trying to access FrmAppHelper::get_plugins when upgrading from a Lite version before v5.5 results in a one-off error.
600 564 *
601 565 * @since 5.5.2
602 - *
603 566 * @return array
604 567 */
605 568 protected static function get_plugins() {
606 569 if ( ! function_exists( 'get_plugins' ) ) {
@@ -635,49 +598,43 @@
635 598 $version_info = array();
636 599
637 600 foreach ( $installed_addons as $addon ) {
638 601 if ( $addon->store_url !== 'https://formidableforms.com' ) {
639 - // Check if this is a third-party addon
602 + // check if this is a third-party addon
640 603 continue;
641 604 }
642 605
643 606 $new_license = $addon->license;
644 -
645 - if ( ! $new_license || in_array( $new_license, $checked_licenses, true ) ) {
607 + if ( empty( $new_license ) || in_array( $new_license, $checked_licenses ) ) {
646 608 continue;
647 609 }
648 610
649 611 $checked_licenses[] = $new_license;
650 - $api = new FrmFormApi( $new_license );
651 612
652 - if ( ! $version_info ) {
613 + $api = new FrmFormApi( $new_license );
614 + if ( empty( $version_info ) ) {
653 615 $version_info = $api->get_api_info();
654 616 continue;
655 617 }
656 618
657 619 $plugin = $api->get_addon_for_license( $addon, $version_info );
658 -
659 - if ( ! $plugin ) {
620 + if ( empty( $plugin ) ) {
660 621 continue;
661 622 }
662 623
663 - $download_id = $plugin['id'] ?? 0;
624 + $download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0;
625 + if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) {
626 + // if this addon is using its own license, get the update url
627 + $addon_info = $api->get_api_info();
664 628
665 - if ( ! $download_id || isset( $version_info[ $download_id ]['package'] ) ) {
666 - continue;
629 + $version_info[ $download_id ] = $addon_info[ $download_id ];
630 + if ( isset( $addon_info['error'] ) ) {
631 + $version_info[ $download_id ]['error'] = array(
632 + 'message' => $addon_info['error']['message'],
633 + 'code' => $addon_info['error']['code'],
634 + );
635 + }
667 636 }
668 -
669 - // If this addon is using its own license, get the update url
670 - $addon_info = $api->get_api_info();
671 -
672 - $version_info[ $download_id ] = $addon_info[ $download_id ];
673 -
674 - if ( isset( $addon_info['error'] ) ) {
675 - $version_info[ $download_id ]['error'] = array(
676 - 'message' => $addon_info['error']['message'],
677 - 'code' => $addon_info['error']['code'],
678 - );
679 - }
680 637 }//end foreach
681 638
682 639 return $version_info;
683 640 }
@@ -685,11 +642,9 @@
685 642 /**
686 643 * Get the action link for an addon that isn't active.
687 644 *
688 645 * @since 3.06.03
689 - *
690 646 * @param string $plugin The plugin slug.
691 - *
692 647 * @return array
693 648 */
694 649 public static function install_link( $plugin ) {
695 650 $link = array();
@@ -711,9 +666,9 @@
711 666 'categories' => $addon['categories'],
712 667 );
713 668 }
714 669
715 - if ( $link ) {
670 + if ( ! empty( $link ) ) {
716 671 $link['status'] = $addon['status']['type'];
717 672 }
718 673 } elseif ( current_user_can( 'activate_plugins' ) && self::is_installed( 'formidable-' . $plugin . '/formidable-' . $plugin . '.php' ) ) {
719 674 $link = array(
@@ -725,81 +680,34 @@
725 680 return $link;
726 681 }
727 682
728 683 /**
729 - * Get the JSON-encoded install data for a plugin update.
730 - *
731 - * @since 6.29
732 - *
733 - * @param string $addon_slug The addon slug (e.g. 'pro', 'dates').
734 - *
735 - * @return string JSON-encoded install data, or empty string if no URL is available.
736 - */
737 - public static function get_update_install_data( $addon_slug ) {
738 - $upgrading = self::install_link( $addon_slug );
739 -
740 - if ( isset( $upgrading['class'] ) && 'frm-install-addon' === $upgrading['class'] ) {
741 - return (string) json_encode( $upgrading );
742 - }
743 -
744 - if ( 'pro' === $addon_slug ) {
745 - $download_url = self::get_pro_download_url();
746 - $plugin_file = 'formidable-pro/formidable-pro.php';
747 - } else {
748 - $addon_data = self::get_addon( $addon_slug );
749 - $download_url = $addon_data && ! empty( $addon_data['url'] ) ? $addon_data['url'] : '';
750 - $plugin_file = $addon_data && ! empty( $addon_data['plugin'] ) ? $addon_data['plugin'] : 'formidable-' . $addon_slug . '/formidable-' . $addon_slug . '.php';
751 - }
752 -
753 - if ( ! $download_url ) {
754 - $update_plugins = get_site_transient( 'update_plugins' );
755 - $plugin_update = $update_plugins->response[ $plugin_file ] ?? null;
756 - $download_url = $plugin_update && ! empty( $plugin_update->package ) ? $plugin_update->package : '';
757 - }
758 -
759 - return $download_url ? (string) json_encode(
760 - array(
761 - 'url' => $download_url,
762 - 'class' => 'frm-install-addon',
763 - )
764 - ) : '';
765 - }
766 -
767 - /**
768 684 * @since 4.09
769 - *
770 685 * @param string $plugin The plugin slug.
771 - *
772 686 * @return array|false
773 687 */
774 688 public static function get_addon( $plugin ) {
775 689 $addons = self::get_api_addons();
776 690 self::prepare_addons( $addons );
777 -
778 691 foreach ( $addons as $addon ) {
779 692 $slug = explode( '/', $addon['plugin'] );
780 -
781 693 if ( $slug[0] === 'formidable-' . $plugin ) {
782 694 return $addon;
783 695 }
784 696 }
785 -
786 697 return false;
787 698 }
788 699
789 700 /**
790 701 * @since 4.09
791 - *
792 702 * @return string
793 703 */
794 704 protected static function get_license_type() {
795 705 $license_type = '';
796 706 $addons = self::get_api_addons();
797 -
798 707 if ( isset( $addons['error'] ) && isset( $addons['error']['type'] ) ) {
799 - return $addons['error']['type'];
708 + $license_type = $addons['error']['type'];
800 709 }
801 -
802 710 return $license_type;
803 711 }
804 712
805 713 /**
@@ -812,12 +720,11 @@
812 720 */
813 721 public static function get_addon_for_license( $addons, $license ) {
814 722 $download_id = $license->download_id;
815 723 $plugin = array();
816 -
817 - if ( ! $download_id && $addons ) {
724 + if ( empty( $download_id ) && ! empty( $addons ) ) {
818 725 foreach ( $addons as $addon ) {
819 - if ( 0 === strcasecmp( $license->plugin_name, $addon['title'] ) ) {
726 + if ( strtolower( $license->plugin_name ) === strtolower( $addon['title'] ) ) {
820 727 return $addon;
821 728 }
822 729 }
823 730 } elseif ( isset( $addons[ $download_id ] ) ) {
@@ -827,33 +734,29 @@
827 734 return $plugin;
828 735 }
829 736
830 737 /**
831 - * @param array $addons
832 - *
833 738 * @return void
834 739 */
835 740 protected static function prepare_addons( &$addons ) {
836 - // Reset categories to prevent count accumulation across multiple calls.
837 - self::$categories = array();
838 -
839 741 $activate_url = '';
840 -
841 742 if ( current_user_can( 'activate_plugins' ) ) {
842 743 $activate_url = add_query_arg( array( 'action' => 'activate' ), admin_url( 'plugins.php' ) );
843 744 }
844 745
845 746 $loop_addons = $addons;
846 -
847 747 foreach ( $loop_addons as $id => $addon ) {
848 748 if ( is_numeric( $id ) ) {
849 749 $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] );
850 750 $file_name = $addon['plugin'];
851 751 } else {
852 - $slug = $id;
853 - $base_file = $addon['file'] ?? 'formidable-' . $slug;
752 + $slug = $id;
753 + if ( isset( $addon['file'] ) ) {
754 + $base_file = $addon['file'];
755 + } else {
756 + $base_file = 'formidable-' . $slug;
757 + }
854 758 $file_name = $base_file . '/' . $base_file . '.php';
855 -
856 759 if ( ! isset( $addon['plugin'] ) ) {
857 760 $addon['plugin'] = $file_name;
858 761 }
859 762 }
@@ -858,17 +761,10 @@
858 761 }
859 762 }
860 763
861 764 $addon['installed'] = self::is_installed( $file_name );
862 -
863 - if ( 'highrise' === $slug && ! $addon['installed'] ) {
864 - unset( $addons[ $id ] );
865 - continue;
866 - }
867 -
868 765 if ( $addon['installed'] && 'formidable-views/formidable-views.php' === $file_name ) {
869 766 $active_views_version = self::get_active_views_version();
870 -
871 767 if ( false !== $active_views_version && $slug !== $active_views_version ) {
872 768 $addon['installed'] = false;
873 769 }
874 770 }
@@ -874,9 +770,9 @@
874 770 }
875 771
876 772 $addon['activate_url'] = '';
877 773
878 - if ( $addon['installed'] && $activate_url && ! self::is_plugin_active( $file_name, $slug ) ) {
774 + if ( $addon['installed'] && ! empty( $activate_url ) && ! self::is_plugin_active( $file_name, $slug ) ) {
879 775 $addon['activate_url'] = add_query_arg(
880 776 array(
881 777 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $file_name ),
882 778 'plugin' => $file_name,
@@ -902,11 +798,8 @@
902 798 }//end foreach
903 799 }
904 800
905 801 /**
906 - * @param string $file_name
907 - * @param string $slug
908 - *
909 802 * @return bool
910 803 */
911 804 private static function is_plugin_active( $file_name, $slug ) {
912 805 if ( 'formidable-views/formidable-views.php' === $file_name ) {
@@ -921,9 +814,8 @@
921 814 private static function get_active_views_version() {
922 815 if ( ! is_callable( 'FrmViewsAppHelper::plugin_version' ) ) {
923 816 return false;
924 817 }
925 -
926 818 $plugin_version = FrmViewsAppHelper::plugin_version();
927 819 return version_compare( $plugin_version, '5.0', '>=' ) ? 'visual-views' : 'views';
928 820 }
929 821
@@ -929,25 +821,22 @@
929 821
930 822 /**
931 823 * @since 3.04.02
932 824 *
933 - * @param string $link
934 - *
935 825 * @return void
936 826 */
937 827 protected static function prepare_addon_link( &$link ) {
938 828 $site_url = 'https://formidableforms.com/';
939 -
940 - if ( ! str_starts_with( $link, 'http' ) ) {
829 + if ( strpos( $link, 'http' ) !== 0 ) {
941 830 $link = $site_url . $link;
942 831 }
943 -
944 - $link = FrmAppHelper::make_affiliate_url( $link );
945 -
946 - $utm = array(
947 - 'campaign' => 'addons',
832 + $link = FrmAppHelper::make_affiliate_url( $link );
833 + $query_args = array(
834 + 'utm_source' => 'WordPress',
835 + 'utm_medium' => 'addons',
836 + 'utm_campaign' => 'liteplugin',
948 837 );
949 - $link = FrmAppHelper::maybe_add_missing_utm( $link, $utm );
838 + $link = add_query_arg( $query_args, $link );
950 839 }
951 840
952 841 /**
953 842 * Add the status to the addon array. Status options are:
@@ -954,10 +843,8 @@
954 843 * installed, active, not installed
955 844 *
956 845 * @since 3.04.02
957 846 *
958 - * @param array $addon
959 - *
960 847 * @return void
961 848 */
962 849 protected static function set_addon_status( &$addon ) {
963 850 if ( ! empty( $addon['activate_url'] ) ) {
@@ -978,8 +865,218 @@
978 865 }
979 866 }
980 867
981 868 /**
869 + * @return void
870 + */
871 + public static function upgrade_to_pro() {
872 + FrmAppHelper::include_svg();
873 +
874 + $link_parts = array(
875 + 'medium' => 'upgrade',
876 + 'content' => 'button',
877 + );
878 +
879 + $features = array(
880 + 'Display Entries' => array(
881 + array(
882 + 'label' => 'Display form data with virtually limitless views',
883 + 'link' => array(
884 + 'content' => 'views',
885 + 'param' => 'views-display-form-data',
886 + ),
887 + 'lite' => false,
888 + ),
889 + array(
890 + 'label' => 'Generate graphs and stats based on your submitted data',
891 + 'link' => array(
892 + 'content' => 'graphs',
893 + 'param' => 'statistics-graphs-wordpress-forms',
894 + ),
895 + 'lite' => false,
896 + ),
897 + ),
898 + 'Entry Management' => array(
899 + array(
900 + 'label' => 'Import entries from a CSV',
901 + 'link' => array(
902 + 'content' => 'import-entries',
903 + 'param' => 'importing-exporting-wordpress-forms',
904 + ),
905 + 'lite' => false,
906 + ),
907 + array(
908 + 'label' => 'Logged-in users can save drafts and return later',
909 + 'link' => array(
910 + 'content' => 'save-drafts',
911 + 'param' => 'save-drafts-wordpress-form',
912 + ),
913 + 'lite' => false,
914 + ),
915 + array(
916 + 'label' => 'Flexibly and powerfully view, edit, and delete entries from anywhere on your site',
917 + 'link' => array(
918 + 'content' => 'front-edit',
919 + 'param' => 'wordpress-front-end-editing',
920 + ),
921 + 'lite' => false,
922 + ),
923 + array(
924 + 'label' => 'View form submissions from the back-end',
925 + 'lite' => true,
926 + ),
927 + array(
928 + 'label' => 'Export your entries to a CSV',
929 + 'lite' => true,
930 + ),
931 + ),
932 + 'Form Building' => array(
933 + array(
934 + 'label' => 'Save a calculated value into a field',
935 + 'link' => array(
936 + 'content' => 'calculations',
937 + 'param' => 'field-calculations-wordpress-form',
938 + ),
939 + 'lite' => false,
940 + ),
941 + array(
942 + 'label' => 'Allow multiple file uploads',
943 + 'link' => array(
944 + 'content' => 'file-uploads',
945 + 'param' => 'wordpress-multi-file-upload-fields',
946 + ),
947 + 'lite' => false,
948 + ),
949 + array(
950 + 'label' => 'Repeat sections of fields',
951 + 'link' => array(
952 + 'content' => 'repeaters',
953 + 'param' => 'repeatable-sections-forms',
954 + ),
955 + 'lite' => false,
956 + ),
957 + array(
958 + 'label' => 'Hide and show fields conditionally based on other fields or the user\'s role',
959 + 'link' => array(
960 + 'content' => 'conditional-logic',
961 + 'param' => 'conditional-logic-wordpress-forms',
962 + ),
963 + 'lite' => false,
964 + ),
965 + array(
966 + 'label' => 'Confirmation fields',
967 + 'link' => array(
968 + 'content' => 'confirmation-fields',
969 + 'param' => 'confirmation-fields-wordpress-forms',
970 + ),
971 + 'lite' => false,
972 + ),
973 + array(
974 + 'label' => 'Multi-paged forms',
975 + 'link' => array(
976 + 'content' => 'page-breaks',
977 + 'param' => 'wordpress-multi-page-forms',
978 + ),
979 + 'lite' => false,
980 + ),
981 + array(
982 + '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.',
983 + 'lite' => false,
984 + ),
985 + array(
986 + 'label' => 'Include text, email, url, paragraph text, radio, checkbox, dropdown fields, hidden fields, user ID fields, and HTML blocks in your form.',
987 + 'lite' => true,
988 + ),
989 + array(
990 + 'label' => 'Drag & Drop Form building',
991 + 'link' => array(
992 + 'content' => 'drag-drop',
993 + 'param' => 'drag-drop-forms',
994 + ),
995 + 'lite' => true,
996 + ),
997 + array(
998 + 'label' => 'Create forms from Templates',
999 + 'link' => array(
1000 + 'content' => 'form-templates',
1001 + 'param' => 'wordpress-form-templates',
1002 + ),
1003 + 'lite' => true,
1004 + ),
1005 + array(
1006 + 'label' => 'Import and export forms with XML',
1007 + 'link' => array(
1008 + 'content' => 'import',
1009 + 'param' => 'importing-exporting-wordpress-forms',
1010 + ),
1011 + 'lite' => true,
1012 + ),
1013 + array(
1014 + 'label' => 'Use input placeholder text in your fields that clear when typing starts.',
1015 + 'lite' => true,
1016 + ),
1017 + ),
1018 + 'Form Actions' => array(
1019 + array(
1020 + 'label' => 'Conditionally send your email notifications based on values in your form',
1021 + 'link' => array(
1022 + 'content' => 'conditional-emails',
1023 + ),
1024 + 'lite' => false,
1025 + ),
1026 + array(
1027 + 'label' => 'Create and edit WordPress posts or custom posts from the front-end',
1028 + 'link' => array(
1029 + 'content' => 'create-posts',
1030 + 'param' => 'create-posts-pages-wordpress-forms',
1031 + ),
1032 + 'lite' => false,
1033 + ),
1034 + array(
1035 + 'label' => 'Send multiple emails and autoresponders',
1036 + 'link' => array(
1037 + 'content' => 'multiple-emails',
1038 + 'param' => 'virtually-unlimited-emails',
1039 + ),
1040 + 'lite' => true,
1041 + ),
1042 + ),
1043 + 'Form Appearance' => array(
1044 + array(
1045 + 'label' => 'Create Multiple styles for different forms',
1046 + 'link' => array(
1047 + 'content' => 'multiple-styles',
1048 + 'param' => 'wordpress-visual-form-styler',
1049 + ),
1050 + 'lite' => false,
1051 + ),
1052 + array(
1053 + 'label' => 'Customizable layout with CSS classes',
1054 + 'link' => array(
1055 + 'content' => 'form-layout',
1056 + 'param' => 'wordpress-mobile-friendly-forms',
1057 + ),
1058 + 'lite' => true,
1059 + ),
1060 + array(
1061 + 'label' => 'Customize the HTML for your forms',
1062 + 'link' => array(
1063 + 'content' => 'custom-html',
1064 + 'param' => 'customizable-html-wordpress-form',
1065 + ),
1066 + 'lite' => true,
1067 + ),
1068 + array(
1069 + 'label' => 'Style your form with the Visual Form Styler',
1070 + 'lite' => true,
1071 + ),
1072 + ),
1073 + );
1074 +
1075 + include FrmAppHelper::plugin_path() . '/classes/views/addons/upgrade_to_pro.php';
1076 + }
1077 +
1078 + /**
982 1079 * @since 5.5.2
983 1080 *
984 1081 * @param string $plugin
985 1082 * @param string $redirect
@@ -984,9 +1081,8 @@
984 1081 * @param string $plugin
985 1082 * @param string $redirect
986 1083 * @param bool $network_wide
987 1084 * @param bool $silent
988 - *
989 1085 * @return WP_Error|null Null on success, WP_Error on invalid file.
990 1086 */
991 1087 protected static function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
992 1088 if ( ! function_exists( 'activate_plugin' ) ) {
@@ -1001,9 +1097,8 @@
1001 1097 * @since 6.8
1002 1098 *
1003 1099 * @param string $plugin
1004 1100 * @param bool $silent
1005 - *
1006 1101 * @return void
1007 1102 */
1008 1103 protected static function deactivate_plugin( $plugin, $silent = false ) {
1009 1104 if ( ! function_exists( 'deactivate_plugins' ) ) {
@@ -1017,9 +1112,8 @@
1017 1112 *
1018 1113 * @since 6.8
1019 1114 *
1020 1115 * @param string $plugin
1021 - *
1022 1116 * @return true|WP_Error True on success, WP_Error on invalid file.
1023 1117 */
1024 1118 protected static function uninstall_plugin( $plugin ) {
1025 1119 if ( ! current_user_can( 'delete_plugins' ) ) {
@@ -1032,9 +1126,13 @@
1032 1126
1033 1127 self::deactivate_plugin( $plugin, true );
1034 1128 $result = delete_plugins( array( $plugin ) );
1035 1129
1036 - return is_wp_error( $result ) ? $result : true;
1130 + if ( is_wp_error( $result ) ) {
1131 + return $result;
1132 + }
1133 +
1134 + return true;
1037 1135 }
1038 1136
1039 1137 /**
1040 1138 * @since 5.0.10
@@ -1041,9 +1139,9 @@
1041 1139 *
1042 1140 * @return string
1043 1141 */
1044 1142 protected static function get_current_plugin() {
1045 - if ( ! self::$plugin ) {
1143 + if ( empty( self::$plugin ) ) {
1046 1144 self::$plugin = FrmAppHelper::get_param( 'plugin', '', 'post', 'esc_url_raw' );
1047 1145 }
1048 1146 return self::$plugin;
1049 1147 }
@@ -1050,9 +1148,9 @@
1050 1148
1051 1149 /**
1052 1150 * @since 4.08
1053 1151 *
1054 - * @return mixed[]|null
1152 + * @return array|void
1055 1153 */
1056 1154 protected static function download_and_activate() {
1057 1155 if ( is_admin() ) {
1058 1156 FrmAppHelper::set_current_screen_and_hook_suffix();
@@ -1060,14 +1158,12 @@
1060 1158
1061 1159 self::maybe_show_cred_form();
1062 1160
1063 1161 $installed = self::install_addon();
1064 -
1065 1162 if ( is_array( $installed ) && isset( $installed['message'] ) ) {
1066 1163 return $installed;
1067 1164 }
1068 1165 self::handle_addon_action( $installed, 'activate' );
1069 - return null;
1070 1166 }
1071 1167
1072 1168 /**
1073 1169 * @since 3.04.02
@@ -1078,9 +1174,9 @@
1078 1174 if ( ! function_exists( 'request_filesystem_credentials' ) ) {
1079 1175 include_once ABSPATH . 'wp-admin/includes/file.php';
1080 1176 }
1081 1177
1082 - // Start output buffering to catch the filesystem form if credentials are needed.
1178 + // Start output bufferring to catch the filesystem form if credentials are needed.
1083 1179 ob_start();
1084 1180
1085 1181 $show_form = false;
1086 1182 $method = '';
@@ -1097,8 +1193,9 @@
1097 1193
1098 1194 if ( $show_form ) {
1099 1195 $form = ob_get_clean();
1100 1196 $message = __( 'Sorry, your site requires FTP authentication. Please download plugins from FormidableForms.com and install them manually.', 'formidable' );
1197 + $data = $form;
1101 1198 $response = array(
1102 1199 'success' => false,
1103 1200 'message' => $message,
1104 1201 'form' => $form,
@@ -1126,10 +1223,8 @@
1126 1223 * We do not need any extra credentials if we have gotten this far,
1127 1224 * so let's install the plugin.
1128 1225 *
1129 1226 * @since 3.04.02
1130 - *
1131 - * @return array|string
1132 1227 */
1133 1228 protected static function install_addon() {
1134 1229 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1135 1230
@@ -1143,15 +1238,14 @@
1143 1238 }
1144 1239
1145 1240 // Create the plugin upgrader with our custom skin.
1146 1241 $installer = new Plugin_Upgrader( new FrmInstallerSkin() );
1147 - $installer->install( $download_url, array( 'overwrite_package' => true ) );
1242 + $installer->install( $download_url );
1148 1243
1149 1244 // Flush the cache and return the newly installed plugin basename.
1150 1245 wp_cache_flush();
1151 1246
1152 1247 $plugin = $installer->plugin_info();
1153 -
1154 1248 if ( ! $plugin ) {
1155 1249 return array(
1156 1250 'message' => 'Plugin was not installed. ' . $installer->result,
1157 1251 'success' => false,
@@ -1156,9 +1250,8 @@
1156 1250 'message' => 'Plugin was not installed. ' . $installer->result,
1157 1251 'success' => false,
1158 1252 );
1159 1253 }
1160 -
1161 1254 return $plugin;
1162 1255 }
1163 1256
1164 1257 /**
@@ -1222,9 +1315,8 @@
1222 1315 * @since 6.8
1223 1316 *
1224 1317 * @param callable $action_callback The specific add-on action to be executed.
1225 1318 * @param callable|null $response_callback Optional. The response handling callback. Default null.
1226 - *
1227 1319 * @return void
1228 1320 */
1229 1321 private static function process_addon_action( $action_callback, $response_callback = null ) {
1230 1322 self::install_addon_permissions();
@@ -1247,14 +1339,13 @@
1247 1339 * @since 6.8
1248 1340 *
1249 1341 * @param string $installed The plugin folder name with file name.
1250 1342 * @param string $action The action type ('activate', 'deactivate', 'uninstall').
1251 - *
1252 - * @return mixed[]|null
1343 + * @return array|void
1253 1344 */
1254 1345 protected static function handle_addon_action( $installed, $action ) {
1255 1346 if ( ! $installed || ! $action ) {
1256 - return null;
1347 + return;
1257 1348 }
1258 1349
1259 1350 $result = null;
1260 1351 switch ( $action ) {
@@ -1274,9 +1365,8 @@
1274 1365 if ( $result->get_error_code() !== 'no_plugin_header' ) {
1275 1366 if ( wp_doing_ajax() ) {
1276 1367 wp_send_json_error( array( 'error' => $result->get_error_message() ) );
1277 1368 }
1278 -
1279 1369 return array(
1280 1370 'message' => $result->get_error_message(),
1281 1371 'success' => false,
1282 1372 );
@@ -1290,14 +1380,17 @@
1290 1380 * @return array
1291 1381 */
1292 1382 private static function get_addon_activation_response() {
1293 1383 $activating_page = self::get_activating_page();
1294 - $message = $activating_page ? __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ) : __( 'Your plugin has been activated.', 'formidable' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
1295 1384
1296 - return array(
1385 + $message = $activating_page ? __( 'Your plugin has been activated. Would you like to save and reload the page now?', 'formidable' ) : __( 'Your plugin has been activated.', 'formidable' );
1386 +
1387 + $response = array(
1297 1388 'message' => $message,
1298 1389 'saveAndReload' => $activating_page,
1299 1390 );
1391 +
1392 + return $response;
1300 1393 }
1301 1394
1302 1395 /**
1303 1396 * Return a string that reflects the page from which the addon is being activated on,
@@ -1306,14 +1399,17 @@
1306 1399 * @return string
1307 1400 */
1308 1401 private static function get_activating_page() {
1309 1402 $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' );
1403 + if ( false !== strpos( $referer, 'frm_action=settings' ) ) {
1404 + return 'settings';
1405 + }
1310 1406
1311 - if ( str_contains( $referer, 'frm_action=settings' ) ) {
1312 - return 'settings';
1407 + if ( false !== strpos( $referer, 'frm_action=edit' ) ) {
1408 + return 'form_builder';
1313 1409 }
1314 1410
1315 - return str_contains( $referer, 'frm_action=edit' ) ? 'form_builder' : '';
1411 + return '';
1316 1412 }
1317 1413
1318 1414 /**
1319 1415 * Run security checks before installing
@@ -1324,14 +1420,12 @@
1324 1420 */
1325 1421 protected static function install_addon_permissions() {
1326 1422 check_ajax_referer( 'frm_ajax', 'nonce' );
1327 1423
1328 - if ( current_user_can( 'activate_plugins' ) && self::get_current_plugin() ) {
1329 - return;
1424 + if ( ! current_user_can( 'activate_plugins' ) || ! self::get_current_plugin() ) {
1425 + echo json_encode( true );
1426 + wp_die();
1330 1427 }
1331 -
1332 - echo json_encode( true );
1333 - wp_die();
1334 1428 }
1335 1429
1336 1430 /**
1337 1431 * @since 4.08
@@ -1339,14 +1433,12 @@
1339 1433 * @return string
1340 1434 */
1341 1435 public static function connect_link() {
1342 1436 $auth = get_option( 'frm_connect_token' );
1343 -
1344 - if ( ! $auth ) {
1437 + if ( empty( $auth ) ) {
1345 1438 $auth = hash( 'sha512', wp_rand() );
1346 - update_option( 'frm_connect_token', $auth, false );
1439 + update_option( 'frm_connect_token', $auth, 'no' );
1347 1440 }
1348 -
1349 1441 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title', 'formidable-settings' );
1350 1442 $link = 'https://formidableforms.com/api-connect/';
1351 1443 $args = array(
1352 1444 'v' => 2,
@@ -1374,10 +1466,9 @@
1374 1466 $post_url = FrmAppHelper::get_param( 'file_url', '', 'request', 'sanitize_text_field' );
1375 1467
1376 1468 // The download link is not required if already installed.
1377 1469 $is_installed = FrmAppHelper::pro_is_included();
1378 - $file_missing = ! $is_installed && ! $post_url;
1379 -
1470 + $file_missing = ! $is_installed && empty( $post_url );
1380 1471 if ( ! $post_auth || $file_missing ) {
1381 1472 return false;
1382 1473 }
1383 1474
@@ -1382,9 +1473,13 @@
1382 1473 }
1383 1474
1384 1475 // Verify auth.
1385 1476 $auth = get_option( 'frm_connect_token' );
1386 - return $auth && hash_equals( $auth, $post_auth );
1477 + if ( empty( $auth ) || ! hash_equals( $auth, $post_auth ) ) {
1478 + return false;
1479 + }
1480 +
1481 + return true;
1387 1482 }
1388 1483
1389 1484 /**
1390 1485 * Install and/or activate the add-on file.
@@ -1395,17 +1490,17 @@
1395 1490 */
1396 1491 public static function install_addon_api() {
1397 1492 self::$plugin = FrmAppHelper::get_param( 'file_url', '', 'request', 'esc_url_raw' );
1398 1493
1494 + $error = esc_html__( 'Could not install an upgrade. Please download from formidableforms.com and install manually.', 'formidable' );
1495 +
1399 1496 // Delete so cannot replay.
1400 1497 delete_option( 'frm_connect_token' );
1401 1498
1402 1499 // It's already installed and active.
1403 1500 $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true );
1404 -
1405 1501 if ( is_wp_error( $active ) ) {
1406 1502 $response = self::maybe_download_and_activate();
1407 -
1408 1503 if ( is_array( $response ) ) {
1409 1504 // The download failed.
1410 1505 return $response;
1411 1506 }
@@ -1411,12 +1506,11 @@
1411 1506 }
1412 1507 }
1413 1508
1414 1509 // If empty license, save it now.
1415 - if ( ! self::get_pro_license() && function_exists( 'load_formidable_pro' ) ) {
1510 + if ( empty( self::get_pro_license() ) && function_exists( 'load_formidable_pro' ) ) {
1416 1511 load_formidable_pro();
1417 1512 $license = stripslashes( FrmAppHelper::get_param( 'key', '', 'request', 'sanitize_text_field' ) );
1418 -
1419 1513 if ( ! $license ) {
1420 1514 return array(
1421 1515 'success' => false,
1422 1516 'error' => 'That site does not have a valid license key.',
@@ -1423,9 +1517,8 @@
1423 1517 );
1424 1518 }
1425 1519
1426 1520 $response = FrmAddon::activate_license_for_plugin( $license, 'formidable_pro' );
1427 -
1428 1521 if ( ! $response['success'] ) {
1429 1522 // Could not activate license.
1430 1523 return $response;
1431 1524 }
@@ -1450,9 +1543,8 @@
1450 1543 }
1451 1544
1452 1545 // Download plugin now.
1453 1546 $response = self::download_and_activate();
1454 -
1455 1547 if ( is_array( $response ) && isset( $response['success'] ) ) {
1456 1548 // The download failed.
1457 1549 return $response;
1458 1550 }
@@ -1466,9 +1558,8 @@
1466 1558 * @since 4.09
1467 1559 *
1468 1560 * @param string $plugin
1469 1561 * @param array|string $upgrade_link_args
1470 - *
1471 1562 * @return void
1472 1563 */
1473 1564 public static function conditional_action_button( $plugin, $upgrade_link_args ) {
1474 1565 if ( is_callable( 'FrmProAddonsController::conditional_action_button' ) ) {
@@ -1503,9 +1594,8 @@
1503 1594 * @type false|string $license_type
1504 1595 * @type string $plan_required
1505 1596 * @type string $upgrade_link
1506 1597 * }
1507 - *
1508 1598 * @return void
1509 1599 */
1510 1600 public static function show_conditional_action_button( $atts ) {
1511 1601 if ( is_callable( 'FrmProAddonsController::show_conditional_action_button' ) ) {
@@ -1526,9 +1616,8 @@
1526 1616 */
1527 1617 public static function addon_upgrade_link( $addon, $upgrade_link ) {
1528 1618 $atts = is_array( $upgrade_link ) ? $upgrade_link : array();
1529 1619 $upgrade_link = is_array( $upgrade_link ) ? $upgrade_link['link'] : $upgrade_link;
1530 - $text = ! empty( $atts['text'] ) ? $atts['text'] : __( 'Upgrade Now', 'formidable' );
1531 1620
1532 1621 if ( $addon ) {
1533 1622 $upgrade_link .= '&utm_content=' . $addon['slug'];
1534 1623 }
@@ -1538,19 +1627,16 @@
1538 1627 $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] );
1539 1628 }
1540 1629
1541 1630 $class = ! empty( $atts['class'] ) ? $atts['class'] : '';
1542 -
1543 - if ( ! str_contains( $class, 'frm-button' ) ) {
1631 + if ( strpos( $class, 'frm-button' ) === false ) {
1544 1632 $class .= ' frm-button-secondary frm-button-sm';
1545 1633 }
1546 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1547 1634 ?>
1548 - <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' ); ?>"><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?>
1549 - <?php echo esc_html( $text ); ?>
1635 + <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' ); ?>">
1636 + <?php esc_html_e( 'Upgrade Now', 'formidable' ); ?>
1550 1637 </a>
1551 1638 <?php
1552 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1553 1639 }
1554 1640
1555 1641 /**
1556 1642 * @since 3.04.02
@@ -1560,9 +1646,8 @@
1560 1646 public static function ajax_install_addon() {
1561 1647 self::install_addon_permissions();
1562 1648
1563 1649 $result = self::download_and_activate();
1564 -
1565 1650 if ( isset( $result['success'] ) && ! $result['success'] ) {
1566 1651 echo json_encode( $result );
1567 1652 wp_die();
1568 1653 }
@@ -1595,8 +1680,9 @@
1595 1680 $allowed_url_list = apply_filters( 'frm_allowed_external_urls', $allowed_url_list );
1596 1681
1597 1682 if ( ! is_array( $allowed_url_list ) ) {
1598 1683 _doing_it_wrong( __METHOD__, 'Only an array of URLs could be used within this filter.', '6.3.1' );
1684 +
1599 1685 return array();
1600 1686 }
1601 1687
1602 1688 return $allowed_url_list;
@@ -1606,10 +1692,8 @@
1606 1692 * Gets required plan for an addon.
1607 1693 *
1608 1694 * @since 6.4.2
1609 1695 *
1610 - * @param int|string $addon_id
1611 - *
1612 1696 * @return string Empty string if no plan is required for active license.
1613 1697 */
1614 1698 public static function get_addon_required_plan( $addon_id ) {
1615 1699 $api = new FrmFormApi();
@@ -1620,10 +1704,38 @@
1620 1704 $requires = FrmFormsHelper::get_plan_required( $dates );
1621 1705 }
1622 1706
1623 1707 if ( ! isset( $requires ) || ! is_string( $requires ) ) {
1624 - return '';
1708 + $requires = '';
1625 1709 }
1626 1710
1627 1711 return $requires;
1712 + }
1713 +
1714 + /**
1715 + * @since 4.02.05
1716 + * @deprecated 6.8.3
1717 + *
1718 + * @codeCoverageIgnore
1719 + *
1720 + * @return void
1721 + */
1722 + public static function connect_pro() {
1723 + _deprecated_function( __METHOD__, '6.8.3' );
1724 + }
1725 +
1726 + /**
1727 + * @since 4.08
1728 + * @deprecated 6.11.1
1729 + *
1730 + * @return bool|int false or the number of days until expiration.
1731 + */
1732 + public static function is_license_expiring() {
1733 + _deprecated_function( __METHOD__, '6.11.1', 'FrmProAddonsController::is_license_expiring' );
1734 +
1735 + if ( is_callable( 'FrmProAddonsController::is_license_expiring' ) ) {
1736 + return FrmProAddonsController::is_license_expiring();
1737 + }
1738 +
1739 + return false;
1628 1740 }
1629 1741 }