| @@ -9,19 +9,13 @@ | ||
| 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(); |
| 19 | - | |
| 20 | - if ( in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) { | |
| 21 | - $menu_name .= wp_kses_post( FrmInboxController::get_notice_count() ); | |
| 22 | - } | |
| 23 | - | |
| 24 | 18 | add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() ); |
| 25 | 19 | } |
| 26 | 20 | |
| 27 | 21 | /** |
| @@ -32,10 +26,8 @@ | ||
| 32 | 26 | } |
| 33 | 27 | |
| 34 | 28 | /** |
| 35 | 29 | * @since 3.05 |
| 36 | - * | |
| 37 | - * @return string | |
| 38 | 30 | */ |
| 39 | 31 | private static function menu_icon() { |
| 40 | 32 | $icon = FrmAppHelper::svg_logo( |
| 41 | 33 | array( |
| @@ -49,12 +41,8 @@ | ||
| 49 | 41 | } |
| 50 | 42 | |
| 51 | 43 | /** |
| 52 | 44 | * @since 3.0 |
| 53 | - * | |
| 54 | - * @param string $classes | |
| 55 | - * | |
| 56 | - * @return string | |
| 57 | 45 | */ |
| 58 | 46 | public static function add_admin_class( $classes ) { |
| 59 | 47 | if ( self::is_white_page() ) { |
| 60 | 48 | $classes .= ' frm-white-body '; |
| @@ -60,12 +48,10 @@ | ||
| 60 | 48 | $classes .= ' frm-white-body '; |
| 61 | 49 | $classes .= self::get_os(); |
| 62 | 50 | |
| 63 | 51 | $page = str_replace( 'formidable-', '', FrmAppHelper::simple_get( 'page', 'sanitize_title' ) ); |
| 64 | - | |
| 65 | 52 | if ( empty( $page ) || $page === 'formidable' ) { |
| 66 | 53 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 67 | - | |
| 68 | 54 | if ( in_array( $action, array( 'settings', 'edit', 'list' ) ) ) { |
| 69 | 55 | $page .= $action; |
| 70 | 56 | } else { |
| 71 | 57 | $page = $action; |
| @@ -70,9 +56,8 @@ | ||
| 70 | 56 | } else { |
| 71 | 57 | $page = $action; |
| 72 | 58 | } |
| 73 | 59 | } |
| 74 | - | |
| 75 | 60 | if ( ! empty( $page ) ) { |
| 76 | 61 | $classes .= ' frm-admin-page-' . $page; |
| 77 | 62 | } |
| 78 | 63 | } |
| @@ -83,9 +68,8 @@ | ||
| 83 | 68 | |
| 84 | 69 | if ( FrmAppHelper::is_full_screen() ) { |
| 85 | 70 | $full_screen_on = self::get_full_screen_setting(); |
| 86 | 71 | $add_class = ''; |
| 87 | - | |
| 88 | 72 | if ( $full_screen_on ) { |
| 89 | 73 | $add_class = ' frm-full-screen is-fullscreen-mode'; |
| 90 | 74 | |
| 91 | 75 | // Load the CSS for .is-fullscreen-mode. |
| @@ -90,9 +74,8 @@ | ||
| 90 | 74 | |
| 91 | 75 | // Load the CSS for .is-fullscreen-mode. |
| 92 | 76 | wp_enqueue_style( 'wp-edit-post' ); |
| 93 | 77 | } |
| 94 | - | |
| 95 | 78 | $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class ); |
| 96 | 79 | } |
| 97 | 80 | |
| 98 | 81 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| @@ -117,9 +100,8 @@ | ||
| 117 | 100 | global $wpdb; |
| 118 | 101 | $meta_key = $wpdb->get_blog_prefix() . 'persisted_preferences'; |
| 119 | 102 | |
| 120 | 103 | $prefs = get_user_meta( get_current_user_id(), $meta_key, true ); |
| 121 | - | |
| 122 | 104 | if ( $prefs && isset( $prefs['core/edit-post']['fullscreenMode'] ) ) { |
| 123 | 105 | return $prefs['core/edit-post']['fullscreenMode']; |
| 124 | 106 | } |
| 125 | 107 | |
| @@ -133,9 +115,8 @@ | ||
| 133 | 115 | */ |
| 134 | 116 | private static function get_os() { |
| 135 | 117 | $agent = strtolower( FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ) ); |
| 136 | 118 | $os = ''; |
| 137 | - | |
| 138 | 119 | if ( strpos( $agent, 'mac' ) !== false ) { |
| 139 | 120 | $os = ' osx'; |
| 140 | 121 | } elseif ( strpos( $agent, 'linux' ) !== false ) { |
| 141 | 122 | $os = ' linux'; |
| @@ -146,10 +127,8 @@ | ||
| 146 | 127 | } |
| 147 | 128 | |
| 148 | 129 | /** |
| 149 | 130 | * @since 3.0 |
| 150 | - * | |
| 151 | - * @return bool | |
| 152 | 131 | */ |
| 153 | 132 | private static function is_white_page() { |
| 154 | 133 | $white_pages = array( |
| 155 | 134 | 'formidable', |
| @@ -155,8 +134,9 @@ | ||
| 155 | 134 | 'formidable', |
| 156 | 135 | 'formidable-entries', |
| 157 | 136 | 'formidable-views', |
| 158 | 137 | 'formidable-views-editor', |
| 138 | + 'formidable-pro-upgrade', | |
| 159 | 139 | 'formidable-addons', |
| 160 | 140 | 'formidable-import', |
| 161 | 141 | 'formidable-settings', |
| 162 | 142 | 'formidable-styles', |
| @@ -201,9 +181,8 @@ | ||
| 201 | 181 | private static function is_grey_page() { |
| 202 | 182 | $grey_pages = array( |
| 203 | 183 | 'formidable-applications', |
| 204 | 184 | 'formidable-dashboard', |
| 205 | - 'formidable-views', | |
| 206 | 185 | ); |
| 207 | 186 | |
| 208 | 187 | $is_grey_page = self::is_page_in_list( $grey_pages ); |
| 209 | 188 | |
| @@ -212,9 +191,8 @@ | ||
| 212 | 191 | * |
| 213 | 192 | * @since 6.8 |
| 214 | 193 | * |
| 215 | 194 | * @param bool $is_grey_page |
| 216 | - * | |
| 217 | 195 | * @return bool |
| 218 | 196 | */ |
| 219 | 197 | return apply_filters( 'frm_is_grey_page', $is_grey_page ); |
| 220 | 198 | } |
| @@ -222,9 +200,8 @@ | ||
| 222 | 200 | /** |
| 223 | 201 | * @since 6.8 |
| 224 | 202 | * |
| 225 | 203 | * @param array $pages A list of page names to check. |
| 226 | - * | |
| 227 | 204 | * @return bool |
| 228 | 205 | */ |
| 229 | 206 | private static function is_page_in_list( $pages ) { |
| 230 | 207 | $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| @@ -248,15 +225,13 @@ | ||
| 248 | 225 | * @return void |
| 249 | 226 | */ |
| 250 | 227 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
| 251 | 228 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 252 | - | |
| 253 | 229 | if ( empty( $show_nav ) || ! $form ) { |
| 254 | 230 | return; |
| 255 | 231 | } |
| 256 | 232 | |
| 257 | 233 | FrmForm::maybe_get_form( $form ); |
| 258 | - | |
| 259 | 234 | if ( ! is_object( $form ) ) { |
| 260 | 235 | return; |
| 261 | 236 | } |
| 262 | 237 | |
| @@ -283,9 +258,8 @@ | ||
| 283 | 258 | } |
| 284 | 259 | |
| 285 | 260 | /** |
| 286 | 261 | * @param object $form |
| 287 | - * | |
| 288 | 262 | * @return array |
| 289 | 263 | */ |
| 290 | 264 | private static function get_form_nav_items( $form ) { |
| 291 | 265 | $id = $form->parent_form_id ? $form->parent_form_id : $form->id; |
| @@ -320,9 +294,9 @@ | ||
| 320 | 294 | 'permission' => 'frm_view_entries', |
| 321 | 295 | ), |
| 322 | 296 | ); |
| 323 | 297 | |
| 324 | - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed(); | |
| 298 | + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed(); | |
| 325 | 299 | |
| 326 | 300 | if ( ! $views_installed ) { |
| 327 | 301 | $nav_items[] = array( |
| 328 | 302 | 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ), |
| @@ -357,13 +331,10 @@ | ||
| 357 | 331 | |
| 358 | 332 | return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args ); |
| 359 | 333 | } |
| 360 | 334 | |
| 335 | + // Adds a settings link to the plugins page | |
| 361 | 336 | /** |
| 362 | - * Adds a settings link to the plugins page | |
| 363 | - * | |
| 364 | - * @param array $links | |
| 365 | - * | |
| 366 | 337 | * @return array |
| 367 | 338 | */ |
| 368 | 339 | public static function settings_link( $links ) { |
| 369 | 340 | $settings = array(); |
| @@ -368,29 +339,12 @@ | ||
| 368 | 339 | public static function settings_link( $links ) { |
| 369 | 340 | $settings = array(); |
| 370 | 341 | |
| 371 | 342 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 372 | - if ( FrmAddonsController::is_license_expired() ) { | |
| 373 | - $label = __( 'Renew', 'formidable' ); | |
| 374 | - } else { | |
| 375 | - $label = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_text' ); | |
| 343 | + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' ); | |
| 344 | + $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>'; | |
| 345 | + } | |
| 376 | 346 | |
| 377 | - if ( ! $label ) { | |
| 378 | - $label = __( 'Upgrade to Pro', 'formidable' ); | |
| 379 | - } | |
| 380 | - } | |
| 381 | - | |
| 382 | - $upgrade_link = FrmSalesApi::get_best_sale_value( 'plugin_page_cta_link' ); | |
| 383 | - | |
| 384 | - if ( $upgrade_link ) { | |
| 385 | - $upgrade_link = FrmAppHelper::maybe_add_missing_utm( $upgrade_link, array( 'medium' => 'plugin-row' ) ); | |
| 386 | - } else { | |
| 387 | - $upgrade_link = FrmAppHelper::admin_upgrade_link( 'plugin-row' ); | |
| 388 | - } | |
| 389 | - | |
| 390 | - $settings[] = '<a href="' . esc_url( $upgrade_link ) . '" target="_blank" rel="noopener"><b style="color:#1da867;font-weight:700;">' . esc_html( $label ) . '</b></a>'; | |
| 391 | - }//end if | |
| 392 | - | |
| 393 | 347 | $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>'; |
| 394 | 348 | |
| 395 | 349 | return array_merge( $settings, $links ); |
| 396 | 350 | } |
| @@ -399,9 +353,9 @@ | ||
| 399 | 353 | * @return void |
| 400 | 354 | */ |
| 401 | 355 | public static function pro_get_started_headline() { |
| 402 | 356 | self::review_request(); |
| 403 | - FrmAppHelper::min_pro_version_notice( '6.20' ); | |
| 357 | + FrmAppHelper::min_pro_version_notice( '4.0' ); | |
| 404 | 358 | } |
| 405 | 359 | |
| 406 | 360 | /** |
| 407 | 361 | * Add admin notices as needed for reviews |
| @@ -476,9 +430,8 @@ | ||
| 476 | 430 | * |
| 477 | 431 | * @param string $form_key |
| 478 | 432 | * @param string $title |
| 479 | 433 | * @param string $description |
| 480 | - * | |
| 481 | 434 | * @return void |
| 482 | 435 | */ |
| 483 | 436 | public static function api_email_form( $form_key, $title = '', $description = '' ) { |
| 484 | 437 | $user = wp_get_current_user(); |
| @@ -511,9 +464,10 @@ | ||
| 511 | 464 | * @return void |
| 512 | 465 | */ |
| 513 | 466 | public static function remove_upsells() { |
| 514 | 467 | remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
| 515 | - remove_action( 'frm_after_settings_tabs', 'FrmSettingsController::settings_cta' ); | |
| 468 | + remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' ); | |
| 469 | + remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' ); | |
| 516 | 470 | remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' ); |
| 517 | 471 | } |
| 518 | 472 | |
| 519 | 473 | /** |
| @@ -535,9 +489,8 @@ | ||
| 535 | 489 | /** |
| 536 | 490 | * Check if the database is outdated |
| 537 | 491 | * |
| 538 | 492 | * @since 2.0.1 |
| 539 | - * | |
| 540 | 493 | * @return bool |
| 541 | 494 | */ |
| 542 | 495 | public static function needs_update() { |
| 543 | 496 | $needs_upgrade = self::compare_for_update( |
| @@ -560,9 +513,8 @@ | ||
| 560 | 513 | * |
| 561 | 514 | * @since 3.0.04 |
| 562 | 515 | * |
| 563 | 516 | * @param array $atts |
| 564 | - * | |
| 565 | 517 | * @return bool |
| 566 | 518 | */ |
| 567 | 519 | public static function compare_for_update( $atts ) { |
| 568 | 520 | $db_version = get_option( $atts['option'] ); |
| @@ -594,34 +546,13 @@ | ||
| 594 | 546 | if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) { |
| 595 | 547 | FrmFormsController::duplicate(); |
| 596 | 548 | } |
| 597 | 549 | |
| 598 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) && FrmAppHelper::simple_get( 'frm_add_tables' ) ) { | |
| 599 | - self::add_missing_tables(); | |
| 600 | - } | |
| 601 | - | |
| 602 | 550 | if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) { |
| 603 | 551 | // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent. |
| 604 | 552 | FrmStylesController::save_style(); |
| 605 | 553 | } |
| 606 | 554 | |
| 607 | - if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) { | |
| 608 | - $redirect = FrmSalesApi::get_best_sale_value( 'menu_cta_link' ); | |
| 609 | - $utm = array( | |
| 610 | - 'campaign' => 'upgrade', | |
| 611 | - 'content' => 'submenu-upgrade', | |
| 612 | - ); | |
| 613 | - | |
| 614 | - if ( $redirect ) { | |
| 615 | - $redirect = FrmAppHelper::maybe_add_missing_utm( $redirect, $utm ); | |
| 616 | - } else { | |
| 617 | - $redirect = FrmAppHelper::admin_upgrade_link( $utm ); | |
| 618 | - } | |
| 619 | - | |
| 620 | - wp_redirect( $redirect ); | |
| 621 | - die(); | |
| 622 | - } | |
| 623 | - | |
| 624 | 555 | // Register personal data hooks. |
| 625 | 556 | new FrmPersonalData(); |
| 626 | 557 | |
| 627 | 558 | if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) { |
| @@ -639,9 +570,8 @@ | ||
| 639 | 570 | // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions. |
| 640 | 571 | // This provides backward compatibility for old addons that use legacy modal templates. |
| 641 | 572 | $action = FrmAppHelper::get_param( 'frm_action' ); |
| 642 | 573 | $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' ); |
| 643 | - | |
| 644 | 574 | if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { |
| 645 | 575 | $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' ); |
| 646 | 576 | $url_param = $application_id ? '&applicationId=' . $application_id : ''; |
| 647 | 577 | |
| @@ -650,8 +580,11 @@ | ||
| 650 | 580 | } |
| 651 | 581 | |
| 652 | 582 | FrmInbox::maybe_disable_screen_options(); |
| 653 | 583 | } |
| 584 | + | |
| 585 | + self::maybe_add_ip_warning(); | |
| 586 | + self::maybe_add_deprecated_message(); | |
| 654 | 587 | } |
| 655 | 588 | |
| 656 | 589 | /** |
| 657 | 590 | * Get the current page and check for a possible function to trigger. |
| @@ -662,9 +595,8 @@ | ||
| 662 | 595 | * @return void |
| 663 | 596 | */ |
| 664 | 597 | private static function trigger_page_load_hooks() { |
| 665 | 598 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 666 | - | |
| 667 | 599 | if ( strpos( $page, 'formidable-' ) !== 0 ) { |
| 668 | 600 | // Only trigger hooks on Formidable pages. |
| 669 | 601 | return; |
| 670 | 602 | } |
| @@ -671,9 +603,8 @@ | ||
| 671 | 603 | |
| 672 | 604 | $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page ); |
| 673 | 605 | $page = str_replace( ' ', '', ucwords( $page ) ); |
| 674 | 606 | $class = 'Frm' . $page . 'Controller'; |
| 675 | - | |
| 676 | 607 | if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) { |
| 677 | 608 | call_user_func( array( $class, 'load_page' ) ); |
| 678 | 609 | } |
| 679 | 610 | } |
| @@ -678,10 +609,69 @@ | ||
| 678 | 609 | } |
| 679 | 610 | } |
| 680 | 611 | |
| 681 | 612 | /** |
| 613 | + * Show a warning for the IP address setting if it hasn't been set. | |
| 614 | + * | |
| 615 | + * @since 6.1 | |
| 616 | + * | |
| 682 | 617 | * @return void |
| 683 | 618 | */ |
| 619 | + private static function maybe_add_ip_warning() { | |
| 620 | + $settings = FrmAppHelper::get_settings(); | |
| 621 | + if ( false !== $settings->custom_header_ip ) { | |
| 622 | + // The setting has been changed from the false default (to either 1 or 0), so stop showing the message. | |
| 623 | + return; | |
| 624 | + } | |
| 625 | + | |
| 626 | + if ( ! self::is_behind_proxy() ) { | |
| 627 | + // This message is only applicable when using a reverse proxy. | |
| 628 | + return; | |
| 629 | + } | |
| 630 | + | |
| 631 | + if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) { | |
| 632 | + // Avoid the message on a POST action. We don't want to show the message if we're saving global settings. | |
| 633 | + return; | |
| 634 | + } | |
| 635 | + | |
| 636 | + $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip'; | |
| 637 | + $message = sprintf( | |
| 638 | + // Translators: 1: Global Settings Link | |
| 639 | + __( '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' ), | |
| 640 | + '<a href="' . esc_url( $global_settings_link ) . '">' . __( 'Global Settings', 'formidable' ) . '</a>' | |
| 641 | + ); | |
| 642 | + $option_name = 'frm_dismiss_ip_address_notice'; | |
| 643 | + FrmAppHelper::add_dismissable_warning_message( $message, $option_name ); | |
| 644 | + } | |
| 645 | + | |
| 646 | + /** | |
| 647 | + * Check if any reverse proxy headers are set. | |
| 648 | + * | |
| 649 | + * @since 6.1 | |
| 650 | + * | |
| 651 | + * @return bool | |
| 652 | + */ | |
| 653 | + private static function is_behind_proxy() { | |
| 654 | + $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip(); | |
| 655 | + foreach ( $custom_headers as $header ) { | |
| 656 | + if ( 'REMOTE_ADDR' === $header ) { | |
| 657 | + // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers. | |
| 658 | + continue; | |
| 659 | + } | |
| 660 | + | |
| 661 | + $ip = trim( FrmAppHelper::get_server_value( $header ) ); | |
| 662 | + // Return true for anything that isn't empty but ignoring values like ::1. | |
| 663 | + if ( $ip && 0 !== strpos( $ip, '::' ) ) { | |
| 664 | + return true; | |
| 665 | + } | |
| 666 | + } | |
| 667 | + | |
| 668 | + return false; | |
| 669 | + } | |
| 670 | + | |
| 671 | + /** | |
| 672 | + * @return void | |
| 673 | + */ | |
| 684 | 674 | public static function admin_js() { |
| 685 | 675 | $plugin_url = FrmAppHelper::plugin_url(); |
| 686 | 676 | $version = FrmAppHelper::plugin_version(); |
| 687 | 677 | |
| @@ -703,16 +693,11 @@ | ||
| 703 | 693 | wp_register_style( 'formidable-grids', $plugin_url . '/css/frm_grids.css', array(), $version ); |
| 704 | 694 | |
| 705 | 695 | wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true ); |
| 706 | 696 | wp_register_script( 'formidable_embed', $plugin_url . '/js/admin/embed.js', array( 'formidable_dom', 'jquery-ui-autocomplete' ), $version, true ); |
| 707 | - self::register_popper2(); | |
| 708 | - wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '5.0.2', true ); | |
| 709 | - | |
| 710 | - $settings_js_vars = array( | |
| 711 | - 'currencies' => FrmCurrencyHelper::get_currencies(), | |
| 712 | - ); | |
| 697 | + self::register_popper1(); | |
| 698 | + wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true ); | |
| 713 | 699 | wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true ); |
| 714 | - wp_localize_script( 'formidable_settings', 'frmSettings', $settings_js_vars ); | |
| 715 | 700 | |
| 716 | 701 | if ( self::should_show_floating_links() ) { |
| 717 | 702 | self::enqueue_floating_links( $plugin_url, $version ); |
| 718 | 703 | } |
| @@ -743,9 +728,9 @@ | ||
| 743 | 728 | // For the existing page dropdown in the Form embed modal. |
| 744 | 729 | wp_enqueue_script( 'jquery-ui-autocomplete' ); |
| 745 | 730 | } |
| 746 | 731 | |
| 747 | - wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '2.0', true ); | |
| 732 | + wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true ); | |
| 748 | 733 | |
| 749 | 734 | if ( ! class_exists( 'FrmTransHooksController', false ) ) { |
| 750 | 735 | /** |
| 751 | 736 | * Gateway fields are included for add-on compatibility but we do not want it to be visible. |
| @@ -760,27 +745,22 @@ | ||
| 760 | 745 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 761 | 746 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 762 | 747 | |
| 763 | 748 | global $pagenow; |
| 764 | - | |
| 765 | 749 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) { |
| 766 | - self::enqueue_global_settings_scripts( $page ); | |
| 767 | 750 | |
| 768 | 751 | wp_enqueue_script( 'admin-widgets' ); |
| 769 | 752 | wp_enqueue_style( 'widgets' ); |
| 770 | - self::maybe_deregister_popper1(); | |
| 753 | + self::maybe_deregister_popper2(); | |
| 771 | 754 | wp_enqueue_script( 'formidable_admin' ); |
| 772 | - wp_set_script_translations( 'formidable_admin', 'formidable' ); | |
| 773 | 755 | wp_enqueue_script( 'formidable_embed' ); |
| 774 | - wp_set_script_translations( 'formidable_embed', 'formidable' ); | |
| 775 | 756 | FrmAppHelper::localize_script( 'admin' ); |
| 776 | 757 | |
| 777 | 758 | wp_enqueue_style( 'formidable-animations' ); |
| 778 | 759 | wp_enqueue_style( 'formidable-admin' ); |
| 779 | - | |
| 780 | 760 | if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) { |
| 781 | 761 | wp_enqueue_style( 'formidable-grids' ); |
| 782 | - self::maybe_enqueue_dropzone_css( $page ); | |
| 762 | + wp_enqueue_style( 'formidable-dropzone' ); | |
| 783 | 763 | } else { |
| 784 | 764 | wp_enqueue_style( 'formidable-grids' ); |
| 785 | 765 | } |
| 786 | 766 | |
| @@ -800,13 +780,11 @@ | ||
| 800 | 780 | if ( isset( $_REQUEST['post_type'] ) ) { |
| 801 | 781 | $post_type = sanitize_title( wp_unslash( $_REQUEST['post_type'] ) ); |
| 802 | 782 | } elseif ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 803 | 783 | $post = get_post( absint( wp_unslash( $_REQUEST['post'] ) ) ); |
| 804 | - | |
| 805 | 784 | if ( ! $post ) { |
| 806 | 785 | return; |
| 807 | 786 | } |
| 808 | - | |
| 809 | 787 | $post_type = $post->post_type; |
| 810 | 788 | } else { |
| 811 | 789 | return; |
| 812 | 790 | } |
| @@ -819,70 +797,11 @@ | ||
| 819 | 797 | if ( 'formidable-addons' === $page ) { |
| 820 | 798 | wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true ); |
| 821 | 799 | wp_enqueue_script( 'formidable_addons' ); |
| 822 | 800 | } |
| 823 | - | |
| 824 | - self::enqueue_builder_assets( $plugin_url, $version ); | |
| 825 | 801 | } |
| 826 | 802 | |
| 827 | 803 | /** |
| 828 | - * Enqueue the Form Builder assets. | |
| 829 | - * | |
| 830 | - * @since 6.24 | |
| 831 | - * | |
| 832 | - * @param string $plugin_url The plugin URL. | |
| 833 | - * @param string $version The plugin version. | |
| 834 | - * | |
| 835 | - * @return void | |
| 836 | - */ | |
| 837 | - private static function enqueue_builder_assets( $plugin_url, $version ) { | |
| 838 | - wp_register_style( 'formidable-settings-components', $plugin_url . '/css/admin/frm-settings-components.css', array( 'formidable-admin', 'formidable-grids' ), $version ); | |
| 839 | - wp_register_script( 'formidable-settings-components', $plugin_url . '/js/formidable-settings-components.js', array( 'formidable_admin' ), $version, true ); | |
| 840 | - | |
| 841 | - if ( ! FrmAppHelper::is_form_builder_page() ) { | |
| 842 | - return; | |
| 843 | - } | |
| 844 | - | |
| 845 | - wp_enqueue_style( 'formidable-settings-components' ); | |
| 846 | - wp_enqueue_script( 'formidable-settings-components' ); | |
| 847 | - } | |
| 848 | - | |
| 849 | - /** | |
| 850 | - * Enqueues global settings scripts. | |
| 851 | - * | |
| 852 | - * @param string $page The `page` param in URL. | |
| 853 | - * | |
| 854 | - * @return void | |
| 855 | - */ | |
| 856 | - private static function enqueue_global_settings_scripts( $page ) { | |
| 857 | - if ( 'formidable-settings' === $page ) { | |
| 858 | - wp_enqueue_style( 'wp-color-picker' ); | |
| 859 | - wp_enqueue_script( 'formidable_settings' ); | |
| 860 | - } | |
| 861 | - } | |
| 862 | - | |
| 863 | - /** | |
| 864 | - * Avoid loading dropzone CSS on the form list page. It isn't required there. | |
| 865 | - * | |
| 866 | - * @since 6.11 | |
| 867 | - * | |
| 868 | - * @param string $page | |
| 869 | - * | |
| 870 | - * @return void | |
| 871 | - */ | |
| 872 | - private static function maybe_enqueue_dropzone_css( $page ) { | |
| 873 | - if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 874 | - return; | |
| 875 | - } | |
| 876 | - | |
| 877 | - $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); | |
| 878 | - | |
| 879 | - if ( ! $should_avoid_loading_dropzone ) { | |
| 880 | - wp_enqueue_style( 'formidable-dropzone' ); | |
| 881 | - } | |
| 882 | - } | |
| 883 | - | |
| 884 | - /** | |
| 885 | 804 | * The floating links are not shown on every page. |
| 886 | 805 | * They are also not shown if white labeling is being used. |
| 887 | 806 | * |
| 888 | 807 | * @since 6.8.4 |
| @@ -893,21 +812,12 @@ | ||
| 893 | 812 | if ( ! FrmAppHelper::is_formidable_branding() ) { |
| 894 | 813 | return false; |
| 895 | 814 | } |
| 896 | 815 | |
| 897 | - $should_show = FrmAppHelper::is_formidable_admin() && | |
| 816 | + return FrmAppHelper::is_formidable_admin() && | |
| 898 | 817 | ! FrmAppHelper::is_style_editor_page() && |
| 899 | 818 | ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) && |
| 900 | 819 | ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 901 | - | |
| 902 | - /** | |
| 903 | - * Filters whether the floating links should be displayed. | |
| 904 | - * | |
| 905 | - * @since 6.25.1 | |
| 906 | - * | |
| 907 | - * @param bool $should_show Whether the floating links should be shown. | |
| 908 | - */ | |
| 909 | - return apply_filters( 'frm_should_show_floating_links', $should_show ); | |
| 910 | 820 | } |
| 911 | 821 | |
| 912 | 822 | /** |
| 913 | 823 | * @since 6.3.2 |
| @@ -916,14 +826,8 @@ | ||
| 916 | 826 | */ |
| 917 | 827 | public static function admin_enqueue_scripts() { |
| 918 | 828 | self::load_wp_admin_style(); |
| 919 | 829 | self::maybe_force_formidable_block_on_gutenberg_page(); |
| 920 | - | |
| 921 | - if ( FrmAppHelper::is_admin_page( 'formidable-settings' ) ) { | |
| 922 | - wp_enqueue_style( FrmDashboardController::PAGE_SLUG, FrmAppHelper::plugin_url() . '/css/admin/dashboard.css', array(), FrmAppHelper::plugin_version() ); | |
| 923 | - } | |
| 924 | - | |
| 925 | - FrmUsageController::load_scripts(); | |
| 926 | 830 | } |
| 927 | 831 | |
| 928 | 832 | /** |
| 929 | 833 | * Enqueue required assets for the Legacy Views editor (Views v4.x). |
| @@ -934,9 +838,9 @@ | ||
| 934 | 838 | */ |
| 935 | 839 | private static function enqueue_legacy_views_assets() { |
| 936 | 840 | wp_enqueue_style( 'formidable-grids' ); |
| 937 | 841 | wp_enqueue_script( 'jquery-ui-draggable' ); |
| 938 | - self::maybe_deregister_popper1(); | |
| 842 | + self::maybe_deregister_popper2(); | |
| 939 | 843 | wp_enqueue_script( 'formidable_admin' ); |
| 940 | 844 | wp_add_inline_style( |
| 941 | 845 | 'formidable-admin', |
| 942 | 846 | ' |
| @@ -959,21 +863,20 @@ | ||
| 959 | 863 | } |
| 960 | 864 | ' |
| 961 | 865 | ); |
| 962 | 866 | wp_enqueue_style( 'formidable-admin' ); |
| 963 | - wp_enqueue_script( 'formidable_legacy_views', FrmAppHelper::plugin_url() . '/js/admin/legacy-views.js', array( 'jquery', 'formidable_admin' ), FrmAppHelper::plugin_version() ); | |
| 964 | 867 | FrmAppHelper::localize_script( 'admin' ); |
| 965 | 868 | self::include_info_overlay(); |
| 966 | 869 | } |
| 967 | 870 | |
| 968 | 871 | /** |
| 969 | - * Unregister Popper if the registered version is outdated. | |
| 872 | + * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459. | |
| 970 | 873 | * |
| 971 | - * @since 6.26 | |
| 874 | + * @since 5.2.02.01 | |
| 972 | 875 | * |
| 973 | 876 | * @return void |
| 974 | 877 | */ |
| 975 | - private static function maybe_deregister_popper1() { | |
| 878 | + private static function maybe_deregister_popper2() { | |
| 976 | 879 | global $wp_scripts; |
| 977 | 880 | |
| 978 | 881 | if ( ! array_key_exists( 'popper', $wp_scripts->registered ) ) { |
| 979 | 882 | return; |
| @@ -979,63 +882,26 @@ | ||
| 979 | 882 | return; |
| 980 | 883 | } |
| 981 | 884 | |
| 982 | 885 | $popper = $wp_scripts->registered['popper']; |
| 983 | - | |
| 984 | - if ( version_compare( $popper->ver, '2.0', '<' ) ) { | |
| 886 | + if ( version_compare( $popper->ver, '2.0', '>=' ) ) { | |
| 985 | 887 | wp_deregister_script( 'popper' ); |
| 986 | - self::register_popper2(); | |
| 888 | + self::register_popper1(); | |
| 987 | 889 | } |
| 988 | 890 | } |
| 989 | 891 | |
| 990 | 892 | /** |
| 991 | - * Register Popper required for Bootstrap 5. | |
| 893 | + * Register Popper required for Bootstrap 4. | |
| 992 | 894 | * |
| 993 | - * @since 6.26 | |
| 895 | + * @since 5.2.02.01 | |
| 994 | 896 | * |
| 995 | 897 | * @return void |
| 996 | 898 | */ |
| 997 | - private static function register_popper2() { | |
| 998 | - if ( ! self::should_register_popper() ) { | |
| 999 | - return; | |
| 1000 | - } | |
| 1001 | - wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array(), '2.11.8', true ); | |
| 899 | + private static function register_popper1() { | |
| 900 | + wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true ); | |
| 1002 | 901 | } |
| 1003 | 902 | |
| 1004 | 903 | /** |
| 1005 | - * Only register popper on Formidable pages. | |
| 1006 | - * This helps to avoid popper conflicts on other plugin pages, including the WP Bakery page editor. | |
| 1007 | - * | |
| 1008 | - * @since 6.11.1 | |
| 1009 | - * | |
| 1010 | - * @return bool | |
| 1011 | - */ | |
| 1012 | - private static function should_register_popper() { | |
| 1013 | - global $pagenow; | |
| 1014 | - | |
| 1015 | - $post_id = FrmAppHelper::simple_get( 'post', 'absint' ); | |
| 1016 | - | |
| 1017 | - if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) { | |
| 1018 | - return true; | |
| 1019 | - } | |
| 1020 | - | |
| 1021 | - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); | |
| 1022 | - $is_views_post_type = 'frm_display' === $post_type; | |
| 1023 | - | |
| 1024 | - if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) { | |
| 1025 | - return true; | |
| 1026 | - } | |
| 1027 | - | |
| 1028 | - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 1029 | - | |
| 1030 | - if ( strpos( $page, 'formidable' ) === 0 ) { | |
| 1031 | - return true; | |
| 1032 | - } | |
| 1033 | - | |
| 1034 | - return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && FrmAppHelper::simple_get( 'taxonomy' ) === 'frm_application'; | |
| 1035 | - } | |
| 1036 | - | |
| 1037 | - /** | |
| 1038 | 904 | * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set. |
| 1039 | 905 | * |
| 1040 | 906 | * @since 5.2 |
| 1041 | 907 | * |
| @@ -1042,15 +908,13 @@ | ||
| 1042 | 908 | * @return void |
| 1043 | 909 | */ |
| 1044 | 910 | private static function maybe_force_formidable_block_on_gutenberg_page() { |
| 1045 | 911 | global $pagenow; |
| 1046 | - | |
| 1047 | 912 | if ( 'post.php' !== $pagenow ) { |
| 1048 | 913 | return; |
| 1049 | 914 | } |
| 1050 | 915 | |
| 1051 | 916 | $form_id = FrmAppHelper::simple_get( 'frmForm', 'absint' ); |
| 1052 | - | |
| 1053 | 917 | if ( ! $form_id ) { |
| 1054 | 918 | return; |
| 1055 | 919 | } |
| 1056 | 920 | |
| @@ -1098,9 +962,9 @@ | ||
| 1098 | 962 | public static function create_rest_routes() { |
| 1099 | 963 | $args = array( |
| 1100 | 964 | 'methods' => 'GET', |
| 1101 | 965 | 'callback' => 'FrmAppController::api_install', |
| 1102 | - 'permission_callback' => self::class . '::can_update_db', | |
| 966 | + 'permission_callback' => __CLASS__ . '::can_update_db', | |
| 1103 | 967 | ); |
| 1104 | 968 | |
| 1105 | 969 | register_rest_route( 'frm-admin/v1', '/install', $args ); |
| 1106 | 970 | |
| @@ -1117,10 +981,8 @@ | ||
| 1117 | 981 | * Make sure the install is only being run when we tell it to. |
| 1118 | 982 | * We don't want to run manually by people calling the API. |
| 1119 | 983 | * |
| 1120 | 984 | * @since 4.06.02 |
| 1121 | - * | |
| 1122 | - * @return bool | |
| 1123 | 985 | */ |
| 1124 | 986 | public static function can_update_db() { |
| 1125 | 987 | return get_transient( 'frm_updating_api' ); |
| 1126 | 988 | } |
| @@ -1164,9 +1026,8 @@ | ||
| 1164 | 1026 | */ |
| 1165 | 1027 | private static function maybe_add_wp_site_health() { |
| 1166 | 1028 | if ( ! class_exists( 'WP_Site_Health' ) ) { |
| 1167 | 1029 | $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; |
| 1168 | - | |
| 1169 | 1030 | if ( file_exists( $wp_site_health_path ) ) { |
| 1170 | 1031 | require_once $wp_site_health_path; |
| 1171 | 1032 | } |
| 1172 | 1033 | } |
| @@ -1178,12 +1039,10 @@ | ||
| 1178 | 1039 | * @return true |
| 1179 | 1040 | */ |
| 1180 | 1041 | public static function api_install() { |
| 1181 | 1042 | delete_transient( 'frm_updating_api' ); |
| 1182 | - | |
| 1183 | 1043 | if ( self::needs_update() ) { |
| 1184 | 1044 | $running = get_option( 'frm_install_running' ); |
| 1185 | - | |
| 1186 | 1045 | if ( false === $running || $running < strtotime( '-5 minutes' ) ) { |
| 1187 | 1046 | update_option( 'frm_install_running', time(), 'no' ); |
| 1188 | 1047 | self::install(); |
| 1189 | 1048 | delete_option( 'frm_install_running' ); |
| @@ -1233,13 +1092,8 @@ | ||
| 1233 | 1092 | |
| 1234 | 1093 | wp_die(); |
| 1235 | 1094 | } |
| 1236 | 1095 | |
| 1237 | - /** | |
| 1238 | - * @param array $tables | |
| 1239 | - * | |
| 1240 | - * @return array | |
| 1241 | - */ | |
| 1242 | 1096 | public static function drop_tables( $tables ) { |
| 1243 | 1097 | global $wpdb; |
| 1244 | 1098 | $tables[] = $wpdb->prefix . 'frm_fields'; |
| 1245 | 1099 | $tables[] = $wpdb->prefix . 'frm_forms'; |
| @@ -1287,13 +1141,8 @@ | ||
| 1287 | 1141 | |
| 1288 | 1142 | FrmTransLiteAppController::maybe_schedule_cron(); |
| 1289 | 1143 | } |
| 1290 | 1144 | |
| 1291 | - /** | |
| 1292 | - * @param string $text | |
| 1293 | - * | |
| 1294 | - * @return string | |
| 1295 | - */ | |
| 1296 | 1145 | public static function set_footer_text( $text ) { |
| 1297 | 1146 | if ( FrmAppHelper::is_formidable_admin() ) { |
| 1298 | 1147 | $text = ''; |
| 1299 | 1148 | } |
| @@ -1308,10 +1157,8 @@ | ||
| 1308 | 1157 | * |
| 1309 | 1158 | * @return void |
| 1310 | 1159 | */ |
| 1311 | 1160 | public static function add_admin_footer_links() { |
| 1312 | - FrmFormsController::include_device_too_small_message(); | |
| 1313 | - | |
| 1314 | 1161 | if ( self::should_show_footer_links() ) { |
| 1315 | 1162 | include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php'; |
| 1316 | 1163 | } |
| 1317 | 1164 | } |
| @@ -1326,9 +1173,8 @@ | ||
| 1326 | 1173 | private static function should_show_footer_links() { |
| 1327 | 1174 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 1328 | 1175 | $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type; |
| 1329 | 1176 | $show_footer_links = $is_formidable_page; |
| 1330 | - | |
| 1331 | 1177 | if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) { |
| 1332 | 1178 | $show_footer_links = false; |
| 1333 | 1179 | } |
| 1334 | 1180 | |
| @@ -1337,9 +1183,8 @@ | ||
| 1337 | 1183 | * |
| 1338 | 1184 | * @since 6.7 |
| 1339 | 1185 | * |
| 1340 | 1186 | * @param bool $show_footer_links |
| 1341 | - * | |
| 1342 | 1187 | * @return bool |
| 1343 | 1188 | */ |
| 1344 | 1189 | return apply_filters( 'frm_show_footer_links', $show_footer_links ); |
| 1345 | 1190 | } |
| @@ -1353,10 +1198,8 @@ | ||
| 1353 | 1198 | * |
| 1354 | 1199 | * @return void |
| 1355 | 1200 | */ |
| 1356 | 1201 | public static function show_error_modal( $error_args ) { |
| 1357 | - add_filter( 'frm_show_footer_links', '__return_false' ); | |
| 1358 | - | |
| 1359 | 1202 | $defaults = array( |
| 1360 | 1203 | 'title' => '', |
| 1361 | 1204 | 'body' => '', |
| 1362 | 1205 | 'cancel_url' => '', |
| @@ -1366,9 +1209,8 @@ | ||
| 1366 | 1209 | 'icon' => 'frm_lock_simple', |
| 1367 | 1210 | ); |
| 1368 | 1211 | |
| 1369 | 1212 | $error_args = wp_parse_args( $error_args, $defaults ); |
| 1370 | - | |
| 1371 | 1213 | if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) { |
| 1372 | 1214 | $error_args['cancel_text'] = __( 'Cancel', 'formidable' ); |
| 1373 | 1215 | } |
| 1374 | 1216 | |
| @@ -1385,9 +1227,8 @@ | ||
| 1385 | 1227 | * @since 6.4 |
| 1386 | 1228 | * |
| 1387 | 1229 | * @param string $plugin_url URL of the plugin. |
| 1388 | 1230 | * @param string $version Current version of the plugin. |
| 1389 | - * | |
| 1390 | 1231 | * @return void |
| 1391 | 1232 | */ |
| 1392 | 1233 | private static function enqueue_floating_links( $plugin_url, $version ) { |
| 1393 | 1234 | if ( ! $plugin_url || ! $version ) { |
| @@ -1398,9 +1239,9 @@ | ||
| 1398 | 1239 | // Enqueue the Floating Links styles. |
| 1399 | 1240 | wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version ); |
| 1400 | 1241 | |
| 1401 | 1242 | // Enqueue the Floating Links script. |
| 1402 | - wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array( 'formidable_admin' ), $version, true ); | |
| 1243 | + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true ); | |
| 1403 | 1244 | |
| 1404 | 1245 | // Enqueue the config script. |
| 1405 | 1246 | wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true ); |
| 1406 | 1247 | |
| @@ -1407,20 +1248,10 @@ | ||
| 1407 | 1248 | if ( function_exists( 'wp_set_script_translations' ) ) { |
| 1408 | 1249 | wp_set_script_translations( 's11-floating-links-config', 's11-' ); |
| 1409 | 1250 | } |
| 1410 | 1251 | |
| 1411 | - $upgrade_utm = array( | |
| 1412 | - 'campaign' => 'floating-links', | |
| 1413 | - 'content' => 'floating-links-upgrade', | |
| 1414 | - ); | |
| 1415 | - $docs_utm = array( | |
| 1416 | - 'campaign' => 'floating-links', | |
| 1417 | - 'content' => 'floating-links-docs', | |
| 1418 | - ); | |
| 1419 | 1252 | $floating_links_data = array( |
| 1420 | - 'proIsInstalled' => FrmAppHelper::pro_is_installed(), | |
| 1421 | - 'upgradeUrl' => FrmAppHelper::admin_upgrade_link( $upgrade_utm ), | |
| 1422 | - 'documentationUrl' => FrmAppHelper::admin_upgrade_link( $docs_utm, 'knowledgebase/' ), | |
| 1253 | + 'proIsInstalled' => FrmAppHelper::pro_is_installed(), | |
| 1423 | 1254 | ); |
| 1424 | 1255 | wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data ); |
| 1425 | 1256 | |
| 1426 | 1257 | /** |
| @@ -1432,249 +1263,86 @@ | ||
| 1432 | 1263 | do_action( 'frm_enqueue_floating_links' ); |
| 1433 | 1264 | } |
| 1434 | 1265 | |
| 1435 | 1266 | /** |
| 1436 | - * Check if we are in our admin pages. | |
| 1437 | - * | |
| 1438 | - * @return bool | |
| 1267 | + * @return void | |
| 1439 | 1268 | */ |
| 1440 | - private static function in_our_pages() { | |
| 1441 | - global $current_screen, $pagenow; | |
| 1269 | + private static function maybe_add_deprecated_message() { | |
| 1270 | + $settings = FrmAppHelper::get_settings(); | |
| 1442 | 1271 | |
| 1443 | - if ( FrmAppHelper::is_formidable_admin() ) { | |
| 1444 | - return true; | |
| 1445 | - } | |
| 1446 | - | |
| 1447 | - if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) { | |
| 1448 | - return true; | |
| 1449 | - } | |
| 1450 | - | |
| 1451 | - if ( in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' ) ) { | |
| 1452 | - return true; | |
| 1453 | - } | |
| 1454 | - | |
| 1455 | - return false; | |
| 1456 | - } | |
| 1457 | - | |
| 1458 | - /** | |
| 1459 | - * Handles actions related to the current screen. | |
| 1460 | - * | |
| 1461 | - * @since 6.19 | |
| 1462 | - * | |
| 1463 | - * @return void | |
| 1464 | - */ | |
| 1465 | - public static function handle_current_screen() { | |
| 1466 | - if ( ! self::in_our_pages() ) { | |
| 1272 | + if ( ! empty( $settings->use_html ) ) { | |
| 1273 | + // Dont' show a message if Use HTML 5 is already enabled. | |
| 1467 | 1274 | return; |
| 1468 | 1275 | } |
| 1469 | 1276 | |
| 1470 | - self::filter_admin_notices(); | |
| 1471 | - self::remember_custom_sort(); | |
| 1472 | - } | |
| 1473 | - | |
| 1474 | - /** | |
| 1475 | - * Hide all third-parties admin notices only in our admin pages. | |
| 1476 | - * | |
| 1477 | - * @return void | |
| 1478 | - */ | |
| 1479 | - public static function filter_admin_notices() { | |
| 1480 | - $actions = array( | |
| 1481 | - 'admin_notices', | |
| 1482 | - 'network_admin_notices', | |
| 1483 | - 'user_admin_notices', | |
| 1484 | - 'all_admin_notices', | |
| 1485 | - ); | |
| 1486 | - | |
| 1487 | - global $wp_filter; | |
| 1488 | - | |
| 1489 | - foreach ( $actions as $action ) { | |
| 1490 | - if ( empty( $wp_filter[ $action ]->callbacks ) ) { | |
| 1491 | - continue; | |
| 1492 | - } | |
| 1493 | - | |
| 1494 | - foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) { | |
| 1495 | - foreach ( $callbacks as $callback_name => $callback ) { | |
| 1496 | - if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) { | |
| 1497 | - continue; | |
| 1277 | + if ( FrmAppHelper::is_admin_page( 'formidable-settings' ) ) { | |
| 1278 | + add_action( | |
| 1279 | + 'frm_update_settings', | |
| 1280 | + function ( $params ) { | |
| 1281 | + if ( ! empty( $params['frm_use_html'] ) ) { | |
| 1282 | + $inbox = new FrmInbox(); | |
| 1283 | + $inbox->dismiss( 'deprecated_use_html' ); | |
| 1498 | 1284 | } |
| 1499 | - unset( $wp_filter[ $action ]->callbacks[ $priority ][ $callback_name ] ); | |
| 1500 | 1285 | } |
| 1501 | - } | |
| 1502 | - } | |
| 1503 | - } | |
| 1504 | - | |
| 1505 | - /** | |
| 1506 | - * Remembers and applies user-specific sorting preferences. | |
| 1507 | - * | |
| 1508 | - * @return void | |
| 1509 | - */ | |
| 1510 | - private static function remember_custom_sort() { | |
| 1511 | - $meta_key = self::get_sort_pref_user_meta_key(); | |
| 1512 | - | |
| 1513 | - if ( false === $meta_key ) { | |
| 1286 | + ); | |
| 1287 | + // Don't show the message on global settings. | |
| 1514 | 1288 | return; |
| 1515 | 1289 | } |
| 1516 | 1290 | |
| 1517 | - $is_form_list = FrmAppHelper::is_admin_list_page(); | |
| 1518 | - $is_entry_list = FrmAppHelper::is_admin_list_page( 'formidable-entries' ); | |
| 1291 | + $url = admin_url( 'admin.php?page=formidable-settings&t=misc_settings' ); | |
| 1519 | 1292 | |
| 1520 | - if ( ! $is_form_list && ! $is_entry_list ) { | |
| 1521 | - return; | |
| 1522 | - } | |
| 1293 | + add_filter( | |
| 1294 | + 'frm_message_list', | |
| 1295 | + /** | |
| 1296 | + * @param array $messages | |
| 1297 | + * @return array | |
| 1298 | + */ | |
| 1299 | + function ( $messages ) use ( $url ) { | |
| 1300 | + $messages[] = '<p>The option to use HTML5 in forms is currently disabled. In a future release, this setting will be removed and using HTML5 will be a requirement. <a href="' . esc_url( $url ) . '">Click here to enable it in Global Settings now</a>.</p>'; | |
| 1301 | + return $messages; | |
| 1302 | + } | |
| 1303 | + ); | |
| 1523 | 1304 | |
| 1524 | - $orderby = FrmAppHelper::get_param( 'orderby' ); | |
| 1525 | - | |
| 1526 | - if ( ! $orderby ) { | |
| 1527 | - return; | |
| 1528 | - } | |
| 1529 | - | |
| 1530 | - $user_id = get_current_user_id(); | |
| 1531 | - $order = FrmAppHelper::get_param( 'order' ); | |
| 1532 | - $new_sort = array( | |
| 1533 | - 'orderby' => $orderby, | |
| 1534 | - 'order' => $order, | |
| 1305 | + $inbox = new FrmInbox(); | |
| 1306 | + $inbox->add_message( | |
| 1307 | + array( | |
| 1308 | + 'key' => 'deprecated_use_html', | |
| 1309 | + 'force' => true, | |
| 1310 | + 'subject' => 'The option to use HTML5 in forms will soon be removed', | |
| 1311 | + 'message' => 'The option to use HTML5 in forms is currently disabled. In a future release, this setting will be removed and using HTML5 will be a requirement.', | |
| 1312 | + 'icon' => 'frm_report_problem_icon', | |
| 1313 | + 'cta' => '<a class="button-secondary frm-button-secondary" href="' . esc_url( $url ) . '">Enable in Global Settings</a>', | |
| 1314 | + ) | |
| 1535 | 1315 | ); |
| 1536 | - $previous_meta = get_user_meta( $user_id, $meta_key, true ); | |
| 1537 | - $current_sort = $previous_meta; | |
| 1538 | - $form_id = $is_entry_list ? FrmAppHelper::simple_get( 'form', 'absint' ) : 0; | |
| 1539 | - | |
| 1540 | - if ( is_array( $current_sort ) && $form_id && is_int( $form_id ) && isset( $current_sort[ $form_id ] ) ) { | |
| 1541 | - $current_sort = $current_sort[ $form_id ]; | |
| 1542 | - } | |
| 1543 | - | |
| 1544 | - if ( $new_sort !== $current_sort ) { | |
| 1545 | - $new_meta = $new_sort; | |
| 1546 | - | |
| 1547 | - if ( $is_entry_list && $form_id && is_int( $form_id ) ) { | |
| 1548 | - // Index meta by form ID. | |
| 1549 | - $temp_meta = is_array( $previous_meta ) ? $previous_meta : array(); | |
| 1550 | - $temp_meta[ $form_id ] = $new_meta; | |
| 1551 | - $new_meta = $temp_meta; | |
| 1552 | - unset( $temp_meta ); | |
| 1553 | - } | |
| 1554 | - | |
| 1555 | - update_user_meta( $user_id, $meta_key, $new_meta ); | |
| 1556 | - } | |
| 1557 | 1316 | } |
| 1558 | 1317 | |
| 1559 | 1318 | /** |
| 1560 | - * Retrieve and apply any saved sorting preferences for the current screen. | |
| 1319 | + * Include icons on page for Embed Form modal. | |
| 1561 | 1320 | * |
| 1562 | - * @since 6.19 | |
| 1321 | + * @since 5.2 | |
| 1563 | 1322 | * |
| 1564 | - * @param string &$orderby Reference to the current 'orderby' parameter. | |
| 1565 | - * @param string &$order Reference to the current 'order' parameter. | |
| 1566 | - * | |
| 1567 | 1323 | * @return void |
| 1568 | 1324 | */ |
| 1569 | - public static function apply_saved_sort_preference( &$orderby, &$order ) { | |
| 1570 | - $meta_key = self::get_sort_pref_user_meta_key(); | |
| 1571 | - | |
| 1572 | - if ( false === $meta_key ) { | |
| 1573 | - return; | |
| 1574 | - } | |
| 1575 | - | |
| 1576 | - $user_id = get_current_user_id(); | |
| 1577 | - $preferred_list_sort = get_user_meta( $user_id, $meta_key, true ); | |
| 1578 | - $form_id = FrmAppHelper::simple_get( 'form', 'absint' ); | |
| 1579 | - | |
| 1580 | - if ( is_array( $preferred_list_sort ) && $form_id && is_int( $form_id ) && isset( $preferred_list_sort[ $form_id ] ) ) { | |
| 1581 | - $preferred_list_sort = $preferred_list_sort[ $form_id ]; | |
| 1582 | - } | |
| 1583 | - | |
| 1584 | - if ( is_array( $preferred_list_sort ) && ! empty( $preferred_list_sort['orderby'] ) ) { | |
| 1585 | - $orderby = $preferred_list_sort['orderby']; | |
| 1586 | - | |
| 1587 | - if ( ! empty( $preferred_list_sort['order'] ) ) { | |
| 1588 | - $order = $preferred_list_sort['order']; | |
| 1589 | - } | |
| 1590 | - } | |
| 1325 | + public static function include_embed_form_icons() { | |
| 1326 | + _deprecated_function( __METHOD__, '5.3' ); | |
| 1591 | 1327 | } |
| 1592 | 1328 | |
| 1593 | 1329 | /** |
| 1594 | - * Get a simple user meta key that only includes the screen ID. | |
| 1330 | + * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13. | |
| 1331 | + * @codeCoverageIgnore | |
| 1595 | 1332 | * |
| 1596 | - * @since 6.25.1 | |
| 1597 | - * | |
| 1598 | - * @return false|string | |
| 1333 | + * @param array $atts | |
| 1334 | + * @return string | |
| 1599 | 1335 | */ |
| 1600 | - private static function get_sort_pref_user_meta_key() { | |
| 1601 | - if ( ! function_exists( 'get_current_screen' ) ) { | |
| 1602 | - return false; | |
| 1603 | - } | |
| 1604 | - | |
| 1605 | - $screen = get_current_screen(); | |
| 1606 | - return $screen ? 'frm_preferred_list_sort_' . $screen->id : false; | |
| 1336 | + public static function get_form_shortcode( $atts ) { | |
| 1337 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' ); | |
| 1338 | + return FrmFormsController::get_form_shortcode( $atts ); | |
| 1607 | 1339 | } |
| 1608 | 1340 | |
| 1609 | 1341 | /** |
| 1610 | - * Validate that the callback name is ours not from third-party. | |
| 1611 | - * | |
| 1612 | - * @param string $callback_name WordPress callback name. | |
| 1613 | - * | |
| 1614 | - * @return bool | |
| 1342 | + * @deprecated 3.0 This is still referenced in https://formidableforms.com/knowledgebase/php-examples/ as of May 8, 2024. | |
| 1343 | + * @codeCoverageIgnore | |
| 1615 | 1344 | */ |
| 1616 | - private static function is_our_callback_string( $callback_name ) { | |
| 1617 | - return 0 === stripos( $callback_name, 'frm' ); | |
| 1618 | - } | |
| 1619 | - | |
| 1620 | - /** | |
| 1621 | - * Validate that the callback array is ours not from third-party. | |
| 1622 | - * | |
| 1623 | - * @param array $callback WordPress callback array. | |
| 1624 | - * | |
| 1625 | - * @return bool | |
| 1626 | - */ | |
| 1627 | - private static function is_our_callback_array( $callback ) { | |
| 1628 | - return ! empty( $callback['function'] ) && | |
| 1629 | - is_array( $callback['function'] ) && | |
| 1630 | - ! empty( $callback['function'][0] ) && | |
| 1631 | - self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] ); | |
| 1632 | - } | |
| 1633 | - | |
| 1634 | - /** | |
| 1635 | - * In some cases, the DB tables may fail to install. | |
| 1636 | - * This function tries to add them again when the user clicks the link to try again | |
| 1637 | - * from the given inbox notice. | |
| 1638 | - * | |
| 1639 | - * @since 6.19 | |
| 1640 | - */ | |
| 1641 | - private static function add_missing_tables() { | |
| 1642 | - FrmAppHelper::permission_check( 'frm_view_forms' ); | |
| 1643 | - | |
| 1644 | - $inbox = new FrmInbox(); | |
| 1645 | - $error = $inbox->check_for_error(); | |
| 1646 | - | |
| 1647 | - if ( ! $error || 'failed-to-create-tables' !== $error['key'] ) { | |
| 1648 | - // Confirm the inbox item with this CTA exists. | |
| 1649 | - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) ); | |
| 1650 | - exit; | |
| 1651 | - } | |
| 1652 | - | |
| 1653 | - global $wpdb; | |
| 1654 | - $exists = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->prefix . 'frm_forms' ) ); | |
| 1655 | - | |
| 1656 | - if ( $exists ) { | |
| 1657 | - // Exit early if the table already exists. | |
| 1658 | - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) ); | |
| 1659 | - exit; | |
| 1660 | - } | |
| 1661 | - | |
| 1662 | - delete_option( 'frm_db_version' ); | |
| 1663 | - wp_safe_redirect( admin_url( 'admin.php?page=formidable' ) ); | |
| 1664 | - exit; | |
| 1665 | - } | |
| 1666 | - | |
| 1667 | - /** | |
| 1668 | - * Handles the small screen proceed action. | |
| 1669 | - * | |
| 1670 | - * @since 6.21 | |
| 1671 | - * | |
| 1672 | - * @return void | |
| 1673 | - */ | |
| 1674 | - public static function small_screen_proceed() { | |
| 1675 | - FrmAppHelper::permission_check( 'frm_view_forms' ); | |
| 1676 | - check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 1677 | - update_user_option( get_current_user_id(), 'frm_ignore_small_screen_warning', true ); | |
| 1678 | - wp_send_json_success(); | |
| 1345 | + public static function page_route( $content ) { | |
| 1346 | + return FrmDeprecated::page_route( $content ); | |
| 1679 | 1347 | } |
| 1680 | 1348 | } |