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 +453 -162 6.3.16.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,20 +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 - $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
140 - $is_white_page = in_array( $get_page, $white_pages, true );
148 + if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
149 + // Only consider the payments page as a "white page" when the Payments submodule is off.
150 + // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active.
141 151
142 - if ( ! $is_white_page ) {
143 - $screen = get_current_screen();
144 - $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
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 + }
145 157 }
146 158
159 + $is_white_page = self::is_page_in_list( $white_pages ) || self::is_grey_page() || FrmAppHelper::is_view_builder_page();
160 +
147 161 /**
148 162 * Allow another add on to style a page as a Formidable "white page", which adds a white background color.
149 163 *
150 164 * @since 5.3
@@ -156,8 +170,45 @@
156 170 return $is_white_page;
157 171 }
158 172
159 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 + /**
160 211 * @return void
161 212 */
162 213 public static function load_wp_admin_style() {
163 214 FrmAppHelper::load_font_style();
@@ -163,10 +214,11 @@
163 214 FrmAppHelper::load_font_style();
164 215 }
165 216
166 217 /**
167 - * @param bool $show_nav
168 - * @param string $title
218 + * @param int|object $form
219 + * @param bool $show_nav
220 + * @param string $title
169 221 *
170 222 * @psalm-param 'hide'|'show' $title
171 223 *
172 224 * @return void
@@ -185,9 +237,9 @@
185 237 $id = $form->id;
186 238 $current_page = self::get_current_page();
187 239 $nav_items = self::get_form_nav_items( $form );
188 240
189 - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
241 + include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php';
190 242 }
191 243
192 244 /**
193 245 * @return string
@@ -241,18 +293,18 @@
241 293 'permission' => 'frm_view_entries',
242 294 ),
243 295 );
244 296
245 - $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();
246 298
247 299 if ( ! $views_installed ) {
248 300 $nav_items[] = array(
249 - 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
250 - 'label' => __( 'Views', 'formidable' ),
251 - 'current' => array(),
252 - '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',
253 305 'permission' => 'frm_view_entries',
254 - 'atts' => array(
306 + 'atts' => array(
255 307 'class' => 'frm_noallow',
256 308 ),
257 309 );
258 310 }
@@ -259,14 +311,14 @@
259 311
260 312 // Let people know reports and views exist.
261 313 if ( ! FrmAppHelper::pro_is_installed() ) {
262 314 $nav_items[] = array(
263 - 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ),
264 - 'label' => __( 'Reports', 'formidable' ),
265 - 'current' => array( 'reports' ),
266 - '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',
267 319 'permission' => 'frm_view_entries',
268 - 'atts' => array(
320 + 'atts' => array(
269 321 'class' => 'frm_noallow',
270 322 ),
271 323 );
272 324 }
@@ -286,9 +338,10 @@
286 338 public static function settings_link( $links ) {
287 339 $settings = array();
288 340
289 341 if ( ! FrmAppHelper::pro_is_installed() ) {
290 - $settings[] = '<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-row' ) ) . '" target="_blank" rel="noopener"><b>' . 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>';
291 344 }
292 345
293 346 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
294 347
@@ -299,9 +352,9 @@
299 352 * @return void
300 353 */
301 354 public static function pro_get_started_headline() {
302 355 self::review_request();
303 - FrmAppHelper::min_pro_version_notice( '4.0' );
356 + FrmAppHelper::min_pro_version_notice( '6.0' );
304 357 }
305 358
306 359 /**
307 360 * Add admin notices as needed for reviews
@@ -368,63 +421,26 @@
368 421 $shared_path = $plugin_path . '/classes/views/shared/';
369 422
370 423 include $shared_path . 'upgrade_overlay.php';
371 424 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 425 }
377 426
378 427 /**
428 + * Create a basic form with an email field.
429 + *
430 + * @param string $form_key
431 + * @param string $title
432 + * @param string $description
379 433 * @return void
380 434 */
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 - )
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,
396 441 );
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';
442 + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php';
427 443 }
428 444
429 445 /**
430 446 * @return void
@@ -448,9 +464,8 @@
448 464 */
449 465 public static function remove_upsells() {
450 466 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
451 467 remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
452 - remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
453 468 remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
454 469 }
455 470
456 471 /**
@@ -472,9 +487,9 @@
472 487 /**
473 488 * Check if the database is outdated
474 489 *
475 490 * @since 2.0.1
476 - * @return boolean
491 + * @return bool
477 492 */
478 493 public static function needs_update() {
479 494 $needs_upgrade = self::compare_for_update(
480 495 array(
@@ -521,8 +536,12 @@
521 536 *
522 537 * @return void
523 538 */
524 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 +
525 544 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
526 545 FrmFormsController::duplicate();
527 546 }
528 547
@@ -530,10 +549,23 @@
530 549 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
531 550 FrmStylesController::save_style();
532 551 }
533 552
534 - 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 + }
535 564
565 + // Register personal data hooks.
566 + new FrmPersonalData();
567 +
536 568 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
537 569 self::network_upgrade_site();
538 570 }
539 571
@@ -541,82 +573,51 @@
541 573 // don't continue during ajax calls
542 574 self::admin_js();
543 575 }
544 576
577 + self::trigger_page_load_hooks();
578 +
545 579 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
546 - $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 : '';
547 587
548 - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
549 - 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 ) );
550 589 exit;
551 590 }
552 591
553 592 FrmInbox::maybe_disable_screen_options();
554 593 }
555 -
556 - self::maybe_add_ip_warning();
557 594 }
558 595
559 596 /**
560 - * 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.
561 599 *
562 - * @since 6.1
600 + * @since 6.8
563 601 *
564 602 * @return void
565 603 */
566 - private static function maybe_add_ip_warning() {
567 - $settings = FrmAppHelper::get_settings();
568 - if ( false !== $settings->custom_header_ip ) {
569 - // 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.
570 608 return;
571 609 }
572 610
573 - if ( ! self::is_behind_proxy() ) {
574 - // This message is only applicable when using a reverse proxy.
575 - 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' ) );
576 616 }
577 -
578 - if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) {
579 - // Avoid the message on a POST action. We don't want to show the message if we're saving global settings.
580 - return;
581 - }
582 -
583 - $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
584 - $message = sprintf(
585 - // Translators: 1: Global Settings Link
586 - __( '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' ),
587 - '<a href="' . esc_url( $global_settings_link ) . '">Global Settings</a>'
588 - );
589 - $option_name = 'frm_dismiss_ip_address_notice';
590 - FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
591 617 }
592 618
593 619 /**
594 - * Check if any reverse proxy headers are set.
595 - *
596 - * @since 6.1
597 - *
598 - * @return bool
599 - */
600 - private static function is_behind_proxy() {
601 - $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip();
602 - foreach ( $custom_headers as $header ) {
603 - if ( 'REMOTE_ADDR' === $header ) {
604 - // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers.
605 - continue;
606 - }
607 -
608 - $ip = trim( FrmAppHelper::get_server_value( $header ) );
609 - // Return true for anything that isn't empty but ignoring values like ::1.
610 - if ( $ip && 0 !== strpos( $ip, '::' ) ) {
611 - return true;
612 - }
613 - }
614 -
615 - return false;
616 - }
617 -
618 - /**
619 620 * @return void
620 621 */
621 622 public static function admin_js() {
622 623 $plugin_url = FrmAppHelper::plugin_url();
@@ -623,8 +624,17 @@
623 624 $version = FrmAppHelper::plugin_version();
624 625
625 626 FrmAppHelper::load_admin_wide_js();
626 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 +
627 637 wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version );
628 638 wp_enqueue_style( 'formidable_admin_global' );
629 639
630 640 wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version );
@@ -635,13 +645,10 @@
635 645 self::register_popper1();
636 646 wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
637 647 wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
638 648
639 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
640 -
641 - if ( 'formidable-applications' === $page ) {
642 - FrmApplicationsController::load_assets();
643 - return;
649 + if ( self::should_show_floating_links() ) {
650 + self::enqueue_floating_links( $plugin_url, $version );
644 651 }
645 652
646 653 $dependencies = array(
647 654 'formidable_admin_global',
@@ -651,9 +658,10 @@
651 658 'jquery-ui-sortable',
652 659 'bootstrap_tooltip',
653 660 'bootstrap-multiselect',
654 661 'wp-i18n',
655 - 'wp-hooks', // Required in WP versions older than 5.7
662 + // Required in WP versions older than 5.7
663 + 'wp-hooks',
656 664 'formidable_dom',
657 665 'formidable_embed',
658 666 );
659 667
@@ -670,8 +678,20 @@
670 678 }
671 679
672 680 wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
673 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' );
674 694 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
675 695
676 696 global $pagenow;
677 697 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
@@ -679,15 +699,18 @@
679 699 wp_enqueue_script( 'admin-widgets' );
680 700 wp_enqueue_style( 'widgets' );
681 701 self::maybe_deregister_popper2();
682 702 wp_enqueue_script( 'formidable_admin' );
703 + wp_set_script_translations( 'formidable_admin', 'formidable' );
683 704 wp_enqueue_script( 'formidable_embed' );
705 + wp_set_script_translations( 'formidable_embed', 'formidable' );
684 706 FrmAppHelper::localize_script( 'admin' );
685 707
708 + wp_enqueue_style( 'formidable-animations' );
686 709 wp_enqueue_style( 'formidable-admin' );
687 710 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
688 711 wp_enqueue_style( 'formidable-grids' );
689 - wp_enqueue_style( 'formidable-dropzone' );
712 + self::maybe_enqueue_dropzone_css( $page );
690 713 } else {
691 714 wp_enqueue_style( 'formidable-grids' );
692 715 }
693 716
@@ -693,8 +716,12 @@
693 716
694 717 if ( 'formidable-entries' === $page ) {
695 718 // Load front end js for entries.
696 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' );
697 724 }
698 725
699 726 do_action( 'frm_enqueue_builder_scripts' );
700 727 self::include_upgrade_overlay();
@@ -714,11 +741,63 @@
714 741
715 742 if ( $post_type === 'frm_display' ) {
716 743 self::enqueue_legacy_views_assets();
717 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' );
718 750 }
751 + }
719 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 + }
770 + }
771 +
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 + /**
792 + * @since 6.3.2
793 + *
794 + * @return void
795 + */
796 + public static function admin_enqueue_scripts() {
797 + self::load_wp_admin_style();
720 798 self::maybe_force_formidable_block_on_gutenberg_page();
799 + FrmUsageController::load_scripts();
721 800 }
722 801
723 802 /**
724 803 * Enqueue required assets for the Legacy Views editor (Views v4.x).
@@ -787,12 +866,45 @@
787 866 *
788 867 * @return void
789 868 */
790 869 private static function register_popper1() {
870 + if ( ! self::should_register_popper() ) {
871 + return;
872 + }
791 873 wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
792 874 }
793 875
794 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 + /**
795 907 * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set.
796 908 *
797 909 * @since 5.2
798 910 *
@@ -851,10 +963,10 @@
851 963 * @return void
852 964 */
853 965 public static function create_rest_routes() {
854 966 $args = array(
855 - 'methods' => 'GET',
856 - 'callback' => 'FrmAppController::api_install',
967 + 'methods' => 'GET',
968 + 'callback' => 'FrmAppController::api_install',
857 969 'permission_callback' => __CLASS__ . '::can_update_db',
858 970 );
859 971
860 972 register_rest_route( 'frm-admin/v1', '/install', $args );
@@ -859,10 +971,10 @@
859 971
860 972 register_rest_route( 'frm-admin/v1', '/install', $args );
861 973
862 974 $args = array(
863 - 'methods' => 'GET',
864 - 'callback' => 'FrmAddonsController::install_addon_api',
975 + 'methods' => 'GET',
976 + 'callback' => 'FrmAddonsController::install_addon_api',
865 977 'permission_callback' => 'FrmAddonsController::can_install_addon_api',
866 978 );
867 979
868 980 register_rest_route( 'frm-admin/v1', '/install-addon', $args );
@@ -975,9 +1087,9 @@
975 1087
976 1088 $frmdb = new FrmMigrate();
977 1089 $frmdb->uninstall();
978 1090
979 - //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.
980 1092 $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
981 1093 deactivate_plugins( $plugins, false, false );
982 1094 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
983 1095
@@ -1007,8 +1119,33 @@
1007 1119 delete_site_option( 'frmpro-authorized' );
1008 1120 wp_die();
1009 1121 }
1010 1122
1123 + /**
1124 + * This is triggered when Formidable is activated.
1125 + *
1126 + * @return void
1127 + */
1128 + public static function handle_activation() {
1129 + self::maybe_activate_payment_cron();
1130 + }
1131 +
1132 + /**
1133 + * The payment cron is unscheduled when Formidable is deactivated.
1134 + * We need to add it back again on activation if Stripe is configured.
1135 + *
1136 + * @since 6.5
1137 + *
1138 + * @return void
1139 + */
1140 + private static function maybe_activate_payment_cron() {
1141 + if ( ! FrmStrpLiteConnectHelper::stripe_connect_is_setup() ) {
1142 + return;
1143 + }
1144 +
1145 + FrmTransLiteAppController::maybe_schedule_cron();
1146 + }
1147 +
1011 1148 public static function set_footer_text( $text ) {
1012 1149 if ( FrmAppHelper::is_formidable_admin() ) {
1013 1150 $text = '';
1014 1151 }
@@ -1016,45 +1153,199 @@
1016 1153 return $text;
1017 1154 }
1018 1155
1019 1156 /**
1020 - * @deprecated 3.0.04
1157 + * Add admin footer links.
1021 1158 *
1022 - * @codeCoverageIgnore
1159 + * @since 6.4.1
1023 1160 *
1024 1161 * @return void
1025 1162 */
1026 - public static function activation_install() {
1027 - FrmDeprecated::activation_install();
1163 + public static function add_admin_footer_links() {
1164 + if ( self::should_show_footer_links() ) {
1165 + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1166 + }
1028 1167 }
1029 1168
1030 1169 /**
1031 - * @deprecated 3.0
1032 - * @codeCoverageIgnore
1170 + * Check if the footer links should be shown.
1171 + *
1172 + * @since 6.7
1173 + *
1174 + * @return bool
1033 1175 */
1034 - public static function page_route( $content ) {
1035 - return FrmDeprecated::page_route( $content );
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 + }
1183 +
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 );
1036 1193 }
1037 1194
1038 1195 /**
1039 - * Include icons on page for Embed Form modal.
1196 + * Show an error modal and terminate the script execution.
1040 1197 *
1041 - * @since 5.2
1198 + * @since 6.7
1042 1199 *
1200 + * @param array $error_args Arguments that control the behavior of the error modal.
1201 + *
1043 1202 * @return void
1044 1203 */
1045 - public static function include_embed_form_icons() {
1046 - _deprecated_function( __METHOD__, '5.3' );
1204 + public static function show_error_modal( $error_args ) {
1205 + add_filter( 'frm_show_footer_links', '__return_false' );
1206 +
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';
1047 1227 }
1048 1228
1049 1229 /**
1050 - * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13.
1051 - * @codeCoverageIgnore
1230 + * Handles Floating Links' scripts and styles enqueueing.
1052 1231 *
1053 - * @param array $atts
1054 - * @return string
1232 + * @since 6.4
1233 + *
1234 + * @param string $plugin_url URL of the plugin.
1235 + * @param string $version Current version of the plugin.
1236 + * @return void
1055 1237 */
1056 - public static function get_form_shortcode( $atts ) {
1057 - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1058 - return FrmFormsController::get_form_shortcode( $atts );
1238 + private static function enqueue_floating_links( $plugin_url, $version ) {
1239 + if ( ! $plugin_url || ! $version ) {
1240 + // If any required parameters are missing, exit early.
1241 + return;
1242 + }
1243 +
1244 + // Enqueue the Floating Links styles.
1245 + wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1246 +
1247 + // Enqueue the Floating Links script.
1248 + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array( 'formidable_admin' ), $version, true );
1249 +
1250 + // Enqueue the config script.
1251 + wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1252 +
1253 + if ( function_exists( 'wp_set_script_translations' ) ) {
1254 + wp_set_script_translations( 's11-floating-links-config', 's11-' );
1255 + }
1256 +
1257 + $floating_links_data = array(
1258 + 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1259 + );
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] );
1059 1350 }
1060 1351 }