PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmAppController.php +140 -466 6.25.16.8 View file →
@@ -14,13 +14,8 @@
14 14 return;
15 15 }
16 16
17 17 $menu_name = FrmAppHelper::get_menu_name();
18 -
19 - if ( in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) {
20 - $menu_name .= wp_kses_post( FrmInboxController::get_notice_count() );
21 - }
22 -
23 18 add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
24 19 }
25 20
26 21 /**
@@ -72,9 +67,9 @@
72 67 }
73 68
74 69 if ( FrmAppHelper::is_full_screen() ) {
75 70 $full_screen_on = self::get_full_screen_setting();
76 - $add_class = '';
71 + $add_class = '';
77 72 if ( $full_screen_on ) {
78 73 $add_class = ' frm-full-screen is-fullscreen-mode';
79 74
80 75 // Load the CSS for .is-fullscreen-mode.
@@ -139,8 +134,9 @@
139 134 'formidable',
140 135 'formidable-entries',
141 136 'formidable-views',
142 137 'formidable-views-editor',
138 + 'formidable-pro-upgrade',
143 139 'formidable-addons',
144 140 'formidable-import',
145 141 'formidable-settings',
146 142 'formidable-styles',
@@ -146,9 +142,8 @@
146 142 'formidable-styles',
147 143 'formidable-styles2',
148 144 'formidable-inbox',
149 145 FrmFormTemplatesController::PAGE_SLUG,
150 - FrmOnboardingWizardController::PAGE_SLUG,
151 146 );
152 147
153 148 if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
154 149 // Only consider the payments page as a "white page" when the Payments submodule is off.
@@ -185,9 +180,8 @@
185 180 private static function is_grey_page() {
186 181 $grey_pages = array(
187 182 'formidable-applications',
188 183 'formidable-dashboard',
189 - 'formidable-views',
190 184 );
191 185
192 186 $is_grey_page = self::is_page_in_list( $grey_pages );
193 187
@@ -243,9 +237,9 @@
243 237 $id = $form->id;
244 238 $current_page = self::get_current_page();
245 239 $nav_items = self::get_form_nav_items( $form );
246 240
247 - include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php';
241 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
248 242 }
249 243
250 244 /**
251 245 * @return string
@@ -299,18 +293,18 @@
299 293 'permission' => 'frm_view_entries',
300 294 ),
301 295 );
302 296
303 - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed();
297 + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed();
304 298
305 299 if ( ! $views_installed ) {
306 300 $nav_items[] = array(
307 - 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
308 - 'label' => __( 'Views', 'formidable' ),
309 - 'current' => array(),
310 - 'page' => 'formidable-views',
301 + 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
302 + 'label' => __( 'Views', 'formidable' ),
303 + 'current' => array(),
304 + 'page' => 'formidable-views',
311 305 'permission' => 'frm_view_entries',
312 - 'atts' => array(
306 + 'atts' => array(
313 307 'class' => 'frm_noallow',
314 308 ),
315 309 );
316 310 }
@@ -317,14 +311,14 @@
317 311
318 312 // Let people know reports and views exist.
319 313 if ( ! FrmAppHelper::pro_is_installed() ) {
320 314 $nav_items[] = array(
321 - 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ),
322 - 'label' => __( 'Reports', 'formidable' ),
323 - 'current' => array( 'reports' ),
324 - 'page' => 'formidable',
315 + 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ),
316 + 'label' => __( 'Reports', 'formidable' ),
317 + 'current' => array( 'reports' ),
318 + 'page' => 'formidable',
325 319 'permission' => 'frm_view_entries',
326 - 'atts' => array(
320 + 'atts' => array(
327 321 'class' => 'frm_noallow',
328 322 ),
329 323 );
330 324 }
@@ -336,12 +330,10 @@
336 330
337 331 return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
338 332 }
339 333
334 + // Adds a settings link to the plugins page
340 335 /**
341 - * Adds a settings link to the plugins page
342 - *
343 - * @param array $links
344 336 * @return array
345 337 */
346 338 public static function settings_link( $links ) {
347 339 $settings = array();
@@ -346,25 +338,10 @@
346 338 public static function settings_link( $links ) {
347 339 $settings = array();
348 340
349 341 if ( ! FrmAppHelper::pro_is_installed() ) {
350 - if ( FrmAddonsController::is_license_expired() ) {
351 - $label = __( 'Renew', 'formidable' );
352 - } else {
353 - $label = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_text' );
354 - if ( ! $label ) {
355 - $label = __( 'Upgrade to Pro', 'formidable' );
356 - }
357 - }
358 -
359 - $upgrade_link = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_link' );
360 - if ( $upgrade_link ) {
361 - $upgrade_link = FrmAppHelper::maybe_add_missing_utm( $upgrade_link, array( 'medium' => 'plugin-row' ) );
362 - } else {
363 - $upgrade_link = FrmAppHelper::admin_upgrade_link( 'plugin-row' );
364 - }
365 -
366 - $settings[] = '<a href="' . esc_url( $upgrade_link ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>';
342 + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' );
343 + $settings[] = '<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-row' ) ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>';
367 344 }
368 345
369 346 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
370 347
@@ -375,9 +352,9 @@
375 352 * @return void
376 353 */
377 354 public static function pro_get_started_headline() {
378 355 self::review_request();
379 - FrmAppHelper::min_pro_version_notice( '6.20' );
356 + FrmAppHelper::min_pro_version_notice( '4.0' );
380 357 }
381 358
382 359 /**
383 360 * Add admin notices as needed for reviews
@@ -454,10 +431,10 @@
454 431 * @param string $title
455 432 * @param string $description
456 433 * @return void
457 434 */
458 - public static function api_email_form( $form_key, $title = '', $description = '' ) {
459 - $user = wp_get_current_user();
435 + public static function api_email_form( $form_key, $title, $description ) {
436 + $user = wp_get_current_user();
460 437 $args = array(
461 438 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css',
462 439 'title' => $title,
463 440 'description' => $description,
@@ -486,9 +463,10 @@
486 463 * @return void
487 464 */
488 465 public static function remove_upsells() {
489 466 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
490 - remove_action( 'frm_after_settings_tabs', 'FrmSettingsController::settings_cta' );
467 + remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
468 + remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
491 469 remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
492 470 }
493 471
494 472 /**
@@ -510,9 +488,9 @@
510 488 /**
511 489 * Check if the database is outdated
512 490 *
513 491 * @since 2.0.1
514 - * @return bool
492 + * @return boolean
515 493 */
516 494 public static function needs_update() {
517 495 $needs_upgrade = self::compare_for_update(
518 496 array(
@@ -567,34 +545,13 @@
567 545 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
568 546 FrmFormsController::duplicate();
569 547 }
570 548
571 - if ( FrmAppHelper::is_admin_page( 'formidable' ) && FrmAppHelper::simple_get( 'frm_add_tables' ) ) {
572 - self::add_missing_tables();
573 - }
574 -
575 549 if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) {
576 550 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
577 551 FrmStylesController::save_style();
578 552 }
579 553
580 - if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) {
581 - $redirect = FrmSalesApi::get_best_sale_value( 'menu_cta_link' );
582 - $utm = array(
583 - 'campaign' => 'upgrade',
584 - 'content' => 'submenu-upgrade',
585 - );
586 -
587 - if ( $redirect ) {
588 - $redirect = FrmAppHelper::maybe_add_missing_utm( $redirect, $utm );
589 - } else {
590 - $redirect = FrmAppHelper::admin_upgrade_link( $utm );
591 - }
592 -
593 - wp_redirect( $redirect );
594 - die();
595 - }
596 -
597 554 // Register personal data hooks.
598 555 new FrmPersonalData();
599 556
600 557 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
@@ -610,13 +567,13 @@
610 567
611 568 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
612 569 // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
613 570 // This provides backward compatibility for old addons that use legacy modal templates.
614 - $action = FrmAppHelper::get_param( 'frm_action' );
571 + $action = FrmAppHelper::get_param( 'frm_action' );
615 572 $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
616 573 if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
617 574 $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
618 - $url_param = $application_id ? '&applicationId=' . $application_id : '';
575 + $url_param = $application_id ? '&applicationId=' . $application_id : '';
619 576
620 577 wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
621 578 exit;
622 579 }
@@ -622,8 +579,10 @@
622 579 }
623 580
624 581 FrmInbox::maybe_disable_screen_options();
625 582 }
583 +
584 + self::maybe_add_ip_warning();
626 585 }
627 586
628 587 /**
629 588 * Get the current page and check for a possible function to trigger.
@@ -648,10 +607,69 @@
648 607 }
649 608 }
650 609
651 610 /**
611 + * Show a warning for the IP address setting if it hasn't been set.
612 + *
613 + * @since 6.1
614 + *
652 615 * @return void
653 616 */
617 + private static function maybe_add_ip_warning() {
618 + $settings = FrmAppHelper::get_settings();
619 + if ( false !== $settings->custom_header_ip ) {
620 + // The setting has been changed from the false default (to either 1 or 0), so stop showing the message.
621 + return;
622 + }
623 +
624 + if ( ! self::is_behind_proxy() ) {
625 + // This message is only applicable when using a reverse proxy.
626 + return;
627 + }
628 +
629 + if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) {
630 + // Avoid the message on a POST action. We don't want to show the message if we're saving global settings.
631 + return;
632 + }
633 +
634 + $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
635 + $message = sprintf(
636 + // Translators: 1: Global Settings Link
637 + __( 'IP addresses in form submissions may no longer be accurate! If you are experiencing issues, we recommend going to %1$s and enabling the "Use custom headers when retrieving IPs with form submissions." setting.', 'formidable' ),
638 + '<a href="' . esc_url( $global_settings_link ) . '">Global Settings</a>'
639 + );
640 + $option_name = 'frm_dismiss_ip_address_notice';
641 + FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
642 + }
643 +
644 + /**
645 + * Check if any reverse proxy headers are set.
646 + *
647 + * @since 6.1
648 + *
649 + * @return bool
650 + */
651 + private static function is_behind_proxy() {
652 + $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip();
653 + foreach ( $custom_headers as $header ) {
654 + if ( 'REMOTE_ADDR' === $header ) {
655 + // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers.
656 + continue;
657 + }
658 +
659 + $ip = trim( FrmAppHelper::get_server_value( $header ) );
660 + // Return true for anything that isn't empty but ignoring values like ::1.
661 + if ( $ip && 0 !== strpos( $ip, '::' ) ) {
662 + return true;
663 + }
664 + }
665 +
666 + return false;
667 + }
668 +
669 + /**
670 + * @return void
671 + */
654 672 public static function admin_js() {
655 673 $plugin_url = FrmAppHelper::plugin_url();
656 674 $version = FrmAppHelper::plugin_version();
657 675
@@ -656,11 +674,8 @@
656 674 $version = FrmAppHelper::plugin_version();
657 675
658 676 FrmAppHelper::load_admin_wide_js();
659 677
660 - // Register component assets early to ensure they can be enqueued later in controllers.
661 - wp_register_style( 'formidable-animations', $plugin_url . '/css/admin/animations.css', array(), $version );
662 -
663 678 if ( class_exists( 'FrmOverlayController' ) ) {
664 679 // This should always exist.
665 680 // But it may not have loaded properly when updating the plugin.
666 681 FrmOverlayController::register_assets();
@@ -675,18 +690,22 @@
675 690 wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
676 691 wp_register_script( 'formidable_embed', $plugin_url . '/js/admin/embed.js', array( 'formidable_dom', 'jquery-ui-autocomplete' ), $version, true );
677 692 self::register_popper1();
678 693 wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
694 + wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
679 695
680 - $settings_js_vars = array(
681 - 'currencies' => FrmCurrencyHelper::get_currencies(),
682 - );
683 - wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
684 - wp_localize_script( 'formidable_settings', 'frmSettings', $settings_js_vars );
696 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
685 697
686 - if ( self::should_show_floating_links() ) {
698 + // Enqueue Floating Links.
699 + $is_valid_page =
700 + FrmAppHelper::is_formidable_admin() &&
701 + ! FrmAppHelper::is_style_editor_page() &&
702 + ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
703 + ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
704 + if ( $is_valid_page && FrmAppHelper::is_formidable_branding() ) {
687 705 self::enqueue_floating_links( $plugin_url, $version );
688 706 }
707 + unset( $is_valid_page );
689 708
690 709 $dependencies = array(
691 710 'formidable_admin_global',
692 711 'jquery',
@@ -726,29 +745,24 @@
726 745 '#frm_builder_page li[data-ftype="gateway"] { display: none; }'
727 746 );
728 747 }
729 748
730 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
731 749 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
732 750
733 751 global $pagenow;
734 752 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
735 - self::enqueue_global_settings_scripts( $page );
736 753
737 754 wp_enqueue_script( 'admin-widgets' );
738 755 wp_enqueue_style( 'widgets' );
739 756 self::maybe_deregister_popper2();
740 757 wp_enqueue_script( 'formidable_admin' );
741 - wp_set_script_translations( 'formidable_admin', 'formidable' );
742 758 wp_enqueue_script( 'formidable_embed' );
743 - wp_set_script_translations( 'formidable_embed', 'formidable' );
744 759 FrmAppHelper::localize_script( 'admin' );
745 760
746 - wp_enqueue_style( 'formidable-animations' );
747 761 wp_enqueue_style( 'formidable-admin' );
748 762 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
749 763 wp_enqueue_style( 'formidable-grids' );
750 - self::maybe_enqueue_dropzone_css( $page );
764 + wp_enqueue_style( 'formidable-dropzone' );
751 765 } else {
752 766 wp_enqueue_style( 'formidable-grids' );
753 767 }
754 768
@@ -785,93 +799,11 @@
785 799 if ( 'formidable-addons' === $page ) {
786 800 wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
787 801 wp_enqueue_script( 'formidable_addons' );
788 802 }
789 -
790 - self::enqueue_builder_assets( $plugin_url, $version );
791 803 }
792 804
793 805 /**
794 - * Enqueue the Form Builder assets.
795 - *
796 - * @since 6.24
797 - *
798 - * @param string $plugin_url The plugin URL.
799 - * @param string $version The plugin version.
800 - * @return void
801 - */
802 - private static function enqueue_builder_assets( $plugin_url, $version ) {
803 - wp_register_style( 'formidable-settings-components', $plugin_url . '/css/admin/frm-settings-components.css', array( 'formidable-admin', 'formidable-grids' ), $version );
804 - wp_register_script( 'formidable-settings-components', $plugin_url . '/js/formidable-settings-components.js', array( 'formidable_admin' ), $version, true );
805 -
806 - if ( ! FrmAppHelper::is_form_builder_page() ) {
807 - return;
808 - }
809 -
810 - wp_enqueue_style( 'formidable-settings-components' );
811 - wp_enqueue_script( 'formidable-settings-components' );
812 - }
813 -
814 - /**
815 - * Enqueues global settings scripts.
816 - *
817 - * @param string $page The `page` param in URL.
818 - */
819 - private static function enqueue_global_settings_scripts( $page ) {
820 - if ( 'formidable-settings' === $page ) {
821 - wp_enqueue_style( 'wp-color-picker' );
822 - wp_enqueue_script( 'formidable_settings' );
823 - }
824 - }
825 -
826 - /**
827 - * Avoid loading dropzone CSS on the form list page. It isn't required there.
828 - *
829 - * @since 6.11
830 - *
831 - * @param string $page
832 - * @return void
833 - */
834 - private static function maybe_enqueue_dropzone_css( $page ) {
835 - if ( ! FrmAppHelper::pro_is_installed() ) {
836 - return;
837 - }
838 -
839 - $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
840 - if ( ! $should_avoid_loading_dropzone ) {
841 - wp_enqueue_style( 'formidable-dropzone' );
842 - }
843 - }
844 -
845 - /**
846 - * The floating links are not shown on every page.
847 - * They are also not shown if white labeling is being used.
848 - *
849 - * @since 6.8.4
850 - *
851 - * @return bool
852 - */
853 - private static function should_show_floating_links() {
854 - if ( ! FrmAppHelper::is_formidable_branding() ) {
855 - return false;
856 - }
857 -
858 - $should_show = FrmAppHelper::is_formidable_admin() &&
859 - ! FrmAppHelper::is_style_editor_page() &&
860 - ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
861 - ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
862 -
863 - /**
864 - * Filters whether the floating links should be displayed.
865 - *
866 - * @since 6.25.1
867 - *
868 - * @param bool $should_show Whether the floating links should be shown.
869 - */
870 - return apply_filters( 'frm_should_show_floating_links', $should_show );
871 - }
872 -
873 - /**
874 806 * @since 6.3.2
875 807 *
876 808 * @return void
877 809 */
@@ -877,14 +809,8 @@
877 809 */
878 810 public static function admin_enqueue_scripts() {
879 811 self::load_wp_admin_style();
880 812 self::maybe_force_formidable_block_on_gutenberg_page();
881 -
882 - if ( FrmAppHelper::is_admin_page( 'formidable-settings' ) ) {
883 - wp_enqueue_style( FrmDashboardController::PAGE_SLUG, FrmAppHelper::plugin_url() . '/css/admin/dashboard.css', array(), FrmAppHelper::plugin_version() );
884 - }
885 -
886 - FrmUsageController::load_scripts();
887 813 }
888 814
889 815 /**
890 816 * Enqueue required assets for the Legacy Views editor (Views v4.x).
@@ -920,9 +846,8 @@
920 846 }
921 847 '
922 848 );
923 849 wp_enqueue_style( 'formidable-admin' );
924 - wp_enqueue_script( 'formidable_legacy_views', FrmAppHelper::plugin_url() . '/js/admin/legacy-views.js', array( 'jquery', 'formidable_admin' ), FrmAppHelper::plugin_version() );
925 850 FrmAppHelper::localize_script( 'admin' );
926 851 self::include_info_overlay();
927 852 }
928 853
@@ -954,45 +879,12 @@
954 879 *
955 880 * @return void
956 881 */
957 882 private static function register_popper1() {
958 - if ( ! self::should_register_popper() ) {
959 - return;
960 - }
961 883 wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
962 884 }
963 885
964 886 /**
965 - * Only register popper on Formidable pages.
966 - * This helps to avoid popper conflicts on other plugin pages, including the WP Bakery page editor.
967 - *
968 - * @since 6.11.1
969 - *
970 - * @return bool
971 - */
972 - private static function should_register_popper() {
973 - global $pagenow;
974 -
975 - $post_id = FrmAppHelper::simple_get( 'post', 'absint' );
976 - if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) {
977 - return true;
978 - }
979 -
980 - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
981 - $is_views_post_type = 'frm_display' === $post_type;
982 - if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) {
983 - return true;
984 - }
985 -
986 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
987 - if ( strpos( $page, 'formidable' ) === 0 ) {
988 - return true;
989 - }
990 -
991 - return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && FrmAppHelper::simple_get( 'taxonomy' ) === 'frm_application';
992 - }
993 -
994 - /**
995 887 * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set.
996 888 *
997 889 * @since 5.2
998 890 *
@@ -1051,18 +943,18 @@
1051 943 * @return void
1052 944 */
1053 945 public static function create_rest_routes() {
1054 946 $args = array(
1055 - 'methods' => 'GET',
1056 - 'callback' => 'FrmAppController::api_install',
1057 - 'permission_callback' => self::class . '::can_update_db',
947 + 'methods' => 'GET',
948 + 'callback' => 'FrmAppController::api_install',
949 + 'permission_callback' => __CLASS__ . '::can_update_db',
1058 950 );
1059 951
1060 952 register_rest_route( 'frm-admin/v1', '/install', $args );
1061 953
1062 954 $args = array(
1063 - 'methods' => 'GET',
1064 - 'callback' => 'FrmAddonsController::install_addon_api',
955 + 'methods' => 'GET',
956 + 'callback' => 'FrmAddonsController::install_addon_api',
1065 957 'permission_callback' => 'FrmAddonsController::can_install_addon_api',
1066 958 );
1067 959
1068 960 register_rest_route( 'frm-admin/v1', '/install-addon', $args );
@@ -1248,9 +1140,8 @@
1248 1140 *
1249 1141 * @return void
1250 1142 */
1251 1143 public static function add_admin_footer_links() {
1252 - FrmFormsController::include_device_too_small_message();
1253 1144 if ( self::should_show_footer_links() ) {
1254 1145 include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1255 1146 }
1256 1147 }
@@ -1290,10 +1181,8 @@
1290 1181 *
1291 1182 * @return void
1292 1183 */
1293 1184 public static function show_error_modal( $error_args ) {
1294 - add_filter( 'frm_show_footer_links', '__return_false' );
1295 -
1296 1185 $defaults = array(
1297 1186 'title' => '',
1298 1187 'body' => '',
1299 1188 'cancel_url' => '',
@@ -1315,294 +1204,79 @@
1315 1204 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php';
1316 1205 }
1317 1206
1318 1207 /**
1319 - * Handles Floating Links' scripts and styles enqueueing.
1208 + * @deprecated 3.0.04
1320 1209 *
1321 - * @since 6.4
1210 + * @codeCoverageIgnore
1322 1211 *
1323 - * @param string $plugin_url URL of the plugin.
1324 - * @param string $version Current version of the plugin.
1325 1212 * @return void
1326 1213 */
1327 - private static function enqueue_floating_links( $plugin_url, $version ) {
1328 - if ( ! $plugin_url || ! $version ) {
1329 - // If any required parameters are missing, exit early.
1330 - return;
1331 - }
1332 -
1333 - // Enqueue the Floating Links styles.
1334 - wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1335 -
1336 - // Enqueue the Floating Links script.
1337 - wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array( 'formidable_admin' ), $version, true );
1338 -
1339 - // Enqueue the config script.
1340 - wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1341 -
1342 - if ( function_exists( 'wp_set_script_translations' ) ) {
1343 - wp_set_script_translations( 's11-floating-links-config', 's11-' );
1344 - }
1345 -
1346 - $upgrade_utm = array(
1347 - 'campaign' => 'floating-links',
1348 - 'content' => 'floating-links-upgrade',
1349 - );
1350 - $docs_utm = array(
1351 - 'campaign' => 'floating-links',
1352 - 'content' => 'floating-links-docs',
1353 - );
1354 - $floating_links_data = array(
1355 - 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1356 - 'upgradeUrl' => FrmAppHelper::admin_upgrade_link( $upgrade_utm ),
1357 - 'documentationUrl' => FrmAppHelper::admin_upgrade_link( $docs_utm, 'knowledgebase/' ),
1358 - );
1359 - wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1360 -
1361 - /**
1362 - * Prompt Pro to load additional floating links scripts.
1363 - * This is used to include images in the Inbox SlideIn when Pro is active.
1364 - *
1365 - * @since 6.8.4
1366 - */
1367 - do_action( 'frm_enqueue_floating_links' );
1214 + public static function activation_install() {
1215 + FrmDeprecated::activation_install();
1368 1216 }
1369 1217
1370 1218 /**
1371 - * Check if we are in our admin pages.
1372 - *
1373 - * @return bool
1219 + * @deprecated 3.0
1220 + * @codeCoverageIgnore
1374 1221 */
1375 - private static function in_our_pages() {
1376 - global $current_screen, $pagenow;
1377 - if ( FrmAppHelper::is_formidable_admin() ) {
1378 - return true;
1379 - }
1380 -
1381 - if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) {
1382 - return true;
1383 - }
1384 -
1385 - if ( in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' ) ) {
1386 - return true;
1387 - }
1388 -
1389 - return false;
1222 + public static function page_route( $content ) {
1223 + return FrmDeprecated::page_route( $content );
1390 1224 }
1391 1225
1392 1226 /**
1393 - * Handles actions related to the current screen.
1227 + * Include icons on page for Embed Form modal.
1394 1228 *
1395 - * @since 6.19
1229 + * @since 5.2
1396 1230 *
1397 1231 * @return void
1398 1232 */
1399 - public static function handle_current_screen() {
1400 - if ( ! self::in_our_pages() ) {
1401 - return;
1402 - }
1403 -
1404 - self::filter_admin_notices();
1405 - self::remember_custom_sort();
1233 + public static function include_embed_form_icons() {
1234 + _deprecated_function( __METHOD__, '5.3' );
1406 1235 }
1407 1236
1408 1237 /**
1409 - * Hide all third-parties admin notices only in our admin pages.
1238 + * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13.
1239 + * @codeCoverageIgnore
1410 1240 *
1411 - * @return void
1241 + * @param array $atts
1242 + * @return string
1412 1243 */
1413 - public static function filter_admin_notices() {
1414 - $actions = array(
1415 - 'admin_notices',
1416 - 'network_admin_notices',
1417 - 'user_admin_notices',
1418 - 'all_admin_notices',
1419 - );
1420 -
1421 - global $wp_filter;
1422 -
1423 - foreach ( $actions as $action ) {
1424 - if ( empty( $wp_filter[ $action ]->callbacks ) ) {
1425 - continue;
1426 - }
1427 - foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) {
1428 - foreach ( $callbacks as $callback_name => $callback ) {
1429 - if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) {
1430 - continue;
1431 - }
1432 - unset( $wp_filter[ $action ]->callbacks[ $priority ][ $callback_name ] );
1433 - }
1434 - }
1435 - }
1244 + public static function get_form_shortcode( $atts ) {
1245 + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1246 + return FrmFormsController::get_form_shortcode( $atts );
1436 1247 }
1437 1248
1438 1249 /**
1439 - * Remembers and applies user-specific sorting preferences.
1250 + * Handles Floating Links' scripts and styles enqueueing.
1440 1251 *
1441 - * @return void
1442 - */
1443 - private static function remember_custom_sort() {
1444 - $meta_key = self::get_sort_pref_user_meta_key();
1445 - if ( false === $meta_key ) {
1446 - return;
1447 - }
1448 -
1449 - $is_form_list = FrmAppHelper::is_admin_list_page();
1450 - $is_entry_list = FrmAppHelper::is_admin_list_page( 'formidable-entries' );
1451 - if ( ! $is_form_list && ! $is_entry_list ) {
1452 - return;
1453 - }
1454 -
1455 - $orderby = FrmAppHelper::get_param( 'orderby' );
1456 - if ( ! $orderby ) {
1457 - return;
1458 - }
1459 -
1460 - $user_id = get_current_user_id();
1461 - $order = FrmAppHelper::get_param( 'order' );
1462 - $new_sort = array(
1463 - 'orderby' => $orderby,
1464 - 'order' => $order,
1465 - );
1466 - $previous_meta = get_user_meta( $user_id, $meta_key, true );
1467 - $current_sort = $previous_meta;
1468 - $form_id = $is_entry_list ? FrmAppHelper::simple_get( 'form', 'absint' ) : 0;
1469 -
1470 - if ( is_array( $current_sort ) && $form_id && is_int( $form_id ) && isset( $current_sort[ $form_id ] ) ) {
1471 - $current_sort = $current_sort[ $form_id ];
1472 - }
1473 -
1474 - if ( $new_sort !== $current_sort ) {
1475 - $new_meta = $new_sort;
1476 -
1477 - if ( $is_entry_list && $form_id && is_int( $form_id ) ) {
1478 - // Index meta by form ID.
1479 - $temp_meta = is_array( $previous_meta ) ? $previous_meta : array();
1480 - $temp_meta[ $form_id ] = $new_meta;
1481 - $new_meta = $temp_meta;
1482 - unset( $temp_meta );
1483 - }
1484 -
1485 - update_user_meta( $user_id, $meta_key, $new_meta );
1486 - }
1487 - }
1488 -
1489 - /**
1490 - * Retrieve and apply any saved sorting preferences for the current screen.
1252 + * @since 6.4
1491 1253 *
1492 - * @since 6.19
1493 - *
1494 - * @param string &$orderby Reference to the current 'orderby' parameter.
1495 - * @param string &$order Reference to the current 'order' parameter.
1254 + * @param string $plugin_url URL of the plugin.
1255 + * @param string $version Current version of the plugin.
1496 1256 * @return void
1497 1257 */
1498 - public static function apply_saved_sort_preference( &$orderby, &$order ) {
1499 - $meta_key = self::get_sort_pref_user_meta_key();
1500 - if ( false === $meta_key ) {
1258 + private static function enqueue_floating_links( $plugin_url, $version ) {
1259 + if ( ! $plugin_url || ! $version ) {
1260 + // If any required parameters are missing, exit early.
1501 1261 return;
1502 1262 }
1503 1263
1504 - $user_id = get_current_user_id();
1505 - $preferred_list_sort = get_user_meta( $user_id, $meta_key, true );
1506 - $form_id = FrmAppHelper::simple_get( 'form', 'absint' );
1264 + // Enqueue the Floating Links styles.
1265 + wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1507 1266
1508 - if ( is_array( $preferred_list_sort ) && $form_id && is_int( $form_id ) && isset( $preferred_list_sort[ $form_id ] ) ) {
1509 - $preferred_list_sort = $preferred_list_sort[ $form_id ];
1510 - }
1267 + // Enqueue the Floating Links script.
1268 + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1511 1269
1512 - if ( is_array( $preferred_list_sort ) && ! empty( $preferred_list_sort['orderby'] ) ) {
1513 - $orderby = $preferred_list_sort['orderby'];
1270 + // Enqueue the config script.
1271 + wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1514 1272
1515 - if ( ! empty( $preferred_list_sort['order'] ) ) {
1516 - $order = $preferred_list_sort['order'];
1517 - }
1273 + if ( function_exists( 'wp_set_script_translations' ) ) {
1274 + wp_set_script_translations( 's11-floating-links-config', 's11-' );
1518 1275 }
1519 - }
1520 1276
1521 - /**
1522 - * Get a simple user meta key that only includes the screen ID.
1523 - *
1524 - * @since 6.25.1
1525 - *
1526 - * @return false|string
1527 - */
1528 - private static function get_sort_pref_user_meta_key() {
1529 - if ( ! function_exists( 'get_current_screen' ) ) {
1530 - return false;
1531 - }
1532 -
1533 - $screen = get_current_screen();
1534 - return $screen ? 'frm_preferred_list_sort_' . $screen->id : false;
1535 - }
1536 -
1537 - /**
1538 - * Validate that the callback name is ours not from third-party.
1539 - *
1540 - * @param string $callback_name WordPress callback name.
1541 - *
1542 - * @return bool
1543 - */
1544 - private static function is_our_callback_string( $callback_name ) {
1545 - return 0 === stripos( $callback_name, 'frm' );
1546 - }
1547 -
1548 - /**
1549 - * Validate that the callback array is ours not from third-party.
1550 - *
1551 - * @param array $callback WordPress callback array.
1552 - *
1553 - * @return bool
1554 - */
1555 - private static function is_our_callback_array( $callback ) {
1556 - return ! empty( $callback['function'] ) &&
1557 - is_array( $callback['function'] ) &&
1558 - ! empty( $callback['function'][0] ) &&
1559 - self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] );
1560 - }
1561 -
1562 - /**
1563 - * In some cases, the DB tables may fail to install.
1564 - * This function tries to add them again when the user clicks the link to try again
1565 - * from the given inbox notice.
1566 - *
1567 - * @since 6.19
1568 - */
1569 - private static function add_missing_tables() {
1570 - FrmAppHelper::permission_check( 'frm_view_forms' );
1571 -
1572 - $inbox = new FrmInbox();
1573 - $error = $inbox->check_for_error();
1574 -
1575 - if ( ! $error || 'failed-to-create-tables' !== $error['key'] ) {
1576 - // Confirm the inbox item with this CTA exists.
1577 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1578 - exit;
1579 - }
1580 -
1581 - global $wpdb;
1582 - $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->prefix . 'frm_forms' ) );
1583 -
1584 - if ( $exists ) {
1585 - // Exit early if the table already exists.
1586 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1587 - exit;
1588 - }
1589 -
1590 - delete_option( 'frm_db_version' );
1591 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1592 - exit;
1593 - }
1594 -
1595 - /**
1596 - * Handles the small screen proceed action.
1597 - *
1598 - * @since 6.21
1599 - *
1600 - * @return void
1601 - */
1602 - public static function small_screen_proceed() {
1603 - FrmAppHelper::permission_check( 'frm_view_forms' );
1604 - check_ajax_referer( 'frm_ajax', 'nonce' );
1605 - update_user_option( get_current_user_id(), 'frm_ignore_small_screen_warning', true );
1606 - wp_send_json_success();
1277 + $floating_links_data = array(
1278 + 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1279 + );
1280 + wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1607 1281 }
1608 1282 }