PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.01.02
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.01.02
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 +137 -598 6.44.01.02 View file →
@@ -1,14 +1,8 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - die( 'You are not allowed to call this page directly.' );
4 -}
5 2
6 3 class FrmAppController {
7 4
8 - /**
9 - * @return void
10 - */
11 5 public static function menu() {
12 6 FrmAppHelper::maybe_add_permissions();
13 7 if ( ! current_user_can( 'frm_view_forms' ) ) {
14 8 return;
@@ -17,13 +11,10 @@
17 11 $menu_name = FrmAppHelper::get_menu_name();
18 12 add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
19 13 }
20 14
21 - /**
22 - * @return int
23 - */
24 15 private static function get_menu_position() {
25 - return (int) apply_filters( 'frm_menu_position', 29 );
16 + return apply_filters( 'frm_menu_position', '29.3' );
26 17 }
27 18
28 19 /**
29 20 * @since 3.05
@@ -62,47 +53,16 @@
62 53 }
63 54 }
64 55
65 56 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 );
57 + $classes .= apply_filters( 'frm_admin_full_screen_class', ' frm-full-screen folded' );
73 58 }
74 59
75 - if ( ! FrmAppHelper::pro_is_installed() ) {
76 - $classes .= ' frm-lite ';
77 - }
78 -
79 60 return $classes;
80 61 }
81 62
82 63 /**
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 64 * @since 4.0
103 - *
104 - * @return string
105 65 */
106 66 private static function get_os() {
107 67 $agent = strtolower( FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ) );
108 68 $os = '';
@@ -122,23 +82,17 @@
122 82 private static function is_white_page() {
123 83 $white_pages = array(
124 84 'formidable',
125 85 'formidable-entries',
126 - 'formidable-views',
127 - 'formidable-views-editor',
128 86 'formidable-pro-upgrade',
129 87 'formidable-addons',
130 88 'formidable-import',
131 89 'formidable-settings',
132 90 'formidable-styles',
133 - 'formidable-styles2',
134 - 'formidable-inbox',
135 - 'formidable-welcome',
136 - 'formidable-applications',
137 91 );
138 92
139 93 $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
140 - $is_white_page = in_array( $get_page, $white_pages, true );
94 + $is_white_page = in_array( $get_page, $white_pages );
141 95
142 96 if ( ! $is_white_page ) {
143 97 $screen = get_current_screen();
144 98 $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
@@ -143,35 +97,15 @@
143 97 $screen = get_current_screen();
144 98 $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false );
145 99 }
146 100
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 101 return $is_white_page;
157 102 }
158 103
159 - /**
160 - * @return void
161 - */
162 104 public static function load_wp_admin_style() {
163 105 FrmAppHelper::load_font_style();
164 106 }
165 107
166 - /**
167 - * @param bool $show_nav
168 - * @param string $title
169 - *
170 - * @psalm-param 'hide'|'show' $title
171 - *
172 - * @return void
173 - */
174 108 public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) {
175 109 $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' );
176 110 if ( empty( $show_nav ) || ! $form ) {
177 111 return;
@@ -188,11 +122,8 @@
188 122
189 123 include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' );
190 124 }
191 125
192 - /**
193 - * @return string
194 - */
195 126 private static function get_current_page() {
196 127 $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
197 128 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' );
198 129 $current_page = isset( $_GET['page'] ) ? $page : $post_type;
@@ -203,12 +134,8 @@
203 134
204 135 return $current_page;
205 136 }
206 137
207 - /**
208 - * @param object $form
209 - * @return array
210 - */
211 138 private static function get_form_nav_items( $form ) {
212 139 $id = $form->parent_form_id ? $form->parent_form_id : $form->id;
213 140
214 141 $nav_items = array(
@@ -219,15 +146,8 @@
219 146 'page' => 'formidable',
220 147 'permission' => 'frm_edit_forms',
221 148 ),
222 149 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 150 'link' => admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . absint( $id ) ),
231 151 'label' => __( 'Settings', 'formidable' ),
232 152 'current' => array( 'settings' ),
233 153 'page' => 'formidable',
@@ -233,9 +153,9 @@
233 153 'page' => 'formidable',
234 154 'permission' => 'frm_edit_forms',
235 155 ),
236 156 array(
237 - 'link' => admin_url( 'admin.php?page=formidable-entries&frm_action=list&form=' . absint( $id ) ),
157 + 'link' => admin_url( 'admin.php?page=formidable-entries&frm-full=1&frm_action=list&form=' . absint( $id ) ),
238 158 'label' => __( 'Entries', 'formidable' ),
239 159 'current' => array(),
240 160 'page' => 'formidable-entries',
241 161 'permission' => 'frm_view_entries',
@@ -241,33 +161,32 @@
241 161 'permission' => 'frm_view_entries',
242 162 ),
243 163 );
244 164
245 - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed();
246 -
247 - if ( ! $views_installed ) {
165 + // Let people know reports and views exist.
166 + if ( ! FrmAppHelper::pro_is_installed() ) {
248 167 $nav_items[] = array(
249 - 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ),
168 + 'link' => '',
250 169 'label' => __( 'Views', 'formidable' ),
251 170 'current' => array(),
252 - 'page' => 'formidable-views',
171 + 'page' => '',
253 172 'permission' => 'frm_view_entries',
254 173 'atts' => array(
255 - 'class' => 'frm_noallow',
174 + 'class' => 'frm_show_upgrade frm_noallow',
175 + 'data-upgrade' => __( 'Views', 'formidable' ),
176 + 'data-medium' => 'views-nav',
256 177 ),
257 178 );
258 - }
259 -
260 - // Let people know reports and views exist.
261 - if ( ! FrmAppHelper::pro_is_installed() ) {
262 179 $nav_items[] = array(
263 - 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ),
180 + 'link' => '',
264 181 'label' => __( 'Reports', 'formidable' ),
265 - 'current' => array( 'reports' ),
266 - 'page' => 'formidable',
182 + 'current' => array(),
183 + 'page' => '',
267 184 'permission' => 'frm_view_entries',
268 185 'atts' => array(
269 - 'class' => 'frm_noallow',
186 + 'class' => 'frm_show_upgrade frm_noallow',
187 + 'data-upgrade' => __( 'Reports', 'formidable' ),
188 + 'data-medium' => 'reports-nav',
270 189 ),
271 190 );
272 191 }
273 192
@@ -275,33 +194,68 @@
275 194 'form_id' => $id,
276 195 'form' => $form,
277 196 );
278 197
279 - return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
198 + return apply_filters( 'frm_form_nav_list', $nav_items, $nav_args );
280 199 }
281 200
282 201 // Adds a settings link to the plugins page
283 - /**
284 - * @return array
285 - */
286 202 public static function settings_link( $links ) {
287 - $settings = array();
203 + $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>';
204 + array_unshift( $links, $settings );
288 205
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 );
206 + return $links;
296 207 }
297 208
298 - /**
299 - * @return void
300 - */
301 209 public static function pro_get_started_headline() {
302 210 self::review_request();
303 211 FrmAppHelper::min_pro_version_notice( '4.0' );
212 +
213 + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message
214 + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) {
215 + return;
216 + }
217 +
218 + $pro_installed = is_dir( WP_PLUGIN_DIR . '/formidable-pro' );
219 + $authorized = get_site_option( 'frmpro-authorized' ) && ! is_callable( 'load_formidable_pro' );
220 + if ( ! $authorized ) {
221 + return;
222 + }
223 +
224 + FrmAppHelper::load_admin_wide_js();
225 +
226 + // user is authorized, but running free version
227 + $download_url = '';
228 + if ( $pro_installed ) {
229 + // if pro version is installed, include link to activate it
230 + $inst_install_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=formidable-pro/formidable-pro.php' ), 'activate-plugin_formidable-pro/formidable-pro.php' );
231 + } else {
232 + $inst_install_url = '#';
233 + $download_url = FrmAddonsController::get_pro_download_url();
234 +
235 + if ( empty( $download_url ) ) {
236 + $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/?utm_source=WordPress&utm_medium=get-started&utm_campaign=liteplugin';
237 + }
238 + }
239 + ?>
240 + <div class="error frm_previous_install">
241 + <?php
242 + echo apply_filters( // WPCS: XSS ok.
243 + 'frm_pro_update_msg',
244 + sprintf(
245 + /* translators: %1$s: Start link HTML, %2$s: End link HTML, %3$s: Start link HTML, %4$s: End link HTML */
246 + esc_html__( 'This site has been previously authorized to run Formidable Forms. %1$sInstall Formidable Pro%2$s or %3$sdeauthorize%4$s this site to continue running the free version and remove this message.', 'formidable' ),
247 + '<br/><a href="' . esc_url( $inst_install_url ) . '" id="frm_install_link" target="_blank" data-prourl="' . esc_url( $download_url ) . '">',
248 + '</a>',
249 + '<a href="#" class="frm_deauthorize_link">',
250 + '</a>'
251 + ),
252 + esc_url( $inst_install_url )
253 + );
254 + ?>
255 + <div id="frm_install_message" class="hidden frm_hidden"></div>
256 + </div>
257 + <?php
304 258 }
305 259
306 260 /**
307 261 * Add admin notices as needed for reviews
@@ -306,10 +260,8 @@
306 260 /**
307 261 * Add admin notices as needed for reviews
308 262 *
309 263 * @since 3.04.03
310 - *
311 - * @return void
312 264 */
313 265 private static function review_request() {
314 266 $reviews = new FrmReviews();
315 267 $reviews->review_request();
@@ -318,10 +270,8 @@
318 270 /**
319 271 * Save the request to hide the review
320 272 *
321 273 * @since 3.04.03
322 - *
323 - * @return void
324 274 */
325 275 public static function dismiss_review() {
326 276 FrmAppHelper::permission_check( 'frm_change_settings' );
327 277 check_ajax_referer( 'frm_ajax', 'nonce' );
@@ -331,32 +281,18 @@
331 281 }
332 282
333 283 /**
334 284 * @since 3.04.02
335 - *
336 - * @return void
337 285 */
338 286 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 287 wp_enqueue_script( 'jquery-ui-dialog' );
352 288 wp_enqueue_style( 'jquery-ui-dialog' );
289 +
290 + add_action( 'admin_footer', 'FrmAppController::upgrade_overlay_html' );
353 291 }
354 292
355 293 /**
356 294 * @since 3.06.03
357 - *
358 - * @return void
359 295 */
360 296 public static function upgrade_overlay_html() {
361 297 $is_pro = FrmAppHelper::pro_is_installed();
362 298 $upgrade_link = array(
@@ -362,112 +298,47 @@
362 298 $upgrade_link = array(
363 299 'medium' => 'builder',
364 300 'content' => 'upgrade',
365 301 );
366 - $default_link = FrmAppHelper::admin_upgrade_link( $upgrade_link );
367 - $plugin_path = FrmAppHelper::plugin_path();
368 - $shared_path = $plugin_path . '/classes/views/shared/';
302 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/upgrade_overlay.php' );
369 303
370 - include $shared_path . 'upgrade_overlay.php';
371 - include $shared_path . 'confirm-overlay.php';
372 -
373 - if ( FrmAppHelper::is_admin_page( 'formidable-welcome' ) || FrmAppHelper::on_form_listing_page() ) {
374 - self::new_form_overlay_html();
375 - }
304 + include( FrmAppHelper::plugin_path() . '/classes/views/shared/confirm-overlay.php' );
376 305 }
377 306
378 307 /**
379 - * @return void
308 + * @since 3.04.02
380 309 */
381 - private static function new_form_overlay_html() {
382 - FrmFormsController::before_list_templates();
383 -
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';
310 + public static function remove_upsells() {
311 + remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
312 + remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
427 313 }
428 314
429 315 /**
430 - * @return void
316 + * Don't nag people to install WPForms
317 + *
318 + * @since 3.05
431 319 */
432 - public static function include_info_overlay() {
433 - self::enqueue_dialog_assets();
434 - add_action( 'admin_footer', 'FrmAppController::info_overlay_html' );
435 - }
320 + public static function remove_wpforms_nag( $upsell ) {
321 + if ( is_array( $upsell ) ) {
322 + foreach ( $upsell as $k => $plugin ) {
323 + if ( strpos( $plugin['slug'], 'wpforms' ) !== false ) {
324 + unset( $upsell[ $k ] );
325 + }
326 + }
327 + }
436 328
437 - /**
438 - * @return void
439 - */
440 - public static function info_overlay_html() {
441 - include FrmAppHelper::plugin_path() . '/classes/views/shared/info-overlay.php';
329 + return $upsell;
442 330 }
443 331
444 332 /**
445 - * @since 3.04.02
446 - *
447 - * @return void
448 - */
449 - public static function remove_upsells() {
450 - remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
451 - remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
452 - remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
453 - remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
454 - }
455 -
456 - /**
457 333 * If there are CURL problems on this server, wp_remote_post won't work for installing
458 334 * Use a javascript fallback instead.
459 335 *
460 336 * @since 2.0.3
461 - *
462 - * @return void
463 337 */
464 338 public static function install_js_fallback() {
465 339 FrmAppHelper::load_admin_wide_js();
466 - ?>
467 - <div id="frm_install_message"></div>
468 - <script>jQuery(document).ready( frm_install_now );</script>
469 - <?php
340 + echo '<div id="hidden frm_install_message"></div><script type="text/javascript">jQuery(document).ready(function(){frm_install_now();});</script>';
470 341 }
471 342
472 343 /**
473 344 * Check if the database is outdated
@@ -494,11 +365,8 @@
494 365 /**
495 366 * Check both version number and DB number for changes
496 367 *
497 368 * @since 3.0.04
498 - *
499 - * @param array $atts
500 - * @return bool
501 369 */
502 370 public static function compare_for_update( $atts ) {
503 371 $db_version = get_option( $atts['option'] );
504 372
@@ -517,21 +385,10 @@
517 385 /**
518 386 * Check for database update and trigger js loading
519 387 *
520 388 * @since 2.0.1
521 - *
522 - * @return void
523 389 */
524 390 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 391 new FrmPersonalData(); // register personal data hooks
535 392
536 393 if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) {
537 394 self::network_upgrade_site();
@@ -540,123 +397,17 @@
540 397 if ( ! FrmAppHelper::doing_ajax() ) {
541 398 // don't continue during ajax calls
542 399 self::admin_js();
543 400 }
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 401 }
558 402
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 403 public static function admin_js() {
622 - $plugin_url = FrmAppHelper::plugin_url();
623 - $version = FrmAppHelper::plugin_version();
404 + $version = FrmAppHelper::plugin_version();
405 + FrmAppHelper::load_admin_wide_js( false );
624 406
625 - FrmAppHelper::load_admin_wide_js();
626 -
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 - // Enqueue Floating Links.
642 - $is_valid_page =
643 - FrmAppHelper::is_formidable_admin() &&
644 - ! FrmAppHelper::is_style_editor_page() &&
645 - ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) &&
646 - ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
647 - if ( $is_valid_page ) {
648 - self::enqueue_floating_links( $plugin_url, $version );
649 - }
650 - unset( $is_valid_page );
651 -
652 - if ( 'formidable-applications' === $page ) {
653 - FrmApplicationsController::load_assets();
654 - return;
655 - }
656 -
657 - $dependencies = array(
407 + $dependecies = array(
658 408 'formidable_admin_global',
409 + 'formidable',
659 410 'jquery',
660 411 'jquery-ui-core',
661 412 'jquery-ui-draggable',
662 413 'jquery-ui-sortable',
@@ -661,56 +412,48 @@
661 412 'jquery-ui-draggable',
662 413 'jquery-ui-sortable',
663 414 'bootstrap_tooltip',
664 415 'bootstrap-multiselect',
665 - 'wp-i18n',
666 - 'wp-hooks', // Required in WP versions older than 5.7
667 - 'formidable_dom',
668 - 'formidable_embed',
669 416 );
670 417
671 - if ( FrmAppHelper::is_style_editor_page( 'edit' ) ) {
672 - // We only need to load the color picker when editing styles.
673 - $dependencies[] = 'wp-color-picker';
418 + if ( FrmAppHelper::is_admin_page( 'formidable-styles' ) ) {
419 + $dependecies[] = 'wp-color-picker';
674 420 }
675 421
676 - wp_register_script( 'formidable_admin', $plugin_url . '/js/formidable_admin.js', $dependencies, $version, true );
422 + wp_register_script( 'formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', $dependecies, $version, true );
423 + wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version );
424 + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' );
425 + wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
677 426
678 - if ( FrmAppHelper::on_form_listing_page() ) {
679 - // For the existing page dropdown in the Form embed modal.
680 - wp_enqueue_script( 'jquery-ui-autocomplete' );
681 - }
427 + // load multselect js
428 + $depends_on = array( 'jquery', 'bootstrap_tooltip' );
429 + wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', $depends_on, '0.9.8', true );
682 430
683 - wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true );
684 -
431 + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' );
685 432 $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
686 433
687 434 global $pagenow;
688 - if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
435 + if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
689 436
690 437 wp_enqueue_script( 'admin-widgets' );
691 438 wp_enqueue_style( 'widgets' );
692 - self::maybe_deregister_popper2();
439 + wp_enqueue_script( 'formidable' );
693 440 wp_enqueue_script( 'formidable_admin' );
694 - wp_enqueue_script( 'formidable_embed' );
695 441 FrmAppHelper::localize_script( 'admin' );
696 442
697 443 wp_enqueue_style( 'formidable-admin' );
698 - if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) {
444 + if ( 'formidable-styles' !== $page ) {
699 445 wp_enqueue_style( 'formidable-grids' );
700 446 wp_enqueue_style( 'formidable-dropzone' );
701 447 } else {
702 - wp_enqueue_style( 'formidable-grids' );
448 + $settings = FrmAppHelper::get_settings();
449 + if ( empty( $settings->old_css ) ) {
450 + wp_enqueue_style( 'formidable-grids' );
451 + }
703 452 }
704 453
705 - if ( 'formidable-entries' === $page ) {
706 - // Load front end js for entries.
707 - wp_enqueue_script( 'formidable' );
708 - }
709 -
710 454 do_action( 'frm_enqueue_builder_scripts' );
711 455 self::include_upgrade_overlay();
712 - self::include_info_overlay();
713 456 } elseif ( FrmAppHelper::is_view_builder_page() ) {
714 457 if ( isset( $_REQUEST['post_type'] ) ) {
715 458 $post_type = sanitize_title( wp_unslash( $_REQUEST['post_type'] ) );
716 459 } elseif ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) {
@@ -722,133 +465,20 @@
722 465 } else {
723 466 return;
724 467 }
725 468
726 - if ( $post_type === 'frm_display' ) {
727 - self::enqueue_legacy_views_assets();
469 + if ( $post_type == 'frm_display' ) {
470 + wp_enqueue_style( 'formidable-grids' );
471 + wp_enqueue_script( 'jquery-ui-draggable' );
472 + wp_enqueue_script( 'formidable_admin' );
473 + wp_enqueue_style( 'formidable-admin' );
474 + FrmAppHelper::localize_script( 'admin' );
728 475 }
476 + } elseif ( $pagenow == 'widgets.php' ) {
477 + FrmAppHelper::load_admin_wide_js();
729 478 }
730 -
731 479 }
732 480
733 - /**
734 - * @since 6.3.2
735 - *
736 - * @return void
737 - */
738 - public static function admin_enqueue_scripts() {
739 - self::load_wp_admin_style();
740 - self::maybe_force_formidable_block_on_gutenberg_page();
741 - }
742 -
743 - /**
744 - * Enqueue required assets for the Legacy Views editor (Views v4.x).
745 - *
746 - * @since 6.1.2
747 - *
748 - * @return void
749 - */
750 - private static function enqueue_legacy_views_assets() {
751 - wp_enqueue_style( 'formidable-grids' );
752 - wp_enqueue_script( 'jquery-ui-draggable' );
753 - self::maybe_deregister_popper2();
754 - wp_enqueue_script( 'formidable_admin' );
755 - wp_add_inline_style(
756 - 'formidable-admin',
757 - '
758 - .frm-white-body.post-type-frm_display .columns-2 {
759 - display: block;
760 - overflow: visible;
761 - }
762 -
763 - .frm-white-body.post-type-frm_display .columns-2 > div {
764 - overflow-y: hidden;
765 - }
766 -
767 - .frm-white-body.post-type-frm_display #titlediv #title-prompt-text {
768 - padding: 3px 0 0 10px;
769 - }
770 -
771 - .post-type-frm_display #field-search-input,
772 - .post-type-frm_display #advanced-search-input {
773 - flex: 1;
774 - }
775 - '
776 - );
777 - wp_enqueue_style( 'formidable-admin' );
778 - FrmAppHelper::localize_script( 'admin' );
779 - self::include_info_overlay();
780 - }
781 -
782 - /**
783 - * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459.
784 - *
785 - * @since 5.2.02.01
786 - *
787 - * @return void
788 - */
789 - private static function maybe_deregister_popper2() {
790 - global $wp_scripts;
791 -
792 - if ( ! array_key_exists( 'popper', $wp_scripts->registered ) ) {
793 - return;
794 - }
795 -
796 - $popper = $wp_scripts->registered['popper'];
797 - if ( version_compare( $popper->ver, '2.0', '>=' ) ) {
798 - wp_deregister_script( 'popper' );
799 - self::register_popper1();
800 - }
801 - }
802 -
803 - /**
804 - * Register Popper required for Bootstrap 4.
805 - *
806 - * @since 5.2.02.01
807 - *
808 - * @return void
809 - */
810 - private static function register_popper1() {
811 - wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true );
812 - }
813 -
814 - /**
815 - * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set.
816 - *
817 - * @since 5.2
818 - *
819 - * @return void
820 - */
821 - private static function maybe_force_formidable_block_on_gutenberg_page() {
822 - global $pagenow;
823 - if ( 'post.php' !== $pagenow ) {
824 - return;
825 - }
826 -
827 - $form_id = FrmAppHelper::simple_get( 'frmForm', 'absint' );
828 - if ( ! $form_id ) {
829 - return;
830 - }
831 -
832 - self::add_js_to_inject_gutenberg_block( 'formidable/simple-form', 'formId', $form_id );
833 - }
834 -
835 - /**
836 - * @since 5.3
837 - *
838 - * @param string $block_name
839 - * @param string $object_key
840 - * @param array|string $object_id
841 - *
842 - * @return void
843 - */
844 - public static function add_js_to_inject_gutenberg_block( $block_name, $object_key, $object_id ) {
845 - require FrmAppHelper::plugin_path() . '/classes/views/shared/edit-page-js.php';
846 - }
847 -
848 - /**
849 - * @return void
850 - */
851 481 public static function load_lang() {
852 482 load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' );
853 483 }
854 484
@@ -855,10 +485,8 @@
855 485 /**
856 486 * Check if the styles are updated when a form is loaded on the front-end
857 487 *
858 488 * @since 3.0.1
859 - *
860 - * @return void
861 489 */
862 490 public static function maybe_update_styles() {
863 491 if ( self::needs_update() ) {
864 492 self::network_upgrade_site();
@@ -866,40 +494,18 @@
866 494 }
867 495
868 496 /**
869 497 * @since 3.0
870 - *
871 - * @return void
872 498 */
873 499 public static function create_rest_routes() {
874 500 $args = array(
875 501 'methods' => 'GET',
876 502 'callback' => 'FrmAppController::api_install',
877 - 'permission_callback' => __CLASS__ . '::can_update_db',
878 503 );
879 -
880 504 register_rest_route( 'frm-admin/v1', '/install', $args );
881 -
882 - $args = array(
883 - 'methods' => 'GET',
884 - 'callback' => 'FrmAddonsController::install_addon_api',
885 - 'permission_callback' => 'FrmAddonsController::can_install_addon_api',
886 - );
887 -
888 - register_rest_route( 'frm-admin/v1', '/install-addon', $args );
889 505 }
890 506
891 507 /**
892 - * Make sure the install is only being run when we tell it to.
893 - * We don't want to run manually by people calling the API.
894 - *
895 - * @since 4.06.02
896 - */
897 - public static function can_update_db() {
898 - return get_transient( 'frm_updating_api' );
899 - }
900 -
901 - /**
902 508 * Run silent upgrade on each site in the network during a network upgrade.
903 509 * Update database settings for all sites in a network during network upgrade process.
904 510 *
905 511 * @since 2.0.1
@@ -904,18 +510,13 @@
904 510 *
905 511 * @since 2.0.1
906 512 *
907 513 * @param int $blog_id Blog ID.
908 - *
909 - * @return void
910 514 */
911 515 public static function network_upgrade_site( $blog_id = 0 ) {
912 - // Flag to check if install is happening as intended.
913 - set_transient( 'frm_updating_api', true, MINUTE_IN_SECONDS );
516 +
914 517 $request = new WP_REST_Request( 'GET', '/frm-admin/v1/install' );
915 518
916 - self::maybe_add_wp_site_health();
917 -
918 519 if ( $blog_id ) {
919 520 switch_to_blog( $blog_id );
920 521 $response = rest_do_request( $request );
921 522 restore_current_blog();
@@ -929,29 +530,11 @@
929 530 }
930 531 }
931 532
932 533 /**
933 - * Make sure WP_Site_Health has been included because it is required when calling rest_do_request.
934 - * Check first that the file exists because WP_Site_Health was only introduced in WordPress 5.2.
935 - *
936 - * @return void
937 - */
938 - private static function maybe_add_wp_site_health() {
939 - if ( ! class_exists( 'WP_Site_Health' ) ) {
940 - $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
941 - if ( file_exists( $wp_site_health_path ) ) {
942 - require_once $wp_site_health_path;
943 - }
944 - }
945 - }
946 -
947 - /**
948 534 * @since 3.0
949 - *
950 - * @return true
951 535 */
952 536 public static function api_install() {
953 - delete_transient( 'frm_updating_api' );
954 537 if ( self::needs_update() ) {
955 538 $running = get_option( 'frm_install_running' );
956 539 if ( false === $running || $running < strtotime( '-5 minutes' ) ) {
957 540 update_option( 'frm_install_running', time(), 'no' );
@@ -967,29 +550,19 @@
967 550 * Silent database upgrade (no redirect).
968 551 * Called via ajax request during network upgrade process.
969 552 *
970 553 * @since 2.0.1
971 - *
972 - * @return void
973 554 */
974 555 public static function ajax_install() {
975 - FrmAppHelper::permission_check( 'frm_change_settings' );
976 - check_ajax_referer( 'frm_ajax', 'nonce' );
977 556 self::api_install();
978 557 wp_die();
979 558 }
980 559
981 - /**
982 - * @return void
983 - */
984 560 public static function install() {
985 561 $frmdb = new FrmMigrate();
986 562 $frmdb->upgrade();
987 563 }
988 564
989 - /**
990 - * @return void
991 - */
992 565 public static function uninstall() {
993 566 FrmAppHelper::permission_check( 'administrator' );
994 567 check_ajax_referer( 'frm_ajax', 'nonce' );
995 568
@@ -996,10 +569,9 @@
996 569 $frmdb = new FrmMigrate();
997 570 $frmdb->uninstall();
998 571
999 572 //disable the plugin and redirect after uninstall so the tables don't get added right back
1000 - $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' );
1001 - deactivate_plugins( $plugins, false, false );
573 + deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false );
1002 574 echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) );
1003 575
1004 576 wp_die();
1005 577 }
@@ -1013,11 +585,8 @@
1013 585
1014 586 return $tables;
1015 587 }
1016 588
1017 - /**
1018 - * @return void
1019 - */
1020 589 public static function deauthorize() {
1021 590 FrmAppHelper::permission_check( 'frm_change_settings' );
1022 591 check_ajax_referer( 'frm_ajax', 'nonce' );
1023 592
@@ -1036,75 +605,45 @@
1036 605 return $text;
1037 606 }
1038 607
1039 608 /**
1040 - * @deprecated 3.0.04
1041 - *
609 + * @deprecated 1.07.05
1042 610 * @codeCoverageIgnore
1043 - *
1044 - * @return void
1045 611 */
1046 - public static function activation_install() {
1047 - FrmDeprecated::activation_install();
612 + public static function get_form_shortcode( $atts ) {
613 + return FrmDeprecated::get_form_shortcode( $atts );
1048 614 }
1049 615
1050 616 /**
1051 - * @deprecated 3.0
617 + * @deprecated 2.5.4
1052 618 * @codeCoverageIgnore
1053 619 */
1054 - public static function page_route( $content ) {
1055 - return FrmDeprecated::page_route( $content );
620 + public static function widget_text_filter( $content ) {
621 + return FrmDeprecated::widget_text_filter( $content );
1056 622 }
1057 623
1058 624 /**
1059 - * Include icons on page for Embed Form modal.
625 + * Deprecated in favor of wpmu_upgrade_site
1060 626 *
1061 - * @since 5.2
1062 - *
1063 - * @return void
627 + * @deprecated 2.3
628 + * @codeCoverageIgnore
1064 629 */
1065 - public static function include_embed_form_icons() {
1066 - _deprecated_function( __METHOD__, '5.3' );
630 + public static function front_head() {
631 + FrmDeprecated::front_head();
1067 632 }
1068 633
1069 634 /**
1070 - * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13.
635 + * @deprecated 3.0.04
1071 636 * @codeCoverageIgnore
1072 - *
1073 - * @param array $atts
1074 - * @return string
1075 637 */
1076 - public static function get_form_shortcode( $atts ) {
1077 - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' );
1078 - return FrmFormsController::get_form_shortcode( $atts );
638 + public static function activation_install() {
639 + FrmDeprecated::activation_install();
1079 640 }
1080 641
1081 642 /**
1082 - * Handles Floating Links' scripts and styles enqueueing.
1083 - *
1084 - * @since x.x
1085 - *
1086 - * @param string $plugin_url URL of the plugin.
1087 - * @param string $version Current version of the plugin.
1088 - * @return void
643 + * @deprecated 3.0
644 + * @codeCoverageIgnore
1089 645 */
1090 - private static function enqueue_floating_links( $plugin_url, $version ) {
1091 - if ( ! $plugin_url || ! $version ) {
1092 - // If any required parameters are missing, exit early.
1093 - return;
1094 - }
1095 -
1096 - // Enqueue the Floating Links styles.
1097 - wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version );
1098 -
1099 - // Enqueue the Floating Links script.
1100 - wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true );
1101 -
1102 - // Enqueue the config script.
1103 - wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true );
1104 - wp_set_script_translations( 's11-floating-links-config', 's11-' );
1105 - $floating_links_data = array(
1106 - 'proIsInstalled' => FrmAppHelper::pro_is_installed(),
1107 - );
1108 - wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data );
646 + public static function page_route( $content ) {
647 + return FrmDeprecated::page_route( $content );
1109 648 }
1110 649 }