PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.3
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 +385 -198 6.56.16.3 View file →
@@ -61,14 +61,20 @@
61 61 $classes .= ' frm-admin-page-' . $page;
62 62 }
63 63 }
64 64
65 + if ( self::is_grey_page() ) {
66 + $classes .= ' frm-grey-body ';
67 + }
68 +
65 69 if ( FrmAppHelper::is_full_screen() ) {
66 70 $full_screen_on = self::get_full_screen_setting();
67 - $add_class = '';
71 + $add_class = '';
68 72 if ( $full_screen_on ) {
69 73 $add_class = ' frm-full-screen is-fullscreen-mode';
70 - wp_enqueue_style( 'wp-edit-post' ); // Load the CSS for .is-fullscreen-mode.
74 +
75 + // Load the CSS for .is-fullscreen-mode.
76 + wp_enqueue_style( 'wp-edit-post' );
71 77 }
72 78 $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
73 79 }
74 80
@@ -75,8 +81,12 @@
75 81 if ( ! FrmAppHelper::pro_is_installed() ) {
76 82 $classes .= ' frm-lite ';
77 83 }
78 84
85 + if ( get_user_setting( 'unfold' ) && 'f' !== get_user_setting( 'mfold' ) ) {
86 + $classes .= ' frm-unfold ';
87 + }
88 +
79 89 return $classes;
80 90 }
81 91
82 92 /**
@@ -124,9 +134,8 @@
124 134 'formidable',
125 135 'formidable-entries',
126 136 'formidable-views',
127 137 'formidable-views-editor',
128 - 'formidable-pro-upgrade',
129 138 'formidable-addons',
130 139 'formidable-import',
131 140 'formidable-settings',
132 141 'formidable-styles',
@@ -131,26 +140,25 @@
131 140 'formidable-settings',
132 141 'formidable-styles',
133 142 'formidable-styles2',
134 143 'formidable-inbox',
135 - 'formidable-welcome',
136 - 'formidable-applications',
144 + FrmFormTemplatesController::PAGE_SLUG,
145 + FrmOnboardingWizardController::PAGE_SLUG,
137 146 );
138 147
139 - if ( ! class_exists( 'FrmTransHooksController', false ) ) {
148 + if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
140 149 // Only consider the payments page as a "white page" when the Payments submodule is off.
141 150 // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active.
142 - $white_pages[] = 'formidable-payments';
151 +
152 + // Add an extra check to avoid white page styling on the PayPal "edit" action.
153 + // We fallback to the PayPal add on for the "edit" action since Stripe Lite does not have an edit view.
154 + if ( ! in_array( FrmAppHelper::simple_get( 'action' ), array( 'edit', 'new' ), true ) || ! is_callable( 'FrmPaymentsController::route' ) ) {
155 + $white_pages[] = 'formidable-payments';
156 + }
143 157 }
144 158
145 - $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
146 - $is_white_page = in_array( $get_page, $white_pages, true );
159 + $is_white_page = self::is_page_in_list( $white_pages ) || self::is_grey_page() || FrmAppHelper::is_view_builder_page();
147 160
148 - if ( ! $is_white_page ) {
149 - $screen = get_current_screen();
150 - $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
151 - }
152 -
153 161 /**
154 162 * Allow another add on to style a page as a Formidable "white page", which adds a white background color.
155 163 *
156 164 * @since 5.3
@@ -162,8 +170,45 @@
162 170 return $is_white_page;
163 171 }
164 172
165 173 /**
174 + * Add a grey bg instead of white.
175 + *
176 + * @since 6.8
177 + *
178 + * @return bool
179 + */
180 + private static function is_grey_page() {
181 + $grey_pages = array(
182 + 'formidable-applications',
183 + 'formidable-dashboard',
184 + );
185 +
186 + $is_grey_page = self::is_page_in_list( $grey_pages );
187 +
188 + /**
189 + * Filter to change FF wrapper background to grey.
190 + *
191 + * @since 6.8
192 + *
193 + * @param bool $is_grey_page
194 + * @return bool
195 + */
196 + return apply_filters( 'frm_is_grey_page', $is_grey_page );
197 + }
198 +
199 + /**
200 + * @since 6.8
201 + *
202 + * @param array $pages A list of page names to check.
203 + * @return bool
204 + */
205 + private static function is_page_in_list( $pages ) {
206 + $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
207 + return in_array( $get_page, $pages, true );
208 + }
209 +
210 + /**
166 211 * @return void
167 212 */
168 213 public static function load_wp_admin_style() {
169 214 FrmAppHelper::load_font_style();
@@ -169,10 +214,11 @@
169 214 FrmAppHelper::load_font_style();
170 215 }
171 216
172 217 /**
173 - * @param bool $show_nav
174 - * @param string $title
218 + * @param int|object $form
219 + * @param bool $show_nav
220 + * @param string $title
175 221 *
176 222 * @psalm-param 'hide'|'show' $title
177 223 *
178 224 * @return void
@@ -191,9 +237,9 @@
191 237 $id = $form->id;
192 238 $current_page = self::get_current_page();
193 239 $nav_items = self::get_form_nav_items( $form );
194 240
195 - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
241 + include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php';
196 242 }
197 243
198 244 /**
199 245 * @return string
@@ -247,18 +293,18 @@
247 293 'permission' => 'frm_view_entries',
248 294 ),
249 295 );
250 296
251 - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed();
297 + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed();
252 298
253 299 if ( ! $views_installed ) {
254 300 $nav_items[] = array(
255 - 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
256 - 'label' => __( 'Views', 'formidable' ),
257 - 'current' => array(),
258 - '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',
259 305 'permission' => 'frm_view_entries',
260 - 'atts' => array(
306 + 'atts' => array(
261 307 'class' => 'frm_noallow',
262 308 ),
263 309 );
264 310 }
@@ -265,14 +311,14 @@
265 311
266 312 // Let people know reports and views exist.
267 313 if ( ! FrmAppHelper::pro_is_installed() ) {
268 314 $nav_items[] = array(
269 - 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ),
270 - 'label' => __( 'Reports', 'formidable' ),
271 - 'current' => array( 'reports' ),
272 - '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',
273 319 'permission' => 'frm_view_entries',
274 - 'atts' => array(
320 + 'atts' => array(
275 321 'class' => 'frm_noallow',
276 322 ),
277 323 );
278 324 }
@@ -292,9 +338,10 @@
292 338 public static function settings_link( $links ) {
293 339 $settings = array();
294 340
295 341 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>';
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>';
297 344 }
298 345
299 346 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
300 347
@@ -305,9 +352,9 @@
305 352 * @return void
306 353 */
307 354 public static function pro_get_started_headline() {
308 355 self::review_request();
309 - FrmAppHelper::min_pro_version_notice( '4.0' );
356 + FrmAppHelper::min_pro_version_notice( '6.0' );
310 357 }
311 358
312 359 /**
313 360 * Add admin notices as needed for reviews
@@ -374,63 +421,26 @@
374 421 $shared_path = $plugin_path . '/classes/views/shared/';
375 422
376 423 include $shared_path . 'upgrade_overlay.php';
377 424 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 425 }
383 426
384 427 /**
428 + * Create a basic form with an email field.
429 + *
430 + * @param string $form_key
431 + * @param string $title
432 + * @param string $description
385 433 * @return void
386 434 */
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 - )
435 + public static function api_email_form( $form_key, $title = '', $description = '' ) {
436 + $user = wp_get_current_user();
437 + $args = array(
438 + 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css',
439 + 'title' => $title,
440 + 'description' => $description,
402 441 );
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';
442 + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php';
433 443 }
434 444
435 445 /**
436 446 * @return void
@@ -454,9 +464,8 @@
454 464 */
455 465 public static function remove_upsells() {
456 466 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
457 467 remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
458 - remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
459 468 remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
460 469 }
461 470
462 471 /**
@@ -478,9 +487,9 @@
478 487 /**
479 488 * Check if the database is outdated
480 489 *
481 490 * @since 2.0.1
482 - * @return boolean
491 + * @return bool
483 492 */
484 493 public static function needs_update() {
485 494 $needs_upgrade = self::compare_for_update(
486 495 array(
@@ -527,8 +536,12 @@
527 536 *
528 537 * @return void
529 538 */
530 539 public static function admin_init() {
540 + if ( FrmAppHelper::get_param( 'delete_all' ) && FrmAppHelper::is_admin_page( 'formidable' ) && 'trash' === FrmAppHelper::get_param( 'form_type' ) ) {
541 + FrmFormsController::delete_all();
542 + }
543 +
531 544 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
532 545 FrmFormsController::duplicate();
533 546 }
534 547
@@ -536,10 +549,23 @@
536 549 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
537 550 FrmStylesController::save_style();
538 551 }
539 552
540 - new FrmPersonalData(); // register personal data hooks
553 + if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) {
554 + wp_redirect(
555 + FrmAppHelper::admin_upgrade_link(
556 + array(
557 + 'medium' => 'upgrade',
558 + 'content' => 'submenu-upgrade',
559 + )
560 + )
561 + );
562 + die();
563 + }
541 564
565 + // Register personal data hooks.
566 + new FrmPersonalData();
567 +
542 568 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
543 569 self::network_upgrade_site();
544 570 }
545 571
@@ -547,82 +573,51 @@
547 573 // don't continue during ajax calls
548 574 self::admin_js();
549 575 }
550 576
577 + self::trigger_page_load_hooks();
578 +
551 579 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
552 - $action = FrmAppHelper::get_param( 'frm_action' );
580 + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
581 + // This provides backward compatibility for old addons that use legacy modal templates.
582 + $action = FrmAppHelper::get_param( 'frm_action' );
583 + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
584 + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
585 + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
586 + $url_param = $application_id ? '&applicationId=' . $application_id : '';
553 587
554 - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
555 - wp_safe_redirect( admin_url( 'admin.php?page=formidable&triggerNewFormModal=1' ) );
588 + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
556 589 exit;
557 590 }
558 591
559 592 FrmInbox::maybe_disable_screen_options();
560 593 }
561 -
562 - self::maybe_add_ip_warning();
563 594 }
564 595
565 596 /**
566 - * Show a warning for the IP address setting if it hasn't been set.
597 + * Get the current page and check for a possible function to trigger.
598 + * If a class name matches the page name, and the class has a load_page() method, trigger it.
567 599 *
568 - * @since 6.1
600 + * @since 6.8
569 601 *
570 602 * @return void
571 603 */
572 - private static function maybe_add_ip_warning() {
573 - $settings = FrmAppHelper::get_settings();
574 - if ( false !== $settings->custom_header_ip ) {
575 - // The setting has been changed from the false default (to either 1 or 0), so stop showing the message.
604 + private static function trigger_page_load_hooks() {
605 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
606 + if ( strpos( $page, 'formidable-' ) !== 0 ) {
607 + // Only trigger hooks on Formidable pages.
576 608 return;
577 609 }
578 610
579 - if ( ! self::is_behind_proxy() ) {
580 - // This message is only applicable when using a reverse proxy.
581 - return;
611 + $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page );
612 + $page = str_replace( ' ', '', ucwords( $page ) );
613 + $class = 'Frm' . $page . 'Controller';
614 + if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) {
615 + call_user_func( array( $class, 'load_page' ) );
582 616 }
583 -
584 - if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) {
585 - // Avoid the message on a POST action. We don't want to show the message if we're saving global settings.
586 - return;
587 - }
588 -
589 - $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
590 - $message = sprintf(
591 - // Translators: 1: Global Settings Link
592 - __( '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' ),
593 - '<a href="' . esc_url( $global_settings_link ) . '">Global Settings</a>'
594 - );
595 - $option_name = 'frm_dismiss_ip_address_notice';
596 - FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
597 617 }
598 618
599 619 /**
600 - * Check if any reverse proxy headers are set.
601 - *
602 - * @since 6.1
603 - *
604 - * @return bool
605 - */
606 - private static function is_behind_proxy() {
607 - $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip();
608 - foreach ( $custom_headers as $header ) {
609 - if ( 'REMOTE_ADDR' === $header ) {
610 - // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers.
611 - continue;
612 - }
613 -
614 - $ip = trim( FrmAppHelper::get_server_value( $header ) );
615 - // Return true for anything that isn't empty but ignoring values like ::1.
616 - if ( $ip && 0 !== strpos( $ip, '::' ) ) {
617 - return true;
618 - }
619 - }
620 -
621 - return false;
622 - }
623 -
624 - /**
625 620 * @return void
626 621 */
627 622 public static function admin_js() {
628 623 $plugin_url = FrmAppHelper::plugin_url();
@@ -629,8 +624,17 @@
629 624 $version = FrmAppHelper::plugin_version();
630 625
631 626 FrmAppHelper::load_admin_wide_js();
632 627
628 + // Register component assets early to ensure they can be enqueued later in controllers.
629 + wp_register_style( 'formidable-animations', $plugin_url . '/css/admin/animations.css', array(), $version );
630 +
631 + if ( class_exists( 'FrmOverlayController' ) ) {
632 + // This should always exist.
633 + // But it may not have loaded properly when updating the plugin.
634 + FrmOverlayController::register_assets();
635 + }
636 +
633 637 wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version );
634 638 wp_enqueue_style( 'formidable_admin_global' );
635 639
636 640 wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version );
@@ -641,26 +645,12 @@
641 645 self::register_popper1();
642 646 wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
643 647 wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
644 648
645 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
646 -
647 - // Enqueue Floating Links.
648 - $is_valid_page =
649 - FrmAppHelper::is_formidable_admin() &&
650 - ! FrmAppHelper::is_style_editor_page() &&
651 - ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
652 - ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
653 - if ( $is_valid_page && FrmAppHelper::is_formidable_branding() ) {
649 + if ( self::should_show_floating_links() ) {
654 650 self::enqueue_floating_links( $plugin_url, $version );
655 651 }
656 - unset( $is_valid_page );
657 652
658 - if ( 'formidable-applications' === $page ) {
659 - FrmApplicationsController::load_assets();
660 - return;
661 - }
662 -
663 653 $dependencies = array(
664 654 'formidable_admin_global',
665 655 'jquery',
666 656 'jquery-ui-core',
@@ -668,9 +658,10 @@
668 658 'jquery-ui-sortable',
669 659 'bootstrap_tooltip',
670 660 'bootstrap-multiselect',
671 661 'wp-i18n',
672 - 'wp-hooks', // Required in WP versions older than 5.7
662 + // Required in WP versions older than 5.7
663 + 'wp-hooks',
673 664 'formidable_dom',
674 665 'formidable_embed',
675 666 );
676 667
@@ -687,8 +678,20 @@
687 678 }
688 679
689 680 wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
690 681
682 + if ( ! class_exists( 'FrmTransHooksController', false ) ) {
683 + /**
684 + * Gateway fields are included for add-on compatibility but we do not want it to be visible.
685 + * They do however need to be visible when the payments submodule is active.
686 + */
687 + wp_add_inline_style(
688 + 'formidable-admin',
689 + '#frm_builder_page li[data-ftype="gateway"] { display: none; }'
690 + );
691 + }
692 +
693 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
691 694 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
692 695
693 696 global $pagenow;
694 697 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
@@ -696,15 +699,18 @@
696 699 wp_enqueue_script( 'admin-widgets' );
697 700 wp_enqueue_style( 'widgets' );
698 701 self::maybe_deregister_popper2();
699 702 wp_enqueue_script( 'formidable_admin' );
703 + wp_set_script_translations( 'formidable_admin', 'formidable' );
700 704 wp_enqueue_script( 'formidable_embed' );
705 + wp_set_script_translations( 'formidable_embed', 'formidable' );
701 706 FrmAppHelper::localize_script( 'admin' );
702 707
708 + wp_enqueue_style( 'formidable-animations' );
703 709 wp_enqueue_style( 'formidable-admin' );
704 710 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
705 711 wp_enqueue_style( 'formidable-grids' );
706 - wp_enqueue_style( 'formidable-dropzone' );
712 + self::maybe_enqueue_dropzone_css( $page );
707 713 } else {
708 714 wp_enqueue_style( 'formidable-grids' );
709 715 }
710 716
@@ -710,8 +716,12 @@
710 716
711 717 if ( 'formidable-entries' === $page ) {
712 718 // Load front end js for entries.
713 719 wp_enqueue_script( 'formidable' );
720 +
721 + // Registers and enqueues the entries page scripts.
722 + wp_register_script( 'formidable_entries', $plugin_url . '/js/admin/entries.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
723 + wp_enqueue_script( 'formidable_entries' );
714 724 }
715 725
716 726 do_action( 'frm_enqueue_builder_scripts' );
717 727 self::include_upgrade_overlay();
@@ -731,13 +741,55 @@
731 741
732 742 if ( $post_type === 'frm_display' ) {
733 743 self::enqueue_legacy_views_assets();
734 744 }
745 + }//end if
746 +
747 + if ( 'formidable-addons' === $page ) {
748 + wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
749 + wp_enqueue_script( 'formidable_addons' );
735 750 }
751 + }
736 752
753 + /**
754 + * Avoid loading dropzone CSS on the form list page. It isn't required there.
755 + *
756 + * @since 6.11
757 + *
758 + * @param string $page
759 + * @return void
760 + */
761 + private static function maybe_enqueue_dropzone_css( $page ) {
762 + if ( ! FrmAppHelper::pro_is_installed() ) {
763 + return;
764 + }
765 +
766 + $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
767 + if ( ! $should_avoid_loading_dropzone ) {
768 + wp_enqueue_style( 'formidable-dropzone' );
769 + }
737 770 }
738 771
739 772 /**
773 + * The floating links are not shown on every page.
774 + * They are also not shown if white labeling is being used.
775 + *
776 + * @since 6.8.4
777 + *
778 + * @return bool
779 + */
780 + private static function should_show_floating_links() {
781 + if ( ! FrmAppHelper::is_formidable_branding() ) {
782 + return false;
783 + }
784 +
785 + return FrmAppHelper::is_formidable_admin() &&
786 + ! FrmAppHelper::is_style_editor_page() &&
787 + ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
788 + ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
789 + }
790 +
791 + /**
740 792 * @since 6.3.2
741 793 *
742 794 * @return void
743 795 */
@@ -743,8 +795,9 @@
743 795 */
744 796 public static function admin_enqueue_scripts() {
745 797 self::load_wp_admin_style();
746 798 self::maybe_force_formidable_block_on_gutenberg_page();
799 + FrmUsageController::load_scripts();
747 800 }
748 801
749 802 /**
750 803 * Enqueue required assets for the Legacy Views editor (Views v4.x).
@@ -813,12 +866,45 @@
813 866 *
814 867 * @return void
815 868 */
816 869 private static function register_popper1() {
870 + if ( ! self::should_register_popper() ) {
871 + return;
872 + }
817 873 wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
818 874 }
819 875
820 876 /**
877 + * Only register popper on Formidable pages.
878 + * This helps to avoid popper conflicts on other plugin pages, including the WP Bakery page editor.
879 + *
880 + * @since 6.11.1
881 + *
882 + * @return bool
883 + */
884 + private static function should_register_popper() {
885 + global $pagenow;
886 +
887 + $post_id = FrmAppHelper::simple_get( 'post', 'absint' );
888 + if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) {
889 + return true;
890 + }
891 +
892 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
893 + $is_views_post_type = 'frm_display' === $post_type;
894 + if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) {
895 + return true;
896 + }
897 +
898 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
899 + if ( strpos( $page, 'formidable' ) === 0 ) {
900 + return true;
901 + }
902 +
903 + return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && FrmAppHelper::simple_get( 'taxonomy' ) === 'frm_application';
904 + }
905 +
906 + /**
821 907 * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set.
822 908 *
823 909 * @since 5.2
824 910 *
@@ -877,10 +963,10 @@
877 963 * @return void
878 964 */
879 965 public static function create_rest_routes() {
880 966 $args = array(
881 - 'methods' => 'GET',
882 - 'callback' => 'FrmAppController::api_install',
967 + 'methods' => 'GET',
968 + 'callback' => 'FrmAppController::api_install',
883 969 'permission_callback' => __CLASS__ . '::can_update_db',
884 970 );
885 971
886 972 register_rest_route( 'frm-admin/v1', '/install', $args );
@@ -885,10 +971,10 @@
885 971
886 972 register_rest_route( 'frm-admin/v1', '/install', $args );
887 973
888 974 $args = array(
889 - 'methods' => 'GET',
890 - 'callback' => 'FrmAddonsController::install_addon_api',
975 + 'methods' => 'GET',
976 + 'callback' => 'FrmAddonsController::install_addon_api',
891 977 'permission_callback' => 'FrmAddonsController::can_install_addon_api',
892 978 );
893 979
894 980 register_rest_route( 'frm-admin/v1', '/install-addon', $args );
@@ -1001,9 +1087,9 @@
1001 1087
1002 1088 $frmdb = new FrmMigrate();
1003 1089 $frmdb->uninstall();
1004 1090
1005 - //disable the plugin and redirect after uninstall so the tables don't get added right back
1091 + // Disable the plugin and redirect after uninstall so the tables don't get added right back.
1006 1092 $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
1007 1093 deactivate_plugins( $plugins, false, false );
1008 1094 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
1009 1095
@@ -1074,63 +1160,71 @@
1074 1160 *
1075 1161 * @return void
1076 1162 */
1077 1163 public static function add_admin_footer_links() {
1078 - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1079 -
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();
1084 -
1085 - // Exit if any of the above conditions are met
1086 - if ( $is_not_admin || $is_full_screen || $is_not_formidable_branding ) {
1087 - return;
1164 + if ( self::should_show_footer_links() ) {
1165 + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1088 1166 }
1089 -
1090 - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1091 1167 }
1092 1168
1093 1169 /**
1094 - * @deprecated 3.0.04
1170 + * Check if the footer links should be shown.
1095 1171 *
1096 - * @codeCoverageIgnore
1172 + * @since 6.7
1097 1173 *
1098 - * @return void
1174 + * @return bool
1099 1175 */
1100 - public static function activation_install() {
1101 - FrmDeprecated::activation_install();
1102 - }
1176 + private static function should_show_footer_links() {
1177 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1178 + $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type;
1179 + $show_footer_links = $is_formidable_page;
1180 + if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) {
1181 + $show_footer_links = false;
1182 + }
1103 1183
1104 - /**
1105 - * @deprecated 3.0
1106 - * @codeCoverageIgnore
1107 - */
1108 - public static function page_route( $content ) {
1109 - return FrmDeprecated::page_route( $content );
1184 + /**
1185 + * Filter whether to show the Formidable footer links.
1186 + *
1187 + * @since 6.7
1188 + *
1189 + * @param bool $show_footer_links
1190 + * @return bool
1191 + */
1192 + return apply_filters( 'frm_show_footer_links', $show_footer_links );
1110 1193 }
1111 1194
1112 1195 /**
1113 - * Include icons on page for Embed Form modal.
1196 + * Show an error modal and terminate the script execution.
1114 1197 *
1115 - * @since 5.2
1198 + * @since 6.7
1116 1199 *
1200 + * @param array $error_args Arguments that control the behavior of the error modal.
1201 + *
1117 1202 * @return void
1118 1203 */
1119 - public static function include_embed_form_icons() {
1120 - _deprecated_function( __METHOD__, '5.3' );
1121 - }
1204 + public static function show_error_modal( $error_args ) {
1205 + add_filter( 'frm_show_footer_links', '__return_false' );
1122 1206
1123 - /**
1124 - * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13.
1125 - * @codeCoverageIgnore
1126 - *
1127 - * @param array $atts
1128 - * @return string
1129 - */
1130 - public static function get_form_shortcode( $atts ) {
1131 - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1132 - return FrmFormsController::get_form_shortcode( $atts );
1207 + $defaults = array(
1208 + 'title' => '',
1209 + 'body' => '',
1210 + 'cancel_url' => '',
1211 + 'cancel_classes' => '',
1212 + 'continue_url' => '',
1213 + 'continue_classes' => '',
1214 + 'icon' => 'frm_lock_simple',
1215 + );
1216 +
1217 + $error_args = wp_parse_args( $error_args, $defaults );
1218 + if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) {
1219 + $error_args['cancel_text'] = __( 'Cancel', 'formidable' );
1220 + }
1221 +
1222 + if ( ! isset( $error_args['continue_text'] ) && ! empty( $error_args['continue_url'] ) ) {
1223 + $error_args['continue_text'] = __( 'Continue', 'formidable' );
1224 + }
1225 +
1226 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php';
1133 1227 }
1134 1228
1135 1229 /**
1136 1230 * Handles Floating Links' scripts and styles enqueueing.
@@ -1150,15 +1244,108 @@
1150 1244 // Enqueue the Floating Links styles.
1151 1245 wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1152 1246
1153 1247 // Enqueue the Floating Links script.
1154 - wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1248 + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array( 'formidable_admin' ), $version, true );
1155 1249
1156 1250 // Enqueue the config script.
1157 1251 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-' );
1252 +
1253 + if ( function_exists( 'wp_set_script_translations' ) ) {
1254 + wp_set_script_translations( 's11-floating-links-config', 's11-' );
1255 + }
1256 +
1159 1257 $floating_links_data = array(
1160 1258 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1161 1259 );
1162 1260 wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1261 +
1262 + /**
1263 + * Prompt Pro to load additional floating links scripts.
1264 + * This is used to include images in the Inbox SlideIn when Pro is active.
1265 + *
1266 + * @since 6.8.4
1267 + */
1268 + do_action( 'frm_enqueue_floating_links' );
1269 + }
1270 +
1271 + /**
1272 + * Check if we are in our admin pages.
1273 + *
1274 + * @return bool
1275 + */
1276 + private static function in_our_pages() {
1277 + global $current_screen, $pagenow;
1278 + if ( FrmAppHelper::is_formidable_admin() ) {
1279 + return true;
1280 + }
1281 +
1282 + if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) {
1283 + return true;
1284 + }
1285 +
1286 + if ( in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' ) ) {
1287 + return true;
1288 + }
1289 +
1290 + return false;
1291 + }
1292 +
1293 + /**
1294 + * Hide all third-parties admin notices only in our admin pages.
1295 + *
1296 + * @return void
1297 + */
1298 + public static function filter_admin_notices() {
1299 + if ( ! self::in_our_pages() ) {
1300 + return;
1301 + }
1302 +
1303 + $actions = array(
1304 + 'admin_notices',
1305 + 'network_admin_notices',
1306 + 'user_admin_notices',
1307 + 'all_admin_notices',
1308 + );
1309 +
1310 + global $wp_filter;
1311 +
1312 + foreach ( $actions as $action ) {
1313 + if ( empty( $wp_filter[ $action ]->callbacks ) ) {
1314 + continue;
1315 + }
1316 + foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) {
1317 + foreach ( $callbacks as $callback_name => $callback ) {
1318 + if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) {
1319 + continue;
1320 + }
1321 + unset( $wp_filter[ $action ]->callbacks[ $priority ][ $callback_name ] );
1322 + }
1323 + }
1324 + }
1325 + }
1326 +
1327 + /**
1328 + * Validate that the callback name is ours not from third-party.
1329 + *
1330 + * @param string $callback_name WordPress callback name.
1331 + *
1332 + * @return bool
1333 + */
1334 + private static function is_our_callback_string( $callback_name ) {
1335 + return 0 === stripos( $callback_name, 'frm' );
1336 + }
1337 +
1338 + /**
1339 + * Validate that the callback array is ours not from third-party.
1340 + *
1341 + * @param array $callback WordPress callback array.
1342 + *
1343 + * @return bool
1344 + */
1345 + private static function is_our_callback_array( $callback ) {
1346 + return ! empty( $callback['function'] ) &&
1347 + is_array( $callback['function'] ) &&
1348 + ! empty( $callback['function'][0] ) &&
1349 + self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] );
1163 1350 }
1164 1351 }