| @@ -26,19 +26,17 @@ | ||
| 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 | 35 | if ( FrmAppHelper::is_admin_page( 'formidable-addons' ) ) { |
| 38 | 36 | self::$request_addon_url = 'https://connect.formidableforms.com/add-on-request/'; |
| 39 | 37 | |
| 40 | - add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 ); | |
| 38 | + add_action( 'admin_enqueue_scripts', __CLASS__ . '::enqueue_assets', 15 ); | |
| 41 | 39 | add_filter( 'frm_show_footer_links', '__return_false' ); |
| 42 | 40 | } |
| 43 | 41 | } |
| 44 | 42 | |
| @@ -107,9 +105,8 @@ | ||
| 107 | 105 | remove_submenu_page( 'formidable', 'formidable' ); |
| 108 | 106 | |
| 109 | 107 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 110 | 108 | $cta_text = FrmSalesApi::get_best_sale_value( 'menu_cta_text' ); |
| 111 | - | |
| 112 | 109 | if ( ! $cta_text ) { |
| 113 | 110 | $cta_text = __( 'Upgrade', 'formidable' ); |
| 114 | 111 | } |
| 115 | 112 | |
| @@ -145,9 +142,9 @@ | ||
| 145 | 142 | |
| 146 | 143 | if ( isset( $addons['error'] ) ) { |
| 147 | 144 | $api = new FrmFormApi(); |
| 148 | 145 | $errors = $api->get_error_from_response( $addons ); |
| 149 | - $license_type = $addons['error']['type'] ?? ''; | |
| 146 | + $license_type = isset( $addons['error']['type'] ) ? $addons['error']['type'] : ''; | |
| 150 | 147 | unset( $addons['error'] ); |
| 151 | 148 | } |
| 152 | 149 | |
| 153 | 150 | $pro = array( |
| @@ -198,9 +195,8 @@ | ||
| 198 | 195 | } |
| 199 | 196 | } |
| 200 | 197 | |
| 201 | 198 | $special_categories = array(); |
| 202 | - | |
| 203 | 199 | if ( 'elite' !== self::license_type() ) { |
| 204 | 200 | $special_categories['available-addons'] = array( |
| 205 | 201 | 'name' => __( 'Available', 'formidable' ), |
| 206 | 202 | // To be assigned via JavaScript. |
| @@ -232,9 +228,8 @@ | ||
| 232 | 228 | * |
| 233 | 229 | * @since 6.15 |
| 234 | 230 | * |
| 235 | 231 | * @param array $addon The addon array that will be modified by reference. |
| 236 | - * | |
| 237 | 232 | * @return void |
| 238 | 233 | */ |
| 239 | 234 | protected static function set_categories( &$addon ) { |
| 240 | 235 | if ( ! isset( $addon['categories'] ) ) { |
| @@ -265,9 +260,8 @@ | ||
| 265 | 260 | * @return void |
| 266 | 261 | */ |
| 267 | 262 | public static function license_settings() { |
| 268 | 263 | $plugins = apply_filters( 'frm_installed_addons', array() ); |
| 269 | - | |
| 270 | 264 | if ( empty( $plugins ) ) { |
| 271 | 265 | esc_html_e( 'There are no plugins on your site that require a license', 'formidable' ); |
| 272 | 266 | |
| 273 | 267 | return; |
| @@ -314,9 +308,8 @@ | ||
| 314 | 308 | /** |
| 315 | 309 | * If the API is unable to connect, show something on the addons page |
| 316 | 310 | * |
| 317 | 311 | * @since 3.04.03 |
| 318 | - * | |
| 319 | 312 | * @return array |
| 320 | 313 | */ |
| 321 | 314 | protected static function fallback_plugin_list() { |
| 322 | 315 | $list = array( |
| @@ -413,9 +406,8 @@ | ||
| 413 | 406 | /** |
| 414 | 407 | * If Pro is missing but has been authenticated, include a download URL |
| 415 | 408 | * |
| 416 | 409 | * @since 3.04.03 |
| 417 | - * | |
| 418 | 410 | * @return string |
| 419 | 411 | */ |
| 420 | 412 | public static function get_pro_download_url() { |
| 421 | 413 | $license = self::get_pro_license(); |
| @@ -422,20 +414,17 @@ | ||
| 422 | 414 | $api = new FrmFormApi( $license ); |
| 423 | 415 | $downloads = $api->get_api_info(); |
| 424 | 416 | $pro = self::get_pro_from_addons( $downloads ); |
| 425 | 417 | |
| 426 | - return $pro['url'] ?? ''; | |
| 418 | + return isset( $pro['url'] ) ? $pro['url'] : ''; | |
| 427 | 419 | } |
| 428 | 420 | |
| 429 | 421 | /** |
| 430 | 422 | * @since 4.08 |
| 431 | - * | |
| 432 | - * @return string | |
| 433 | 423 | */ |
| 434 | 424 | public static function get_pro_license() { |
| 435 | 425 | $pro_cred_store = 'frmpro-credentials'; |
| 436 | 426 | $pro_wpmu_store = 'frmpro-wpmu-sitewide'; |
| 437 | - | |
| 438 | 427 | if ( is_multisite() && get_site_option( $pro_wpmu_store ) ) { |
| 439 | 428 | $creds = get_site_option( $pro_cred_store ); |
| 440 | 429 | } else { |
| 441 | 430 | $creds = get_option( $pro_cred_store ); |
| @@ -445,9 +434,8 @@ | ||
| 445 | 434 | return ''; |
| 446 | 435 | } |
| 447 | 436 | |
| 448 | 437 | $license = $creds['license']; |
| 449 | - | |
| 450 | 438 | if ( empty( $license ) ) { |
| 451 | 439 | return ''; |
| 452 | 440 | } |
| 453 | 441 | |
| @@ -461,19 +449,16 @@ | ||
| 461 | 449 | /** |
| 462 | 450 | * @since 4.08 |
| 463 | 451 | * |
| 464 | 452 | * @param array $addons |
| 465 | - * | |
| 466 | 453 | * @return array |
| 467 | 454 | */ |
| 468 | 455 | protected static function get_pro_from_addons( $addons ) { |
| 469 | - return $addons['93790'] ?? array(); | |
| 456 | + return isset( $addons['93790'] ) ? $addons['93790'] : array(); | |
| 470 | 457 | } |
| 471 | 458 | |
| 472 | 459 | /** |
| 473 | 460 | * @since 4.06 |
| 474 | - * | |
| 475 | - * @return string | |
| 476 | 461 | */ |
| 477 | 462 | public static function license_type() { |
| 478 | 463 | if ( is_callable( 'FrmProAddonsController::license_type' ) ) { |
| 479 | 464 | return FrmProAddonsController::license_type(); |
| @@ -488,21 +473,18 @@ | ||
| 488 | 473 | * @return bool |
| 489 | 474 | */ |
| 490 | 475 | public static function is_license_expired() { |
| 491 | 476 | $version_info = self::get_primary_license_info(); |
| 492 | - | |
| 493 | 477 | if ( ! isset( $version_info['error'] ) ) { |
| 494 | 478 | return false; |
| 495 | 479 | } |
| 496 | 480 | |
| 497 | - $expires = $version_info['error']['expires'] ?? 0; | |
| 498 | - | |
| 481 | + $expires = isset( $version_info['error']['expires'] ) ? $version_info['error']['expires'] : 0; | |
| 499 | 482 | if ( empty( $expires ) || $expires > time() ) { |
| 500 | 483 | return false; |
| 501 | 484 | } |
| 502 | 485 | |
| 503 | 486 | $rate_limited = ! empty( $version_info['response_code'] ) && 429 === (int) $version_info['response_code']; |
| 504 | - | |
| 505 | 487 | if ( $rate_limited ) { |
| 506 | 488 | // Do not return false positives for rate limited responses. |
| 507 | 489 | return false; |
| 508 | 490 | } |
| @@ -517,13 +499,11 @@ | ||
| 517 | 499 | * @return array|false |
| 518 | 500 | */ |
| 519 | 501 | public static function get_primary_license_info() { |
| 520 | 502 | $installed_addons = apply_filters( 'frm_installed_addons', array() ); |
| 521 | - | |
| 522 | 503 | if ( empty( $installed_addons ) || ! isset( $installed_addons['formidable_pro'] ) ) { |
| 523 | 504 | return false; |
| 524 | 505 | } |
| 525 | - | |
| 526 | 506 | $installed_addons = array( |
| 527 | 507 | 'formidable_pro' => $installed_addons['formidable_pro'], |
| 528 | 508 | ); |
| 529 | 509 | |
| @@ -531,12 +511,8 @@ | ||
| 531 | 511 | } |
| 532 | 512 | |
| 533 | 513 | /** |
| 534 | 514 | * @since 3.04.03 |
| 535 | - * | |
| 536 | - * @param mixed $transient | |
| 537 | - * | |
| 538 | - * @return object | |
| 539 | 515 | */ |
| 540 | 516 | public static function check_update( $transient ) { |
| 541 | 517 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 542 | 518 | // Don't make any changes if only Lite is installed. |
| @@ -547,9 +523,8 @@ | ||
| 547 | 523 | $transient = new stdClass(); |
| 548 | 524 | } |
| 549 | 525 | |
| 550 | 526 | $installed_addons = apply_filters( 'frm_installed_addons', array() ); |
| 551 | - | |
| 552 | 527 | if ( empty( $installed_addons ) ) { |
| 553 | 528 | return $transient; |
| 554 | 529 | } |
| 555 | 530 | |
| @@ -564,9 +539,8 @@ | ||
| 564 | 539 | continue; |
| 565 | 540 | } |
| 566 | 541 | |
| 567 | 542 | $folder = $plugin->plugin; |
| 568 | - | |
| 569 | 543 | if ( empty( $folder ) ) { |
| 570 | 544 | continue; |
| 571 | 545 | } |
| 572 | 546 | |
| @@ -574,10 +548,10 @@ | ||
| 574 | 548 | // don't show an update if the plugin isn't installed |
| 575 | 549 | continue; |
| 576 | 550 | } |
| 577 | 551 | |
| 578 | - $wp_plugin = $wp_plugins[ $folder ] ?? array(); | |
| 579 | - $wp_version = $wp_plugin['Version'] ?? '1.0'; | |
| 552 | + $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array(); | |
| 553 | + $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0'; | |
| 580 | 554 | $plugin->slug = explode( '/', $folder )[0]; |
| 581 | 555 | |
| 582 | 556 | if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) { |
| 583 | 557 | $transient->response[ $folder ] = $plugin; |
| @@ -597,9 +571,8 @@ | ||
| 597 | 571 | * Because this gets called on "pre_set_site_transient_update_plugins" an old version of FrmAppHelper may be loaded on plugin update. |
| 598 | 572 | * 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 | 573 | * |
| 600 | 574 | * @since 5.5.2 |
| 601 | - * | |
| 602 | 575 | * @return array |
| 603 | 576 | */ |
| 604 | 577 | protected static function get_plugins() { |
| 605 | 578 | if ( ! function_exists( 'get_plugins' ) ) { |
| @@ -639,9 +612,8 @@ | ||
| 639 | 612 | continue; |
| 640 | 613 | } |
| 641 | 614 | |
| 642 | 615 | $new_license = $addon->license; |
| 643 | - | |
| 644 | 616 | if ( empty( $new_license ) || in_array( $new_license, $checked_licenses ) ) { |
| 645 | 617 | continue; |
| 646 | 618 | } |
| 647 | 619 | |
| @@ -647,9 +619,8 @@ | ||
| 647 | 619 | |
| 648 | 620 | $checked_licenses[] = $new_license; |
| 649 | 621 | |
| 650 | 622 | $api = new FrmFormApi( $new_license ); |
| 651 | - | |
| 652 | 623 | if ( empty( $version_info ) ) { |
| 653 | 624 | $version_info = $api->get_api_info(); |
| 654 | 625 | continue; |
| 655 | 626 | } |
| @@ -654,21 +625,18 @@ | ||
| 654 | 625 | continue; |
| 655 | 626 | } |
| 656 | 627 | |
| 657 | 628 | $plugin = $api->get_addon_for_license( $addon, $version_info ); |
| 658 | - | |
| 659 | 629 | if ( empty( $plugin ) ) { |
| 660 | 630 | continue; |
| 661 | 631 | } |
| 662 | 632 | |
| 663 | - $download_id = $plugin['id'] ?? 0; | |
| 664 | - | |
| 633 | + $download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0; | |
| 665 | 634 | if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) { |
| 666 | 635 | // if this addon is using its own license, get the update url |
| 667 | 636 | $addon_info = $api->get_api_info(); |
| 668 | 637 | |
| 669 | 638 | $version_info[ $download_id ] = $addon_info[ $download_id ]; |
| 670 | - | |
| 671 | 639 | if ( isset( $addon_info['error'] ) ) { |
| 672 | 640 | $version_info[ $download_id ]['error'] = array( |
| 673 | 641 | 'message' => $addon_info['error']['message'], |
| 674 | 642 | 'code' => $addon_info['error']['code'], |
| @@ -683,11 +651,9 @@ | ||
| 683 | 651 | /** |
| 684 | 652 | * Get the action link for an addon that isn't active. |
| 685 | 653 | * |
| 686 | 654 | * @since 3.06.03 |
| 687 | - * | |
| 688 | 655 | * @param string $plugin The plugin slug. |
| 689 | - * | |
| 690 | 656 | * @return array |
| 691 | 657 | */ |
| 692 | 658 | public static function install_link( $plugin ) { |
| 693 | 659 | $link = array(); |
| @@ -724,20 +690,16 @@ | ||
| 724 | 690 | } |
| 725 | 691 | |
| 726 | 692 | /** |
| 727 | 693 | * @since 4.09 |
| 728 | - * | |
| 729 | 694 | * @param string $plugin The plugin slug. |
| 730 | - * | |
| 731 | 695 | * @return array|false |
| 732 | 696 | */ |
| 733 | 697 | public static function get_addon( $plugin ) { |
| 734 | 698 | $addons = self::get_api_addons(); |
| 735 | 699 | self::prepare_addons( $addons ); |
| 736 | - | |
| 737 | 700 | foreach ( $addons as $addon ) { |
| 738 | 701 | $slug = explode( '/', $addon['plugin'] ); |
| 739 | - | |
| 740 | 702 | if ( $slug[0] === 'formidable-' . $plugin ) { |
| 741 | 703 | return $addon; |
| 742 | 704 | } |
| 743 | 705 | } |
| @@ -745,15 +707,13 @@ | ||
| 745 | 707 | } |
| 746 | 708 | |
| 747 | 709 | /** |
| 748 | 710 | * @since 4.09 |
| 749 | - * | |
| 750 | 711 | * @return string |
| 751 | 712 | */ |
| 752 | 713 | protected static function get_license_type() { |
| 753 | 714 | $license_type = ''; |
| 754 | 715 | $addons = self::get_api_addons(); |
| 755 | - | |
| 756 | 716 | if ( isset( $addons['error'] ) && isset( $addons['error']['type'] ) ) { |
| 757 | 717 | $license_type = $addons['error']['type']; |
| 758 | 718 | } |
| 759 | 719 | return $license_type; |
| @@ -769,9 +729,8 @@ | ||
| 769 | 729 | */ |
| 770 | 730 | public static function get_addon_for_license( $addons, $license ) { |
| 771 | 731 | $download_id = $license->download_id; |
| 772 | 732 | $plugin = array(); |
| 773 | - | |
| 774 | 733 | if ( empty( $download_id ) && ! empty( $addons ) ) { |
| 775 | 734 | foreach ( $addons as $addon ) { |
| 776 | 735 | if ( strtolower( $license->plugin_name ) === strtolower( $addon['title'] ) ) { |
| 777 | 736 | return $addon; |
| @@ -784,21 +743,17 @@ | ||
| 784 | 743 | return $plugin; |
| 785 | 744 | } |
| 786 | 745 | |
| 787 | 746 | /** |
| 788 | - * @param array $addons | |
| 789 | - * | |
| 790 | 747 | * @return void |
| 791 | 748 | */ |
| 792 | 749 | protected static function prepare_addons( &$addons ) { |
| 793 | 750 | $activate_url = ''; |
| 794 | - | |
| 795 | 751 | if ( current_user_can( 'activate_plugins' ) ) { |
| 796 | 752 | $activate_url = add_query_arg( array( 'action' => 'activate' ), admin_url( 'plugins.php' ) ); |
| 797 | 753 | } |
| 798 | 754 | |
| 799 | 755 | $loop_addons = $addons; |
| 800 | - | |
| 801 | 756 | foreach ( $loop_addons as $id => $addon ) { |
| 802 | 757 | if ( is_numeric( $id ) ) { |
| 803 | 758 | $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] ); |
| 804 | 759 | $file_name = $addon['plugin']; |
| @@ -803,17 +758,14 @@ | ||
| 803 | 758 | $slug = str_replace( array( '-wordpress-plugin', '-wordpress' ), '', $addon['slug'] ); |
| 804 | 759 | $file_name = $addon['plugin']; |
| 805 | 760 | } else { |
| 806 | 761 | $slug = $id; |
| 807 | - | |
| 808 | 762 | if ( isset( $addon['file'] ) ) { |
| 809 | 763 | $base_file = $addon['file']; |
| 810 | 764 | } else { |
| 811 | 765 | $base_file = 'formidable-' . $slug; |
| 812 | 766 | } |
| 813 | - | |
| 814 | 767 | $file_name = $base_file . '/' . $base_file . '.php'; |
| 815 | - | |
| 816 | 768 | if ( ! isset( $addon['plugin'] ) ) { |
| 817 | 769 | $addon['plugin'] = $file_name; |
| 818 | 770 | } |
| 819 | 771 | } |
| @@ -818,12 +770,10 @@ | ||
| 818 | 770 | } |
| 819 | 771 | } |
| 820 | 772 | |
| 821 | 773 | $addon['installed'] = self::is_installed( $file_name ); |
| 822 | - | |
| 823 | 774 | if ( $addon['installed'] && 'formidable-views/formidable-views.php' === $file_name ) { |
| 824 | 775 | $active_views_version = self::get_active_views_version(); |
| 825 | - | |
| 826 | 776 | if ( false !== $active_views_version && $slug !== $active_views_version ) { |
| 827 | 777 | $addon['installed'] = false; |
| 828 | 778 | } |
| 829 | 779 | } |
| @@ -857,11 +807,8 @@ | ||
| 857 | 807 | }//end foreach |
| 858 | 808 | } |
| 859 | 809 | |
| 860 | 810 | /** |
| 861 | - * @param string $file_name | |
| 862 | - * @param string $slug | |
| 863 | - * | |
| 864 | 811 | * @return bool |
| 865 | 812 | */ |
| 866 | 813 | private static function is_plugin_active( $file_name, $slug ) { |
| 867 | 814 | if ( 'formidable-views/formidable-views.php' === $file_name ) { |
| @@ -876,9 +823,8 @@ | ||
| 876 | 823 | private static function get_active_views_version() { |
| 877 | 824 | if ( ! is_callable( 'FrmViewsAppHelper::plugin_version' ) ) { |
| 878 | 825 | return false; |
| 879 | 826 | } |
| 880 | - | |
| 881 | 827 | $plugin_version = FrmViewsAppHelper::plugin_version(); |
| 882 | 828 | return version_compare( $plugin_version, '5.0', '>=' ) ? 'visual-views' : 'views'; |
| 883 | 829 | } |
| 884 | 830 | |
| @@ -884,25 +830,22 @@ | ||
| 884 | 830 | |
| 885 | 831 | /** |
| 886 | 832 | * @since 3.04.02 |
| 887 | 833 | * |
| 888 | - * @param string $link | |
| 889 | - * | |
| 890 | 834 | * @return void |
| 891 | 835 | */ |
| 892 | 836 | protected static function prepare_addon_link( &$link ) { |
| 893 | 837 | $site_url = 'https://formidableforms.com/'; |
| 894 | - | |
| 895 | 838 | if ( strpos( $link, 'http' ) !== 0 ) { |
| 896 | 839 | $link = $site_url . $link; |
| 897 | 840 | } |
| 898 | - | |
| 899 | 841 | $link = FrmAppHelper::make_affiliate_url( $link ); |
| 900 | - | |
| 901 | - $utm = array( | |
| 902 | - 'campaign' => 'addons', | |
| 842 | + $query_args = array( | |
| 843 | + 'utm_source' => 'WordPress', | |
| 844 | + 'utm_medium' => 'addons', | |
| 845 | + 'utm_campaign' => 'liteplugin', | |
| 903 | 846 | ); |
| 904 | - $link = FrmAppHelper::maybe_add_missing_utm( $link, $utm ); | |
| 847 | + $link = add_query_arg( $query_args, $link ); | |
| 905 | 848 | } |
| 906 | 849 | |
| 907 | 850 | /** |
| 908 | 851 | * Add the status to the addon array. Status options are: |
| @@ -909,10 +852,8 @@ | ||
| 909 | 852 | * installed, active, not installed |
| 910 | 853 | * |
| 911 | 854 | * @since 3.04.02 |
| 912 | 855 | * |
| 913 | - * @param array $addon | |
| 914 | - * | |
| 915 | 856 | * @return void |
| 916 | 857 | */ |
| 917 | 858 | protected static function set_addon_status( &$addon ) { |
| 918 | 859 | if ( ! empty( $addon['activate_url'] ) ) { |
| @@ -939,9 +880,8 @@ | ||
| 939 | 880 | * @param string $plugin |
| 940 | 881 | * @param string $redirect |
| 941 | 882 | * @param bool $network_wide |
| 942 | 883 | * @param bool $silent |
| 943 | - * | |
| 944 | 884 | * @return WP_Error|null Null on success, WP_Error on invalid file. |
| 945 | 885 | */ |
| 946 | 886 | protected static function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) { |
| 947 | 887 | if ( ! function_exists( 'activate_plugin' ) ) { |
| @@ -956,9 +896,8 @@ | ||
| 956 | 896 | * @since 6.8 |
| 957 | 897 | * |
| 958 | 898 | * @param string $plugin |
| 959 | 899 | * @param bool $silent |
| 960 | - * | |
| 961 | 900 | * @return void |
| 962 | 901 | */ |
| 963 | 902 | protected static function deactivate_plugin( $plugin, $silent = false ) { |
| 964 | 903 | if ( ! function_exists( 'deactivate_plugins' ) ) { |
| @@ -972,9 +911,8 @@ | ||
| 972 | 911 | * |
| 973 | 912 | * @since 6.8 |
| 974 | 913 | * |
| 975 | 914 | * @param string $plugin |
| 976 | - * | |
| 977 | 915 | * @return true|WP_Error True on success, WP_Error on invalid file. |
| 978 | 916 | */ |
| 979 | 917 | protected static function uninstall_plugin( $plugin ) { |
| 980 | 918 | if ( ! current_user_can( 'delete_plugins' ) ) { |
| @@ -1019,9 +957,8 @@ | ||
| 1019 | 957 | |
| 1020 | 958 | self::maybe_show_cred_form(); |
| 1021 | 959 | |
| 1022 | 960 | $installed = self::install_addon(); |
| 1023 | - | |
| 1024 | 961 | if ( is_array( $installed ) && isset( $installed['message'] ) ) { |
| 1025 | 962 | return $installed; |
| 1026 | 963 | } |
| 1027 | 964 | self::handle_addon_action( $installed, 'activate' ); |
| @@ -1036,9 +973,9 @@ | ||
| 1036 | 973 | if ( ! function_exists( 'request_filesystem_credentials' ) ) { |
| 1037 | 974 | include_once ABSPATH . 'wp-admin/includes/file.php'; |
| 1038 | 975 | } |
| 1039 | 976 | |
| 1040 | - // Start output buffering to catch the filesystem form if credentials are needed. | |
| 977 | + // Start output bufferring to catch the filesystem form if credentials are needed. | |
| 1041 | 978 | ob_start(); |
| 1042 | 979 | |
| 1043 | 980 | $show_form = false; |
| 1044 | 981 | $method = ''; |
| @@ -1085,10 +1022,8 @@ | ||
| 1085 | 1022 | * We do not need any extra credentials if we have gotten this far, |
| 1086 | 1023 | * so let's install the plugin. |
| 1087 | 1024 | * |
| 1088 | 1025 | * @since 3.04.02 |
| 1089 | - * | |
| 1090 | - * @return array|string | |
| 1091 | 1026 | */ |
| 1092 | 1027 | protected static function install_addon() { |
| 1093 | 1028 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 1094 | 1029 | |
| @@ -1108,9 +1043,8 @@ | ||
| 1108 | 1043 | // Flush the cache and return the newly installed plugin basename. |
| 1109 | 1044 | wp_cache_flush(); |
| 1110 | 1045 | |
| 1111 | 1046 | $plugin = $installer->plugin_info(); |
| 1112 | - | |
| 1113 | 1047 | if ( ! $plugin ) { |
| 1114 | 1048 | return array( |
| 1115 | 1049 | 'message' => 'Plugin was not installed. ' . $installer->result, |
| 1116 | 1050 | 'success' => false, |
| @@ -1180,9 +1114,8 @@ | ||
| 1180 | 1114 | * @since 6.8 |
| 1181 | 1115 | * |
| 1182 | 1116 | * @param callable $action_callback The specific add-on action to be executed. |
| 1183 | 1117 | * @param callable|null $response_callback Optional. The response handling callback. Default null. |
| 1184 | - * | |
| 1185 | 1118 | * @return void |
| 1186 | 1119 | */ |
| 1187 | 1120 | private static function process_addon_action( $action_callback, $response_callback = null ) { |
| 1188 | 1121 | self::install_addon_permissions(); |
| @@ -1205,9 +1138,8 @@ | ||
| 1205 | 1138 | * @since 6.8 |
| 1206 | 1139 | * |
| 1207 | 1140 | * @param string $installed The plugin folder name with file name. |
| 1208 | 1141 | * @param string $action The action type ('activate', 'deactivate', 'uninstall'). |
| 1209 | - * | |
| 1210 | 1142 | * @return array|void |
| 1211 | 1143 | */ |
| 1212 | 1144 | protected static function handle_addon_action( $installed, $action ) { |
| 1213 | 1145 | if ( ! $installed || ! $action ) { |
| @@ -1266,9 +1198,8 @@ | ||
| 1266 | 1198 | * @return string |
| 1267 | 1199 | */ |
| 1268 | 1200 | private static function get_activating_page() { |
| 1269 | 1201 | $referer = FrmAppHelper::get_server_value( 'HTTP_REFERER' ); |
| 1270 | - | |
| 1271 | 1202 | if ( false !== strpos( $referer, 'frm_action=settings' ) ) { |
| 1272 | 1203 | return 'settings'; |
| 1273 | 1204 | } |
| 1274 | 1205 | |
| @@ -1301,14 +1232,12 @@ | ||
| 1301 | 1232 | * @return string |
| 1302 | 1233 | */ |
| 1303 | 1234 | public static function connect_link() { |
| 1304 | 1235 | $auth = get_option( 'frm_connect_token' ); |
| 1305 | - | |
| 1306 | 1236 | if ( empty( $auth ) ) { |
| 1307 | 1237 | $auth = hash( 'sha512', wp_rand() ); |
| 1308 | 1238 | update_option( 'frm_connect_token', $auth, 'no' ); |
| 1309 | 1239 | } |
| 1310 | - | |
| 1311 | 1240 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title', 'formidable-settings' ); |
| 1312 | 1241 | $link = 'https://formidableforms.com/api-connect/'; |
| 1313 | 1242 | $args = array( |
| 1314 | 1243 | 'v' => 2, |
| @@ -1337,9 +1266,8 @@ | ||
| 1337 | 1266 | |
| 1338 | 1267 | // The download link is not required if already installed. |
| 1339 | 1268 | $is_installed = FrmAppHelper::pro_is_included(); |
| 1340 | 1269 | $file_missing = ! $is_installed && empty( $post_url ); |
| 1341 | - | |
| 1342 | 1270 | if ( ! $post_auth || $file_missing ) { |
| 1343 | 1271 | return false; |
| 1344 | 1272 | } |
| 1345 | 1273 | |
| @@ -1344,9 +1272,8 @@ | ||
| 1344 | 1272 | } |
| 1345 | 1273 | |
| 1346 | 1274 | // Verify auth. |
| 1347 | 1275 | $auth = get_option( 'frm_connect_token' ); |
| 1348 | - | |
| 1349 | 1276 | if ( empty( $auth ) || ! hash_equals( $auth, $post_auth ) ) { |
| 1350 | 1277 | return false; |
| 1351 | 1278 | } |
| 1352 | 1279 | |
| @@ -1362,17 +1289,17 @@ | ||
| 1362 | 1289 | */ |
| 1363 | 1290 | public static function install_addon_api() { |
| 1364 | 1291 | self::$plugin = FrmAppHelper::get_param( 'file_url', '', 'request', 'esc_url_raw' ); |
| 1365 | 1292 | |
| 1293 | + $error = esc_html__( 'Could not install an upgrade. Please download from formidableforms.com and install manually.', 'formidable' ); | |
| 1294 | + | |
| 1366 | 1295 | // Delete so cannot replay. |
| 1367 | 1296 | delete_option( 'frm_connect_token' ); |
| 1368 | 1297 | |
| 1369 | 1298 | // It's already installed and active. |
| 1370 | 1299 | $active = self::activate_plugin( 'formidable-pro/formidable-pro.php', false, false, true ); |
| 1371 | - | |
| 1372 | 1300 | if ( is_wp_error( $active ) ) { |
| 1373 | 1301 | $response = self::maybe_download_and_activate(); |
| 1374 | - | |
| 1375 | 1302 | if ( is_array( $response ) ) { |
| 1376 | 1303 | // The download failed. |
| 1377 | 1304 | return $response; |
| 1378 | 1305 | } |
| @@ -1381,9 +1308,8 @@ | ||
| 1381 | 1308 | // If empty license, save it now. |
| 1382 | 1309 | if ( empty( self::get_pro_license() ) && function_exists( 'load_formidable_pro' ) ) { |
| 1383 | 1310 | load_formidable_pro(); |
| 1384 | 1311 | $license = stripslashes( FrmAppHelper::get_param( 'key', '', 'request', 'sanitize_text_field' ) ); |
| 1385 | - | |
| 1386 | 1312 | if ( ! $license ) { |
| 1387 | 1313 | return array( |
| 1388 | 1314 | 'success' => false, |
| 1389 | 1315 | 'error' => 'That site does not have a valid license key.', |
| @@ -1390,9 +1316,8 @@ | ||
| 1390 | 1316 | ); |
| 1391 | 1317 | } |
| 1392 | 1318 | |
| 1393 | 1319 | $response = FrmAddon::activate_license_for_plugin( $license, 'formidable_pro' ); |
| 1394 | - | |
| 1395 | 1320 | if ( ! $response['success'] ) { |
| 1396 | 1321 | // Could not activate license. |
| 1397 | 1322 | return $response; |
| 1398 | 1323 | } |
| @@ -1417,9 +1342,8 @@ | ||
| 1417 | 1342 | } |
| 1418 | 1343 | |
| 1419 | 1344 | // Download plugin now. |
| 1420 | 1345 | $response = self::download_and_activate(); |
| 1421 | - | |
| 1422 | 1346 | if ( is_array( $response ) && isset( $response['success'] ) ) { |
| 1423 | 1347 | // The download failed. |
| 1424 | 1348 | return $response; |
| 1425 | 1349 | } |
| @@ -1433,9 +1357,8 @@ | ||
| 1433 | 1357 | * @since 4.09 |
| 1434 | 1358 | * |
| 1435 | 1359 | * @param string $plugin |
| 1436 | 1360 | * @param array|string $upgrade_link_args |
| 1437 | - * | |
| 1438 | 1361 | * @return void |
| 1439 | 1362 | */ |
| 1440 | 1363 | public static function conditional_action_button( $plugin, $upgrade_link_args ) { |
| 1441 | 1364 | if ( is_callable( 'FrmProAddonsController::conditional_action_button' ) ) { |
| @@ -1470,9 +1393,8 @@ | ||
| 1470 | 1393 | * @type false|string $license_type |
| 1471 | 1394 | * @type string $plan_required |
| 1472 | 1395 | * @type string $upgrade_link |
| 1473 | 1396 | * } |
| 1474 | - * | |
| 1475 | 1397 | * @return void |
| 1476 | 1398 | */ |
| 1477 | 1399 | public static function show_conditional_action_button( $atts ) { |
| 1478 | 1400 | if ( is_callable( 'FrmProAddonsController::show_conditional_action_button' ) ) { |
| @@ -1505,9 +1427,8 @@ | ||
| 1505 | 1427 | $upgrade_link = FrmAppHelper::admin_upgrade_link( 'addons', $addon['link'] ); |
| 1506 | 1428 | } |
| 1507 | 1429 | |
| 1508 | 1430 | $class = ! empty( $atts['class'] ) ? $atts['class'] : ''; |
| 1509 | - | |
| 1510 | 1431 | if ( strpos( $class, 'frm-button' ) === false ) { |
| 1511 | 1432 | $class .= ' frm-button-secondary frm-button-sm'; |
| 1512 | 1433 | } |
| 1513 | 1434 | ?> |
| @@ -1525,9 +1446,8 @@ | ||
| 1525 | 1446 | public static function ajax_install_addon() { |
| 1526 | 1447 | self::install_addon_permissions(); |
| 1527 | 1448 | |
| 1528 | 1449 | $result = self::download_and_activate(); |
| 1529 | - | |
| 1530 | 1450 | if ( isset( $result['success'] ) && ! $result['success'] ) { |
| 1531 | 1451 | echo json_encode( $result ); |
| 1532 | 1452 | wp_die(); |
| 1533 | 1453 | } |
| @@ -1571,10 +1491,8 @@ | ||
| 1571 | 1491 | /** |
| 1572 | 1492 | * Gets required plan for an addon. |
| 1573 | 1493 | * |
| 1574 | 1494 | * @since 6.4.2 |
| 1575 | - * | |
| 1576 | - * @param int|string $addon_id | |
| 1577 | 1495 | * |
| 1578 | 1496 | * @return string Empty string if no plan is required for active license. |
| 1579 | 1497 | */ |
| 1580 | 1498 | public static function get_addon_required_plan( $addon_id ) { |