PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16
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 +238 -503 6.306.16 View file →
@@ -9,20 +9,16 @@
9 9 * @return void
10 10 */
11 11 public static function menu() {
12 12 FrmAppHelper::maybe_add_permissions();
13 -
14 13 if ( ! current_user_can( 'frm_view_forms' ) ) {
15 14 return;
16 15 }
17 16
18 17 $menu_name = FrmAppHelper::get_menu_name();
18 + add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
19 19
20 - if ( in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) {
21 - $menu_name .= wp_kses_post( FrmInboxController::get_notice_count() );
22 - }
23 -
24 - add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
20 + self::maybe_add_black_friday_submenu_item();
25 21 }
26 22
27 23 /**
28 24 * @return int
@@ -32,10 +28,8 @@
32 28 }
33 29
34 30 /**
35 31 * @since 3.05
36 - *
37 - * @return string
38 32 */
39 33 private static function menu_icon() {
40 34 $icon = FrmAppHelper::svg_logo(
41 35 array(
@@ -48,14 +42,86 @@
48 42 return apply_filters( 'frm_icon', $icon );
49 43 }
50 44
51 45 /**
52 - * @since 3.0
46 + * @since 6.16
53 47 *
54 - * @param string $classes
48 + * @return void
49 + */
50 + private static function maybe_add_black_friday_submenu_item() {
51 + if ( ! current_user_can( 'frm_change_settings' ) ) {
52 + return;
53 + }
54 +
55 + $is_black_friday = self::is_black_friday();
56 + $is_cyber_monday = self::is_cyber_monday();
57 +
58 + if ( ! $is_black_friday && ! $is_cyber_monday ) {
59 + return;
60 + }
61 +
62 + $black_friday_menu_label = $is_black_friday ? __( 'Black Friday!', 'formidable' ) : __( 'Cyber Monday!', 'formidable' );
63 + $black_friday_menu_label = '<span class="frm-orange-text">' . esc_html( $black_friday_menu_label ) . '</span>';
64 +
65 + add_action(
66 + 'admin_menu',
67 + function () use ( $black_friday_menu_label ) {
68 + add_submenu_page(
69 + 'formidable',
70 + 'Formidable',
71 + $black_friday_menu_label,
72 + 'frm_change_settings',
73 + 'formidable-black-friday',
74 + function () {
75 + // This function should do nothing. The redirect is handled earlier to avoid header conflicts.
76 + }
77 + );
78 + },
79 + 1000
80 + );
81 + }
82 +
83 + /**
84 + * Black Friday sale is from November 25 to 29.
55 85 *
56 - * @return string
86 + * @since 6.16
87 + *
88 + * @return bool
57 89 */
90 + private static function is_black_friday() {
91 + return self::within_sale_date_range( '2024-11-25', '2024-11-29' );
92 + }
93 +
94 + /**
95 + * Cyber Monday sale rules from November 30 to December 4.
96 + *
97 + * @since 6.16
98 + *
99 + * @return bool
100 + */
101 + private static function is_cyber_monday() {
102 + return self::within_sale_date_range( '2024-11-30', '2024-12-04' );
103 + }
104 +
105 + /**
106 + * Check if the current time is within a sale date range.
107 + * Our sales are based on Eastern Time, so we use New York's timezone.
108 + *
109 + * @since 6.16
110 + *
111 + * @param string $from The beginning of the date range. Y-m-d format is expected.
112 + * @param string $to The end of the date range. Y-m-d format is expected.
113 + * @return bool
114 + */
115 + private static function within_sale_date_range( $from, $to ) {
116 + $date = new DateTime( 'now', new DateTimeZone( 'America/New_York' ) );
117 + $today = $date->format( 'Y-m-d' );
118 + return $today >= $from && $today <= $to;
119 + }
120 +
121 + /**
122 + * @since 3.0
123 + */
58 124 public static function add_admin_class( $classes ) {
59 125 if ( self::is_white_page() ) {
60 126 $classes .= ' frm-white-body ';
61 127 $classes .= self::get_os();
@@ -60,20 +126,17 @@
60 126 $classes .= ' frm-white-body ';
61 127 $classes .= self::get_os();
62 128
63 129 $page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) );
64 -
65 - if ( ! $page || $page === 'formidable' ) {
130 + if ( empty( $page ) || $page === 'formidable' ) {
66 131 $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
67 -
68 - if ( in_array( $action, array( 'settings', 'edit', 'list' ), true ) ) {
132 + if ( in_array( $action, array( 'settings', 'edit', 'list' ) ) ) {
69 133 $page .= $action;
70 134 } else {
71 135 $page = $action;
72 136 }
73 137 }
74 -
75 - if ( $page ) {
138 + if ( ! empty( $page ) ) {
76 139 $classes .= ' frm-admin-page-' . $page;
77 140 }
78 141 }
79 142
@@ -81,17 +144,16 @@
81 144 $classes .= ' frm-grey-body ';
82 145 }
83 146
84 147 if ( FrmAppHelper::is_full_screen() ) {
85 - $add_class = '';
86 -
87 - if ( self::get_full_screen_setting() ) {
148 + $full_screen_on = self::get_full_screen_setting();
149 + $add_class = '';
150 + if ( $full_screen_on ) {
88 151 $add_class = ' frm-full-screen is-fullscreen-mode';
89 152
90 153 // Load the CSS for .is-fullscreen-mode.
91 154 wp_enqueue_style( 'wp-edit-post' );
92 155 }
93 -
94 156 $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
95 157 }
96 158
97 159 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -114,10 +176,10 @@
114 176 */
115 177 private static function get_full_screen_setting() {
116 178 global $wpdb;
117 179 $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences';
118 - $prefs = get_user_meta( get_current_user_id(), $meta_key, true );
119 180
181 + $prefs = get_user_meta( get_current_user_id(), $meta_key, true );
120 182 if ( $prefs && isset( $prefs['core/edit-post']['fullscreenMode'] ) ) {
121 183 return $prefs['core/edit-post']['fullscreenMode'];
122 184 }
123 185
@@ -131,24 +193,20 @@
131 193 */
132 194 private static function get_os() {
133 195 $agent = strtolower( FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ) );
134 196 $os = '';
135 -
136 - if ( str_contains( $agent, 'mac' ) ) {
197 + if ( strpos( $agent, 'mac' ) !== false ) {
137 198 $os = ' osx';
138 - } elseif ( str_contains( $agent, 'linux' ) ) {
199 + } elseif ( strpos( $agent, 'linux' ) !== false ) {
139 200 $os = ' linux';
140 - } elseif ( str_contains( $agent, 'windows' ) ) {
201 + } elseif ( strpos( $agent, 'windows' ) !== false ) {
141 202 $os = ' windows';
142 203 }
143 -
144 204 return $os;
145 205 }
146 206
147 207 /**
148 208 * @since 3.0
149 - *
150 - * @return bool
151 209 */
152 210 private static function is_white_page() {
153 211 $white_pages = array(
154 212 'formidable',
@@ -164,10 +222,17 @@
164 222 FrmFormTemplatesController::PAGE_SLUG,
165 223 FrmOnboardingWizardController::PAGE_SLUG,
166 224 );
167 225
168 - if ( self::is_white_payments_page() ) {
169 - $white_pages[] = 'formidable-payments';
226 + if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) {
227 + // Only consider the payments page as a "white page" when the Payments submodule is off.
228 + // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active.
229 +
230 + // Add an extra check to avoid white page styling on the PayPal "edit" action.
231 + // We fallback to the PayPal add on for the "edit" action since Stripe Lite does not have an edit view.
232 + if ( ! in_array( FrmAppHelper::simple_get( 'action' ), array( 'edit', 'new' ), true ) || ! is_callable( 'FrmPaymentsController::route' ) ) {
233 + $white_pages[] = 'formidable-payments';
234 + }
170 235 }
171 236
172 237 $is_white_page = self::is_page_in_list( $white_pages ) || self::is_grey_page() || FrmAppHelper::is_view_builder_page();
173 238
@@ -177,25 +242,11 @@
177 242 * @since 5.3
178 243 *
179 244 * @param bool $is_white_page
180 245 */
181 - return apply_filters( 'frm_is_white_page', $is_white_page );
182 - }
246 + $is_white_page = apply_filters( 'frm_is_white_page', $is_white_page );
183 247
184 - /**
185 - * Check if the payments page should be styled as a white page.
186 - * Fallback to the Stripe, Authorize.Net, or PayPal add on for the "edit" action since
187 - * Stripe Lite does not have an edit view. Also fallback for bulk deleting, since that
188 - * isn't built into Lite. The pages we fall back to should not be styled as white pages.
189 - *
190 - * @since 6.27
191 - *
192 - * @return bool
193 - */
194 - private static function is_white_payments_page() {
195 - $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
196 - $on_edit_page = in_array( $action, array( 'edit', 'new' ), true );
197 - return ! $on_edit_page && 'bulk_delete' !== $action;
248 + return $is_white_page;
198 249 }
199 250
200 251 /**
201 252 * Add a grey bg instead of white.
@@ -207,9 +258,8 @@
207 258 private static function is_grey_page() {
208 259 $grey_pages = array(
209 260 'formidable-applications',
210 261 'formidable-dashboard',
211 - 'formidable-views',
212 262 );
213 263
214 264 $is_grey_page = self::is_page_in_list( $grey_pages );
215 265
@@ -218,9 +268,8 @@
218 268 *
219 269 * @since 6.8
220 270 *
221 271 * @param bool $is_grey_page
222 - *
223 272 * @return bool
224 273 */
225 274 return apply_filters( 'frm_is_grey_page', $is_grey_page );
226 275 }
@@ -228,9 +277,8 @@
228 277 /**
229 278 * @since 6.8
230 279 *
231 280 * @param array $pages A list of page names to check.
232 - *
233 281 * @return bool
234 282 */
235 283 private static function is_page_in_list( $pages ) {
236 284 $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
@@ -254,15 +302,13 @@
254 302 * @return void
255 303 */
256 304 public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
257 305 $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
258 -
259 - if ( ! $show_nav || ! $form ) {
306 + if ( empty( $show_nav ) || ! $form ) {
260 307 return;
261 308 }
262 309
263 310 FrmForm::maybe_get_form( $form );
264 -
265 311 if ( ! is_object( $form ) ) {
266 312 return;
267 313 }
268 314
@@ -276,21 +322,21 @@
276 322 /**
277 323 * @return string
278 324 */
279 325 private static function get_current_page() {
326 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
327 + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
328 + $current_page = isset( $_GET['page'] ) ? $page : $post_type;
329 +
280 330 if ( FrmAppHelper::is_view_builder_page() ) {
281 - return 'frm_display';
331 + $current_page = 'frm_display';
282 332 }
283 333
284 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
285 - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
286 -
287 - return isset( $_GET['page'] ) ? $page : $post_type;
334 + return $current_page;
288 335 }
289 336
290 337 /**
291 338 * @param object $form
292 - *
293 339 * @return array
294 340 */
295 341 private static function get_form_nav_items( $form ) {
296 342 $id = $form->parent_form_id ? $form->parent_form_id : $form->id;
@@ -362,13 +408,10 @@
362 408
363 409 return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
364 410 }
365 411
412 + // Adds a settings link to the plugins page
366 413 /**
367 - * Adds a settings link to the plugins page
368 - *
369 - * @param array $links
370 - *
371 414 * @return array
372 415 */
373 416 public static function settings_link( $links ) {
374 417 $settings = array();
@@ -373,31 +416,14 @@
373 416 public static function settings_link( $links ) {
374 417 $settings = array();
375 418
376 419 if ( ! FrmAppHelper::pro_is_installed() ) {
377 - if ( FrmAddonsController::is_license_expired() ) {
378 - $label = __( 'Renew', 'formidable' );
379 - } else {
380 - $label = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_text' );
420 + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' );
421 + $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>';
422 + }
381 423
382 - if ( ! $label ) {
383 - $label = __( 'Upgrade to Pro', 'formidable' );
384 - }
385 - }
424 + $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
386 425
387 - $upgrade_link = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_link' );
388 -
389 - if ( $upgrade_link ) {
390 - $upgrade_link = FrmAppHelper::maybe_add_missing_utm( $upgrade_link, array( 'medium' => 'plugin-row' ) );
391 - } else {
392 - $upgrade_link = FrmAppHelper::admin_upgrade_link( 'plugin-row' );
393 - }
394 -
395 - $settings[] = '<a href="' . esc_url( $upgrade_link ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>';
396 - }//end if
397 -
398 - $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . esc_html__( 'Build a Form', 'formidable' ) . '</a>';
399 -
400 426 return array_merge( $settings, $links );
401 427 }
402 428
403 429 /**
@@ -404,9 +430,9 @@
404 430 * @return void
405 431 */
406 432 public static function pro_get_started_headline() {
407 433 self::review_request();
408 - FrmAppHelper::min_pro_version_notice( '6.20' );
434 + FrmAppHelper::min_pro_version_notice( '6.0' );
409 435 }
410 436
411 437 /**
412 438 * Add admin notices as needed for reviews
@@ -481,9 +507,8 @@
481 507 *
482 508 * @param string $form_key
483 509 * @param string $title
484 510 * @param string $description
485 - *
486 511 * @return void
487 512 */
488 513 public static function api_email_form( $form_key, $title = '', $description = '' ) {
489 514 $user = wp_get_current_user();
@@ -516,9 +541,10 @@
516 541 * @return void
517 542 */
518 543 public static function remove_upsells() {
519 544 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
520 - remove_action( 'frm_after_settings_tabs', 'FrmSettingsController::settings_cta' );
545 + remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
546 + remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
521 547 remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
522 548 }
523 549
524 550 /**
@@ -530,14 +556,12 @@
530 556 * @return void
531 557 */
532 558 public static function install_js_fallback() {
533 559 FrmAppHelper::load_admin_wide_js();
534 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
535 560 ?>
536 561 <div id="frm_install_message"></div>
537 562 <script>jQuery(document).ready( frm_install_now );</script>
538 563 <?php
539 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
540 564 }
541 565
542 566 /**
543 567 * Check if the database is outdated
@@ -542,9 +566,8 @@
542 566 /**
543 567 * Check if the database is outdated
544 568 *
545 569 * @since 2.0.1
546 - *
547 570 * @return bool
548 571 */
549 572 public static function needs_update() {
550 573 $needs_upgrade = self::compare_for_update(
@@ -555,9 +578,9 @@
555 578 )
556 579 );
557 580
558 581 if ( ! $needs_upgrade ) {
559 - return apply_filters( 'frm_db_needs_upgrade', $needs_upgrade );
582 + $needs_upgrade = apply_filters( 'frm_db_needs_upgrade', $needs_upgrade );
560 583 }
561 584
562 585 return $needs_upgrade;
563 586 }
@@ -567,27 +590,23 @@
567 590 *
568 591 * @since 3.0.04
569 592 *
570 593 * @param array $atts
571 - *
572 594 * @return bool
573 595 */
574 596 public static function compare_for_update( $atts ) {
575 597 $db_version = get_option( $atts['option'] );
576 598
577 - if ( ! str_contains( $db_version, '-' ) ) {
578 - return true;
599 + if ( strpos( $db_version, '-' ) === false ) {
600 + $needs_upgrade = true;
601 + } else {
602 + $last_upgrade = explode( '-', $db_version );
603 + $needs_db_upgrade = (int) $last_upgrade[1] < (int) $atts['new_db_version'];
604 + $new_version = version_compare( $last_upgrade[0], $atts['new_plugin_version'], '<' );
605 + $needs_upgrade = $needs_db_upgrade || $new_version;
579 606 }
580 607
581 - $last_upgrade = explode( '-', $db_version );
582 - $needs_db_upgrade = (int) $last_upgrade[1] < (int) $atts['new_db_version'];
583 -
584 - if ( $needs_db_upgrade ) {
585 - return true;
586 - }
587 -
588 - // New plugin version.
589 - return version_compare( $last_upgrade[0], $atts['new_plugin_version'], '<' );
608 + return $needs_upgrade;
590 609 }
591 610
592 611 /**
593 612 * Check for database update and trigger js loading
@@ -604,12 +623,8 @@
604 623 if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
605 624 FrmFormsController::duplicate();
606 625 }
607 626
608 - if ( FrmAppHelper::is_admin_page( 'formidable' ) && FrmAppHelper::simple_get( 'frm_add_tables' ) ) {
609 - self::add_missing_tables();
610 - }
611 -
612 627 if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) {
613 628 // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
614 629 FrmStylesController::save_style();
615 630 }
@@ -614,17 +629,29 @@
614 629 FrmStylesController::save_style();
615 630 }
616 631
617 632 if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) {
618 - $redirect = FrmSalesApi::get_best_sale_value( 'menu_cta_link' );
619 - $utm = array(
620 - 'campaign' => 'upgrade',
621 - 'content' => 'submenu-upgrade',
633 + wp_redirect(
634 + FrmAppHelper::admin_upgrade_link(
635 + array(
636 + 'medium' => 'upgrade',
637 + 'content' => 'submenu-upgrade',
638 + )
639 + )
622 640 );
641 + die();
642 + }
623 643
624 - $redirect = $redirect ? FrmAppHelper::maybe_add_missing_utm( $redirect, $utm ) : FrmAppHelper::admin_upgrade_link( $utm );
625 -
626 - wp_redirect( $redirect );
644 + if ( 'formidable-black-friday' === FrmAppHelper::get_param( 'page' ) && current_user_can( 'frm_change_settings' ) ) {
645 + wp_redirect(
646 + FrmAppHelper::admin_upgrade_link(
647 + array(
648 + 'medium' => 'black-friday-submenu',
649 + 'content' => self::is_cyber_monday() ? 'cyber-monday-submenu' : 'black-friday-submenu',
650 + ),
651 + 'black-friday'
652 + )
653 + );
627 654 die();
628 655 }
629 656
630 657 // Register personal data hooks.
@@ -634,32 +661,29 @@
634 661 self::network_upgrade_site();
635 662 }
636 663
637 664 if ( ! FrmAppHelper::doing_ajax() ) {
638 - // Don't continue during ajax calls
665 + // don't continue during ajax calls
639 666 self::admin_js();
640 667 }
641 668
642 669 self::trigger_page_load_hooks();
643 670
644 - if ( ! FrmAppHelper::is_admin_page( 'formidable' ) ) {
645 - return;
646 - }
671 + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
672 + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
673 + // This provides backward compatibility for old addons that use legacy modal templates.
674 + $action = FrmAppHelper::get_param( 'frm_action' );
675 + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
676 + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
677 + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
678 + $url_param = $application_id ? '&applicationId=' . $application_id : '';
647 679
648 - // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions.
649 - // This provides backward compatibility for old addons that use legacy modal templates.
650 - $action = FrmAppHelper::get_param( 'frm_action' );
651 - $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' );
680 + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
681 + exit;
682 + }
652 683
653 - if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
654 - $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' );
655 - $url_param = $application_id ? '&applicationId=' . $application_id : '';
656 -
657 - wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) );
658 - exit;
684 + FrmInbox::maybe_disable_screen_options();
659 685 }
660 -
661 - FrmInbox::maybe_disable_screen_options();
662 686 }
663 687
664 688 /**
665 689 * Get the current page and check for a possible function to trigger.
@@ -670,10 +694,9 @@
670 694 * @return void
671 695 */
672 696 private static function trigger_page_load_hooks() {
673 697 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
674 -
675 - if ( ! str_starts_with( $page, 'formidable-' ) ) {
698 + if ( strpos( $page, 'formidable-' ) !== 0 ) {
676 699 // Only trigger hooks on Formidable pages.
677 700 return;
678 701 }
679 702
@@ -679,9 +702,8 @@
679 702
680 703 $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page );
681 704 $page = str_replace( ' ', '', ucwords( $page ) );
682 705 $class = 'Frm' . $page . 'Controller';
683 -
684 706 if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) {
685 707 call_user_func( array( $class, 'load_page' ) );
686 708 }
687 709 }
@@ -689,14 +711,13 @@
689 711 /**
690 712 * @return void
691 713 */
692 714 public static function admin_js() {
693 - $plugin_url = FrmAppHelper::plugin_url();
694 - $version = FrmAppHelper::plugin_version();
695 - $is_pro_min_v6_28 = FrmAppHelper::pro_is_installed() && FrmAppHelper::meets_min_pro_version( '6.28' );
696 - $frm_components_dependencies = $is_pro_min_v6_28 ? array( 'formidable_admin', 'formidable-pro-web-components' ) : array( 'formidable_admin' );
715 + $plugin_url = FrmAppHelper::plugin_url();
716 + $version = FrmAppHelper::plugin_version();
697 717
698 718 FrmAppHelper::load_admin_wide_js();
719 +
699 720 // Register component assets early to ensure they can be enqueued later in controllers.
700 721 wp_register_style( 'formidable-animations', $plugin_url . '/css/admin/animations.css', array(), $version );
701 722
702 723 if ( class_exists( 'FrmOverlayController' ) ) {
@@ -712,33 +733,54 @@
712 733 wp_register_style( 'formidable-grids', $plugin_url . '/css/frm_grids.css', array(), $version );
713 734
714 735 wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
715 736 wp_register_script( 'formidable_embed', $plugin_url . '/js/admin/embed.js', array( 'formidable_dom', 'jquery-ui-autocomplete' ), $version, true );
716 - self::register_popper2();
717 - wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '5.0.2', true );
718 -
719 - $settings_js_vars = array(
720 - 'currencies' => FrmCurrencyHelper::get_currencies(),
721 - );
737 + self::register_popper1();
738 + wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
722 739 wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
723 - wp_localize_script( 'formidable_settings', 'frmSettings', $settings_js_vars );
724 - wp_register_script( 'formidable-web-components', $plugin_url . '/js/formidable-web-components.js', $frm_components_dependencies, $version, true );
725 740
726 741 if ( self::should_show_floating_links() ) {
727 742 self::enqueue_floating_links( $plugin_url, $version );
728 743 }
729 744
730 - wp_register_script( 'formidable_admin', $plugin_url . '/js/formidable_admin.js', self::get_admin_js_dependencies(), $version, true );
745 + $dependencies = array(
746 + 'formidable_admin_global',
747 + 'jquery',
748 + 'jquery-ui-core',
749 + 'jquery-ui-draggable',
750 + 'jquery-ui-sortable',
751 + 'bootstrap_tooltip',
752 + 'bootstrap-multiselect',
753 + 'wp-i18n',
754 + // Required in WP versions older than 5.7
755 + 'wp-hooks',
756 + 'formidable_dom',
757 + 'formidable_embed',
758 + );
731 759
760 + if ( FrmAppHelper::is_style_editor_page( 'edit' ) ) {
761 + // We only need to load the color picker when editing styles.
762 + $dependencies[] = 'wp-color-picker';
763 + }
764 +
765 + wp_register_script( 'formidable_admin', $plugin_url . '/js/formidable_admin.js', $dependencies, $version, true );
766 +
732 767 if ( FrmAppHelper::on_form_listing_page() ) {
733 768 // For the existing page dropdown in the Form embed modal.
734 769 wp_enqueue_script( 'jquery-ui-autocomplete' );
735 770 }
736 771
737 - wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '2.0', true );
772 + wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
738 773
739 774 if ( ! class_exists( 'FrmTransHooksController', false ) ) {
740 - FrmTransLiteAppController::hide_gateway_fields_in_builder();
775 + /**
776 + * Gateway fields are included for add-on compatibility but we do not want it to be visible.
777 + * They do however need to be visible when the payments submodule is active.
778 + */
779 + wp_add_inline_style(
780 + 'formidable-admin',
781 + '#frm_builder_page li[data-ftype="gateway"] { display: none; }'
782 + );
741 783 }
742 784
743 785 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
744 786 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
@@ -743,15 +785,13 @@
743 785 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
744 786 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
745 787
746 788 global $pagenow;
789 + if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
747 790
748 - if ( str_starts_with( $page, 'formidable' ) || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
749 - self::enqueue_global_settings_scripts( $page );
750 -
751 791 wp_enqueue_script( 'admin-widgets' );
752 792 wp_enqueue_style( 'widgets' );
753 - self::maybe_deregister_popper1();
793 + self::maybe_deregister_popper2();
754 794 wp_enqueue_script( 'formidable_admin' );
755 795 wp_set_script_translations( 'formidable_admin', 'formidable' );
756 796 wp_enqueue_script( 'formidable_embed' );
757 797 wp_set_script_translations( 'formidable_embed', 'formidable' );
@@ -758,9 +798,8 @@
758 798 FrmAppHelper::localize_script( 'admin' );
759 799
760 800 wp_enqueue_style( 'formidable-animations' );
761 801 wp_enqueue_style( 'formidable-admin' );
762 -
763 802 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
764 803 wp_enqueue_style( 'formidable-grids' );
765 804 self::maybe_enqueue_dropzone_css( $page );
766 805 } else {
@@ -783,13 +822,11 @@
783 822 if ( isset( $_REQUEST['post_type'] ) ) {
784 823 $post_type = sanitize_title( wp_unslash( $_REQUEST['post_type'] ) );
785 824 } elseif ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
786 825 $post = get_post( absint( wp_unslash( $_REQUEST['post'] ) ) );
787 -
788 826 if ( ! $post ) {
789 827 return;
790 828 }
791 -
792 829 $post_type = $post->post_type;
793 830 } else {
794 831 return;
795 832 }
@@ -802,86 +839,16 @@
802 839 if ( 'formidable-addons' === $page ) {
803 840 wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true );
804 841 wp_enqueue_script( 'formidable_addons' );
805 842 }
806 -
807 - self::enqueue_builder_assets( $plugin_url, $version );
808 843 }
809 844
810 845 /**
811 - * @since 6.27
812 - *
813 - * @return array
814 - */
815 - private static function get_admin_js_dependencies() {
816 - $dependencies = array(
817 - 'formidable_admin_global',
818 - 'jquery',
819 - 'jquery-ui-core',
820 - 'jquery-ui-draggable',
821 - 'jquery-ui-sortable',
822 - 'bootstrap_tooltip',
823 - 'bootstrap-multiselect',
824 - 'wp-i18n',
825 - // Required in WP versions older than 5.7
826 - 'wp-hooks',
827 - 'formidable_dom',
828 - 'formidable_embed',
829 - );
830 -
831 - if ( FrmAppHelper::is_style_editor_page( 'edit' ) ) {
832 - // We only need to load the color picker when editing styles.
833 - $dependencies[] = 'wp-color-picker';
834 - }
835 -
836 - return $dependencies;
837 - }
838 -
839 - /**
840 - * Enqueue the Form Builder assets.
841 - *
842 - * @since 6.24
843 - *
844 - * @param string $plugin_url The plugin URL.
845 - * @param string $version The plugin version.
846 - *
847 - * @return void
848 - */
849 - private static function enqueue_builder_assets( $plugin_url, $version ) {
850 - wp_register_style( 'formidable-settings-components', $plugin_url . '/css/admin/frm-settings-components.css', array( 'formidable-admin', 'formidable-grids' ), $version );
851 - wp_register_script( 'formidable-settings-components', $plugin_url . '/js/formidable-settings-components.js', array( 'formidable_admin' ), $version, true );
852 -
853 - if ( ! FrmAppHelper::is_form_builder_page() ) {
854 - return;
855 - }
856 -
857 - wp_enqueue_style( 'formidable-settings-components' );
858 - wp_enqueue_script( 'formidable-settings-components' );
859 - }
860 -
861 - /**
862 - * Enqueues global settings scripts.
863 - *
864 - * @param string $page The `page` param in URL.
865 - *
866 - * @return void
867 - */
868 - private static function enqueue_global_settings_scripts( $page ) {
869 - if ( 'formidable-settings' !== $page ) {
870 - return;
871 - }
872 -
873 - wp_enqueue_style( 'wp-color-picker' );
874 - wp_enqueue_script( 'formidable_settings' );
875 - }
876 -
877 - /**
878 846 * Avoid loading dropzone CSS on the form list page. It isn't required there.
879 847 *
880 848 * @since 6.11
881 849 *
882 850 * @param string $page
883 - *
884 851 * @return void
885 852 */
886 853 private static function maybe_enqueue_dropzone_css( $page ) {
887 854 if ( ! FrmAppHelper::pro_is_installed() ) {
@@ -888,9 +855,8 @@
888 855 return;
889 856 }
890 857
891 858 $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
892 -
893 859 if ( ! $should_avoid_loading_dropzone ) {
894 860 wp_enqueue_style( 'formidable-dropzone' );
895 861 }
896 862 }
@@ -907,18 +873,12 @@
907 873 if ( ! FrmAppHelper::is_formidable_branding() ) {
908 874 return false;
909 875 }
910 876
911 - $should_show = FrmAppHelper::is_formidable_admin() && ! FrmAppHelper::is_style_editor_page() && ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
912 -
913 - /**
914 - * Filters whether the floating links should be displayed.
915 - *
916 - * @since 6.25.1
917 - *
918 - * @param bool $should_show Whether the floating links should be shown.
919 - */
920 - return apply_filters( 'frm_should_show_floating_links', $should_show );
877 + return FrmAppHelper::is_formidable_admin() &&
878 + ! FrmAppHelper::is_style_editor_page() &&
879 + ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
880 + ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
921 881 }
922 882
923 883 /**
924 884 * @since 6.3.2
@@ -927,14 +887,8 @@
927 887 */
928 888 public static function admin_enqueue_scripts() {
929 889 self::load_wp_admin_style();
930 890 self::maybe_force_formidable_block_on_gutenberg_page();
931 -
932 - if ( FrmAppHelper::is_admin_page( 'formidable-settings' ) ) {
933 - wp_enqueue_style( FrmDashboardController::PAGE_SLUG, FrmAppHelper::plugin_url() . '/css/admin/dashboard.css', array(), FrmAppHelper::plugin_version() );
934 - }
935 -
936 - FrmUsageController::load_scripts();
937 891 }
938 892
939 893 /**
940 894 * Enqueue required assets for the Legacy Views editor (Views v4.x).
@@ -945,9 +899,9 @@
945 899 */
946 900 private static function enqueue_legacy_views_assets() {
947 901 wp_enqueue_style( 'formidable-grids' );
948 902 wp_enqueue_script( 'jquery-ui-draggable' );
949 - self::maybe_deregister_popper1();
903 + self::maybe_deregister_popper2();
950 904 wp_enqueue_script( 'formidable_admin' );
951 905 wp_add_inline_style(
952 906 'formidable-admin',
953 907 '
@@ -970,21 +924,20 @@
970 924 }
971 925 '
972 926 );
973 927 wp_enqueue_style( 'formidable-admin' );
974 - wp_enqueue_script( 'formidable_legacy_views', FrmAppHelper::plugin_url() . '/js/admin/legacy-views.js', array( 'jquery', 'formidable_admin' ), FrmAppHelper::plugin_version() ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
975 928 FrmAppHelper::localize_script( 'admin' );
976 929 self::include_info_overlay();
977 930 }
978 931
979 932 /**
980 - * Unregister Popper if the registered version is outdated.
933 + * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459.
981 934 *
982 - * @since 6.26
935 + * @since 5.2.02.01
983 936 *
984 937 * @return void
985 938 */
986 - private static function maybe_deregister_popper1() {
939 + private static function maybe_deregister_popper2() {
987 940 global $wp_scripts;
988 941
989 942 if ( ! array_key_exists( 'popper', $wp_scripts->registered ) ) {
990 943 return;
@@ -990,29 +943,26 @@
990 943 return;
991 944 }
992 945
993 946 $popper = $wp_scripts->registered['popper'];
994 -
995 - if ( ! version_compare( $popper->ver, '2.0', '<' ) ) {
996 - return;
947 + if ( version_compare( $popper->ver, '2.0', '>=' ) ) {
948 + wp_deregister_script( 'popper' );
949 + self::register_popper1();
997 950 }
998 -
999 - wp_deregister_script( 'popper' );
1000 - self::register_popper2();
1001 951 }
1002 952
1003 953 /**
1004 - * Register Popper required for Bootstrap 5.
954 + * Register Popper required for Bootstrap 4.
1005 955 *
1006 - * @since 6.26
956 + * @since 5.2.02.01
1007 957 *
1008 958 * @return void
1009 959 */
1010 - private static function register_popper2() {
960 + private static function register_popper1() {
1011 961 if ( ! self::should_register_popper() ) {
1012 962 return;
1013 963 }
1014 - wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array(), '2.11.8', true );
964 + wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
1015 965 }
1016 966
1017 967 /**
1018 968 * Only register popper on Formidable pages.
@@ -1025,9 +975,8 @@
1025 975 private static function should_register_popper() {
1026 976 global $pagenow;
1027 977
1028 978 $post_id = FrmAppHelper::simple_get( 'post', 'absint' );
1029 -
1030 979 if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) {
1031 980 return true;
1032 981 }
1033 982
@@ -1032,16 +981,14 @@
1032 981 }
1033 982
1034 983 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1035 984 $is_views_post_type = 'frm_display' === $post_type;
1036 -
1037 985 if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) {
1038 986 return true;
1039 987 }
1040 988
1041 989 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
1042 -
1043 - if ( str_starts_with( $page, 'formidable' ) ) {
990 + if ( strpos( $page, 'formidable' ) === 0 ) {
1044 991 return true;
1045 992 }
1046 993
1047 994 return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && FrmAppHelper::simple_get( 'taxonomy' ) === 'frm_application';
@@ -1055,15 +1002,13 @@
1055 1002 * @return void
1056 1003 */
1057 1004 private static function maybe_force_formidable_block_on_gutenberg_page() {
1058 1005 global $pagenow;
1059 -
1060 1006 if ( 'post.php' !== $pagenow ) {
1061 1007 return;
1062 1008 }
1063 1009
1064 1010 $form_id = FrmAppHelper::simple_get( 'frmForm', 'absint' );
1065 -
1066 1011 if ( ! $form_id ) {
1067 1012 return;
1068 1013 }
1069 1014
@@ -1111,9 +1056,9 @@
1111 1056 public static function create_rest_routes() {
1112 1057 $args = array(
1113 1058 'methods' => 'GET',
1114 1059 'callback' => 'FrmAppController::api_install',
1115 - 'permission_callback' => self::class . '::can_update_db',
1060 + 'permission_callback' => __CLASS__ . '::can_update_db',
1116 1061 );
1117 1062
1118 1063 register_rest_route( 'frm-admin/v1', '/install', $args );
1119 1064
@@ -1130,10 +1075,8 @@
1130 1075 * Make sure the install is only being run when we tell it to.
1131 1076 * We don't want to run manually by people calling the API.
1132 1077 *
1133 1078 * @since 4.06.02
1134 - *
1135 - * @return bool
1136 1079 */
1137 1080 public static function can_update_db() {
1138 1081 return get_transient( 'frm_updating_api' );
1139 1082 }
@@ -1163,9 +1106,9 @@
1163 1106 $response = rest_do_request( $request );
1164 1107 }
1165 1108
1166 1109 if ( $response->is_error() ) {
1167 - // If the remove post fails, use javascript instead
1110 + // if the remove post fails, use javascript instead
1168 1111 add_action( 'admin_notices', 'FrmAppController::install_js_fallback' );
1169 1112 }
1170 1113 }
1171 1114
@@ -1175,17 +1118,14 @@
1175 1118 *
1176 1119 * @return void
1177 1120 */
1178 1121 private static function maybe_add_wp_site_health() {
1179 - if ( class_exists( 'WP_Site_Health' ) ) {
1180 - return;
1122 + if ( ! class_exists( 'WP_Site_Health' ) ) {
1123 + $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
1124 + if ( file_exists( $wp_site_health_path ) ) {
1125 + require_once $wp_site_health_path;
1126 + }
1181 1127 }
1182 -
1183 - $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
1184 -
1185 - if ( file_exists( $wp_site_health_path ) ) {
1186 - require_once $wp_site_health_path;
1187 - }
1188 1128 }
1189 1129
1190 1130 /**
1191 1131 * @since 3.0
@@ -1193,14 +1133,12 @@
1193 1133 * @return true
1194 1134 */
1195 1135 public static function api_install() {
1196 1136 delete_transient( 'frm_updating_api' );
1197 -
1198 1137 if ( self::needs_update() ) {
1199 1138 $running = get_option( 'frm_install_running' );
1200 -
1201 1139 if ( false === $running || $running < strtotime( '-5 minutes' ) ) {
1202 - update_option( 'frm_install_running', time(), false );
1140 + update_option( 'frm_install_running', time(), 'no' );
1203 1141 self::install();
1204 1142 delete_option( 'frm_install_running' );
1205 1143 }
1206 1144 }
@@ -1248,13 +1186,8 @@
1248 1186
1249 1187 wp_die();
1250 1188 }
1251 1189
1252 - /**
1253 - * @param array $tables
1254 - *
1255 - * @return array
1256 - */
1257 1190 public static function drop_tables( $tables ) {
1258 1191 global $wpdb;
1259 1192 $tables[] = $wpdb->prefix . 'frm_fields';
1260 1193 $tables[] = $wpdb->prefix . 'frm_forms';
@@ -1302,15 +1235,14 @@
1302 1235
1303 1236 FrmTransLiteAppController::maybe_schedule_cron();
1304 1237 }
1305 1238
1306 - /**
1307 - * @param string $text
1308 - *
1309 - * @return string
1310 - */
1311 1239 public static function set_footer_text( $text ) {
1312 - return FrmAppHelper::is_formidable_admin() ? '' : $text;
1240 + if ( FrmAppHelper::is_formidable_admin() ) {
1241 + $text = '';
1242 + }
1243 +
1244 + return $text;
1313 1245 }
1314 1246
1315 1247 /**
1316 1248 * Add admin footer links.
@@ -1319,10 +1251,8 @@
1319 1251 *
1320 1252 * @return void
1321 1253 */
1322 1254 public static function add_admin_footer_links() {
1323 - FrmFormsController::include_device_too_small_message();
1324 -
1325 1255 if ( self::should_show_footer_links() ) {
1326 1256 include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php';
1327 1257 }
1328 1258 }
@@ -1337,9 +1267,8 @@
1337 1267 private static function should_show_footer_links() {
1338 1268 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
1339 1269 $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type;
1340 1270 $show_footer_links = $is_formidable_page;
1341 -
1342 1271 if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) {
1343 1272 $show_footer_links = false;
1344 1273 }
1345 1274
@@ -1348,9 +1277,8 @@
1348 1277 *
1349 1278 * @since 6.7
1350 1279 *
1351 1280 * @param bool $show_footer_links
1352 - *
1353 1281 * @return bool
1354 1282 */
1355 1283 return apply_filters( 'frm_show_footer_links', $show_footer_links );
1356 1284 }
@@ -1364,10 +1292,8 @@
1364 1292 *
1365 1293 * @return void
1366 1294 */
1367 1295 public static function show_error_modal( $error_args ) {
1368 - add_filter( 'frm_show_footer_links', '__return_false' );
1369 -
1370 1296 $defaults = array(
1371 1297 'title' => '',
1372 1298 'body' => '',
1373 1299 'cancel_url' => '',
@@ -1377,9 +1303,8 @@
1377 1303 'icon' => 'frm_lock_simple',
1378 1304 );
1379 1305
1380 1306 $error_args = wp_parse_args( $error_args, $defaults );
1381 -
1382 1307 if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) {
1383 1308 $error_args['cancel_text'] = __( 'Cancel', 'formidable' );
1384 1309 }
1385 1310
@@ -1396,9 +1321,8 @@
1396 1321 * @since 6.4
1397 1322 *
1398 1323 * @param string $plugin_url URL of the plugin.
1399 1324 * @param string $version Current version of the plugin.
1400 - *
1401 1325 * @return void
1402 1326 */
1403 1327 private static function enqueue_floating_links( $plugin_url, $version ) {
1404 1328 if ( ! $plugin_url || ! $version ) {
@@ -1418,20 +1342,10 @@
1418 1342 if ( function_exists( 'wp_set_script_translations' ) ) {
1419 1343 wp_set_script_translations( 's11-floating-links-config', 's11-' );
1420 1344 }
1421 1345
1422 - $upgrade_utm = array(
1423 - 'campaign' => 'floating-links',
1424 - 'content' => 'floating-links-upgrade',
1425 - );
1426 - $docs_utm = array(
1427 - 'campaign' => 'floating-links',
1428 - 'content' => 'floating-links-docs',
1429 - );
1430 1346 $floating_links_data = array(
1431 - 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1432 - 'upgradeUrl' => FrmAppHelper::admin_upgrade_link( $upgrade_utm ),
1433 - 'documentationUrl' => FrmAppHelper::admin_upgrade_link( $docs_utm, 'knowledgebase/' ),
1347 + 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1434 1348 );
1435 1349 wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
1436 1350
1437 1351 /**
@@ -1443,48 +1357,35 @@
1443 1357 do_action( 'frm_enqueue_floating_links' );
1444 1358 }
1445 1359
1446 1360 /**
1361 + * @deprecated 3.0 This is still referenced in https://formidableforms.com/knowledgebase/php-examples/ as of May 8, 2024.
1362 + * @codeCoverageIgnore
1363 + */
1364 + public static function page_route( $content ) {
1365 + return FrmDeprecated::page_route( $content );
1366 + }
1367 +
1368 + /**
1447 1369 * Check if we are in our admin pages.
1448 1370 *
1449 1371 * @return bool
1450 1372 */
1451 1373 private static function in_our_pages() {
1452 - global $current_screen, $pagenow;
1453 -
1454 - if ( FrmAppHelper::is_formidable_admin() ) {
1455 - return true;
1456 - }
1457 -
1458 - if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) {
1459 - return true;
1460 - }
1461 -
1462 - return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' );
1374 + global $current_screen;
1375 + return FrmAppHelper::is_formidable_admin() || ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type );
1463 1376 }
1464 1377
1465 1378 /**
1466 - * Handles actions related to the current screen.
1379 + * Hide all third-parties admin notices only in our admin pages.
1467 1380 *
1468 - * @since 6.19
1469 - *
1470 1381 * @return void
1471 1382 */
1472 - public static function handle_current_screen() {
1383 + public static function filter_admin_notices() {
1473 1384 if ( ! self::in_our_pages() ) {
1474 1385 return;
1475 1386 }
1476 1387
1477 - self::filter_admin_notices();
1478 - self::remember_custom_sort();
1479 - }
1480 -
1481 - /**
1482 - * Hide all third-parties admin notices only in our admin pages.
1483 - *
1484 - * @return void
1485 - */
1486 - public static function filter_admin_notices() {
1487 1388 $actions = array(
1488 1389 'admin_notices',
1489 1390 'network_admin_notices',
1490 1391 'user_admin_notices',
@@ -1496,9 +1397,8 @@
1496 1397 foreach ( $actions as $action ) {
1497 1398 if ( empty( $wp_filter[ $action ]->callbacks ) ) {
1498 1399 continue;
1499 1400 }
1500 -
1501 1401 foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) {
1502 1402 foreach ( $callbacks as $callback_name => $callback ) {
1503 1403 if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) {
1504 1404 continue;
@@ -1509,115 +1409,8 @@
1509 1409 }
1510 1410 }
1511 1411
1512 1412 /**
1513 - * Remembers and applies user-specific sorting preferences.
1514 - *
1515 - * @return void
1516 - */
1517 - private static function remember_custom_sort() {
1518 - $meta_key = self::get_sort_pref_user_meta_key();
1519 -
1520 - if ( false === $meta_key ) {
1521 - return;
1522 - }
1523 -
1524 - $is_form_list = FrmAppHelper::is_admin_list_page();
1525 - $is_entry_list = FrmAppHelper::is_admin_list_page( 'formidable-entries' );
1526 -
1527 - if ( ! $is_form_list && ! $is_entry_list ) {
1528 - return;
1529 - }
1530 -
1531 - $orderby = FrmAppHelper::get_param( 'orderby' );
1532 -
1533 - if ( ! $orderby ) {
1534 - return;
1535 - }
1536 -
1537 - $user_id = get_current_user_id();
1538 - $order = FrmAppHelper::get_param( 'order' );
1539 - $new_sort = array(
1540 - 'orderby' => $orderby,
1541 - 'order' => $order,
1542 - );
1543 - $previous_meta = get_user_meta( $user_id, $meta_key, true );
1544 - $current_sort = $previous_meta;
1545 - $form_id = $is_entry_list ? FrmAppHelper::simple_get( 'form', 'absint' ) : 0;
1546 -
1547 - if ( is_array( $current_sort ) && $form_id && is_int( $form_id ) && isset( $current_sort[ $form_id ] ) ) {
1548 - $current_sort = $current_sort[ $form_id ];
1549 - }
1550 -
1551 - if ( $new_sort === $current_sort ) {
1552 - return;
1553 - }
1554 -
1555 - $new_meta = $new_sort;
1556 -
1557 - if ( $is_entry_list && $form_id && is_int( $form_id ) ) {
1558 - // Index meta by form ID.
1559 - $temp_meta = is_array( $previous_meta ) ? $previous_meta : array();
1560 - $temp_meta[ $form_id ] = $new_meta;
1561 - $new_meta = $temp_meta;
1562 - unset( $temp_meta );
1563 - }
1564 -
1565 - update_user_meta( $user_id, $meta_key, $new_meta );
1566 - }
1567 -
1568 - /**
1569 - * Retrieve and apply any saved sorting preferences for the current screen.
1570 - *
1571 - * @since 6.19
1572 - *
1573 - * @param string $orderby Reference to the current 'orderby' parameter.
1574 - * @param string $order Reference to the current 'order' parameter.
1575 - *
1576 - * @return void
1577 - */
1578 - public static function apply_saved_sort_preference( &$orderby, &$order ) {
1579 - $meta_key = self::get_sort_pref_user_meta_key();
1580 -
1581 - if ( false === $meta_key ) {
1582 - return;
1583 - }
1584 -
1585 - $preferred_list_sort = get_user_meta( get_current_user_id(), $meta_key, true );
1586 - $form_id = FrmAppHelper::simple_get( 'form', 'absint' );
1587 -
1588 - if ( is_array( $preferred_list_sort ) && $form_id && is_int( $form_id ) && isset( $preferred_list_sort[ $form_id ] ) ) {
1589 - $preferred_list_sort = $preferred_list_sort[ $form_id ];
1590 - }
1591 -
1592 - if ( ! is_array( $preferred_list_sort ) || empty( $preferred_list_sort['orderby'] ) ) {
1593 - return;
1594 - }
1595 -
1596 - $orderby = $preferred_list_sort['orderby'];
1597 -
1598 - if ( ! empty( $preferred_list_sort['order'] ) ) {
1599 - $order = $preferred_list_sort['order'];
1600 - }
1601 - }
1602 -
1603 - /**
1604 - * Get a simple user meta key that only includes the screen ID.
1605 - *
1606 - * @since 6.25.1
1607 - *
1608 - * @return false|string
1609 - */
1610 - private static function get_sort_pref_user_meta_key() {
1611 - if ( ! function_exists( 'get_current_screen' ) ) {
1612 - return false;
1613 - }
1614 -
1615 - $screen = get_current_screen();
1616 - return $screen ? 'frm_preferred_list_sort_' . $screen->id : false;
1617 - }
1618 -
1619 - /**
1620 1413 * Validate that the callback name is ours not from third-party.
1621 1414 *
1622 1415 * @param string $callback_name WordPress callback name.
1623 1416 *
@@ -1634,68 +1427,10 @@
1634 1427 *
1635 1428 * @return bool
1636 1429 */
1637 1430 private static function is_our_callback_array( $callback ) {
1638 - return ! empty( $callback['function'] ) && is_array( $callback['function'] ) && ! empty( $callback['function'][0] ) && self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
1639 - }
1640 -
1641 - /**
1642 - * In some cases, the DB tables may fail to install.
1643 - * This function tries to add them again when the user clicks the link to try again
1644 - * from the given inbox notice.
1645 - *
1646 - * @since 6.19
1647 - */
1648 - private static function add_missing_tables() {
1649 - FrmAppHelper::permission_check( 'frm_view_forms' );
1650 -
1651 - $error = FrmInbox::check_for_error();
1652 -
1653 - if ( ! $error || 'failed-to-create-tables' !== $error['key'] ) {
1654 - // Confirm the inbox item with this CTA exists.
1655 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1656 - exit;
1657 - }
1658 -
1659 - global $wpdb;
1660 - $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->prefix . 'frm_forms' ) );
1661 -
1662 - if ( $exists ) {
1663 - // Exit early if the table already exists.
1664 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1665 - exit;
1666 - }
1667 -
1668 - delete_option( 'frm_db_version' );
1669 - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) );
1670 - exit;
1671 - }
1672 -
1673 - /**
1674 - * Handles the small screen proceed action.
1675 - *
1676 - * @since 6.21
1677 - *
1678 - * @return void
1679 - */
1680 - public static function small_screen_proceed() {
1681 - FrmAppHelper::permission_check( 'frm_view_forms' );
1682 - check_ajax_referer( 'frm_ajax', 'nonce' );
1683 - update_user_option( get_current_user_id(), 'frm_ignore_small_screen_warning', true );
1684 - wp_send_json_success();
1685 - }
1686 -
1687 - /**
1688 - * Enqueue the components scripts.
1689 - *
1690 - * @since 6.28
1691 - *
1692 - * @return void
1693 - */
1694 - public static function enqueue_components_scripts() {
1695 - if ( is_callable( array( 'FrmProFormsController', 'enqueue_pro_web_components_script' ) ) ) {
1696 - FrmProFormsController::enqueue_pro_web_components_script();
1697 - }
1698 -
1699 - wp_enqueue_script( 'formidable-web-components' );
1431 + return ! empty( $callback['function'] ) &&
1432 + is_array( $callback['function'] ) &&
1433 + ! empty( $callback['function'][0] ) &&
1434 + self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] );
1700 1435 }
1701 1436 }