PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.07.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.07.01
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 +67 -515 6.3.24.07.01 View file →
@@ -4,11 +4,8 @@
4 4 }
5 5
6 6 class FrmAppController {
7 7
8 - /**
9 - * @return void
10 - */
11 8 public static function menu() {
12 9 FrmAppHelper::maybe_add_permissions();
13 10 if ( ! current_user_can( 'frm_view_forms' ) ) {
14 11 return;
@@ -17,13 +14,10 @@
17 14 $menu_name = FrmAppHelper::get_menu_name();
18 15 add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
19 16 }
20 17
21 - /**
22 - * @return int
23 - */
24 18 private static function get_menu_position() {
25 - return (int) apply_filters( 'frm_menu_position', 29 );
19 + return apply_filters( 'frm_menu_position', '29.3' );
26 20 }
27 21
28 22 /**
29 23 * @since 3.05
@@ -62,47 +56,16 @@
62 56 }
63 57 }
64 58
65 59 if ( FrmAppHelper::is_full_screen() ) {
66 - $full_screen_on = self::get_full_screen_setting();
67 - $add_class = '';
68 - if ( $full_screen_on ) {
69 - $add_class = ' frm-full-screen is-fullscreen-mode';
70 - wp_enqueue_style( 'wp-edit-post' ); // Load the CSS for .is-fullscreen-mode.
71 - }
72 - $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
60 + $classes .= apply_filters( 'frm_admin_full_screen_class', ' frm-full-screen folded' );
73 61 }
74 62
75 - if ( ! FrmAppHelper::pro_is_installed() ) {
76 - $classes .= ' frm-lite ';
77 - }
78 -
79 63 return $classes;
80 64 }
81 65
82 66 /**
83 - * Get the full screen mode setting from the block editor.
84 - *
85 - * @since 6.1
86 - *
87 - * @return bool
88 - */
89 - private static function get_full_screen_setting() {
90 - global $wpdb;
91 - $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences';
92 -
93 - $prefs = get_user_meta( get_current_user_id(), $meta_key, true );
94 - if ( $prefs && isset( $prefs['core/edit-post']['fullscreenMode'] ) ) {
95 - return $prefs['core/edit-post']['fullscreenMode'];
96 - }
97 -
98 - return true;
99 - }
100 -
101 - /**
102 67 * @since 4.0
103 - *
104 - * @return string
105 68 */
106 69 private static function get_os() {
107 70 $agent = strtolower( FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ) );
108 71 $os = '';
@@ -123,9 +86,8 @@
123 86 $white_pages = array(
124 87 'formidable',
125 88 'formidable-entries',
126 89 'formidable-views',
127 - 'formidable-views-editor',
128 90 'formidable-pro-upgrade',
129 91 'formidable-addons',
130 92 'formidable-import',
131 93 'formidable-settings',
@@ -131,14 +93,12 @@
131 93 'formidable-settings',
132 94 'formidable-styles',
133 95 'formidable-styles2',
134 96 'formidable-inbox',
135 - 'formidable-welcome',
136 - 'formidable-applications',
137 97 );
138 98
139 99 $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
140 - $is_white_page = in_array( $get_page, $white_pages, true );
100 + $is_white_page = in_array( $get_page, $white_pages );
141 101
142 102 if ( ! $is_white_page ) {
143 103 $screen = get_current_screen();
144 104 $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
@@ -143,35 +103,15 @@
143 103 $screen = get_current_screen();
144 104 $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
145 105 }
146 106
147 - /**
148 - * Allow another add on to style a page as a Formidable "white page", which adds a white background color.
149 - *
150 - * @since 5.3
151 - *
152 - * @param bool $is_white_page
153 - */
154 - $is_white_page = apply_filters( 'frm_is_white_page', $is_white_page );
155 -
156 107 return $is_white_page;
157 108 }
158 109
159 - /**
160 - * @return void
161 - */
162 110 public static function load_wp_admin_style() {
163 111 FrmAppHelper::load_font_style();
164 112 }
165 113
166 - /**
167 - * @param bool $show_nav
168 - * @param string $title
169 - *
170 - * @psalm-param 'hide'|'show' $title
171 - *
172 - * @return void
173 - */
174 114 public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
175 115 $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
176 116 if ( empty( $show_nav ) || ! $form ) {
177 117 return;
@@ -188,11 +128,8 @@
188 128
189 129 include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
190 130 }
191 131
192 - /**
193 - * @return string
194 - */
195 132 private static function get_current_page() {
196 133 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
197 134 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
198 135 $current_page = isset( $_GET['page'] ) ? $page : $post_type;
@@ -203,12 +140,8 @@
203 140
204 141 return $current_page;
205 142 }
206 143
207 - /**
208 - * @param object $form
209 - * @return array
210 - */
211 144 private static function get_form_nav_items( $form ) {
212 145 $id = $form->parent_form_id ? $form->parent_form_id : $form->id;
213 146
214 147 $nav_items = array(
@@ -219,15 +152,8 @@
219 152 'page' => 'formidable',
220 153 'permission' => 'frm_edit_forms',
221 154 ),
222 155 array(
223 - 'link' => FrmStylesHelper::get_list_url( $id ),
224 - 'label' => __( 'Style', 'formidable' ),
225 - 'current' => array(),
226 - 'page' => 'formidable-styles',
227 - 'permission' => 'frm_edit_forms',
228 - ),
229 - array(
230 156 'link' => admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . absint( $id ) ),
231 157 'label' => __( 'Settings', 'formidable' ),
232 158 'current' => array( 'settings' ),
233 159 'page' => 'formidable',
@@ -233,9 +159,9 @@
233 159 'page' => 'formidable',
234 160 'permission' => 'frm_edit_forms',
235 161 ),
236 162 array(
237 - 'link' => admin_url( 'admin.php?page=formidable-entries&frm_action=list&form=' . absint( $id ) ),
163 + 'link' => admin_url( 'admin.php?page=formidable-entries&frm-full=1&frm_action=list&form=' . absint( $id ) ),
238 164 'label' => __( 'Entries', 'formidable' ),
239 165 'current' => array(),
240 166 'page' => 'formidable-entries',
241 167 'permission' => 'frm_view_entries',
@@ -241,13 +167,12 @@
241 167 'permission' => 'frm_view_entries',
242 168 ),
243 169 );
244 170
245 - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed();
246 -
247 - if ( ! $views_installed ) {
171 + // Let people know reports and views exist.
172 + if ( ! FrmAppHelper::pro_is_installed() ) {
248 173 $nav_items[] = array(
249 - 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
174 + 'link' => admin_url( 'admin.php?page=formidable-views&frm-full=1&form=' . absint( $id ) ),
250 175 'label' => __( 'Views', 'formidable' ),
251 176 'current' => array(),
252 177 'page' => 'formidable-views',
253 178 'permission' => 'frm_view_entries',
@@ -254,14 +179,10 @@
254 179 'atts' => array(
255 180 'class' => 'frm_noallow',
256 181 ),
257 182 );
258 - }
259 -
260 - // Let people know reports and views exist.
261 - if ( ! FrmAppHelper::pro_is_installed() ) {
262 183 $nav_items[] = array(
263 - 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ),
184 + 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&frm-full=1&form=' . absint( $id ) ),
264 185 'label' => __( 'Reports', 'formidable' ),
265 186 'current' => array( 'reports' ),
266 187 'page' => 'formidable',
267 188 'permission' => 'frm_view_entries',
@@ -275,30 +196,19 @@
275 196 'form_id' => $id,
276 197 'form' => $form,
277 198 );
278 199
279 - return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
200 + return apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
280 201 }
281 202
282 203 // Adds a settings link to the plugins page
283 - /**
284 - * @return array
285 - */
286 204 public static function settings_link( $links ) {
287 - $settings = array();
205 + $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
206 + array_unshift( $links, $settings );
288 207
289 - if ( ! FrmAppHelper::pro_is_installed() ) {
290 - $settings[] = '<a href="' . esc_url( FrmAppHelper::admin_upgrade_link( 'plugin-row' ) ) . '" target="_blank" rel="noopener"><b>' . esc_html__( 'Upgrade to Pro', 'formidable' ) . '</b></a>';
291 - }
292 -
293 - $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
294 -
295 - return array_merge( $settings, $links );
208 + return $links;
296 209 }
297 210
298 - /**
299 - * @return void
300 - */
301 211 public static function pro_get_started_headline() {
302 212 self::review_request();
303 213 FrmAppHelper::min_pro_version_notice( '4.0' );
304 214 }
@@ -306,10 +216,8 @@
306 216 /**
307 217 * Add admin notices as needed for reviews
308 218 *
309 219 * @since 3.04.03
310 - *
311 - * @return void
312 220 */
313 221 private static function review_request() {
314 222 $reviews = new FrmReviews();
315 223 $reviews->review_request();
@@ -318,10 +226,8 @@
318 226 /**
319 227 * Save the request to hide the review
320 228 *
321 229 * @since 3.04.03
322 - *
323 - * @return void
324 230 */
325 231 public static function dismiss_review() {
326 232 FrmAppHelper::permission_check( 'frm_change_settings' );
327 233 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -331,32 +237,18 @@
331 237 }
332 238
333 239 /**
334 240 * @since 3.04.02
335 - *
336 - * @return void
337 241 */
338 242 public static function include_upgrade_overlay() {
339 - self::enqueue_dialog_assets();
340 - add_action( 'admin_footer', 'FrmAppController::upgrade_overlay_html' );
341 - }
342 -
343 - /**
344 - * Enqueue scripts and styles required for modals.
345 - *
346 - * @since 5.3
347 - *
348 - * @return void
349 - */
350 - public static function enqueue_dialog_assets() {
351 243 wp_enqueue_script( 'jquery-ui-dialog' );
352 244 wp_enqueue_style( 'jquery-ui-dialog' );
245 +
246 + add_action( 'admin_footer', 'FrmAppController::upgrade_overlay_html' );
353 247 }
354 248
355 249 /**
356 250 * @since 3.06.03
357 - *
358 - * @return void
359 251 */
360 252 public static function upgrade_overlay_html() {
361 253 $is_pro = FrmAppHelper::pro_is_installed();
362 254 $upgrade_link = array(
@@ -363,89 +255,27 @@
363 255 'medium' => 'builder',
364 256 'content' => 'upgrade',
365 257 );
366 258 $default_link = FrmAppHelper::admin_upgrade_link( $upgrade_link );
367 - $plugin_path = FrmAppHelper::plugin_path();
368 - $shared_path = $plugin_path . '/classes/views/shared/';
369 259
370 - include $shared_path . 'upgrade_overlay.php';
371 - include $shared_path . 'confirm-overlay.php';
260 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/upgrade_overlay.php' );
372 261
373 - if ( FrmAppHelper::is_admin_page( 'formidable-welcome' ) || FrmAppHelper::on_form_listing_page() ) {
374 - self::new_form_overlay_html();
375 - }
262 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/confirm-overlay.php' );
376 263 }
377 264
378 - /**
379 - * @return void
380 - */
381 - private static function new_form_overlay_html() {
382 - FrmFormsController::before_list_templates();
265 + public static function include_info_overlay() {
266 + wp_enqueue_script( 'jquery-ui-dialog' );
267 + wp_enqueue_style( 'jquery-ui-dialog' );
383 268
384 - $plugin_path = FrmAppHelper::plugin_path();
385 - $path = $plugin_path . '/classes/views/frm-forms/';
386 - $expired = FrmFormsController::expired();
387 - $expiring = FrmAddonsController::is_license_expiring();
388 - $user = wp_get_current_user(); // $user used in leave-email.php to determine a default value for field
389 - $view_path = $path . 'new-form-overlay/';
390 - $modal_class = '';
391 - $upgrade_link = FrmAppHelper::admin_upgrade_link(
392 - array(
393 - 'medium' => 'new-template',
394 - 'content' => 'upgrade',
395 - )
396 - );
397 - $renew_link = FrmAppHelper::admin_upgrade_link(
398 - array(
399 - 'medium' => 'new-template',
400 - 'content' => 'renew',
401 - )
402 - );
403 - $blocks_to_render = array();
404 -
405 - if ( ! FrmAppHelper::pro_is_installed() ) {
406 - // avoid rendering the email and code blocks for users who have upgraded or have a free license already
407 - $api = new FrmFormTemplateApi();
408 - if ( ! $api->has_free_access() ) {
409 - array_push( $blocks_to_render, 'email', 'code' );
410 - }
411 - }
412 -
413 - // avoid rendering the upgrade block for users with elite
414 - if ( 'elite' !== FrmAddonsController::license_type() ) {
415 - $blocks_to_render[] = 'upgrade';
416 - }
417 -
418 - // avoid rendering the renew block for users who are not currently expired
419 - if ( $expired ) {
420 - $blocks_to_render[] = 'renew';
421 - $modal_class = 'frm-expired';
422 - } elseif ( $expiring ) {
423 - $modal_class = 'frm-expiring';
424 - }
425 -
426 - include $path . 'new-form-overlay.php';
427 - }
428 -
429 - /**
430 - * @return void
431 - */
432 - public static function include_info_overlay() {
433 - self::enqueue_dialog_assets();
434 269 add_action( 'admin_footer', 'FrmAppController::info_overlay_html' );
435 270 }
436 271
437 - /**
438 - * @return void
439 - */
440 272 public static function info_overlay_html() {
441 - include FrmAppHelper::plugin_path() . '/classes/views/shared/info-overlay.php';
273 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/info-overlay.php' );
442 274 }
443 275
444 276 /**
445 277 * @since 3.04.02
446 - *
447 - * @return void
448 278 */
449 279 public static function remove_upsells() {
450 280 remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
451 281 remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
@@ -457,17 +287,12 @@
457 287 * If there are CURL problems on this server, wp_remote_post won't work for installing
458 288 * Use a javascript fallback instead.
459 289 *
460 290 * @since 2.0.3
461 - *
462 - * @return void
463 291 */
464 292 public static function install_js_fallback() {
465 293 FrmAppHelper::load_admin_wide_js();
466 - ?>
467 - <div id="frm_install_message"></div>
468 - <script>jQuery(document).ready( frm_install_now );</script>
469 - <?php
294 + echo '<div id="hidden frm_install_message"></div><script type="text/javascript">jQuery(document).ready(function(){frm_install_now();});</script>';
470 295 }
471 296
472 297 /**
473 298 * Check if the database is outdated
@@ -494,11 +319,8 @@
494 319 /**
495 320 * Check both version number and DB number for changes
496 321 *
497 322 * @since 3.0.04
498 - *
499 - * @param array $atts
500 - * @return bool
501 323 */
502 324 public static function compare_for_update( $atts ) {
503 325 $db_version = get_option( $atts['option'] );
504 326
@@ -517,21 +339,10 @@
517 339 /**
518 340 * Check for database update and trigger js loading
519 341 *
520 342 * @since 2.0.1
521 - *
522 - * @return void
523 343 */
524 344 public static function admin_init() {
525 - if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) {
526 - FrmFormsController::duplicate();
527 - }
528 -
529 - if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) {
530 - // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent.
531 - FrmStylesController::save_style();
532 - }
533 -
534 345 new FrmPersonalData(); // register personal data hooks
535 346
536 347 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
537 348 self::network_upgrade_site();
@@ -540,111 +351,15 @@
540 351 if ( ! FrmAppHelper::doing_ajax() ) {
541 352 // don't continue during ajax calls
542 353 self::admin_js();
543 354 }
544 -
545 - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
546 - $action = FrmAppHelper::get_param( 'frm_action' );
547 -
548 - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) {
549 - wp_safe_redirect( admin_url( 'admin.php?page=formidable&triggerNewFormModal=1' ) );
550 - exit;
551 - }
552 -
553 - FrmInbox::maybe_disable_screen_options();
554 - }
555 -
556 - self::maybe_add_ip_warning();
557 355 }
558 356
559 - /**
560 - * Show a warning for the IP address setting if it hasn't been set.
561 - *
562 - * @since 6.1
563 - *
564 - * @return void
565 - */
566 - private static function maybe_add_ip_warning() {
567 - $settings = FrmAppHelper::get_settings();
568 - if ( false !== $settings->custom_header_ip ) {
569 - // The setting has been changed from the false default (to either 1 or 0), so stop showing the message.
570 - return;
571 - }
572 -
573 - if ( ! self::is_behind_proxy() ) {
574 - // This message is only applicable when using a reverse proxy.
575 - return;
576 - }
577 -
578 - if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) {
579 - // Avoid the message on a POST action. We don't want to show the message if we're saving global settings.
580 - return;
581 - }
582 -
583 - $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip';
584 - $message = sprintf(
585 - // Translators: 1: Global Settings Link
586 - __( 'IP addresses in form submissions may no longer be accurate! If you are experiencing issues, we recommend going to %1$s and enabling the "Use custom headers when retrieving IPs with form submissions." setting.', 'formidable' ),
587 - '<a href="' . esc_url( $global_settings_link ) . '">Global Settings</a>'
588 - );
589 - $option_name = 'frm_dismiss_ip_address_notice';
590 - FrmAppHelper::add_dismissable_warning_message( $message, $option_name );
591 - }
592 -
593 - /**
594 - * Check if any reverse proxy headers are set.
595 - *
596 - * @since 6.1
597 - *
598 - * @return bool
599 - */
600 - private static function is_behind_proxy() {
601 - $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip();
602 - foreach ( $custom_headers as $header ) {
603 - if ( 'REMOTE_ADDR' === $header ) {
604 - // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers.
605 - continue;
606 - }
607 -
608 - $ip = trim( FrmAppHelper::get_server_value( $header ) );
609 - // Return true for anything that isn't empty but ignoring values like ::1.
610 - if ( $ip && 0 !== strpos( $ip, '::' ) ) {
611 - return true;
612 - }
613 - }
614 -
615 - return false;
616 - }
617 -
618 - /**
619 - * @return void
620 - */
621 357 public static function admin_js() {
622 - $plugin_url = FrmAppHelper::plugin_url();
623 - $version = FrmAppHelper::plugin_version();
624 -
358 + $version = FrmAppHelper::plugin_version();
625 359 FrmAppHelper::load_admin_wide_js();
626 360
627 - wp_register_style( 'formidable_admin_global', $plugin_url . '/css/admin/frm_admin_global.css', array(), $version );
628 - wp_enqueue_style( 'formidable_admin_global' );
629 -
630 - wp_register_style( 'formidable-admin', $plugin_url . '/css/frm_admin.css', array(), $version );
631 - wp_register_style( 'formidable-grids', $plugin_url . '/css/frm_grids.css', array(), $version );
632 -
633 - wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true );
634 - wp_register_script( 'formidable_embed', $plugin_url . '/js/admin/embed.js', array( 'formidable_dom', 'jquery-ui-autocomplete' ), $version, true );
635 - self::register_popper1();
636 - wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true );
637 - wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true );
638 -
639 - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
640 -
641 - if ( 'formidable-applications' === $page ) {
642 - FrmApplicationsController::load_assets();
643 - return;
644 - }
645 -
646 - $dependencies = array(
361 + $dependecies = array(
647 362 'formidable_admin_global',
648 363 'jquery',
649 364 'jquery-ui-core',
650 365 'jquery-ui-draggable',
@@ -650,38 +365,32 @@
650 365 'jquery-ui-draggable',
651 366 'jquery-ui-sortable',
652 367 'bootstrap_tooltip',
653 368 'bootstrap-multiselect',
654 - 'wp-i18n',
655 - 'wp-hooks', // Required in WP versions older than 5.7
656 - 'formidable_dom',
657 - 'formidable_embed',
658 369 );
659 370
660 - if ( FrmAppHelper::is_style_editor_page( 'edit' ) ) {
661 - // We only need to load the color picker when editing styles.
662 - $dependencies[] = 'wp-color-picker';
371 + if ( FrmAppHelper::is_admin_page( 'formidable-styles' ) || FrmAppHelper::is_admin_page( 'formidable-styles2' ) ) {
372 + $dependecies[] = 'wp-color-picker';
663 373 }
664 374
665 - wp_register_script( 'formidable_admin', $plugin_url . '/js/formidable_admin.js', $dependencies, $version, true );
375 + wp_register_script( 'formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', $dependecies, $version, true );
376 + wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
377 + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
378 + wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
666 379
667 - if ( FrmAppHelper::on_form_listing_page() ) {
668 - // For the existing page dropdown in the Form embed modal.
669 - wp_enqueue_script( 'jquery-ui-autocomplete' );
670 - }
380 + // load multselect js
381 + $depends_on = array( 'jquery', 'bootstrap_tooltip' );
382 + wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', $depends_on, '0.9.8', true );
671 383
672 - wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
673 -
384 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
674 385 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
675 386
676 387 global $pagenow;
677 - if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
388 + if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
678 389
679 390 wp_enqueue_script( 'admin-widgets' );
680 391 wp_enqueue_style( 'widgets' );
681 - self::maybe_deregister_popper2();
682 392 wp_enqueue_script( 'formidable_admin' );
683 - wp_enqueue_script( 'formidable_embed' );
684 393 FrmAppHelper::localize_script( 'admin' );
685 394
686 395 wp_enqueue_style( 'formidable-admin' );
687 396 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
@@ -687,9 +396,12 @@
687 396 if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
688 397 wp_enqueue_style( 'formidable-grids' );
689 398 wp_enqueue_style( 'formidable-dropzone' );
690 399 } else {
691 - wp_enqueue_style( 'formidable-grids' );
400 + $settings = FrmAppHelper::get_settings();
401 + if ( empty( $settings->old_css ) ) {
402 + wp_enqueue_style( 'formidable-grids' );
403 + }
692 404 }
693 405
694 406 if ( 'formidable-entries' === $page ) {
695 407 // Load front end js for entries.
@@ -711,133 +423,19 @@
711 423 } else {
712 424 return;
713 425 }
714 426
715 - if ( $post_type === 'frm_display' ) {
716 - self::enqueue_legacy_views_assets();
427 + if ( $post_type == 'frm_display' ) {
428 + wp_enqueue_style( 'formidable-grids' );
429 + wp_enqueue_script( 'jquery-ui-draggable' );
430 + wp_enqueue_script( 'formidable_admin' );
431 + wp_enqueue_style( 'formidable-admin' );
432 + FrmAppHelper::localize_script( 'admin' );
433 + self::include_info_overlay();
717 434 }
718 435 }
719 -
720 436 }
721 437
722 - /**
723 - * @since 6.3.2
724 - *
725 - * @return void
726 - */
727 - public static function admin_enqueue_scripts() {
728 - self::load_wp_admin_style();
729 - self::maybe_force_formidable_block_on_gutenberg_page();
730 - }
731 -
732 - /**
733 - * Enqueue required assets for the Legacy Views editor (Views v4.x).
734 - *
735 - * @since 6.1.2
736 - *
737 - * @return void
738 - */
739 - private static function enqueue_legacy_views_assets() {
740 - wp_enqueue_style( 'formidable-grids' );
741 - wp_enqueue_script( 'jquery-ui-draggable' );
742 - self::maybe_deregister_popper2();
743 - wp_enqueue_script( 'formidable_admin' );
744 - wp_add_inline_style(
745 - 'formidable-admin',
746 - '
747 - .frm-white-body.post-type-frm_display .columns-2 {
748 - display: block;
749 - overflow: visible;
750 - }
751 -
752 - .frm-white-body.post-type-frm_display .columns-2 > div {
753 - overflow-y: hidden;
754 - }
755 -
756 - .frm-white-body.post-type-frm_display #titlediv #title-prompt-text {
757 - padding: 3px 0 0 10px;
758 - }
759 -
760 - .post-type-frm_display #field-search-input,
761 - .post-type-frm_display #advanced-search-input {
762 - flex: 1;
763 - }
764 - '
765 - );
766 - wp_enqueue_style( 'formidable-admin' );
767 - FrmAppHelper::localize_script( 'admin' );
768 - self::include_info_overlay();
769 - }
770 -
771 - /**
772 - * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459.
773 - *
774 - * @since 5.2.02.01
775 - *
776 - * @return void
777 - */
778 - private static function maybe_deregister_popper2() {
779 - global $wp_scripts;
780 -
781 - if ( ! array_key_exists( 'popper', $wp_scripts->registered ) ) {
782 - return;
783 - }
784 -
785 - $popper = $wp_scripts->registered['popper'];
786 - if ( version_compare( $popper->ver, '2.0', '>=' ) ) {
787 - wp_deregister_script( 'popper' );
788 - self::register_popper1();
789 - }
790 - }
791 -
792 - /**
793 - * Register Popper required for Bootstrap 4.
794 - *
795 - * @since 5.2.02.01
796 - *
797 - * @return void
798 - */
799 - private static function register_popper1() {
800 - wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
801 - }
802 -
803 - /**
804 - * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set.
805 - *
806 - * @since 5.2
807 - *
808 - * @return void
809 - */
810 - private static function maybe_force_formidable_block_on_gutenberg_page() {
811 - global $pagenow;
812 - if ( 'post.php' !== $pagenow ) {
813 - return;
814 - }
815 -
816 - $form_id = FrmAppHelper::simple_get( 'frmForm', 'absint' );
817 - if ( ! $form_id ) {
818 - return;
819 - }
820 -
821 - self::add_js_to_inject_gutenberg_block( 'formidable/simple-form', 'formId', $form_id );
822 - }
823 -
824 - /**
825 - * @since 5.3
826 - *
827 - * @param string $block_name
828 - * @param string $object_key
829 - * @param array|string $object_id
830 - *
831 - * @return void
832 - */
833 - public static function add_js_to_inject_gutenberg_block( $block_name, $object_key, $object_id ) {
834 - require FrmAppHelper::plugin_path() . '/classes/views/shared/edit-page-js.php';
835 - }
836 -
837 - /**
838 - * @return void
839 - */
840 438 public static function load_lang() {
841 439 load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
842 440 }
843 441
@@ -844,10 +442,8 @@
844 442 /**
845 443 * Check if the styles are updated when a form is loaded on the front-end
846 444 *
847 445 * @since 3.0.1
848 - *
849 - * @return void
850 446 */
851 447 public static function maybe_update_styles() {
852 448 if ( self::needs_update() ) {
853 449 self::network_upgrade_site();
@@ -855,10 +451,8 @@
855 451 }
856 452
857 453 /**
858 454 * @since 3.0
859 - *
860 - * @return void
861 455 */
862 456 public static function create_rest_routes() {
863 457 $args = array(
864 458 'methods' => 'GET',
@@ -866,16 +460,8 @@
866 460 'permission_callback' => __CLASS__ . '::can_update_db',
867 461 );
868 462
869 463 register_rest_route( 'frm-admin/v1', '/install', $args );
870 -
871 - $args = array(
872 - 'methods' => 'GET',
873 - 'callback' => 'FrmAddonsController::install_addon_api',
874 - 'permission_callback' => 'FrmAddonsController::can_install_addon_api',
875 - );
876 -
877 - register_rest_route( 'frm-admin/v1', '/install-addon', $args );
878 464 }
879 465
880 466 /**
881 467 * Make sure the install is only being run when we tell it to.
@@ -893,10 +479,8 @@
893 479 *
894 480 * @since 2.0.1
895 481 *
896 482 * @param int $blog_id Blog ID.
897 - *
898 - * @return void
899 483 */
900 484 public static function network_upgrade_site( $blog_id = 0 ) {
901 485 // Flag to check if install is happening as intended.
902 486 set_transient( 'frm_updating_api', true, MINUTE_IN_SECONDS );
@@ -901,10 +485,8 @@
901 485 // Flag to check if install is happening as intended.
902 486 set_transient( 'frm_updating_api', true, MINUTE_IN_SECONDS );
903 487 $request = new WP_REST_Request( 'GET', '/frm-admin/v1/install' );
904 488
905 - self::maybe_add_wp_site_health();
906 -
907 489 if ( $blog_id ) {
908 490 switch_to_blog( $blog_id );
909 491 $response = rest_do_request( $request );
910 492 restore_current_blog();
@@ -918,26 +500,9 @@
918 500 }
919 501 }
920 502
921 503 /**
922 - * Make sure WP_Site_Health has been included because it is required when calling rest_do_request.
923 - * Check first that the file exists because WP_Site_Health was only introduced in WordPress 5.2.
924 - *
925 - * @return void
926 - */
927 - private static function maybe_add_wp_site_health() {
928 - if ( ! class_exists( 'WP_Site_Health' ) ) {
929 - $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
930 - if ( file_exists( $wp_site_health_path ) ) {
931 - require_once $wp_site_health_path;
932 - }
933 - }
934 - }
935 -
936 - /**
937 504 * @since 3.0
938 - *
939 - * @return true
940 505 */
941 506 public static function api_install() {
942 507 delete_transient( 'frm_updating_api' );
943 508 if ( self::needs_update() ) {
@@ -956,29 +521,19 @@
956 521 * Silent database upgrade (no redirect).
957 522 * Called via ajax request during network upgrade process.
958 523 *
959 524 * @since 2.0.1
960 - *
961 - * @return void
962 525 */
963 526 public static function ajax_install() {
964 - FrmAppHelper::permission_check( 'frm_change_settings' );
965 - check_ajax_referer( 'frm_ajax', 'nonce' );
966 527 self::api_install();
967 528 wp_die();
968 529 }
969 530
970 - /**
971 - * @return void
972 - */
973 531 public static function install() {
974 532 $frmdb = new FrmMigrate();
975 533 $frmdb->upgrade();
976 534 }
977 535
978 - /**
979 - * @return void
980 - */
981 536 public static function uninstall() {
982 537 FrmAppHelper::permission_check( 'administrator' );
983 538 check_ajax_referer( 'frm_ajax', 'nonce' );
984 539
@@ -1002,11 +557,8 @@
1002 557
1003 558 return $tables;
1004 559 }
1005 560
1006 - /**
1007 - * @return void
1008 - */
1009 561 public static function deauthorize() {
1010 562 FrmAppHelper::permission_check( 'frm_change_settings' );
1011 563 check_ajax_referer( 'frm_ajax', 'nonce' );
1012 564
@@ -1025,45 +577,45 @@
1025 577 return $text;
1026 578 }
1027 579
1028 580 /**
1029 - * @deprecated 3.0.04
1030 - *
581 + * @deprecated 1.07.05
1031 582 * @codeCoverageIgnore
1032 - *
1033 - * @return void
1034 583 */
1035 - public static function activation_install() {
1036 - FrmDeprecated::activation_install();
584 + public static function get_form_shortcode( $atts ) {
585 + return FrmDeprecated::get_form_shortcode( $atts );
1037 586 }
1038 587
1039 588 /**
1040 - * @deprecated 3.0
589 + * @deprecated 2.5.4
1041 590 * @codeCoverageIgnore
1042 591 */
1043 - public static function page_route( $content ) {
1044 - return FrmDeprecated::page_route( $content );
592 + public static function widget_text_filter( $content ) {
593 + return FrmDeprecated::widget_text_filter( $content );
1045 594 }
1046 595
1047 596 /**
1048 - * Include icons on page for Embed Form modal.
597 + * Deprecated in favor of wpmu_upgrade_site
1049 598 *
1050 - * @since 5.2
1051 - *
1052 - * @return void
599 + * @deprecated 2.3
600 + * @codeCoverageIgnore
1053 601 */
1054 - public static function include_embed_form_icons() {
1055 - _deprecated_function( __METHOD__, '5.3' );
602 + public static function front_head() {
603 + FrmDeprecated::front_head();
1056 604 }
1057 605
1058 606 /**
1059 - * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13.
607 + * @deprecated 3.0.04
1060 608 * @codeCoverageIgnore
1061 - *
1062 - * @param array $atts
1063 - * @return string
1064 609 */
1065 - public static function get_form_shortcode( $atts ) {
1066 - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1067 - return FrmFormsController::get_form_shortcode( $atts );
610 + public static function activation_install() {
611 + FrmDeprecated::activation_install();
612 + }
613 +
614 + /**
615 + * @deprecated 3.0
616 + * @codeCoverageIgnore
617 + */
618 + public static function page_route( $content ) {
619 + return FrmDeprecated::page_route( $content );
1068 620 }
1069 621 }