| @@ -75,8 +75,12 @@ | ||
| 75 | 75 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 76 | 76 | $classes .= ' frm-lite '; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | + if ( get_user_setting( 'unfold' ) && 'f' !== get_user_setting( 'mfold' ) ) { | |
| 80 | + $classes .= ' frm-unfold '; | |
| 81 | + } | |
| 82 | + | |
| 79 | 83 | return $classes; |
| 80 | 84 | } |
| 81 | 85 | |
| 82 | 86 | /** |
| @@ -133,14 +137,20 @@ | ||
| 133 | 137 | 'formidable-styles2', |
| 134 | 138 | 'formidable-inbox', |
| 135 | 139 | 'formidable-welcome', |
| 136 | 140 | 'formidable-applications', |
| 141 | + FrmFormTemplatesController::PAGE_SLUG, | |
| 137 | 142 | ); |
| 138 | 143 | |
| 139 | - if ( ! class_exists( 'FrmTransHooksController', false ) ) { | |
| 144 | + if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) { | |
| 140 | 145 | // Only consider the payments page as a "white page" when the Payments submodule is off. |
| 141 | 146 | // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active. |
| 142 | - $white_pages[] = 'formidable-payments'; | |
| 147 | + | |
| 148 | + // Add an extra check to avoid white page styling on the PayPal "edit" action. | |
| 149 | + // We fallback to the PayPal add on for the "edit" action since Stripe Lite does not have an edit view. | |
| 150 | + if ( ! in_array( FrmAppHelper::simple_get( 'action' ), array( 'edit', 'new' ), true ) || ! is_callable( 'FrmPaymentsController::route' ) ) { | |
| 151 | + $white_pages[] = 'formidable-payments'; | |
| 152 | + } | |
| 143 | 153 | } |
| 144 | 154 | |
| 145 | 155 | $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 146 | 156 | $is_white_page = in_array( $get_page, $white_pages, true ); |
| @@ -375,66 +385,11 @@ | ||
| 375 | 385 | $shared_path = $plugin_path . '/classes/views/shared/'; |
| 376 | 386 | |
| 377 | 387 | include $shared_path . 'upgrade_overlay.php'; |
| 378 | 388 | include $shared_path . 'confirm-overlay.php'; |
| 379 | - | |
| 380 | - if ( FrmAppHelper::is_admin_page( 'formidable-welcome' ) || FrmAppHelper::on_form_listing_page() ) { | |
| 381 | - self::new_form_overlay_html(); | |
| 382 | - } | |
| 383 | 389 | } |
| 384 | 390 | |
| 385 | 391 | /** |
| 386 | - * @return void | |
| 387 | - */ | |
| 388 | - private static function new_form_overlay_html() { | |
| 389 | - FrmFormsController::before_list_templates(); | |
| 390 | - | |
| 391 | - $plugin_path = FrmAppHelper::plugin_path(); | |
| 392 | - $path = $plugin_path . '/classes/views/frm-forms/'; | |
| 393 | - $expired = FrmFormsController::expired(); | |
| 394 | - $expiring = FrmAddonsController::is_license_expiring(); | |
| 395 | - $user = wp_get_current_user(); // $user used in leave-email.php to determine a default value for field | |
| 396 | - $view_path = $path . 'new-form-overlay/'; | |
| 397 | - $modal_class = ''; | |
| 398 | - $upgrade_link = FrmAppHelper::admin_upgrade_link( | |
| 399 | - array( | |
| 400 | - 'medium' => 'new-template', | |
| 401 | - 'content' => 'upgrade', | |
| 402 | - ) | |
| 403 | - ); | |
| 404 | - $renew_link = FrmAppHelper::admin_upgrade_link( | |
| 405 | - array( | |
| 406 | - 'medium' => 'new-template', | |
| 407 | - 'content' => 'renew', | |
| 408 | - ) | |
| 409 | - ); | |
| 410 | - $blocks_to_render = array(); | |
| 411 | - | |
| 412 | - if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 413 | - // avoid rendering the email and code blocks for users who have upgraded or have a free license already | |
| 414 | - $api = new FrmFormTemplateApi(); | |
| 415 | - if ( ! $api->has_free_access() ) { | |
| 416 | - array_push( $blocks_to_render, 'email', 'code' ); | |
| 417 | - } | |
| 418 | - } | |
| 419 | - | |
| 420 | - // avoid rendering the upgrade block for users with elite | |
| 421 | - if ( 'elite' !== FrmAddonsController::license_type() ) { | |
| 422 | - $blocks_to_render[] = 'upgrade'; | |
| 423 | - } | |
| 424 | - | |
| 425 | - // avoid rendering the renew block for users who are not currently expired | |
| 426 | - if ( $expired ) { | |
| 427 | - $blocks_to_render[] = 'renew'; | |
| 428 | - $modal_class = 'frm-expired'; | |
| 429 | - } elseif ( $expiring ) { | |
| 430 | - $modal_class = 'frm-expiring'; | |
| 431 | - } | |
| 432 | - | |
| 433 | - include $path . 'new-form-overlay.php'; | |
| 434 | - } | |
| 435 | - | |
| 436 | - /** | |
| 437 | 392 | * Create a basic form with an email field. |
| 438 | 393 | * |
| 439 | 394 | * @param string $form_key |
| 440 | 395 | * @param string $title |
| @@ -441,12 +396,15 @@ | ||
| 441 | 396 | * @param string $description |
| 442 | 397 | * @return void |
| 443 | 398 | */ |
| 444 | 399 | public static function api_email_form( $form_key, $title, $description ) { |
| 445 | - $url = 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css'; | |
| 446 | - $view_path = FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new-form-overlay/'; | |
| 447 | 400 | $user = wp_get_current_user(); |
| 448 | - require $view_path . 'leave-email.php'; | |
| 401 | + $args = array( | |
| 402 | + 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css', | |
| 403 | + 'title' => $title, | |
| 404 | + 'description' => $description, | |
| 405 | + ); | |
| 406 | + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php'; | |
| 449 | 407 | } |
| 450 | 408 | |
| 451 | 409 | /** |
| 452 | 410 | * @return void |
| @@ -564,12 +522,17 @@ | ||
| 564 | 522 | self::admin_js(); |
| 565 | 523 | } |
| 566 | 524 | |
| 567 | 525 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 526 | + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions. | |
| 527 | + // This provides backward compatibility for old addons that use legacy modal templates. | |
| 568 | 528 | $action = FrmAppHelper::get_param( 'frm_action' ); |
| 529 | + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' ); | |
| 530 | + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { | |
| 531 | + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' ); | |
| 532 | + $url_param = $application_id ? '&applicationId=' . $application_id : ''; | |
| 569 | 533 | |
| 570 | - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { | |
| 571 | - wp_safe_redirect( admin_url( 'admin.php?page=formidable&triggerNewFormModal=1' ) ); | |
| 534 | + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) ); | |
| 572 | 535 | exit; |
| 573 | 536 | } |
| 574 | 537 | |
| 575 | 538 | FrmInbox::maybe_disable_screen_options(); |
| @@ -644,10 +607,15 @@ | ||
| 644 | 607 | $plugin_url = FrmAppHelper::plugin_url(); |
| 645 | 608 | $version = FrmAppHelper::plugin_version(); |
| 646 | 609 | |
| 647 | 610 | FrmAppHelper::load_admin_wide_js(); |
| 648 | - FrmOverlayController::register_assets(); | |
| 649 | 611 | |
| 612 | + if ( class_exists( 'FrmOverlayController' ) ) { | |
| 613 | + // This should always exist. | |
| 614 | + // But it may not have loaded properly when updating the plugin. | |
| 615 | + FrmOverlayController::register_assets(); | |
| 616 | + } | |
| 617 | + | |
| 650 | 618 | wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version ); |
| 651 | 619 | wp_enqueue_style( 'formidable_admin_global' ); |
| 652 | 620 | |
| 653 | 621 | wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version ); |
| @@ -738,8 +706,12 @@ | ||
| 738 | 706 | |
| 739 | 707 | if ( 'formidable-entries' === $page ) { |
| 740 | 708 | // Load front end js for entries. |
| 741 | 709 | wp_enqueue_script( 'formidable' ); |
| 710 | + | |
| 711 | + // Registers and enqueues the entries page scripts. | |
| 712 | + wp_register_script( 'formidable_entries', $plugin_url . '/js/admin/entries.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true ); | |
| 713 | + wp_enqueue_script( 'formidable_entries' ); | |
| 742 | 714 | } |
| 743 | 715 | |
| 744 | 716 | do_action( 'frm_enqueue_builder_scripts' ); |
| 745 | 717 | self::include_upgrade_overlay(); |
| @@ -1102,21 +1074,69 @@ | ||
| 1102 | 1074 | * |
| 1103 | 1075 | * @return void |
| 1104 | 1076 | */ |
| 1105 | 1077 | public static function add_admin_footer_links() { |
| 1106 | - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); | |
| 1078 | + if ( self::should_show_footer_links() ) { | |
| 1079 | + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php'; | |
| 1080 | + } | |
| 1081 | + } | |
| 1107 | 1082 | |
| 1108 | - // Check admin privileges, screen mode, and branding | |
| 1109 | - $is_not_admin = ! FrmAppHelper::is_formidable_admin() && $post_type !== 'frm_logs'; | |
| 1110 | - $is_full_screen = FrmAppHelper::is_full_screen(); | |
| 1111 | - $is_not_formidable_branding = ! FrmAppHelper::is_formidable_branding(); | |
| 1083 | + /** | |
| 1084 | + * Check if the footer links should be shown. | |
| 1085 | + * | |
| 1086 | + * @since 6.7 | |
| 1087 | + * | |
| 1088 | + * @return bool | |
| 1089 | + */ | |
| 1090 | + private static function should_show_footer_links() { | |
| 1091 | + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); | |
| 1092 | + $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type; | |
| 1093 | + $show_footer_links = $is_formidable_page; | |
| 1094 | + if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) { | |
| 1095 | + $show_footer_links = false; | |
| 1096 | + } | |
| 1112 | 1097 | |
| 1113 | - // Exit if any of the above conditions are met | |
| 1114 | - if ( $is_not_admin || $is_full_screen || $is_not_formidable_branding ) { | |
| 1115 | - return; | |
| 1098 | + /** | |
| 1099 | + * Filter whether to show the Formidable footer links. | |
| 1100 | + * | |
| 1101 | + * @since 6.7 | |
| 1102 | + * | |
| 1103 | + * @param bool $show_footer_links | |
| 1104 | + * @return bool | |
| 1105 | + */ | |
| 1106 | + return apply_filters( 'frm_show_footer_links', $show_footer_links ); | |
| 1107 | + } | |
| 1108 | + | |
| 1109 | + /** | |
| 1110 | + * Show an error modal and terminate the script execution. | |
| 1111 | + * | |
| 1112 | + * @since 6.7 | |
| 1113 | + * | |
| 1114 | + * @param array $error_args Arguments that control the behavior of the error modal. | |
| 1115 | + * | |
| 1116 | + * @return void | |
| 1117 | + */ | |
| 1118 | + public static function show_error_modal( $error_args ) { | |
| 1119 | + $defaults = array( | |
| 1120 | + 'title' => '', | |
| 1121 | + 'body' => '', | |
| 1122 | + 'cancel_url' => '', | |
| 1123 | + 'cancel_classes' => '', | |
| 1124 | + 'continue_url' => '', | |
| 1125 | + 'continue_classes' => '', | |
| 1126 | + 'icon' => 'frm_lock_simple', | |
| 1127 | + ); | |
| 1128 | + | |
| 1129 | + $error_args = wp_parse_args( $error_args, $defaults ); | |
| 1130 | + if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) { | |
| 1131 | + $error_args['cancel_text'] = __( 'Cancel', 'formidable' ); | |
| 1116 | 1132 | } |
| 1117 | 1133 | |
| 1118 | - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php'; | |
| 1134 | + if ( ! isset( $error_args['continue_text'] ) && ! empty( $error_args['continue_url'] ) ) { | |
| 1135 | + $error_args['continue_text'] = __( 'Continue', 'formidable' ); | |
| 1136 | + } | |
| 1137 | + | |
| 1138 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php'; | |
| 1119 | 1139 | } |
| 1120 | 1140 | |
| 1121 | 1141 | /** |
| 1122 | 1142 | * @deprecated 3.0.04 |