PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
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 +149 -498 6.256.7 View file →
@@ -14,13 +14,8 @@
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 -
23 18 add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
24 19 }
25 20
26 21 /**
@@ -66,20 +61,14 @@
66 61 $classes .= ' frm-admin-page-' . $page;
67 62 }
68 63 }
69 64
70 - if ( self::is_grey_page() ) {
71 - $classes .= ' frm-grey-body ';
72 - }
73 -
74 65 if ( FrmAppHelper::is_full_screen() ) {
75 66 $full_screen_on = self::get_full_screen_setting();
76 - $add_class = '';
67 + $add_class = '';
77 68 if ( $full_screen_on ) {
78 69 $add_class = ' frm-full-screen is-fullscreen-mode';
79 -
80 - // Load the CSS for .is-fullscreen-mode.
81 - wp_enqueue_style( 'wp-edit-post' );
70 + wp_enqueue_style( 'wp-edit-post' ); // Load the CSS for .is-fullscreen-mode.
82 71 }
83 72 $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
84 73 }
85 74
@@ -139,8 +128,9 @@
139 128 'formidable',
140 129 'formidable-entries',
141 130 'formidable-views',
142 131 'formidable-views-editor',
132 + 'formidable-pro-upgrade',
143 133 'formidable-addons',
144 134 'formidable-import',
145 135 'formidable-settings',
146 136 'formidable-styles',
@@ -145,10 +135,11 @@
145 135 'formidable-settings',
146 136 'formidable-styles',
147 137 'formidable-styles2',
148 138 'formidable-inbox',
139 + 'formidable-welcome',
140 + 'formidable-applications',
149 141 FrmFormTemplatesController::PAGE_SLUG,
150 - FrmOnboardingWizardController::PAGE_SLUG,
151 142 );
152 143
153 144 if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
154 145 // Only consider the payments page as a "white page" when the Payments submodule is off.
@@ -160,10 +151,16 @@
160 151 $white_pages[] = 'formidable-payments';
161 152 }
162 153 }
163 154
164 - $is_white_page = self::is_page_in_list( $white_pages ) || self::is_grey_page() || FrmAppHelper::is_view_builder_page();
155 + $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
156 + $is_white_page = in_array( $get_page, $white_pages, true );
165 157
158 + if ( ! $is_white_page ) {
159 + $screen = get_current_screen();
160 + $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
161 + }
162 +
166 163 /**
167 164 * Allow another add on to style a page as a Formidable "white page", which adds a white background color.
168 165 *
169 166 * @since 5.3
@@ -175,46 +172,8 @@
175 172 return $is_white_page;
176 173 }
177 174
178 175 /**
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 - /**
217 176 * @return void
218 177 */
219 178 public static function load_wp_admin_style() {
220 179 FrmAppHelper::load_font_style();
@@ -220,11 +179,10 @@
220 179 FrmAppHelper::load_font_style();
221 180 }
222 181
223 182 /**
224 - * @param int|object $form
225 - * @param bool $show_nav
226 - * @param string $title
183 + * @param bool $show_nav
184 + * @param string $title
227 185 *
228 186 * @psalm-param 'hide'|'show' $title
229 187 *
230 188 * @return void
@@ -243,9 +201,9 @@
243 201 $id = $form->id;
244 202 $current_page = self::get_current_page();
245 203 $nav_items = self::get_form_nav_items( $form );
246 204
247 - include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php';
205 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
248 206 }
249 207
250 208 /**
251 209 * @return string
@@ -299,18 +257,18 @@
299 257 'permission' => 'frm_view_entries',
300 258 ),
301 259 );
302 260
303 - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed();
261 + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed();
304 262
305 263 if ( ! $views_installed ) {
306 264 $nav_items[] = array(
307 - 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
308 - 'label' => __( 'Views', 'formidable' ),
309 - 'current' => array(),
310 - 'page' => 'formidable-views',
265 + 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
266 + 'label' => __( 'Views', 'formidable' ),
267 + 'current' => array(),
268 + 'page' => 'formidable-views',
311 269 'permission' => 'frm_view_entries',
312 - 'atts' => array(
270 + 'atts' => array(
313 271 'class' => 'frm_noallow',
314 272 ),
315 273 );
316 274 }
@@ -317,14 +275,14 @@
317 275
318 276 // Let people know reports and views exist.
319 277 if ( ! FrmAppHelper::pro_is_installed() ) {
320 278 $nav_items[] = array(
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',
279 + 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ),
280 + 'label' => __( 'Reports', 'formidable' ),
281 + 'current' => array( 'reports' ),
282 + 'page' => 'formidable',
325 283 'permission' => 'frm_view_entries',
326 - 'atts' => array(
284 + 'atts' => array(
327 285 'class' => 'frm_noallow',
328 286 ),
329 287 );
330 288 }
@@ -336,12 +294,10 @@
336 294
337 295 return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
338 296 }
339 297
298 + // Adds a settings link to the plugins page
340 299 /**
341 - * Adds a settings link to the plugins page
342 - *
343 - * @param array $links
344 300 * @return array
345 301 */
346 302 public static function settings_link( $links ) {
347 303 $settings = array();
@@ -346,25 +302,10 @@
346 302 public static function settings_link( $links ) {
347 303 $settings = array();
348 304
349 305 if ( ! FrmAppHelper::pro_is_installed() ) {
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>';
306 + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' );
307 + $settings[] = '<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-row' ) ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>';
367 308 }
368 309
369 310 $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
370 311
@@ -375,9 +316,9 @@
375 316 * @return void
376 317 */
377 318 public static function pro_get_started_headline() {
378 319 self::review_request();
379 - FrmAppHelper::min_pro_version_notice( '6.0' );
320 + FrmAppHelper::min_pro_version_notice( '4.0' );
380 321 }
381 322
382 323 /**
383 324 * Add admin notices as needed for reviews
@@ -454,10 +395,10 @@
454 395 * @param string $title
455 396 * @param string $description
456 397 * @return void
457 398 */
458 - public static function api_email_form( $form_key, $title = '', $description = '' ) {
459 - $user = wp_get_current_user();
399 + public static function api_email_form( $form_key, $title, $description ) {
400 + $user = wp_get_current_user();
460 401 $args = array(
461 402 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css',
462 403 'title' => $title,
463 404 'description' => $description,
@@ -486,9 +427,10 @@
486 427 * @return void
487 428 */
488 429 public static function remove_upsells() {
489 430 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
490 - remove_action( 'frm_after_settings_tabs', 'FrmSettingsController::settings_cta' );
431 + remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
432 + remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
491 433 remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
492 434 }
493 435
494 436 /**
@@ -510,9 +452,9 @@
510 452 /**
511 453 * Check if the database is outdated
512 454 *
513 455 * @since 2.0.1
514 - * @return bool
456 + * @return boolean
515 457 */
516 458 public static function needs_update() {
517 459 $needs_upgrade = self::compare_for_update(
518 460 array(
@@ -559,45 +501,19 @@
559 501 *
560 502 * @return void
561 503 */
562 504 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 -
567 505 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
568 506 FrmFormsController::duplicate();
569 507 }
570 508
571 - if ( FrmAppHelper::is_admin_page( 'formidable' ) && FrmAppHelper::simple_get( 'frm_add_tables' ) ) {
572 - self::add_missing_tables();
573 - }
574 -
575 509 if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) {
576 510 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
577 511 FrmStylesController::save_style();
578 512 }
579 513
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 - );
514 + new FrmPersonalData(); // register personal data hooks
586 515
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 -
600 516 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
601 517 self::network_upgrade_site();
602 518 }
603 519
@@ -605,18 +521,16 @@
605 521 // don't continue during ajax calls
606 522 self::admin_js();
607 523 }
608 524
609 - self::trigger_page_load_hooks();
610 -
611 525 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
612 526 // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
613 527 // This provides backward compatibility for old addons that use legacy modal templates.
614 - $action = FrmAppHelper::get_param( 'frm_action' );
528 + $action = FrmAppHelper::get_param( 'frm_action' );
615 529 $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
616 530 if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
617 531 $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
618 - $url_param = $application_id ? '&applicationId=' . $application_id : '';
532 + $url_param = $application_id ? '&applicationId=' . $application_id : '';
619 533
620 534 wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
621 535 exit;
622 536 }
@@ -622,34 +536,72 @@
622 536 }
623 537
624 538 FrmInbox::maybe_disable_screen_options();
625 539 }
540 +
541 + self::maybe_add_ip_warning();
626 542 }
627 543
628 544 /**
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.
545 + * Show a warning for the IP address setting if it hasn't been set.
631 546 *
632 - * @since 6.8
547 + * @since 6.1
633 548 *
634 549 * @return void
635 550 */
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.
551 + private static function maybe_add_ip_warning() {
552 + $settings = FrmAppHelper::get_settings();
553 + if ( false !== $settings->custom_header_ip ) {
554 + // The setting has been changed from the false default (to either 1 or 0), so stop showing the message.
640 555 return;
641 556 }
642 557
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' ) );
558 + if ( ! self::is_behind_proxy() ) {
559 + // This message is only applicable when using a reverse proxy.
560 + return;
648 561 }
562 +
563 + if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) {
564 + // Avoid the message on a POST action. We don't want to show the message if we're saving global settings.
565 + return;
566 + }
567 +
568 + $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
569 + $message = sprintf(
570 + // Translators: 1: Global Settings Link
571 + __( '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' ),
572 + '<a href="' . esc_url( $global_settings_link ) . '">Global Settings</a>'
573 + );
574 + $option_name = 'frm_dismiss_ip_address_notice';
575 + FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
649 576 }
650 577
651 578 /**
579 + * Check if any reverse proxy headers are set.
580 + *
581 + * @since 6.1
582 + *
583 + * @return bool
584 + */
585 + private static function is_behind_proxy() {
586 + $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip();
587 + foreach ( $custom_headers as $header ) {
588 + if ( 'REMOTE_ADDR' === $header ) {
589 + // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers.
590 + continue;
591 + }
592 +
593 + $ip = trim( FrmAppHelper::get_server_value( $header ) );
594 + // Return true for anything that isn't empty but ignoring values like ::1.
595 + if ( $ip && 0 !== strpos( $ip, '::' ) ) {
596 + return true;
597 + }
598 + }
599 +
600 + return false;
601 + }
602 +
603 + /**
652 604 * @return void
653 605 */
654 606 public static function admin_js() {
655 607 $plugin_url = FrmAppHelper::plugin_url();
@@ -656,11 +608,8 @@
656 608 $version = FrmAppHelper::plugin_version();
657 609
658 610 FrmAppHelper::load_admin_wide_js();
659 611
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 -
663 612 if ( class_exists( 'FrmOverlayController' ) ) {
664 613 // This should always exist.
665 614 // But it may not have loaded properly when updating the plugin.
666 615 FrmOverlayController::register_assets();
@@ -675,19 +624,28 @@
675 624 wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
676 625 wp_register_script( 'formidable_embed', $plugin_url . '/js/admin/embed.js', array( 'formidable_dom', 'jquery-ui-autocomplete' ), $version, true );
677 626 self::register_popper1();
678 627 wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
628 + wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
679 629
680 - $settings_js_vars = array(
681 - 'currencies' => FrmCurrencyHelper::get_currencies(),
682 - );
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 );
630 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
685 631
686 - if ( self::should_show_floating_links() ) {
632 + // Enqueue Floating Links.
633 + $is_valid_page =
634 + FrmAppHelper::is_formidable_admin() &&
635 + ! FrmAppHelper::is_style_editor_page() &&
636 + ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
637 + ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
638 + if ( $is_valid_page && FrmAppHelper::is_formidable_branding() ) {
687 639 self::enqueue_floating_links( $plugin_url, $version );
688 640 }
641 + unset( $is_valid_page );
689 642
643 + if ( 'formidable-applications' === $page ) {
644 + FrmApplicationsController::load_assets();
645 + return;
646 + }
647 +
690 648 $dependencies = array(
691 649 'formidable_admin_global',
692 650 'jquery',
693 651 'jquery-ui-core',
@@ -695,10 +653,9 @@
695 653 'jquery-ui-sortable',
696 654 'bootstrap_tooltip',
697 655 'bootstrap-multiselect',
698 656 'wp-i18n',
699 - // Required in WP versions older than 5.7
700 - 'wp-hooks',
657 + 'wp-hooks', // Required in WP versions older than 5.7
701 658 'formidable_dom',
702 659 'formidable_embed',
703 660 );
704 661
@@ -726,29 +683,24 @@
726 683 '#frm_builder_page li[data-ftype="gateway"] { display: none; }'
727 684 );
728 685 }
729 686
730 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
731 687 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
732 688
733 689 global $pagenow;
734 690 if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
735 - self::enqueue_global_settings_scripts( $page );
736 691
737 692 wp_enqueue_script( 'admin-widgets' );
738 693 wp_enqueue_style( 'widgets' );
739 694 self::maybe_deregister_popper2();
740 695 wp_enqueue_script( 'formidable_admin' );
741 - wp_set_script_translations( 'formidable_admin', 'formidable' );
742 696 wp_enqueue_script( 'formidable_embed' );
743 - wp_set_script_translations( 'formidable_embed', 'formidable' );
744 697 FrmAppHelper::localize_script( 'admin' );
745 698
746 - wp_enqueue_style( 'formidable-animations' );
747 699 wp_enqueue_style( 'formidable-admin' );
748 700 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
749 701 wp_enqueue_style( 'formidable-grids' );
750 - self::maybe_enqueue_dropzone_css( $page );
702 + wp_enqueue_style( 'formidable-dropzone' );
751 703 } else {
752 704 wp_enqueue_style( 'formidable-grids' );
753 705 }
754 706
@@ -779,90 +731,13 @@
779 731
780 732 if ( $post_type === 'frm_display' ) {
781 733 self::enqueue_legacy_views_assets();
782 734 }
783 - }//end if
784 -
785 - if ( 'formidable-addons' === $page ) {
786 - wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
787 - wp_enqueue_script( 'formidable_addons' );
788 735 }
789 736
790 - self::enqueue_builder_assets( $plugin_url, $version );
791 737 }
792 738
793 739 /**
794 - * Enqueue the Form Builder assets.
795 - *
796 - * @since 6.24
797 - *
798 - * @param string $plugin_url The plugin URL.
799 - * @param string $version The plugin version.
800 - * @return void
801 - */
802 - private static function enqueue_builder_assets( $plugin_url, $version ) {
803 - wp_register_style( 'formidable-settings-components', $plugin_url . '/css/admin/frm-settings-components.css', array( 'formidable-admin', 'formidable-grids' ), $version );
804 - wp_register_script( 'formidable-settings-components', $plugin_url . '/js/formidable-settings-components.js', array( 'formidable_admin' ), $version, true );
805 -
806 - if ( ! FrmAppHelper::is_form_builder_page() ) {
807 - return;
808 - }
809 -
810 - wp_enqueue_style( 'formidable-settings-components' );
811 - wp_enqueue_script( 'formidable-settings-components' );
812 - }
813 -
814 - /**
815 - * Enqueues global settings scripts.
816 - *
817 - * @param string $page The `page` param in URL.
818 - */
819 - private static function enqueue_global_settings_scripts( $page ) {
820 - if ( 'formidable-settings' === $page ) {
821 - wp_enqueue_style( 'wp-color-picker' );
822 - wp_enqueue_script( 'formidable_settings' );
823 - }
824 - }
825 -
826 - /**
827 - * Avoid loading dropzone CSS on the form list page. It isn't required there.
828 - *
829 - * @since 6.11
830 - *
831 - * @param string $page
832 - * @return void
833 - */
834 - private static function maybe_enqueue_dropzone_css( $page ) {
835 - if ( ! FrmAppHelper::pro_is_installed() ) {
836 - return;
837 - }
838 -
839 - $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
840 - if ( ! $should_avoid_loading_dropzone ) {
841 - wp_enqueue_style( 'formidable-dropzone' );
842 - }
843 - }
844 -
845 - /**
846 - * The floating links are not shown on every page.
847 - * They are also not shown if white labeling is being used.
848 - *
849 - * @since 6.8.4
850 - *
851 - * @return bool
852 - */
853 - private static function should_show_floating_links() {
854 - if ( ! FrmAppHelper::is_formidable_branding() ) {
855 - return false;
856 - }
857 -
858 - return FrmAppHelper::is_formidable_admin() &&
859 - ! FrmAppHelper::is_style_editor_page() &&
860 - ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
861 - ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
862 - }
863 -
864 - /**
865 740 * @since 6.3.2
866 741 *
867 742 * @return void
868 743 */
@@ -868,14 +743,8 @@
868 743 */
869 744 public static function admin_enqueue_scripts() {
870 745 self::load_wp_admin_style();
871 746 self::maybe_force_formidable_block_on_gutenberg_page();
872 -
873 - if ( FrmAppHelper::is_admin_page( 'formidable-settings' ) ) {
874 - wp_enqueue_style( FrmDashboardController::PAGE_SLUG, FrmAppHelper::plugin_url() . '/css/admin/dashboard.css', array(), FrmAppHelper::plugin_version() );
875 - }
876 -
877 - FrmUsageController::load_scripts();
878 747 }
879 748
880 749 /**
881 750 * Enqueue required assets for the Legacy Views editor (Views v4.x).
@@ -911,9 +780,8 @@
911 780 }
912 781 '
913 782 );
914 783 wp_enqueue_style( 'formidable-admin' );
915 - wp_enqueue_script( 'formidable_legacy_views', FrmAppHelper::plugin_url() . '/js/admin/legacy-views.js', array( 'jquery', 'formidable_admin' ), FrmAppHelper::plugin_version() );
916 784 FrmAppHelper::localize_script( 'admin' );
917 785 self::include_info_overlay();
918 786 }
919 787
@@ -945,45 +813,12 @@
945 813 *
946 814 * @return void
947 815 */
948 816 private static function register_popper1() {
949 - if ( ! self::should_register_popper() ) {
950 - return;
951 - }
952 817 wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
953 818 }
954 819
955 820 /**
956 - * Only register popper on Formidable pages.
957 - * This helps to avoid popper conflicts on other plugin pages, including the WP Bakery page editor.
958 - *
959 - * @since 6.11.1
960 - *
961 - * @return bool
962 - */
963 - private static function should_register_popper() {
964 - global $pagenow;
965 -
966 - $post_id = FrmAppHelper::simple_get( 'post', 'absint' );
967 - if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) {
968 - return true;
969 - }
970 -
971 - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
972 - $is_views_post_type = 'frm_display' === $post_type;
973 - if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) {
974 - return true;
975 - }
976 -
977 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
978 - if ( strpos( $page, 'formidable' ) === 0 ) {
979 - return true;
980 - }
981 -
982 - return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && FrmAppHelper::simple_get( 'taxonomy' ) === 'frm_application';
983 - }
984 -
985 - /**
986 821 * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set.
987 822 *
988 823 * @since 5.2
989 824 *
@@ -1042,18 +877,18 @@
1042 877 * @return void
1043 878 */
1044 879 public static function create_rest_routes() {
1045 880 $args = array(
1046 - 'methods' => 'GET',
1047 - 'callback' => 'FrmAppController::api_install',
1048 - 'permission_callback' => self::class . '::can_update_db',
881 + 'methods' => 'GET',
882 + 'callback' => 'FrmAppController::api_install',
883 + 'permission_callback' => __CLASS__ . '::can_update_db',
1049 884 );
1050 885
1051 886 register_rest_route( 'frm-admin/v1', '/install', $args );
1052 887
1053 888 $args = array(
1054 - 'methods' => 'GET',
1055 - 'callback' => 'FrmAddonsController::install_addon_api',
889 + 'methods' => 'GET',
890 + 'callback' => 'FrmAddonsController::install_addon_api',
1056 891 'permission_callback' => 'FrmAddonsController::can_install_addon_api',
1057 892 );
1058 893
1059 894 register_rest_route( 'frm-admin/v1', '/install-addon', $args );
@@ -1166,9 +1001,9 @@
1166 1001
1167 1002 $frmdb = new FrmMigrate();
1168 1003 $frmdb->uninstall();
1169 1004
1170 - // Disable the plugin and redirect after uninstall so the tables don't get added right back.
1005 + //disable the plugin and redirect after uninstall so the tables don't get added right back
1171 1006 $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
1172 1007 deactivate_plugins( $plugins, false, false );
1173 1008 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
1174 1009
@@ -1239,9 +1074,8 @@
1239 1074 *
1240 1075 * @return void
1241 1076 */
1242 1077 public static function add_admin_footer_links() {
1243 - FrmFormsController::include_device_too_small_message();
1244 1078 if ( self::should_show_footer_links() ) {
1245 1079 include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1246 1080 }
1247 1081 }
@@ -1281,10 +1115,8 @@
1281 1115 *
1282 1116 * @return void
1283 1117 */
1284 1118 public static function show_error_modal( $error_args ) {
1285 - add_filter( 'frm_show_footer_links', '__return_false' );
1286 -
1287 1119 $defaults = array(
1288 1120 'title' => '',
1289 1121 'body' => '',
1290 1122 'cancel_url' => '',
@@ -1306,260 +1138,79 @@
1306 1138 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php';
1307 1139 }
1308 1140
1309 1141 /**
1310 - * Handles Floating Links' scripts and styles enqueueing.
1142 + * @deprecated 3.0.04
1311 1143 *
1312 - * @since 6.4
1144 + * @codeCoverageIgnore
1313 1145 *
1314 - * @param string $plugin_url URL of the plugin.
1315 - * @param string $version Current version of the plugin.
1316 1146 * @return void
1317 1147 */
1318 - private static function enqueue_floating_links( $plugin_url, $version ) {
1319 - if ( ! $plugin_url || ! $version ) {
1320 - // If any required parameters are missing, exit early.
1321 - return;
1322 - }
1323 -
1324 - // Enqueue the Floating Links styles.
1325 - wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1326 -
1327 - // Enqueue the Floating Links script.
1328 - wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array( 'formidable_admin' ), $version, true );
1329 -
1330 - // Enqueue the config script.
1331 - wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1332 -
1333 - if ( function_exists( 'wp_set_script_translations' ) ) {
1334 - wp_set_script_translations( 's11-floating-links-config', 's11-' );
1335 - }
1336 -
1337 - $floating_links_data = array(
1338 - 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1339 - );
1340 - wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1341 -
1342 - /**
1343 - * Prompt Pro to load additional floating links scripts.
1344 - * This is used to include images in the Inbox SlideIn when Pro is active.
1345 - *
1346 - * @since 6.8.4
1347 - */
1348 - do_action( 'frm_enqueue_floating_links' );
1148 + public static function activation_install() {
1149 + FrmDeprecated::activation_install();
1349 1150 }
1350 1151
1351 1152 /**
1352 - * Check if we are in our admin pages.
1353 - *
1354 - * @return bool
1153 + * @deprecated 3.0
1154 + * @codeCoverageIgnore
1355 1155 */
1356 - private static function in_our_pages() {
1357 - global $current_screen, $pagenow;
1358 - if ( FrmAppHelper::is_formidable_admin() ) {
1359 - return true;
1360 - }
1361 -
1362 - if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) {
1363 - return true;
1364 - }
1365 -
1366 - if ( in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' ) ) {
1367 - return true;
1368 - }
1369 -
1370 - return false;
1156 + public static function page_route( $content ) {
1157 + return FrmDeprecated::page_route( $content );
1371 1158 }
1372 1159
1373 1160 /**
1374 - * Handles actions related to the current screen.
1161 + * Include icons on page for Embed Form modal.
1375 1162 *
1376 - * @since 6.19
1163 + * @since 5.2
1377 1164 *
1378 1165 * @return void
1379 1166 */
1380 - public static function handle_current_screen() {
1381 - if ( ! self::in_our_pages() ) {
1382 - return;
1383 - }
1384 -
1385 - self::filter_admin_notices();
1386 - self::remember_custom_sort();
1167 + public static function include_embed_form_icons() {
1168 + _deprecated_function( __METHOD__, '5.3' );
1387 1169 }
1388 1170
1389 1171 /**
1390 - * Hide all third-parties admin notices only in our admin pages.
1172 + * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13.
1173 + * @codeCoverageIgnore
1391 1174 *
1392 - * @return void
1175 + * @param array $atts
1176 + * @return string
1393 1177 */
1394 - public static function filter_admin_notices() {
1395 - $actions = array(
1396 - 'admin_notices',
1397 - 'network_admin_notices',
1398 - 'user_admin_notices',
1399 - 'all_admin_notices',
1400 - );
1401 -
1402 - global $wp_filter;
1403 -
1404 - foreach ( $actions as $action ) {
1405 - if ( empty( $wp_filter[ $action ]->callbacks ) ) {
1406 - continue;
1407 - }
1408 - foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) {
1409 - foreach ( $callbacks as $callback_name => $callback ) {
1410 - if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) {
1411 - continue;
1412 - }
1413 - unset( $wp_filter[ $action ]->callbacks[ $priority ][ $callback_name ] );
1414 - }
1415 - }
1416 - }
1178 + public static function get_form_shortcode( $atts ) {
1179 + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1180 + return FrmFormsController::get_form_shortcode( $atts );
1417 1181 }
1418 1182
1419 1183 /**
1420 - * Remembers and applies user-specific sorting preferences.
1184 + * Handles Floating Links' scripts and styles enqueueing.
1421 1185 *
1422 - * @return void
1423 - */
1424 - private static function remember_custom_sort() {
1425 - $screen = get_current_screen();
1426 - if ( ! $screen ) {
1427 - return;
1428 - }
1429 -
1430 - if ( ! FrmAppHelper::is_admin_list_page() && ! FrmAppHelper::is_admin_list_page( 'formidable-entries' ) ) {
1431 - return;
1432 - }
1433 -
1434 - $orderby = FrmAppHelper::get_param( 'orderby' );
1435 -
1436 - if ( ! $orderby ) {
1437 - return;
1438 - }
1439 -
1440 - $user_id = get_current_user_id();
1441 - $meta_key = 'frm_preferred_list_sort_' . $screen->id;
1442 - $order = FrmAppHelper::get_param( 'order' );
1443 -
1444 - $new_sort = array(
1445 - 'orderby' => $orderby,
1446 - 'order' => $order,
1447 - );
1448 -
1449 - $current_sort = get_user_meta( $user_id, $meta_key, true );
1450 -
1451 - if ( $new_sort !== $current_sort ) {
1452 - update_user_meta(
1453 - $user_id,
1454 - $meta_key,
1455 - array(
1456 - 'orderby' => $orderby,
1457 - 'order' => $order,
1458 - )
1459 - );
1460 - }
1461 - }
1462 -
1463 - /**
1464 - * Retrieve and apply any saved sorting preferences for the current screen.
1186 + * @since 6.4
1465 1187 *
1466 - * @since 6.19
1467 - *
1468 - * @param string &$orderby Reference to the current 'orderby' parameter.
1469 - * @param string &$order Reference to the current 'order' parameter.
1188 + * @param string $plugin_url URL of the plugin.
1189 + * @param string $version Current version of the plugin.
1470 1190 * @return void
1471 1191 */
1472 - public static function apply_saved_sort_preference( &$orderby, &$order ) {
1473 - if ( ! function_exists( 'get_current_screen' ) ) {
1192 + private static function enqueue_floating_links( $plugin_url, $version ) {
1193 + if ( ! $plugin_url || ! $version ) {
1194 + // If any required parameters are missing, exit early.
1474 1195 return;
1475 1196 }
1476 1197
1477 - $screen = get_current_screen();
1478 - if ( ! $screen ) {
1479 - return;
1480 - }
1198 + // Enqueue the Floating Links styles.
1199 + wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1481 1200
1482 - $user_id = get_current_user_id();
1483 - $preferred_list_sort = get_user_meta( $user_id, 'frm_preferred_list_sort_' . $screen->id, true );
1201 + // Enqueue the Floating Links script.
1202 + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1484 1203
1485 - if ( is_array( $preferred_list_sort ) && ! empty( $preferred_list_sort['orderby'] ) ) {
1486 - $orderby = $preferred_list_sort['orderby'];
1204 + // Enqueue the config script.
1205 + wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1487 1206
1488 - if ( ! empty( $preferred_list_sort['order'] ) ) {
1489 - $order = $preferred_list_sort['order'];
1490 - }
1207 + if ( function_exists( 'wp_set_script_translations' ) ) {
1208 + wp_set_script_translations( 's11-floating-links-config', 's11-' );
1491 1209 }
1492 - }
1493 1210
1494 - /**
1495 - * Validate that the callback name is ours not from third-party.
1496 - *
1497 - * @param string $callback_name WordPress callback name.
1498 - *
1499 - * @return bool
1500 - */
1501 - private static function is_our_callback_string( $callback_name ) {
1502 - return 0 === stripos( $callback_name, 'frm' );
1503 - }
1504 -
1505 - /**
1506 - * Validate that the callback array is ours not from third-party.
1507 - *
1508 - * @param array $callback WordPress callback array.
1509 - *
1510 - * @return bool
1511 - */
1512 - private static function is_our_callback_array( $callback ) {
1513 - return ! empty( $callback['function'] ) &&
1514 - is_array( $callback['function'] ) &&
1515 - ! empty( $callback['function'][0] ) &&
1516 - self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] );
1517 - }
1518 -
1519 - /**
1520 - * In some cases, the DB tables may fail to install.
1521 - * This function tries to add them again when the user clicks the link to try again
1522 - * from the given inbox notice.
1523 - *
1524 - * @since 6.19
1525 - */
1526 - private static function add_missing_tables() {
1527 - FrmAppHelper::permission_check( 'frm_view_forms' );
1528 -
1529 - $inbox = new FrmInbox();
1530 - $error = $inbox->check_for_error();
1531 -
1532 - if ( ! $error || 'failed-to-create-tables' !== $error['key'] ) {
1533 - // Confirm the inbox item with this CTA exists.
1534 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1535 - exit;
1536 - }
1537 -
1538 - global $wpdb;
1539 - $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->prefix . 'frm_forms' ) );
1540 -
1541 - if ( $exists ) {
1542 - // Exit early if the table already exists.
1543 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1544 - exit;
1545 - }
1546 -
1547 - delete_option( 'frm_db_version' );
1548 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1549 - exit;
1550 - }
1551 -
1552 - /**
1553 - * Handles the small screen proceed action.
1554 - *
1555 - * @since 6.21
1556 - *
1557 - * @return void
1558 - */
1559 - public static function small_screen_proceed() {
1560 - FrmAppHelper::permission_check( 'frm_view_forms' );
1561 - check_ajax_referer( 'frm_ajax', 'nonce' );
1562 - update_user_option( get_current_user_id(), 'frm_ignore_small_screen_warning', true );
1563 - wp_send_json_success();
1211 + $floating_links_data = array(
1212 + 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1213 + );
1214 + wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1564 1215 }
1565 1216 }