| @@ -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,10 +137,22 @@ | ||
| 133 | 137 | 'formidable-styles2', |
| 134 | 138 | 'formidable-inbox', |
| 135 | 139 | 'formidable-welcome', |
| 136 | 140 | 'formidable-applications', |
| 141 | + FrmFormTemplatesController::PAGE_SLUG, | |
| 137 | 142 | ); |
| 138 | 143 | |
| 144 | + if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) { | |
| 145 | + // Only consider the payments page as a "white page" when the Payments submodule is off. | |
| 146 | + // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active. | |
| 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 | + } | |
| 153 | + } | |
| 154 | + | |
| 139 | 155 | $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 140 | 156 | $is_white_page = in_array( $get_page, $white_pages, true ); |
| 141 | 157 | |
| 142 | 158 | if ( ! $is_white_page ) { |
| @@ -286,9 +302,10 @@ | ||
| 286 | 302 | public static function settings_link( $links ) { |
| 287 | 303 | $settings = array(); |
| 288 | 304 | |
| 289 | 305 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 290 | - $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>'; | |
| 306 | + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' ); | |
| 307 | + $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>'; | |
| 291 | 308 | } |
| 292 | 309 | |
| 293 | 310 | $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>'; |
| 294 | 311 | |
| @@ -368,63 +385,26 @@ | ||
| 368 | 385 | $shared_path = $plugin_path . '/classes/views/shared/'; |
| 369 | 386 | |
| 370 | 387 | include $shared_path . 'upgrade_overlay.php'; |
| 371 | 388 | include $shared_path . 'confirm-overlay.php'; |
| 372 | - | |
| 373 | - if ( FrmAppHelper::is_admin_page( 'formidable-welcome' ) || FrmAppHelper::on_form_listing_page() ) { | |
| 374 | - self::new_form_overlay_html(); | |
| 375 | - } | |
| 376 | 389 | } |
| 377 | 390 | |
| 378 | 391 | /** |
| 392 | + * Create a basic form with an email field. | |
| 393 | + * | |
| 394 | + * @param string $form_key | |
| 395 | + * @param string $title | |
| 396 | + * @param string $description | |
| 379 | 397 | * @return void |
| 380 | 398 | */ |
| 381 | - private static function new_form_overlay_html() { | |
| 382 | - FrmFormsController::before_list_templates(); | |
| 383 | - | |
| 384 | - $plugin_path = FrmAppHelper::plugin_path(); | |
| 385 | - $path = $plugin_path . '/classes/views/frm-forms/'; | |
| 386 | - $expired = FrmFormsController::expired(); | |
| 387 | - $expiring = FrmAddonsController::is_license_expiring(); | |
| 388 | - $user = wp_get_current_user(); // $user used in leave-email.php to determine a default value for field | |
| 389 | - $view_path = $path . 'new-form-overlay/'; | |
| 390 | - $modal_class = ''; | |
| 391 | - $upgrade_link = FrmAppHelper::admin_upgrade_link( | |
| 392 | - array( | |
| 393 | - 'medium' => 'new-template', | |
| 394 | - 'content' => 'upgrade', | |
| 395 | - ) | |
| 399 | + public static function api_email_form( $form_key, $title, $description ) { | |
| 400 | + $user = wp_get_current_user(); | |
| 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, | |
| 396 | 405 | ); |
| 397 | - $renew_link = FrmAppHelper::admin_upgrade_link( | |
| 398 | - array( | |
| 399 | - 'medium' => 'new-template', | |
| 400 | - 'content' => 'renew', | |
| 401 | - ) | |
| 402 | - ); | |
| 403 | - $blocks_to_render = array(); | |
| 404 | - | |
| 405 | - if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 406 | - // avoid rendering the email and code blocks for users who have upgraded or have a free license already | |
| 407 | - $api = new FrmFormTemplateApi(); | |
| 408 | - if ( ! $api->has_free_access() ) { | |
| 409 | - array_push( $blocks_to_render, 'email', 'code' ); | |
| 410 | - } | |
| 411 | - } | |
| 412 | - | |
| 413 | - // avoid rendering the upgrade block for users with elite | |
| 414 | - if ( 'elite' !== FrmAddonsController::license_type() ) { | |
| 415 | - $blocks_to_render[] = 'upgrade'; | |
| 416 | - } | |
| 417 | - | |
| 418 | - // avoid rendering the renew block for users who are not currently expired | |
| 419 | - if ( $expired ) { | |
| 420 | - $blocks_to_render[] = 'renew'; | |
| 421 | - $modal_class = 'frm-expired'; | |
| 422 | - } elseif ( $expiring ) { | |
| 423 | - $modal_class = 'frm-expiring'; | |
| 424 | - } | |
| 425 | - | |
| 426 | - include $path . 'new-form-overlay.php'; | |
| 406 | + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php'; | |
| 427 | 407 | } |
| 428 | 408 | |
| 429 | 409 | /** |
| 430 | 410 | * @return void |
| @@ -542,12 +522,17 @@ | ||
| 542 | 522 | self::admin_js(); |
| 543 | 523 | } |
| 544 | 524 | |
| 545 | 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. | |
| 546 | 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 : ''; | |
| 547 | 533 | |
| 548 | - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { | |
| 549 | - 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 ) ); | |
| 550 | 535 | exit; |
| 551 | 536 | } |
| 552 | 537 | |
| 553 | 538 | FrmInbox::maybe_disable_screen_options(); |
| @@ -623,8 +608,14 @@ | ||
| 623 | 608 | $version = FrmAppHelper::plugin_version(); |
| 624 | 609 | |
| 625 | 610 | FrmAppHelper::load_admin_wide_js(); |
| 626 | 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 | + | |
| 627 | 618 | wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version ); |
| 628 | 619 | wp_enqueue_style( 'formidable_admin_global' ); |
| 629 | 620 | |
| 630 | 621 | wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version ); |
| @@ -681,8 +672,19 @@ | ||
| 681 | 672 | } |
| 682 | 673 | |
| 683 | 674 | wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true ); |
| 684 | 675 | |
| 676 | + if ( ! class_exists( 'FrmTransHooksController', false ) ) { | |
| 677 | + /** | |
| 678 | + * Gateway fields are included for add-on compatibility but we do not want it to be visible. | |
| 679 | + * They do however need to be visible when the payments submodule is active. | |
| 680 | + */ | |
| 681 | + wp_add_inline_style( | |
| 682 | + 'formidable-admin', | |
| 683 | + '#frm_builder_page li[data-ftype="gateway"] { display: none; }' | |
| 684 | + ); | |
| 685 | + } | |
| 686 | + | |
| 685 | 687 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 686 | 688 | |
| 687 | 689 | global $pagenow; |
| 688 | 690 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) { |
| @@ -704,8 +706,12 @@ | ||
| 704 | 706 | |
| 705 | 707 | if ( 'formidable-entries' === $page ) { |
| 706 | 708 | // Load front end js for entries. |
| 707 | 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' ); | |
| 708 | 714 | } |
| 709 | 715 | |
| 710 | 716 | do_action( 'frm_enqueue_builder_scripts' ); |
| 711 | 717 | self::include_upgrade_overlay(); |
| @@ -1027,8 +1033,33 @@ | ||
| 1027 | 1033 | delete_site_option( 'frmpro-authorized' ); |
| 1028 | 1034 | wp_die(); |
| 1029 | 1035 | } |
| 1030 | 1036 | |
| 1037 | + /** | |
| 1038 | + * This is triggered when Formidable is activated. | |
| 1039 | + * | |
| 1040 | + * @return void | |
| 1041 | + */ | |
| 1042 | + public static function handle_activation() { | |
| 1043 | + self::maybe_activate_payment_cron(); | |
| 1044 | + } | |
| 1045 | + | |
| 1046 | + /** | |
| 1047 | + * The payment cron is unscheduled when Formidable is deactivated. | |
| 1048 | + * We need to add it back again on activation if Stripe is configured. | |
| 1049 | + * | |
| 1050 | + * @since 6.5 | |
| 1051 | + * | |
| 1052 | + * @return void | |
| 1053 | + */ | |
| 1054 | + private static function maybe_activate_payment_cron() { | |
| 1055 | + if ( ! FrmStrpLiteConnectHelper::stripe_connect_is_setup() ) { | |
| 1056 | + return; | |
| 1057 | + } | |
| 1058 | + | |
| 1059 | + FrmTransLiteAppController::maybe_schedule_cron(); | |
| 1060 | + } | |
| 1061 | + | |
| 1031 | 1062 | public static function set_footer_text( $text ) { |
| 1032 | 1063 | if ( FrmAppHelper::is_formidable_admin() ) { |
| 1033 | 1064 | $text = ''; |
| 1034 | 1065 | } |
| @@ -1043,21 +1074,69 @@ | ||
| 1043 | 1074 | * |
| 1044 | 1075 | * @return void |
| 1045 | 1076 | */ |
| 1046 | 1077 | public static function add_admin_footer_links() { |
| 1047 | - $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 | + } | |
| 1048 | 1082 | |
| 1049 | - // Check admin privileges, screen mode, and branding | |
| 1050 | - $is_not_admin = ! FrmAppHelper::is_formidable_admin() && $post_type !== 'frm_logs'; | |
| 1051 | - $is_full_screen = FrmAppHelper::is_full_screen(); | |
| 1052 | - $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 | + } | |
| 1053 | 1097 | |
| 1054 | - // Exit if any of the above conditions are met | |
| 1055 | - if ( $is_not_admin || $is_full_screen || $is_not_formidable_branding ) { | |
| 1056 | - 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' ); | |
| 1057 | 1132 | } |
| 1058 | 1133 | |
| 1059 | - 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'; | |
| 1060 | 1139 | } |
| 1061 | 1140 | |
| 1062 | 1141 | /** |
| 1063 | 1142 | * @deprecated 3.0.04 |
| @@ -1123,9 +1202,13 @@ | ||
| 1123 | 1202 | wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true ); |
| 1124 | 1203 | |
| 1125 | 1204 | // Enqueue the config script. |
| 1126 | 1205 | wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true ); |
| 1127 | - wp_set_script_translations( 's11-floating-links-config', 's11-' ); | |
| 1206 | + | |
| 1207 | + if ( function_exists( 'wp_set_script_translations' ) ) { | |
| 1208 | + wp_set_script_translations( 's11-floating-links-config', 's11-' ); | |
| 1209 | + } | |
| 1210 | + | |
| 1128 | 1211 | $floating_links_data = array( |
| 1129 | 1212 | 'proIsInstalled' => FrmAppHelper::pro_is_installed(), |
| 1130 | 1213 | ); |
| 1131 | 1214 | wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data ); |