PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.24
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.24
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 +561 -211 6.5.36.24 View file →
@@ -14,8 +14,13 @@
14 14 return;
15 15 }
16 16
17 17 $menu_name = FrmAppHelper::get_menu_name();
18 +
19 + if ( in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) {
20 + $menu_name .= wp_kses_post( FrmInboxController::get_notice_count() );
21 + }
22 +
18 23 add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
19 24 }
20 25
21 26 /**
@@ -61,14 +66,20 @@
61 66 $classes .= ' frm-admin-page-' . $page;
62 67 }
63 68 }
64 69
70 + if ( self::is_grey_page() ) {
71 + $classes .= ' frm-grey-body ';
72 + }
73 +
65 74 if ( FrmAppHelper::is_full_screen() ) {
66 75 $full_screen_on = self::get_full_screen_setting();
67 - $add_class = '';
76 + $add_class = '';
68 77 if ( $full_screen_on ) {
69 78 $add_class = ' frm-full-screen is-fullscreen-mode';
70 - wp_enqueue_style( 'wp-edit-post' ); // Load the CSS for .is-fullscreen-mode.
79 +
80 + // Load the CSS for .is-fullscreen-mode.
81 + wp_enqueue_style( 'wp-edit-post' );
71 82 }
72 83 $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
73 84 }
74 85
@@ -75,8 +86,12 @@
75 86 if ( ! FrmAppHelper::pro_is_installed() ) {
76 87 $classes .= ' frm-lite ';
77 88 }
78 89
90 + if ( get_user_setting( 'unfold' ) && 'f' !== get_user_setting( 'mfold' ) ) {
91 + $classes .= ' frm-unfold ';
92 + }
93 +
79 94 return $classes;
80 95 }
81 96
82 97 /**
@@ -124,9 +139,8 @@
124 139 'formidable',
125 140 'formidable-entries',
126 141 'formidable-views',
127 142 'formidable-views-editor',
128 - 'formidable-pro-upgrade',
129 143 'formidable-addons',
130 144 'formidable-import',
131 145 'formidable-settings',
132 146 'formidable-styles',
@@ -131,26 +145,25 @@
131 145 'formidable-settings',
132 146 'formidable-styles',
133 147 'formidable-styles2',
134 148 'formidable-inbox',
135 - 'formidable-welcome',
136 - 'formidable-applications',
149 + FrmFormTemplatesController::PAGE_SLUG,
150 + FrmOnboardingWizardController::PAGE_SLUG,
137 151 );
138 152
139 153 if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
140 154 // Only consider the payments page as a "white page" when the Payments submodule is off.
141 155 // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active.
142 - $white_pages[] = 'formidable-payments';
156 +
157 + // Add an extra check to avoid white page styling on the PayPal "edit" action.
158 + // We fallback to the PayPal add on for the "edit" action since Stripe Lite does not have an edit view.
159 + if ( ! in_array( FrmAppHelper::simple_get( 'action' ), array( 'edit', 'new' ), true ) || ! is_callable( 'FrmPaymentsController::route' ) ) {
160 + $white_pages[] = 'formidable-payments';
161 + }
143 162 }
144 163
145 - $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
146 - $is_white_page = in_array( $get_page, $white_pages, true );
164 + $is_white_page = self::is_page_in_list( $white_pages ) || self::is_grey_page() || FrmAppHelper::is_view_builder_page();
147 165
148 - if ( ! $is_white_page ) {
149 - $screen = get_current_screen();
150 - $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
151 - }
152 -
153 166 /**
154 167 * Allow another add on to style a page as a Formidable "white page", which adds a white background color.
155 168 *
156 169 * @since 5.3
@@ -162,8 +175,46 @@
162 175 return $is_white_page;
163 176 }
164 177
165 178 /**
179 + * Add a grey bg instead of white.
180 + *
181 + * @since 6.8
182 + *
183 + * @return bool
184 + */
185 + private static function is_grey_page() {
186 + $grey_pages = array(
187 + 'formidable-applications',
188 + 'formidable-dashboard',
189 + 'formidable-views',
190 + );
191 +
192 + $is_grey_page = self::is_page_in_list( $grey_pages );
193 +
194 + /**
195 + * Filter to change FF wrapper background to grey.
196 + *
197 + * @since 6.8
198 + *
199 + * @param bool $is_grey_page
200 + * @return bool
201 + */
202 + return apply_filters( 'frm_is_grey_page', $is_grey_page );
203 + }
204 +
205 + /**
206 + * @since 6.8
207 + *
208 + * @param array $pages A list of page names to check.
209 + * @return bool
210 + */
211 + private static function is_page_in_list( $pages ) {
212 + $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
213 + return in_array( $get_page, $pages, true );
214 + }
215 +
216 + /**
166 217 * @return void
167 218 */
168 219 public static function load_wp_admin_style() {
169 220 FrmAppHelper::load_font_style();
@@ -169,10 +220,11 @@
169 220 FrmAppHelper::load_font_style();
170 221 }
171 222
172 223 /**
173 - * @param bool $show_nav
174 - * @param string $title
224 + * @param int|object $form
225 + * @param bool $show_nav
226 + * @param string $title
175 227 *
176 228 * @psalm-param 'hide'|'show' $title
177 229 *
178 230 * @return void
@@ -191,9 +243,9 @@
191 243 $id = $form->id;
192 244 $current_page = self::get_current_page();
193 245 $nav_items = self::get_form_nav_items( $form );
194 246
195 - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
247 + include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php';
196 248 }
197 249
198 250 /**
199 251 * @return string
@@ -247,18 +299,18 @@
247 299 'permission' => 'frm_view_entries',
248 300 ),
249 301 );
250 302
251 - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed();
303 + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed();
252 304
253 305 if ( ! $views_installed ) {
254 306 $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',
307 + 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
308 + 'label' => __( 'Views', 'formidable' ),
309 + 'current' => array(),
310 + 'page' => 'formidable-views',
259 311 'permission' => 'frm_view_entries',
260 - 'atts' => array(
312 + 'atts' => array(
261 313 'class' => 'frm_noallow',
262 314 ),
263 315 );
264 316 }
@@ -265,14 +317,14 @@
265 317
266 318 // Let people know reports and views exist.
267 319 if ( ! FrmAppHelper::pro_is_installed() ) {
268 320 $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',
321 + 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ),
322 + 'label' => __( 'Reports', 'formidable' ),
323 + 'current' => array( 'reports' ),
324 + 'page' => 'formidable',
273 325 'permission' => 'frm_view_entries',
274 - 'atts' => array(
326 + 'atts' => array(
275 327 'class' => 'frm_noallow',
276 328 ),
277 329 );
278 330 }
@@ -284,10 +336,12 @@
284 336
285 337 return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
286 338 }
287 339
288 - // Adds a settings link to the plugins page
289 340 /**
341 + * Adds a settings link to the plugins page
342 + *
343 + * @param array $links
290 344 * @return array
291 345 */
292 346 public static function settings_link( $links ) {
293 347 $settings = array();
@@ -292,10 +346,25 @@
292 346 public static function settings_link( $links ) {
293 347 $settings = array();
294 348
295 349 if ( ! FrmAppHelper::pro_is_installed() ) {
296 - $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' );
297 - $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>';
350 + if ( FrmAddonsController::is_license_expired() ) {
351 + $label = __( 'Renew', 'formidable' );
352 + } else {
353 + $label = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_text' );
354 + if ( ! $label ) {
355 + $label = __( 'Upgrade to Pro', 'formidable' );
356 + }
357 + }
358 +
359 + $upgrade_link = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_link' );
360 + if ( $upgrade_link ) {
361 + $upgrade_link = FrmAppHelper::maybe_add_missing_utm( $upgrade_link, array( 'medium' => 'plugin-row' ) );
362 + } else {
363 + $upgrade_link = FrmAppHelper::admin_upgrade_link( 'plugin-row' );
364 + }
365 +
366 + $settings[] = '<a href="' . esc_url( $upgrade_link ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>';
298 367 }
299 368
300 369 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
301 370
@@ -306,9 +375,9 @@
306 375 * @return void
307 376 */
308 377 public static function pro_get_started_headline() {
309 378 self::review_request();
310 - FrmAppHelper::min_pro_version_notice( '4.0' );
379 + FrmAppHelper::min_pro_version_notice( '6.0' );
311 380 }
312 381
313 382 /**
314 383 * Add admin notices as needed for reviews
@@ -375,66 +444,11 @@
375 444 $shared_path = $plugin_path . '/classes/views/shared/';
376 445
377 446 include $shared_path . 'upgrade_overlay.php';
378 447 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 448 }
384 449
385 450 /**
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 451 * Create a basic form with an email field.
438 452 *
439 453 * @param string $form_key
440 454 * @param string $title
@@ -440,13 +454,16 @@
440 454 * @param string $title
441 455 * @param string $description
442 456 * @return void
443 457 */
444 - 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 - $user = wp_get_current_user();
448 - require $view_path . 'leave-email.php';
458 + public static function api_email_form( $form_key, $title = '', $description = '' ) {
459 + $user = wp_get_current_user();
460 + $args = array(
461 + 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css',
462 + 'title' => $title,
463 + 'description' => $description,
464 + );
465 + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php';
449 466 }
450 467
451 468 /**
452 469 * @return void
@@ -469,10 +486,9 @@
469 486 * @return void
470 487 */
471 488 public static function remove_upsells() {
472 489 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
473 - remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
474 - remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
490 + remove_action( 'frm_after_settings_tabs', 'FrmSettingsController::settings_cta' );
475 491 remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
476 492 }
477 493
478 494 /**
@@ -494,9 +510,9 @@
494 510 /**
495 511 * Check if the database is outdated
496 512 *
497 513 * @since 2.0.1
498 - * @return boolean
514 + * @return bool
499 515 */
500 516 public static function needs_update() {
501 517 $needs_upgrade = self::compare_for_update(
502 518 array(
@@ -543,19 +559,45 @@
543 559 *
544 560 * @return void
545 561 */
546 562 public static function admin_init() {
563 + if ( FrmAppHelper::get_param( 'delete_all' ) && FrmAppHelper::is_admin_page( 'formidable' ) && 'trash' === FrmAppHelper::get_param( 'form_type' ) ) {
564 + FrmFormsController::delete_all();
565 + }
566 +
547 567 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
548 568 FrmFormsController::duplicate();
549 569 }
550 570
571 + if ( FrmAppHelper::is_admin_page( 'formidable' ) && FrmAppHelper::simple_get( 'frm_add_tables' ) ) {
572 + self::add_missing_tables();
573 + }
574 +
551 575 if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) {
552 576 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
553 577 FrmStylesController::save_style();
554 578 }
555 579
556 - new FrmPersonalData(); // register personal data hooks
580 + if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) {
581 + $redirect = FrmSalesApi::get_best_sale_value( 'menu_cta_link' );
582 + $utm = array(
583 + 'medium' => 'upgrade',
584 + 'content' => 'submenu-upgrade',
585 + );
557 586
587 + if ( $redirect ) {
588 + $redirect = FrmAppHelper::maybe_add_missing_utm( $redirect, $utm );
589 + } else {
590 + $redirect = FrmAppHelper::admin_upgrade_link( $utm );
591 + }
592 +
593 + wp_redirect( $redirect );
594 + die();
595 + }
596 +
597 + // Register personal data hooks.
598 + new FrmPersonalData();
599 +
558 600 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
559 601 self::network_upgrade_site();
560 602 }
561 603
@@ -563,82 +605,51 @@
563 605 // don't continue during ajax calls
564 606 self::admin_js();
565 607 }
566 608
609 + self::trigger_page_load_hooks();
610 +
567 611 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
568 - $action = FrmAppHelper::get_param( 'frm_action' );
612 + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
613 + // This provides backward compatibility for old addons that use legacy modal templates.
614 + $action = FrmAppHelper::get_param( 'frm_action' );
615 + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
616 + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
617 + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
618 + $url_param = $application_id ? '&applicationId=' . $application_id : '';
569 619
570 - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
571 - wp_safe_redirect( admin_url( 'admin.php?page=formidable&triggerNewFormModal=1' ) );
620 + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
572 621 exit;
573 622 }
574 623
575 624 FrmInbox::maybe_disable_screen_options();
576 625 }
577 -
578 - self::maybe_add_ip_warning();
579 626 }
580 627
581 628 /**
582 - * Show a warning for the IP address setting if it hasn't been set.
629 + * Get the current page and check for a possible function to trigger.
630 + * If a class name matches the page name, and the class has a load_page() method, trigger it.
583 631 *
584 - * @since 6.1
632 + * @since 6.8
585 633 *
586 634 * @return void
587 635 */
588 - private static function maybe_add_ip_warning() {
589 - $settings = FrmAppHelper::get_settings();
590 - if ( false !== $settings->custom_header_ip ) {
591 - // The setting has been changed from the false default (to either 1 or 0), so stop showing the message.
636 + private static function trigger_page_load_hooks() {
637 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
638 + if ( strpos( $page, 'formidable-' ) !== 0 ) {
639 + // Only trigger hooks on Formidable pages.
592 640 return;
593 641 }
594 642
595 - if ( ! self::is_behind_proxy() ) {
596 - // This message is only applicable when using a reverse proxy.
597 - return;
643 + $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page );
644 + $page = str_replace( ' ', '', ucwords( $page ) );
645 + $class = 'Frm' . $page . 'Controller';
646 + if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) {
647 + call_user_func( array( $class, 'load_page' ) );
598 648 }
599 -
600 - if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) {
601 - // Avoid the message on a POST action. We don't want to show the message if we're saving global settings.
602 - return;
603 - }
604 -
605 - $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
606 - $message = sprintf(
607 - // Translators: 1: Global Settings Link
608 - __( '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' ),
609 - '<a href="' . esc_url( $global_settings_link ) . '">Global Settings</a>'
610 - );
611 - $option_name = 'frm_dismiss_ip_address_notice';
612 - FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
613 649 }
614 650
615 651 /**
616 - * Check if any reverse proxy headers are set.
617 - *
618 - * @since 6.1
619 - *
620 - * @return bool
621 - */
622 - private static function is_behind_proxy() {
623 - $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip();
624 - foreach ( $custom_headers as $header ) {
625 - if ( 'REMOTE_ADDR' === $header ) {
626 - // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers.
627 - continue;
628 - }
629 -
630 - $ip = trim( FrmAppHelper::get_server_value( $header ) );
631 - // Return true for anything that isn't empty but ignoring values like ::1.
632 - if ( $ip && 0 !== strpos( $ip, '::' ) ) {
633 - return true;
634 - }
635 - }
636 -
637 - return false;
638 - }
639 -
640 - /**
641 652 * @return void
642 653 */
643 654 public static function admin_js() {
644 655 $plugin_url = FrmAppHelper::plugin_url();
@@ -645,8 +656,11 @@
645 656 $version = FrmAppHelper::plugin_version();
646 657
647 658 FrmAppHelper::load_admin_wide_js();
648 659
660 + // Register component assets early to ensure they can be enqueued later in controllers.
661 + wp_register_style( 'formidable-animations', $plugin_url . '/css/admin/animations.css', array(), $version );
662 +
649 663 if ( class_exists( 'FrmOverlayController' ) ) {
650 664 // This should always exist.
651 665 // But it may not have loaded properly when updating the plugin.
652 666 FrmOverlayController::register_assets();
@@ -661,28 +675,19 @@
661 675 wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
662 676 wp_register_script( 'formidable_embed', $plugin_url . '/js/admin/embed.js', array( 'formidable_dom', 'jquery-ui-autocomplete' ), $version, true );
663 677 self::register_popper1();
664 678 wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
679 +
680 + $settings_js_vars = array(
681 + 'currencies' => FrmCurrencyHelper::get_currencies(),
682 + );
665 683 wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
684 + wp_localize_script( 'formidable_settings', 'frmSettings', $settings_js_vars );
666 685
667 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
668 -
669 - // Enqueue Floating Links.
670 - $is_valid_page =
671 - FrmAppHelper::is_formidable_admin() &&
672 - ! FrmAppHelper::is_style_editor_page() &&
673 - ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
674 - ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
675 - if ( $is_valid_page && FrmAppHelper::is_formidable_branding() ) {
686 + if ( self::should_show_floating_links() ) {
676 687 self::enqueue_floating_links( $plugin_url, $version );
677 688 }
678 - unset( $is_valid_page );
679 689
680 - if ( 'formidable-applications' === $page ) {
681 - FrmApplicationsController::load_assets();
682 - return;
683 - }
684 -
685 690 $dependencies = array(
686 691 'formidable_admin_global',
687 692 'jquery',
688 693 'jquery-ui-core',
@@ -690,9 +695,10 @@
690 695 'jquery-ui-sortable',
691 696 'bootstrap_tooltip',
692 697 'bootstrap-multiselect',
693 698 'wp-i18n',
694 - 'wp-hooks', // Required in WP versions older than 5.7
699 + // Required in WP versions older than 5.7
700 + 'wp-hooks',
695 701 'formidable_dom',
696 702 'formidable_embed',
697 703 );
698 704
@@ -720,24 +726,27 @@
720 726 '#frm_builder_page li[data-ftype="gateway"] { display: none; }'
721 727 );
722 728 }
723 729
730 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
724 731 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
725 732
726 733 global $pagenow;
727 734 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
728 -
729 735 wp_enqueue_script( 'admin-widgets' );
730 736 wp_enqueue_style( 'widgets' );
731 737 self::maybe_deregister_popper2();
732 738 wp_enqueue_script( 'formidable_admin' );
739 + wp_set_script_translations( 'formidable_admin', 'formidable' );
733 740 wp_enqueue_script( 'formidable_embed' );
741 + wp_set_script_translations( 'formidable_embed', 'formidable' );
734 742 FrmAppHelper::localize_script( 'admin' );
735 743
744 + wp_enqueue_style( 'formidable-animations' );
736 745 wp_enqueue_style( 'formidable-admin' );
737 746 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
738 747 wp_enqueue_style( 'formidable-grids' );
739 - wp_enqueue_style( 'formidable-dropzone' );
748 + self::maybe_enqueue_dropzone_css( $page );
740 749 } else {
741 750 wp_enqueue_style( 'formidable-grids' );
742 751 }
743 752
@@ -743,8 +752,12 @@
743 752
744 753 if ( 'formidable-entries' === $page ) {
745 754 // Load front end js for entries.
746 755 wp_enqueue_script( 'formidable' );
756 +
757 + // Registers and enqueues the entries page scripts.
758 + wp_register_script( 'formidable_entries', $plugin_url . '/js/admin/entries.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
759 + wp_enqueue_script( 'formidable_entries' );
747 760 }
748 761
749 762 do_action( 'frm_enqueue_builder_scripts' );
750 763 self::include_upgrade_overlay();
@@ -764,13 +777,78 @@
764 777
765 778 if ( $post_type === 'frm_display' ) {
766 779 self::enqueue_legacy_views_assets();
767 780 }
781 + }//end if
782 +
783 + if ( 'formidable-addons' === $page ) {
784 + wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
785 + wp_enqueue_script( 'formidable_addons' );
768 786 }
769 787
788 + self::enqueue_builder_assets( $plugin_url, $version );
770 789 }
771 790
772 791 /**
792 + * Enqueue the Form Builder assets.
793 + *
794 + * @since 6.24
795 + *
796 + * @param string $plugin_url The plugin URL.
797 + * @param string $version The plugin version.
798 + * @return void
799 + */
800 + private static function enqueue_builder_assets( $plugin_url, $version ) {
801 + wp_register_style( 'formidable-settings-components', $plugin_url . '/css/admin/frm-settings-components.css', array( 'formidable-admin', 'formidable-grids' ), $version );
802 + wp_register_script( 'formidable-settings-components', $plugin_url . '/js/formidable-settings-components.js', array( 'formidable_admin' ), $version, true );
803 +
804 + if ( ! FrmAppHelper::is_form_builder_page() ) {
805 + return;
806 + }
807 +
808 + wp_enqueue_style( 'formidable-settings-components' );
809 + wp_enqueue_script( 'formidable-settings-components' );
810 + }
811 +
812 + /**
813 + * Avoid loading dropzone CSS on the form list page. It isn't required there.
814 + *
815 + * @since 6.11
816 + *
817 + * @param string $page
818 + * @return void
819 + */
820 + private static function maybe_enqueue_dropzone_css( $page ) {
821 + if ( ! FrmAppHelper::pro_is_installed() ) {
822 + return;
823 + }
824 +
825 + $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
826 + if ( ! $should_avoid_loading_dropzone ) {
827 + wp_enqueue_style( 'formidable-dropzone' );
828 + }
829 + }
830 +
831 + /**
832 + * The floating links are not shown on every page.
833 + * They are also not shown if white labeling is being used.
834 + *
835 + * @since 6.8.4
836 + *
837 + * @return bool
838 + */
839 + private static function should_show_floating_links() {
840 + if ( ! FrmAppHelper::is_formidable_branding() ) {
841 + return false;
842 + }
843 +
844 + return FrmAppHelper::is_formidable_admin() &&
845 + ! FrmAppHelper::is_style_editor_page() &&
846 + ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
847 + ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
848 + }
849 +
850 + /**
773 851 * @since 6.3.2
774 852 *
775 853 * @return void
776 854 */
@@ -776,8 +854,14 @@
776 854 */
777 855 public static function admin_enqueue_scripts() {
778 856 self::load_wp_admin_style();
779 857 self::maybe_force_formidable_block_on_gutenberg_page();
858 +
859 + if ( FrmAppHelper::is_admin_page( 'formidable-settings' ) ) {
860 + wp_enqueue_style( FrmDashboardController::PAGE_SLUG, FrmAppHelper::plugin_url() . '/css/admin/dashboard.css', array(), FrmAppHelper::plugin_version() );
861 + }
862 +
863 + FrmUsageController::load_scripts();
780 864 }
781 865
782 866 /**
783 867 * Enqueue required assets for the Legacy Views editor (Views v4.x).
@@ -813,8 +897,9 @@
813 897 }
814 898 '
815 899 );
816 900 wp_enqueue_style( 'formidable-admin' );
901 + wp_enqueue_script( 'formidable_legacy_views', FrmAppHelper::plugin_url() . '/js/admin/legacy-views.js', array( 'jquery', 'formidable_admin' ), FrmAppHelper::plugin_version() );
817 902 FrmAppHelper::localize_script( 'admin' );
818 903 self::include_info_overlay();
819 904 }
820 905
@@ -846,12 +931,45 @@
846 931 *
847 932 * @return void
848 933 */
849 934 private static function register_popper1() {
935 + if ( ! self::should_register_popper() ) {
936 + return;
937 + }
850 938 wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
851 939 }
852 940
853 941 /**
942 + * Only register popper on Formidable pages.
943 + * This helps to avoid popper conflicts on other plugin pages, including the WP Bakery page editor.
944 + *
945 + * @since 6.11.1
946 + *
947 + * @return bool
948 + */
949 + private static function should_register_popper() {
950 + global $pagenow;
951 +
952 + $post_id = FrmAppHelper::simple_get( 'post', 'absint' );
953 + if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) {
954 + return true;
955 + }
956 +
957 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
958 + $is_views_post_type = 'frm_display' === $post_type;
959 + if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) {
960 + return true;
961 + }
962 +
963 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
964 + if ( strpos( $page, 'formidable' ) === 0 ) {
965 + return true;
966 + }
967 +
968 + return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && FrmAppHelper::simple_get( 'taxonomy' ) === 'frm_application';
969 + }
970 +
971 + /**
854 972 * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set.
855 973 *
856 974 * @since 5.2
857 975 *
@@ -910,10 +1028,10 @@
910 1028 * @return void
911 1029 */
912 1030 public static function create_rest_routes() {
913 1031 $args = array(
914 - 'methods' => 'GET',
915 - 'callback' => 'FrmAppController::api_install',
1032 + 'methods' => 'GET',
1033 + 'callback' => 'FrmAppController::api_install',
916 1034 'permission_callback' => __CLASS__ . '::can_update_db',
917 1035 );
918 1036
919 1037 register_rest_route( 'frm-admin/v1', '/install', $args );
@@ -918,10 +1036,10 @@
918 1036
919 1037 register_rest_route( 'frm-admin/v1', '/install', $args );
920 1038
921 1039 $args = array(
922 - 'methods' => 'GET',
923 - 'callback' => 'FrmAddonsController::install_addon_api',
1040 + 'methods' => 'GET',
1041 + 'callback' => 'FrmAddonsController::install_addon_api',
924 1042 'permission_callback' => 'FrmAddonsController::can_install_addon_api',
925 1043 );
926 1044
927 1045 register_rest_route( 'frm-admin/v1', '/install-addon', $args );
@@ -1034,9 +1152,9 @@
1034 1152
1035 1153 $frmdb = new FrmMigrate();
1036 1154 $frmdb->uninstall();
1037 1155
1038 - //disable the plugin and redirect after uninstall so the tables don't get added right back
1156 + // Disable the plugin and redirect after uninstall so the tables don't get added right back.
1039 1157 $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
1040 1158 deactivate_plugins( $plugins, false, false );
1041 1159 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
1042 1160
@@ -1107,63 +1225,72 @@
1107 1225 *
1108 1226 * @return void
1109 1227 */
1110 1228 public static function add_admin_footer_links() {
1111 - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1112 -
1113 - // Check admin privileges, screen mode, and branding
1114 - $is_not_admin = ! FrmAppHelper::is_formidable_admin() && $post_type !== 'frm_logs';
1115 - $is_full_screen = FrmAppHelper::is_full_screen();
1116 - $is_not_formidable_branding = ! FrmAppHelper::is_formidable_branding();
1117 -
1118 - // Exit if any of the above conditions are met
1119 - if ( $is_not_admin || $is_full_screen || $is_not_formidable_branding ) {
1120 - return;
1229 + FrmFormsController::include_device_too_small_message();
1230 + if ( self::should_show_footer_links() ) {
1231 + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1121 1232 }
1122 -
1123 - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1124 1233 }
1125 1234
1126 1235 /**
1127 - * @deprecated 3.0.04
1236 + * Check if the footer links should be shown.
1128 1237 *
1129 - * @codeCoverageIgnore
1238 + * @since 6.7
1130 1239 *
1131 - * @return void
1240 + * @return bool
1132 1241 */
1133 - public static function activation_install() {
1134 - FrmDeprecated::activation_install();
1135 - }
1242 + private static function should_show_footer_links() {
1243 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1244 + $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type;
1245 + $show_footer_links = $is_formidable_page;
1246 + if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) {
1247 + $show_footer_links = false;
1248 + }
1136 1249
1137 - /**
1138 - * @deprecated 3.0
1139 - * @codeCoverageIgnore
1140 - */
1141 - public static function page_route( $content ) {
1142 - return FrmDeprecated::page_route( $content );
1250 + /**
1251 + * Filter whether to show the Formidable footer links.
1252 + *
1253 + * @since 6.7
1254 + *
1255 + * @param bool $show_footer_links
1256 + * @return bool
1257 + */
1258 + return apply_filters( 'frm_show_footer_links', $show_footer_links );
1143 1259 }
1144 1260
1145 1261 /**
1146 - * Include icons on page for Embed Form modal.
1262 + * Show an error modal and terminate the script execution.
1147 1263 *
1148 - * @since 5.2
1264 + * @since 6.7
1149 1265 *
1266 + * @param array $error_args Arguments that control the behavior of the error modal.
1267 + *
1150 1268 * @return void
1151 1269 */
1152 - public static function include_embed_form_icons() {
1153 - _deprecated_function( __METHOD__, '5.3' );
1154 - }
1270 + public static function show_error_modal( $error_args ) {
1271 + add_filter( 'frm_show_footer_links', '__return_false' );
1155 1272
1156 - /**
1157 - * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13.
1158 - * @codeCoverageIgnore
1159 - *
1160 - * @param array $atts
1161 - * @return string
1162 - */
1163 - public static function get_form_shortcode( $atts ) {
1164 - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1165 - return FrmFormsController::get_form_shortcode( $atts );
1273 + $defaults = array(
1274 + 'title' => '',
1275 + 'body' => '',
1276 + 'cancel_url' => '',
1277 + 'cancel_classes' => '',
1278 + 'continue_url' => '',
1279 + 'continue_classes' => '',
1280 + 'icon' => 'frm_lock_simple',
1281 + );
1282 +
1283 + $error_args = wp_parse_args( $error_args, $defaults );
1284 + if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) {
1285 + $error_args['cancel_text'] = __( 'Cancel', 'formidable' );
1286 + }
1287 +
1288 + if ( ! isset( $error_args['continue_text'] ) && ! empty( $error_args['continue_url'] ) ) {
1289 + $error_args['continue_text'] = __( 'Continue', 'formidable' );
1290 + }
1291 +
1292 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php';
1166 1293 }
1167 1294
1168 1295 /**
1169 1296 * Handles Floating Links' scripts and styles enqueueing.
@@ -1183,9 +1310,9 @@
1183 1310 // Enqueue the Floating Links styles.
1184 1311 wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1185 1312
1186 1313 // Enqueue the Floating Links script.
1187 - wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1314 + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array( 'formidable_admin' ), $version, true );
1188 1315
1189 1316 // Enqueue the config script.
1190 1317 wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1191 1318
@@ -1196,6 +1323,229 @@
1196 1323 $floating_links_data = array(
1197 1324 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1198 1325 );
1199 1326 wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1327 +
1328 + /**
1329 + * Prompt Pro to load additional floating links scripts.
1330 + * This is used to include images in the Inbox SlideIn when Pro is active.
1331 + *
1332 + * @since 6.8.4
1333 + */
1334 + do_action( 'frm_enqueue_floating_links' );
1335 + }
1336 +
1337 + /**
1338 + * Check if we are in our admin pages.
1339 + *
1340 + * @return bool
1341 + */
1342 + private static function in_our_pages() {
1343 + global $current_screen, $pagenow;
1344 + if ( FrmAppHelper::is_formidable_admin() ) {
1345 + return true;
1346 + }
1347 +
1348 + if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) {
1349 + return true;
1350 + }
1351 +
1352 + if ( in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' ) ) {
1353 + return true;
1354 + }
1355 +
1356 + return false;
1357 + }
1358 +
1359 + /**
1360 + * Handles actions related to the current screen.
1361 + *
1362 + * @since 6.19
1363 + *
1364 + * @return void
1365 + */
1366 + public static function handle_current_screen() {
1367 + if ( ! self::in_our_pages() ) {
1368 + return;
1369 + }
1370 +
1371 + self::filter_admin_notices();
1372 + self::remember_custom_sort();
1373 + }
1374 +
1375 + /**
1376 + * Hide all third-parties admin notices only in our admin pages.
1377 + *
1378 + * @return void
1379 + */
1380 + public static function filter_admin_notices() {
1381 + $actions = array(
1382 + 'admin_notices',
1383 + 'network_admin_notices',
1384 + 'user_admin_notices',
1385 + 'all_admin_notices',
1386 + );
1387 +
1388 + global $wp_filter;
1389 +
1390 + foreach ( $actions as $action ) {
1391 + if ( empty( $wp_filter[ $action ]->callbacks ) ) {
1392 + continue;
1393 + }
1394 + foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) {
1395 + foreach ( $callbacks as $callback_name => $callback ) {
1396 + if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) {
1397 + continue;
1398 + }
1399 + unset( $wp_filter[ $action ]->callbacks[ $priority ][ $callback_name ] );
1400 + }
1401 + }
1402 + }
1403 + }
1404 +
1405 + /**
1406 + * Remembers and applies user-specific sorting preferences.
1407 + *
1408 + * @return void
1409 + */
1410 + private static function remember_custom_sort() {
1411 + $screen = get_current_screen();
1412 + if ( ! $screen ) {
1413 + return;
1414 + }
1415 +
1416 + if ( ! FrmAppHelper::is_admin_list_page() && ! FrmAppHelper::is_admin_list_page( 'formidable-entries' ) ) {
1417 + return;
1418 + }
1419 +
1420 + $orderby = FrmAppHelper::get_param( 'orderby' );
1421 +
1422 + if ( ! $orderby ) {
1423 + return;
1424 + }
1425 +
1426 + $user_id = get_current_user_id();
1427 + $meta_key = 'frm_preferred_list_sort_' . $screen->id;
1428 + $order = FrmAppHelper::get_param( 'order' );
1429 +
1430 + $new_sort = array(
1431 + 'orderby' => $orderby,
1432 + 'order' => $order,
1433 + );
1434 +
1435 + $current_sort = get_user_meta( $user_id, $meta_key, true );
1436 +
1437 + if ( $new_sort !== $current_sort ) {
1438 + update_user_meta(
1439 + $user_id,
1440 + $meta_key,
1441 + array(
1442 + 'orderby' => $orderby,
1443 + 'order' => $order,
1444 + )
1445 + );
1446 + }
1447 + }
1448 +
1449 + /**
1450 + * Retrieve and apply any saved sorting preferences for the current screen.
1451 + *
1452 + * @since 6.19
1453 + *
1454 + * @param string &$orderby Reference to the current 'orderby' parameter.
1455 + * @param string &$order Reference to the current 'order' parameter.
1456 + * @return void
1457 + */
1458 + public static function apply_saved_sort_preference( &$orderby, &$order ) {
1459 + if ( ! function_exists( 'get_current_screen' ) ) {
1460 + return;
1461 + }
1462 +
1463 + $screen = get_current_screen();
1464 + if ( ! $screen ) {
1465 + return;
1466 + }
1467 +
1468 + $user_id = get_current_user_id();
1469 + $preferred_list_sort = get_user_meta( $user_id, 'frm_preferred_list_sort_' . $screen->id, true );
1470 +
1471 + if ( is_array( $preferred_list_sort ) && ! empty( $preferred_list_sort['orderby'] ) ) {
1472 + $orderby = $preferred_list_sort['orderby'];
1473 +
1474 + if ( ! empty( $preferred_list_sort['order'] ) ) {
1475 + $order = $preferred_list_sort['order'];
1476 + }
1477 + }
1478 + }
1479 +
1480 + /**
1481 + * Validate that the callback name is ours not from third-party.
1482 + *
1483 + * @param string $callback_name WordPress callback name.
1484 + *
1485 + * @return bool
1486 + */
1487 + private static function is_our_callback_string( $callback_name ) {
1488 + return 0 === stripos( $callback_name, 'frm' );
1489 + }
1490 +
1491 + /**
1492 + * Validate that the callback array is ours not from third-party.
1493 + *
1494 + * @param array $callback WordPress callback array.
1495 + *
1496 + * @return bool
1497 + */
1498 + private static function is_our_callback_array( $callback ) {
1499 + return ! empty( $callback['function'] ) &&
1500 + is_array( $callback['function'] ) &&
1501 + ! empty( $callback['function'][0] ) &&
1502 + self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] );
1503 + }
1504 +
1505 + /**
1506 + * In some cases, the DB tables may fail to install.
1507 + * This function tries to add them again when the user clicks the link to try again
1508 + * from the given inbox notice.
1509 + *
1510 + * @since 6.19
1511 + */
1512 + private static function add_missing_tables() {
1513 + FrmAppHelper::permission_check( 'frm_view_forms' );
1514 +
1515 + $inbox = new FrmInbox();
1516 + $error = $inbox->check_for_error();
1517 +
1518 + if ( ! $error || 'failed-to-create-tables' !== $error['key'] ) {
1519 + // Confirm the inbox item with this CTA exists.
1520 + wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1521 + exit;
1522 + }
1523 +
1524 + global $wpdb;
1525 + $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->prefix . 'frm_forms' ) );
1526 +
1527 + if ( $exists ) {
1528 + // Exit early if the table already exists.
1529 + wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1530 + exit;
1531 + }
1532 +
1533 + delete_option( 'frm_db_version' );
1534 + wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1535 + exit;
1536 + }
1537 +
1538 + /**
1539 + * Handles the small screen proceed action.
1540 + *
1541 + * @since 6.21
1542 + *
1543 + * @return void
1544 + */
1545 + public static function small_screen_proceed() {
1546 + FrmAppHelper::permission_check( 'frm_view_forms' );
1547 + check_ajax_referer( 'frm_ajax', 'nonce' );
1548 + update_user_option( get_current_user_id(), 'frm_ignore_small_screen_warning', true );
1549 + wp_send_json_success();
1200 1550 }
1201 1551 }