PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.18
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.18
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 +420 -199 6.56.18 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 - if ( ! class_exists( 'FrmTransHooksController', false ) ) {
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,9 +346,23 @@
292 346 public static function settings_link( $links ) {
293 347 $settings = array();
294 348
295 349 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>';
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::admin_upgrade_link( 'plugin-row' );
362 + }
363 +
364 + $settings[] = '<a href="' . esc_url( $upgrade_link ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>';
297 365 }
298 366
299 367 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
300 368
@@ -305,9 +373,9 @@
305 373 * @return void
306 374 */
307 375 public static function pro_get_started_headline() {
308 376 self::review_request();
309 - FrmAppHelper::min_pro_version_notice( '4.0' );
377 + FrmAppHelper::min_pro_version_notice( '6.0' );
310 378 }
311 379
312 380 /**
313 381 * Add admin notices as needed for reviews
@@ -374,63 +442,26 @@
374 442 $shared_path = $plugin_path . '/classes/views/shared/';
375 443
376 444 include $shared_path . 'upgrade_overlay.php';
377 445 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 446 }
383 447
384 448 /**
449 + * Create a basic form with an email field.
450 + *
451 + * @param string $form_key
452 + * @param string $title
453 + * @param string $description
385 454 * @return void
386 455 */
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 - )
456 + public static function api_email_form( $form_key, $title = '', $description = '' ) {
457 + $user = wp_get_current_user();
458 + $args = array(
459 + 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css',
460 + 'title' => $title,
461 + 'description' => $description,
402 462 );
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';
463 + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php';
433 464 }
434 465
435 466 /**
436 467 * @return void
@@ -454,9 +485,8 @@
454 485 */
455 486 public static function remove_upsells() {
456 487 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
457 488 remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
458 - remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
459 489 remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
460 490 }
461 491
462 492 /**
@@ -478,9 +508,9 @@
478 508 /**
479 509 * Check if the database is outdated
480 510 *
481 511 * @since 2.0.1
482 - * @return boolean
512 + * @return bool
483 513 */
484 514 public static function needs_update() {
485 515 $needs_upgrade = self::compare_for_update(
486 516 array(
@@ -527,8 +557,12 @@
527 557 *
528 558 * @return void
529 559 */
530 560 public static function admin_init() {
561 + if ( FrmAppHelper::get_param( 'delete_all' ) && FrmAppHelper::is_admin_page( 'formidable' ) && 'trash' === FrmAppHelper::get_param( 'form_type' ) ) {
562 + FrmFormsController::delete_all();
563 + }
564 +
531 565 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
532 566 FrmFormsController::duplicate();
533 567 }
534 568
@@ -536,10 +570,26 @@
536 570 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
537 571 FrmStylesController::save_style();
538 572 }
539 573
540 - new FrmPersonalData(); // register personal data hooks
574 + if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) {
575 + $redirect = FrmSalesApi::get_best_sale_value( 'menu_cta_link' );
576 + if ( ! $redirect ) {
577 + $redirct = FrmAppHelper::admin_upgrade_link(
578 + array(
579 + 'medium' => 'upgrade',
580 + 'content' => 'submenu-upgrade',
581 + )
582 + );
583 + }
541 584
585 + wp_redirect( $redirect );
586 + die();
587 + }
588 +
589 + // Register personal data hooks.
590 + new FrmPersonalData();
591 +
542 592 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
543 593 self::network_upgrade_site();
544 594 }
545 595
@@ -547,82 +597,51 @@
547 597 // don't continue during ajax calls
548 598 self::admin_js();
549 599 }
550 600
601 + self::trigger_page_load_hooks();
602 +
551 603 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
552 - $action = FrmAppHelper::get_param( 'frm_action' );
604 + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
605 + // This provides backward compatibility for old addons that use legacy modal templates.
606 + $action = FrmAppHelper::get_param( 'frm_action' );
607 + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
608 + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
609 + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
610 + $url_param = $application_id ? '&applicationId=' . $application_id : '';
553 611
554 - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
555 - wp_safe_redirect( admin_url( 'admin.php?page=formidable&triggerNewFormModal=1' ) );
612 + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
556 613 exit;
557 614 }
558 615
559 616 FrmInbox::maybe_disable_screen_options();
560 617 }
561 -
562 - self::maybe_add_ip_warning();
563 618 }
564 619
565 620 /**
566 - * Show a warning for the IP address setting if it hasn't been set.
621 + * Get the current page and check for a possible function to trigger.
622 + * If a class name matches the page name, and the class has a load_page() method, trigger it.
567 623 *
568 - * @since 6.1
624 + * @since 6.8
569 625 *
570 626 * @return void
571 627 */
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.
628 + private static function trigger_page_load_hooks() {
629 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
630 + if ( strpos( $page, 'formidable-' ) !== 0 ) {
631 + // Only trigger hooks on Formidable pages.
576 632 return;
577 633 }
578 634
579 - if ( ! self::is_behind_proxy() ) {
580 - // This message is only applicable when using a reverse proxy.
581 - return;
635 + $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page );
636 + $page = str_replace( ' ', '', ucwords( $page ) );
637 + $class = 'Frm' . $page . 'Controller';
638 + if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) {
639 + call_user_func( array( $class, 'load_page' ) );
582 640 }
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 641 }
598 642
599 643 /**
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 644 * @return void
626 645 */
627 646 public static function admin_js() {
628 647 $plugin_url = FrmAppHelper::plugin_url();
@@ -629,8 +648,17 @@
629 648 $version = FrmAppHelper::plugin_version();
630 649
631 650 FrmAppHelper::load_admin_wide_js();
632 651
652 + // Register component assets early to ensure they can be enqueued later in controllers.
653 + wp_register_style( 'formidable-animations', $plugin_url . '/css/admin/animations.css', array(), $version );
654 +
655 + if ( class_exists( 'FrmOverlayController' ) ) {
656 + // This should always exist.
657 + // But it may not have loaded properly when updating the plugin.
658 + FrmOverlayController::register_assets();
659 + }
660 +
633 661 wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version );
634 662 wp_enqueue_style( 'formidable_admin_global' );
635 663
636 664 wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version );
@@ -639,28 +667,19 @@
639 667 wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
640 668 wp_register_script( 'formidable_embed', $plugin_url . '/js/admin/embed.js', array( 'formidable_dom', 'jquery-ui-autocomplete' ), $version, true );
641 669 self::register_popper1();
642 670 wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
671 +
672 + $settings_js_vars = array(
673 + 'currencies' => FrmCurrencyHelper::get_currencies(),
674 + );
643 675 wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
676 + wp_localize_script( 'formidable_settings', 'frmSettings', $settings_js_vars );
644 677
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() ) {
678 + if ( self::should_show_floating_links() ) {
654 679 self::enqueue_floating_links( $plugin_url, $version );
655 680 }
656 - unset( $is_valid_page );
657 681
658 - if ( 'formidable-applications' === $page ) {
659 - FrmApplicationsController::load_assets();
660 - return;
661 - }
662 -
663 682 $dependencies = array(
664 683 'formidable_admin_global',
665 684 'jquery',
666 685 'jquery-ui-core',
@@ -668,9 +687,10 @@
668 687 'jquery-ui-sortable',
669 688 'bootstrap_tooltip',
670 689 'bootstrap-multiselect',
671 690 'wp-i18n',
672 - 'wp-hooks', // Required in WP versions older than 5.7
691 + // Required in WP versions older than 5.7
692 + 'wp-hooks',
673 693 'formidable_dom',
674 694 'formidable_embed',
675 695 );
676 696
@@ -687,8 +707,20 @@
687 707 }
688 708
689 709 wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
690 710
711 + if ( ! class_exists( 'FrmTransHooksController', false ) ) {
712 + /**
713 + * Gateway fields are included for add-on compatibility but we do not want it to be visible.
714 + * They do however need to be visible when the payments submodule is active.
715 + */
716 + wp_add_inline_style(
717 + 'formidable-admin',
718 + '#frm_builder_page li[data-ftype="gateway"] { display: none; }'
719 + );
720 + }
721 +
722 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
691 723 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
692 724
693 725 global $pagenow;
694 726 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
@@ -696,15 +728,18 @@
696 728 wp_enqueue_script( 'admin-widgets' );
697 729 wp_enqueue_style( 'widgets' );
698 730 self::maybe_deregister_popper2();
699 731 wp_enqueue_script( 'formidable_admin' );
732 + wp_set_script_translations( 'formidable_admin', 'formidable' );
700 733 wp_enqueue_script( 'formidable_embed' );
734 + wp_set_script_translations( 'formidable_embed', 'formidable' );
701 735 FrmAppHelper::localize_script( 'admin' );
702 736
737 + wp_enqueue_style( 'formidable-animations' );
703 738 wp_enqueue_style( 'formidable-admin' );
704 739 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
705 740 wp_enqueue_style( 'formidable-grids' );
706 - wp_enqueue_style( 'formidable-dropzone' );
741 + self::maybe_enqueue_dropzone_css( $page );
707 742 } else {
708 743 wp_enqueue_style( 'formidable-grids' );
709 744 }
710 745
@@ -710,8 +745,12 @@
710 745
711 746 if ( 'formidable-entries' === $page ) {
712 747 // Load front end js for entries.
713 748 wp_enqueue_script( 'formidable' );
749 +
750 + // Registers and enqueues the entries page scripts.
751 + wp_register_script( 'formidable_entries', $plugin_url . '/js/admin/entries.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
752 + wp_enqueue_script( 'formidable_entries' );
714 753 }
715 754
716 755 do_action( 'frm_enqueue_builder_scripts' );
717 756 self::include_upgrade_overlay();
@@ -731,13 +770,55 @@
731 770
732 771 if ( $post_type === 'frm_display' ) {
733 772 self::enqueue_legacy_views_assets();
734 773 }
774 + }//end if
775 +
776 + if ( 'formidable-addons' === $page ) {
777 + wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
778 + wp_enqueue_script( 'formidable_addons' );
735 779 }
780 + }
736 781
782 + /**
783 + * Avoid loading dropzone CSS on the form list page. It isn't required there.
784 + *
785 + * @since 6.11
786 + *
787 + * @param string $page
788 + * @return void
789 + */
790 + private static function maybe_enqueue_dropzone_css( $page ) {
791 + if ( ! FrmAppHelper::pro_is_installed() ) {
792 + return;
793 + }
794 +
795 + $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
796 + if ( ! $should_avoid_loading_dropzone ) {
797 + wp_enqueue_style( 'formidable-dropzone' );
798 + }
737 799 }
738 800
739 801 /**
802 + * The floating links are not shown on every page.
803 + * They are also not shown if white labeling is being used.
804 + *
805 + * @since 6.8.4
806 + *
807 + * @return bool
808 + */
809 + private static function should_show_floating_links() {
810 + if ( ! FrmAppHelper::is_formidable_branding() ) {
811 + return false;
812 + }
813 +
814 + return FrmAppHelper::is_formidable_admin() &&
815 + ! FrmAppHelper::is_style_editor_page() &&
816 + ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
817 + ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
818 + }
819 +
820 + /**
740 821 * @since 6.3.2
741 822 *
742 823 * @return void
743 824 */
@@ -743,8 +824,14 @@
743 824 */
744 825 public static function admin_enqueue_scripts() {
745 826 self::load_wp_admin_style();
746 827 self::maybe_force_formidable_block_on_gutenberg_page();
828 +
829 + if ( FrmAppHelper::is_admin_page( 'formidable-settings' ) ) {
830 + wp_enqueue_style( FrmDashboardController::PAGE_SLUG, FrmAppHelper::plugin_url() . '/css/admin/dashboard.css', array(), FrmAppHelper::plugin_version() );
831 + }
832 +
833 + FrmUsageController::load_scripts();
747 834 }
748 835
749 836 /**
750 837 * Enqueue required assets for the Legacy Views editor (Views v4.x).
@@ -813,12 +900,45 @@
813 900 *
814 901 * @return void
815 902 */
816 903 private static function register_popper1() {
904 + if ( ! self::should_register_popper() ) {
905 + return;
906 + }
817 907 wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
818 908 }
819 909
820 910 /**
911 + * Only register popper on Formidable pages.
912 + * This helps to avoid popper conflicts on other plugin pages, including the WP Bakery page editor.
913 + *
914 + * @since 6.11.1
915 + *
916 + * @return bool
917 + */
918 + private static function should_register_popper() {
919 + global $pagenow;
920 +
921 + $post_id = FrmAppHelper::simple_get( 'post', 'absint' );
922 + if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) {
923 + return true;
924 + }
925 +
926 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
927 + $is_views_post_type = 'frm_display' === $post_type;
928 + if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) {
929 + return true;
930 + }
931 +
932 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
933 + if ( strpos( $page, 'formidable' ) === 0 ) {
934 + return true;
935 + }
936 +
937 + return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && FrmAppHelper::simple_get( 'taxonomy' ) === 'frm_application';
938 + }
939 +
940 + /**
821 941 * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set.
822 942 *
823 943 * @since 5.2
824 944 *
@@ -877,10 +997,10 @@
877 997 * @return void
878 998 */
879 999 public static function create_rest_routes() {
880 1000 $args = array(
881 - 'methods' => 'GET',
882 - 'callback' => 'FrmAppController::api_install',
1001 + 'methods' => 'GET',
1002 + 'callback' => 'FrmAppController::api_install',
883 1003 'permission_callback' => __CLASS__ . '::can_update_db',
884 1004 );
885 1005
886 1006 register_rest_route( 'frm-admin/v1', '/install', $args );
@@ -885,10 +1005,10 @@
885 1005
886 1006 register_rest_route( 'frm-admin/v1', '/install', $args );
887 1007
888 1008 $args = array(
889 - 'methods' => 'GET',
890 - 'callback' => 'FrmAddonsController::install_addon_api',
1009 + 'methods' => 'GET',
1010 + 'callback' => 'FrmAddonsController::install_addon_api',
891 1011 'permission_callback' => 'FrmAddonsController::can_install_addon_api',
892 1012 );
893 1013
894 1014 register_rest_route( 'frm-admin/v1', '/install-addon', $args );
@@ -1001,9 +1121,9 @@
1001 1121
1002 1122 $frmdb = new FrmMigrate();
1003 1123 $frmdb->uninstall();
1004 1124
1005 - //disable the plugin and redirect after uninstall so the tables don't get added right back
1125 + // Disable the plugin and redirect after uninstall so the tables don't get added right back.
1006 1126 $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
1007 1127 deactivate_plugins( $plugins, false, false );
1008 1128 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
1009 1129
@@ -1074,63 +1194,71 @@
1074 1194 *
1075 1195 * @return void
1076 1196 */
1077 1197 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;
1198 + if ( self::should_show_footer_links() ) {
1199 + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1088 1200 }
1089 -
1090 - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1091 1201 }
1092 1202
1093 1203 /**
1094 - * @deprecated 3.0.04
1204 + * Check if the footer links should be shown.
1095 1205 *
1096 - * @codeCoverageIgnore
1206 + * @since 6.7
1097 1207 *
1098 - * @return void
1208 + * @return bool
1099 1209 */
1100 - public static function activation_install() {
1101 - FrmDeprecated::activation_install();
1102 - }
1210 + private static function should_show_footer_links() {
1211 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1212 + $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type;
1213 + $show_footer_links = $is_formidable_page;
1214 + if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) {
1215 + $show_footer_links = false;
1216 + }
1103 1217
1104 - /**
1105 - * @deprecated 3.0
1106 - * @codeCoverageIgnore
1107 - */
1108 - public static function page_route( $content ) {
1109 - return FrmDeprecated::page_route( $content );
1218 + /**
1219 + * Filter whether to show the Formidable footer links.
1220 + *
1221 + * @since 6.7
1222 + *
1223 + * @param bool $show_footer_links
1224 + * @return bool
1225 + */
1226 + return apply_filters( 'frm_show_footer_links', $show_footer_links );
1110 1227 }
1111 1228
1112 1229 /**
1113 - * Include icons on page for Embed Form modal.
1230 + * Show an error modal and terminate the script execution.
1114 1231 *
1115 - * @since 5.2
1232 + * @since 6.7
1116 1233 *
1234 + * @param array $error_args Arguments that control the behavior of the error modal.
1235 + *
1117 1236 * @return void
1118 1237 */
1119 - public static function include_embed_form_icons() {
1120 - _deprecated_function( __METHOD__, '5.3' );
1121 - }
1238 + public static function show_error_modal( $error_args ) {
1239 + add_filter( 'frm_show_footer_links', '__return_false' );
1122 1240
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 );
1241 + $defaults = array(
1242 + 'title' => '',
1243 + 'body' => '',
1244 + 'cancel_url' => '',
1245 + 'cancel_classes' => '',
1246 + 'continue_url' => '',
1247 + 'continue_classes' => '',
1248 + 'icon' => 'frm_lock_simple',
1249 + );
1250 +
1251 + $error_args = wp_parse_args( $error_args, $defaults );
1252 + if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) {
1253 + $error_args['cancel_text'] = __( 'Cancel', 'formidable' );
1254 + }
1255 +
1256 + if ( ! isset( $error_args['continue_text'] ) && ! empty( $error_args['continue_url'] ) ) {
1257 + $error_args['continue_text'] = __( 'Continue', 'formidable' );
1258 + }
1259 +
1260 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php';
1133 1261 }
1134 1262
1135 1263 /**
1136 1264 * Handles Floating Links' scripts and styles enqueueing.
@@ -1150,15 +1278,108 @@
1150 1278 // Enqueue the Floating Links styles.
1151 1279 wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1152 1280
1153 1281 // 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 );
1282 + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array( 'formidable_admin' ), $version, true );
1155 1283
1156 1284 // Enqueue the config script.
1157 1285 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-' );
1286 +
1287 + if ( function_exists( 'wp_set_script_translations' ) ) {
1288 + wp_set_script_translations( 's11-floating-links-config', 's11-' );
1289 + }
1290 +
1159 1291 $floating_links_data = array(
1160 1292 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1161 1293 );
1162 1294 wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1295 +
1296 + /**
1297 + * Prompt Pro to load additional floating links scripts.
1298 + * This is used to include images in the Inbox SlideIn when Pro is active.
1299 + *
1300 + * @since 6.8.4
1301 + */
1302 + do_action( 'frm_enqueue_floating_links' );
1303 + }
1304 +
1305 + /**
1306 + * Check if we are in our admin pages.
1307 + *
1308 + * @return bool
1309 + */
1310 + private static function in_our_pages() {
1311 + global $current_screen, $pagenow;
1312 + if ( FrmAppHelper::is_formidable_admin() ) {
1313 + return true;
1314 + }
1315 +
1316 + if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) {
1317 + return true;
1318 + }
1319 +
1320 + if ( in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' ) ) {
1321 + return true;
1322 + }
1323 +
1324 + return false;
1325 + }
1326 +
1327 + /**
1328 + * Hide all third-parties admin notices only in our admin pages.
1329 + *
1330 + * @return void
1331 + */
1332 + public static function filter_admin_notices() {
1333 + if ( ! self::in_our_pages() ) {
1334 + return;
1335 + }
1336 +
1337 + $actions = array(
1338 + 'admin_notices',
1339 + 'network_admin_notices',
1340 + 'user_admin_notices',
1341 + 'all_admin_notices',
1342 + );
1343 +
1344 + global $wp_filter;
1345 +
1346 + foreach ( $actions as $action ) {
1347 + if ( empty( $wp_filter[ $action ]->callbacks ) ) {
1348 + continue;
1349 + }
1350 + foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) {
1351 + foreach ( $callbacks as $callback_name => $callback ) {
1352 + if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) {
1353 + continue;
1354 + }
1355 + unset( $wp_filter[ $action ]->callbacks[ $priority ][ $callback_name ] );
1356 + }
1357 + }
1358 + }
1359 + }
1360 +
1361 + /**
1362 + * Validate that the callback name is ours not from third-party.
1363 + *
1364 + * @param string $callback_name WordPress callback name.
1365 + *
1366 + * @return bool
1367 + */
1368 + private static function is_our_callback_string( $callback_name ) {
1369 + return 0 === stripos( $callback_name, 'frm' );
1370 + }
1371 +
1372 + /**
1373 + * Validate that the callback array is ours not from third-party.
1374 + *
1375 + * @param array $callback WordPress callback array.
1376 + *
1377 + * @return bool
1378 + */
1379 + private static function is_our_callback_array( $callback ) {
1380 + return ! empty( $callback['function'] ) &&
1381 + is_array( $callback['function'] ) &&
1382 + ! empty( $callback['function'][0] ) &&
1383 + self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] );
1163 1384 }
1164 1385 }