| @@ -66,9 +66,11 @@ | ||
| 66 | 66 | $full_screen_on = self::get_full_screen_setting(); |
| 67 | 67 | $add_class = ''; |
| 68 | 68 | if ( $full_screen_on ) { |
| 69 | 69 | $add_class = ' frm-full-screen is-fullscreen-mode'; |
| 70 | - wp_enqueue_style( 'wp-edit-post' ); // Load the CSS for .is-fullscreen-mode. | |
| 70 | + | |
| 71 | + // Load the CSS for .is-fullscreen-mode. | |
| 72 | + wp_enqueue_style( 'wp-edit-post' ); | |
| 71 | 73 | } |
| 72 | 74 | $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class ); |
| 73 | 75 | } |
| 74 | 76 | |
| @@ -75,8 +77,12 @@ | ||
| 75 | 77 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 76 | 78 | $classes .= ' frm-lite '; |
| 77 | 79 | } |
| 78 | 80 | |
| 81 | + if ( get_user_setting( 'unfold' ) && 'f' !== get_user_setting( 'mfold' ) ) { | |
| 82 | + $classes .= ' frm-unfold '; | |
| 83 | + } | |
| 84 | + | |
| 79 | 85 | return $classes; |
| 80 | 86 | } |
| 81 | 87 | |
| 82 | 88 | /** |
| @@ -133,14 +139,20 @@ | ||
| 133 | 139 | 'formidable-styles2', |
| 134 | 140 | 'formidable-inbox', |
| 135 | 141 | 'formidable-welcome', |
| 136 | 142 | 'formidable-applications', |
| 143 | + FrmFormTemplatesController::PAGE_SLUG, | |
| 137 | 144 | ); |
| 138 | 145 | |
| 139 | - if ( ! class_exists( 'FrmTransHooksController', false ) ) { | |
| 146 | + if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) { | |
| 140 | 147 | // Only consider the payments page as a "white page" when the Payments submodule is off. |
| 141 | 148 | // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active. |
| 142 | - $white_pages[] = 'formidable-payments'; | |
| 149 | + | |
| 150 | + // Add an extra check to avoid white page styling on the PayPal "edit" action. | |
| 151 | + // We fallback to the PayPal add on for the "edit" action since Stripe Lite does not have an edit view. | |
| 152 | + if ( ! in_array( FrmAppHelper::simple_get( 'action' ), array( 'edit', 'new' ), true ) || ! is_callable( 'FrmPaymentsController::route' ) ) { | |
| 153 | + $white_pages[] = 'formidable-payments'; | |
| 154 | + } | |
| 143 | 155 | } |
| 144 | 156 | |
| 145 | 157 | $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 146 | 158 | $is_white_page = in_array( $get_page, $white_pages, true ); |
| @@ -169,10 +181,11 @@ | ||
| 169 | 181 | FrmAppHelper::load_font_style(); |
| 170 | 182 | } |
| 171 | 183 | |
| 172 | 184 | /** |
| 173 | - * @param bool $show_nav | |
| 174 | - * @param string $title | |
| 185 | + * @param int|object $form | |
| 186 | + * @param bool $show_nav | |
| 187 | + * @param string $title | |
| 175 | 188 | * |
| 176 | 189 | * @psalm-param 'hide'|'show' $title |
| 177 | 190 | * |
| 178 | 191 | * @return void |
| @@ -292,9 +305,10 @@ | ||
| 292 | 305 | public static function settings_link( $links ) { |
| 293 | 306 | $settings = array(); |
| 294 | 307 | |
| 295 | 308 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 296 | - $settings[] = '<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-row' ) ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html__( 'Upgrade to Pro', 'formidable' ) . '</b></a>'; | |
| 309 | + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' ); | |
| 310 | + $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>'; | |
| 297 | 311 | } |
| 298 | 312 | |
| 299 | 313 | $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>'; |
| 300 | 314 | |
| @@ -374,63 +388,26 @@ | ||
| 374 | 388 | $shared_path = $plugin_path . '/classes/views/shared/'; |
| 375 | 389 | |
| 376 | 390 | include $shared_path . 'upgrade_overlay.php'; |
| 377 | 391 | include $shared_path . 'confirm-overlay.php'; |
| 378 | - | |
| 379 | - if ( FrmAppHelper::is_admin_page( 'formidable-welcome' ) || FrmAppHelper::on_form_listing_page() ) { | |
| 380 | - self::new_form_overlay_html(); | |
| 381 | - } | |
| 382 | 392 | } |
| 383 | 393 | |
| 384 | 394 | /** |
| 395 | + * Create a basic form with an email field. | |
| 396 | + * | |
| 397 | + * @param string $form_key | |
| 398 | + * @param string $title | |
| 399 | + * @param string $description | |
| 385 | 400 | * @return void |
| 386 | 401 | */ |
| 387 | - private static function new_form_overlay_html() { | |
| 388 | - FrmFormsController::before_list_templates(); | |
| 389 | - | |
| 390 | - $plugin_path = FrmAppHelper::plugin_path(); | |
| 391 | - $path = $plugin_path . '/classes/views/frm-forms/'; | |
| 392 | - $expired = FrmFormsController::expired(); | |
| 393 | - $expiring = FrmAddonsController::is_license_expiring(); | |
| 394 | - $user = wp_get_current_user(); // $user used in leave-email.php to determine a default value for field | |
| 395 | - $view_path = $path . 'new-form-overlay/'; | |
| 396 | - $modal_class = ''; | |
| 397 | - $upgrade_link = FrmAppHelper::admin_upgrade_link( | |
| 398 | - array( | |
| 399 | - 'medium' => 'new-template', | |
| 400 | - 'content' => 'upgrade', | |
| 401 | - ) | |
| 402 | + public static function api_email_form( $form_key, $title, $description ) { | |
| 403 | + $user = wp_get_current_user(); | |
| 404 | + $args = array( | |
| 405 | + 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css', | |
| 406 | + 'title' => $title, | |
| 407 | + 'description' => $description, | |
| 402 | 408 | ); |
| 403 | - $renew_link = FrmAppHelper::admin_upgrade_link( | |
| 404 | - array( | |
| 405 | - 'medium' => 'new-template', | |
| 406 | - 'content' => 'renew', | |
| 407 | - ) | |
| 408 | - ); | |
| 409 | - $blocks_to_render = array(); | |
| 410 | - | |
| 411 | - if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 412 | - // avoid rendering the email and code blocks for users who have upgraded or have a free license already | |
| 413 | - $api = new FrmFormTemplateApi(); | |
| 414 | - if ( ! $api->has_free_access() ) { | |
| 415 | - array_push( $blocks_to_render, 'email', 'code' ); | |
| 416 | - } | |
| 417 | - } | |
| 418 | - | |
| 419 | - // avoid rendering the upgrade block for users with elite | |
| 420 | - if ( 'elite' !== FrmAddonsController::license_type() ) { | |
| 421 | - $blocks_to_render[] = 'upgrade'; | |
| 422 | - } | |
| 423 | - | |
| 424 | - // avoid rendering the renew block for users who are not currently expired | |
| 425 | - if ( $expired ) { | |
| 426 | - $blocks_to_render[] = 'renew'; | |
| 427 | - $modal_class = 'frm-expired'; | |
| 428 | - } elseif ( $expiring ) { | |
| 429 | - $modal_class = 'frm-expiring'; | |
| 430 | - } | |
| 431 | - | |
| 432 | - include $path . 'new-form-overlay.php'; | |
| 409 | + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php'; | |
| 433 | 410 | } |
| 434 | 411 | |
| 435 | 412 | /** |
| 436 | 413 | * @return void |
| @@ -527,8 +504,12 @@ | ||
| 527 | 504 | * |
| 528 | 505 | * @return void |
| 529 | 506 | */ |
| 530 | 507 | public static function admin_init() { |
| 508 | + if ( FrmAppHelper::get_param( 'delete_all' ) && FrmAppHelper::is_admin_page( 'formidable' ) && 'trash' === FrmAppHelper::get_param( 'form_type' ) ) { | |
| 509 | + FrmFormsController::delete_all(); | |
| 510 | + } | |
| 511 | + | |
| 531 | 512 | if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) { |
| 532 | 513 | FrmFormsController::duplicate(); |
| 533 | 514 | } |
| 534 | 515 | |
| @@ -536,9 +517,10 @@ | ||
| 536 | 517 | // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent. |
| 537 | 518 | FrmStylesController::save_style(); |
| 538 | 519 | } |
| 539 | 520 | |
| 540 | - new FrmPersonalData(); // register personal data hooks | |
| 521 | + // Register personal data hooks. | |
| 522 | + new FrmPersonalData(); | |
| 541 | 523 | |
| 542 | 524 | if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) { |
| 543 | 525 | self::network_upgrade_site(); |
| 544 | 526 | } |
| @@ -548,12 +530,17 @@ | ||
| 548 | 530 | self::admin_js(); |
| 549 | 531 | } |
| 550 | 532 | |
| 551 | 533 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 534 | + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions. | |
| 535 | + // This provides backward compatibility for old addons that use legacy modal templates. | |
| 552 | 536 | $action = FrmAppHelper::get_param( 'frm_action' ); |
| 537 | + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' ); | |
| 538 | + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { | |
| 539 | + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' ); | |
| 540 | + $url_param = $application_id ? '&applicationId=' . $application_id : ''; | |
| 553 | 541 | |
| 554 | - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { | |
| 555 | - wp_safe_redirect( admin_url( 'admin.php?page=formidable&triggerNewFormModal=1' ) ); | |
| 542 | + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) ); | |
| 556 | 543 | exit; |
| 557 | 544 | } |
| 558 | 545 | |
| 559 | 546 | FrmInbox::maybe_disable_screen_options(); |
| @@ -629,8 +616,14 @@ | ||
| 629 | 616 | $version = FrmAppHelper::plugin_version(); |
| 630 | 617 | |
| 631 | 618 | FrmAppHelper::load_admin_wide_js(); |
| 632 | 619 | |
| 620 | + if ( class_exists( 'FrmOverlayController' ) ) { | |
| 621 | + // This should always exist. | |
| 622 | + // But it may not have loaded properly when updating the plugin. | |
| 623 | + FrmOverlayController::register_assets(); | |
| 624 | + } | |
| 625 | + | |
| 633 | 626 | wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version ); |
| 634 | 627 | wp_enqueue_style( 'formidable_admin_global' ); |
| 635 | 628 | |
| 636 | 629 | wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version ); |
| @@ -668,9 +661,10 @@ | ||
| 668 | 661 | 'jquery-ui-sortable', |
| 669 | 662 | 'bootstrap_tooltip', |
| 670 | 663 | 'bootstrap-multiselect', |
| 671 | 664 | 'wp-i18n', |
| 672 | - 'wp-hooks', // Required in WP versions older than 5.7 | |
| 665 | + // Required in WP versions older than 5.7 | |
| 666 | + 'wp-hooks', | |
| 673 | 667 | 'formidable_dom', |
| 674 | 668 | 'formidable_embed', |
| 675 | 669 | ); |
| 676 | 670 | |
| @@ -687,8 +681,19 @@ | ||
| 687 | 681 | } |
| 688 | 682 | |
| 689 | 683 | wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true ); |
| 690 | 684 | |
| 685 | + if ( ! class_exists( 'FrmTransHooksController', false ) ) { | |
| 686 | + /** | |
| 687 | + * Gateway fields are included for add-on compatibility but we do not want it to be visible. | |
| 688 | + * They do however need to be visible when the payments submodule is active. | |
| 689 | + */ | |
| 690 | + wp_add_inline_style( | |
| 691 | + 'formidable-admin', | |
| 692 | + '#frm_builder_page li[data-ftype="gateway"] { display: none; }' | |
| 693 | + ); | |
| 694 | + } | |
| 695 | + | |
| 691 | 696 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 692 | 697 | |
| 693 | 698 | global $pagenow; |
| 694 | 699 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) { |
| @@ -710,8 +715,12 @@ | ||
| 710 | 715 | |
| 711 | 716 | if ( 'formidable-entries' === $page ) { |
| 712 | 717 | // Load front end js for entries. |
| 713 | 718 | wp_enqueue_script( 'formidable' ); |
| 719 | + | |
| 720 | + // Registers and enqueues the entries page scripts. | |
| 721 | + wp_register_script( 'formidable_entries', $plugin_url . '/js/admin/entries.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true ); | |
| 722 | + wp_enqueue_script( 'formidable_entries' ); | |
| 714 | 723 | } |
| 715 | 724 | |
| 716 | 725 | do_action( 'frm_enqueue_builder_scripts' ); |
| 717 | 726 | self::include_upgrade_overlay(); |
| @@ -731,9 +740,9 @@ | ||
| 731 | 740 | |
| 732 | 741 | if ( $post_type === 'frm_display' ) { |
| 733 | 742 | self::enqueue_legacy_views_assets(); |
| 734 | 743 | } |
| 735 | - } | |
| 744 | + }//end if | |
| 736 | 745 | |
| 737 | 746 | } |
| 738 | 747 | |
| 739 | 748 | /** |
| @@ -1001,9 +1010,9 @@ | ||
| 1001 | 1010 | |
| 1002 | 1011 | $frmdb = new FrmMigrate(); |
| 1003 | 1012 | $frmdb->uninstall(); |
| 1004 | 1013 | |
| 1005 | - //disable the plugin and redirect after uninstall so the tables don't get added right back | |
| 1014 | + // Disable the plugin and redirect after uninstall so the tables don't get added right back. | |
| 1006 | 1015 | $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' ); |
| 1007 | 1016 | deactivate_plugins( $plugins, false, false ); |
| 1008 | 1017 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 1009 | 1018 | |
| @@ -1074,21 +1083,69 @@ | ||
| 1074 | 1083 | * |
| 1075 | 1084 | * @return void |
| 1076 | 1085 | */ |
| 1077 | 1086 | public static function add_admin_footer_links() { |
| 1078 | - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); | |
| 1087 | + if ( self::should_show_footer_links() ) { | |
| 1088 | + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php'; | |
| 1089 | + } | |
| 1090 | + } | |
| 1079 | 1091 | |
| 1080 | - // Check admin privileges, screen mode, and branding | |
| 1081 | - $is_not_admin = ! FrmAppHelper::is_formidable_admin() && $post_type !== 'frm_logs'; | |
| 1082 | - $is_full_screen = FrmAppHelper::is_full_screen(); | |
| 1083 | - $is_not_formidable_branding = ! FrmAppHelper::is_formidable_branding(); | |
| 1092 | + /** | |
| 1093 | + * Check if the footer links should be shown. | |
| 1094 | + * | |
| 1095 | + * @since 6.7 | |
| 1096 | + * | |
| 1097 | + * @return bool | |
| 1098 | + */ | |
| 1099 | + private static function should_show_footer_links() { | |
| 1100 | + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); | |
| 1101 | + $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type; | |
| 1102 | + $show_footer_links = $is_formidable_page; | |
| 1103 | + if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) { | |
| 1104 | + $show_footer_links = false; | |
| 1105 | + } | |
| 1084 | 1106 | |
| 1085 | - // Exit if any of the above conditions are met | |
| 1086 | - if ( $is_not_admin || $is_full_screen || $is_not_formidable_branding ) { | |
| 1087 | - return; | |
| 1107 | + /** | |
| 1108 | + * Filter whether to show the Formidable footer links. | |
| 1109 | + * | |
| 1110 | + * @since 6.7 | |
| 1111 | + * | |
| 1112 | + * @param bool $show_footer_links | |
| 1113 | + * @return bool | |
| 1114 | + */ | |
| 1115 | + return apply_filters( 'frm_show_footer_links', $show_footer_links ); | |
| 1116 | + } | |
| 1117 | + | |
| 1118 | + /** | |
| 1119 | + * Show an error modal and terminate the script execution. | |
| 1120 | + * | |
| 1121 | + * @since 6.7 | |
| 1122 | + * | |
| 1123 | + * @param array $error_args Arguments that control the behavior of the error modal. | |
| 1124 | + * | |
| 1125 | + * @return void | |
| 1126 | + */ | |
| 1127 | + public static function show_error_modal( $error_args ) { | |
| 1128 | + $defaults = array( | |
| 1129 | + 'title' => '', | |
| 1130 | + 'body' => '', | |
| 1131 | + 'cancel_url' => '', | |
| 1132 | + 'cancel_classes' => '', | |
| 1133 | + 'continue_url' => '', | |
| 1134 | + 'continue_classes' => '', | |
| 1135 | + 'icon' => 'frm_lock_simple', | |
| 1136 | + ); | |
| 1137 | + | |
| 1138 | + $error_args = wp_parse_args( $error_args, $defaults ); | |
| 1139 | + if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) { | |
| 1140 | + $error_args['cancel_text'] = __( 'Cancel', 'formidable' ); | |
| 1088 | 1141 | } |
| 1089 | 1142 | |
| 1090 | - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php'; | |
| 1143 | + if ( ! isset( $error_args['continue_text'] ) && ! empty( $error_args['continue_url'] ) ) { | |
| 1144 | + $error_args['continue_text'] = __( 'Continue', 'formidable' ); | |
| 1145 | + } | |
| 1146 | + | |
| 1147 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php'; | |
| 1091 | 1148 | } |
| 1092 | 1149 | |
| 1093 | 1150 | /** |
| 1094 | 1151 | * @deprecated 3.0.04 |
| @@ -1154,9 +1211,13 @@ | ||
| 1154 | 1211 | wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true ); |
| 1155 | 1212 | |
| 1156 | 1213 | // Enqueue the config script. |
| 1157 | 1214 | wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true ); |
| 1158 | - wp_set_script_translations( 's11-floating-links-config', 's11-' ); | |
| 1215 | + | |
| 1216 | + if ( function_exists( 'wp_set_script_translations' ) ) { | |
| 1217 | + wp_set_script_translations( 's11-floating-links-config', 's11-' ); | |
| 1218 | + } | |
| 1219 | + | |
| 1159 | 1220 | $floating_links_data = array( |
| 1160 | 1221 | 'proIsInstalled' => FrmAppHelper::pro_is_installed(), |
| 1161 | 1222 | ); |
| 1162 | 1223 | wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data ); |