| @@ -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 | } |
| @@ -82,10 +67,9 @@ | ||
| 82 | 67 | } |
| 83 | 68 | |
| 84 | 69 | if ( FrmAppHelper::is_full_screen() ) { |
| 85 | 70 | $full_screen_on = self::get_full_screen_setting(); |
| 86 | - $add_class = ''; | |
| 87 | - | |
| 71 | + $add_class = ''; | |
| 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', |
| @@ -162,9 +142,8 @@ | ||
| 162 | 142 | 'formidable-styles', |
| 163 | 143 | 'formidable-styles2', |
| 164 | 144 | 'formidable-inbox', |
| 165 | 145 | FrmFormTemplatesController::PAGE_SLUG, |
| 166 | - FrmOnboardingWizardController::PAGE_SLUG, | |
| 167 | 146 | ); |
| 168 | 147 | |
| 169 | 148 | if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) { |
| 170 | 149 | // Only consider the payments page as a "white page" when the Payments submodule is off. |
| @@ -201,9 +180,8 @@ | ||
| 201 | 180 | private static function is_grey_page() { |
| 202 | 181 | $grey_pages = array( |
| 203 | 182 | 'formidable-applications', |
| 204 | 183 | 'formidable-dashboard', |
| 205 | - 'formidable-views', | |
| 206 | 184 | ); |
| 207 | 185 | |
| 208 | 186 | $is_grey_page = self::is_page_in_list( $grey_pages ); |
| 209 | 187 | |
| @@ -212,9 +190,8 @@ | ||
| 212 | 190 | * |
| 213 | 191 | * @since 6.8 |
| 214 | 192 | * |
| 215 | 193 | * @param bool $is_grey_page |
| 216 | - * | |
| 217 | 194 | * @return bool |
| 218 | 195 | */ |
| 219 | 196 | return apply_filters( 'frm_is_grey_page', $is_grey_page ); |
| 220 | 197 | } |
| @@ -222,9 +199,8 @@ | ||
| 222 | 199 | /** |
| 223 | 200 | * @since 6.8 |
| 224 | 201 | * |
| 225 | 202 | * @param array $pages A list of page names to check. |
| 226 | - * | |
| 227 | 203 | * @return bool |
| 228 | 204 | */ |
| 229 | 205 | private static function is_page_in_list( $pages ) { |
| 230 | 206 | $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| @@ -248,15 +224,13 @@ | ||
| 248 | 224 | * @return void |
| 249 | 225 | */ |
| 250 | 226 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
| 251 | 227 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 252 | - | |
| 253 | 228 | if ( empty( $show_nav ) || ! $form ) { |
| 254 | 229 | return; |
| 255 | 230 | } |
| 256 | 231 | |
| 257 | 232 | FrmForm::maybe_get_form( $form ); |
| 258 | - | |
| 259 | 233 | if ( ! is_object( $form ) ) { |
| 260 | 234 | return; |
| 261 | 235 | } |
| 262 | 236 | |
| @@ -263,9 +237,9 @@ | ||
| 263 | 237 | $id = $form->id; |
| 264 | 238 | $current_page = self::get_current_page(); |
| 265 | 239 | $nav_items = self::get_form_nav_items( $form ); |
| 266 | 240 | |
| 267 | - include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php'; | |
| 241 | + include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); | |
| 268 | 242 | } |
| 269 | 243 | |
| 270 | 244 | /** |
| 271 | 245 | * @return string |
| @@ -283,9 +257,8 @@ | ||
| 283 | 257 | } |
| 284 | 258 | |
| 285 | 259 | /** |
| 286 | 260 | * @param object $form |
| 287 | - * | |
| 288 | 261 | * @return array |
| 289 | 262 | */ |
| 290 | 263 | private static function get_form_nav_items( $form ) { |
| 291 | 264 | $id = $form->parent_form_id ? $form->parent_form_id : $form->id; |
| @@ -320,18 +293,18 @@ | ||
| 320 | 293 | 'permission' => 'frm_view_entries', |
| 321 | 294 | ), |
| 322 | 295 | ); |
| 323 | 296 | |
| 324 | - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed(); | |
| 297 | + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed(); | |
| 325 | 298 | |
| 326 | 299 | if ( ! $views_installed ) { |
| 327 | 300 | $nav_items[] = array( |
| 328 | - 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ), | |
| 329 | - 'label' => __( 'Views', 'formidable' ), | |
| 330 | - 'current' => array(), | |
| 331 | - 'page' => 'formidable-views', | |
| 301 | + 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ), | |
| 302 | + 'label' => __( 'Views', 'formidable' ), | |
| 303 | + 'current' => array(), | |
| 304 | + 'page' => 'formidable-views', | |
| 332 | 305 | 'permission' => 'frm_view_entries', |
| 333 | - 'atts' => array( | |
| 306 | + 'atts' => array( | |
| 334 | 307 | 'class' => 'frm_noallow', |
| 335 | 308 | ), |
| 336 | 309 | ); |
| 337 | 310 | } |
| @@ -338,14 +311,14 @@ | ||
| 338 | 311 | |
| 339 | 312 | // Let people know reports and views exist. |
| 340 | 313 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 341 | 314 | $nav_items[] = array( |
| 342 | - 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ), | |
| 343 | - 'label' => __( 'Reports', 'formidable' ), | |
| 344 | - 'current' => array( 'reports' ), | |
| 345 | - 'page' => 'formidable', | |
| 315 | + 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ), | |
| 316 | + 'label' => __( 'Reports', 'formidable' ), | |
| 317 | + 'current' => array( 'reports' ), | |
| 318 | + 'page' => 'formidable', | |
| 346 | 319 | 'permission' => 'frm_view_entries', |
| 347 | - 'atts' => array( | |
| 320 | + 'atts' => array( | |
| 348 | 321 | 'class' => 'frm_noallow', |
| 349 | 322 | ), |
| 350 | 323 | ); |
| 351 | 324 | } |
| @@ -357,13 +330,10 @@ | ||
| 357 | 330 | |
| 358 | 331 | return (array) apply_filters( 'frm_form_nav_list', $nav_items, $nav_args ); |
| 359 | 332 | } |
| 360 | 333 | |
| 334 | + // Adds a settings link to the plugins page | |
| 361 | 335 | /** |
| 362 | - * Adds a settings link to the plugins page | |
| 363 | - * | |
| 364 | - * @param array $links | |
| 365 | - * | |
| 366 | 336 | * @return array |
| 367 | 337 | */ |
| 368 | 338 | public static function settings_link( $links ) { |
| 369 | 339 | $settings = array(); |
| @@ -368,29 +338,12 @@ | ||
| 368 | 338 | public static function settings_link( $links ) { |
| 369 | 339 | $settings = array(); |
| 370 | 340 | |
| 371 | 341 | 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' ); | |
| 342 | + $label = FrmAddonsController::is_license_expired() ? __( 'Renew', 'formidable' ) : __( 'Upgrade to Pro', 'formidable' ); | |
| 343 | + $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>'; | |
| 344 | + } | |
| 376 | 345 | |
| 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 | 346 | $settings[] = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>'; |
| 394 | 347 | |
| 395 | 348 | return array_merge( $settings, $links ); |
| 396 | 349 | } |
| @@ -399,9 +352,9 @@ | ||
| 399 | 352 | * @return void |
| 400 | 353 | */ |
| 401 | 354 | public static function pro_get_started_headline() { |
| 402 | 355 | self::review_request(); |
| 403 | - FrmAppHelper::min_pro_version_notice( '6.20' ); | |
| 356 | + FrmAppHelper::min_pro_version_notice( '4.0' ); | |
| 404 | 357 | } |
| 405 | 358 | |
| 406 | 359 | /** |
| 407 | 360 | * Add admin notices as needed for reviews |
| @@ -476,13 +429,12 @@ | ||
| 476 | 429 | * |
| 477 | 430 | * @param string $form_key |
| 478 | 431 | * @param string $title |
| 479 | 432 | * @param string $description |
| 480 | - * | |
| 481 | 433 | * @return void |
| 482 | 434 | */ |
| 483 | - public static function api_email_form( $form_key, $title = '', $description = '' ) { | |
| 484 | - $user = wp_get_current_user(); | |
| 435 | + public static function api_email_form( $form_key, $title, $description ) { | |
| 436 | + $user = wp_get_current_user(); | |
| 485 | 437 | $args = array( |
| 486 | 438 | 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css', |
| 487 | 439 | 'title' => $title, |
| 488 | 440 | 'description' => $description, |
| @@ -511,9 +463,10 @@ | ||
| 511 | 463 | * @return void |
| 512 | 464 | */ |
| 513 | 465 | public static function remove_upsells() { |
| 514 | 466 | remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
| 515 | - remove_action( 'frm_after_settings_tabs', 'FrmSettingsController::settings_cta' ); | |
| 467 | + remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' ); | |
| 468 | + remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' ); | |
| 516 | 469 | remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' ); |
| 517 | 470 | } |
| 518 | 471 | |
| 519 | 472 | /** |
| @@ -535,10 +488,9 @@ | ||
| 535 | 488 | /** |
| 536 | 489 | * Check if the database is outdated |
| 537 | 490 | * |
| 538 | 491 | * @since 2.0.1 |
| 539 | - * | |
| 540 | - * @return bool | |
| 492 | + * @return boolean | |
| 541 | 493 | */ |
| 542 | 494 | public static function needs_update() { |
| 543 | 495 | $needs_upgrade = self::compare_for_update( |
| 544 | 496 | array( |
| @@ -560,9 +512,8 @@ | ||
| 560 | 512 | * |
| 561 | 513 | * @since 3.0.04 |
| 562 | 514 | * |
| 563 | 515 | * @param array $atts |
| 564 | - * | |
| 565 | 516 | * @return bool |
| 566 | 517 | */ |
| 567 | 518 | public static function compare_for_update( $atts ) { |
| 568 | 519 | $db_version = get_option( $atts['option'] ); |
| @@ -594,34 +545,13 @@ | ||
| 594 | 545 | if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) { |
| 595 | 546 | FrmFormsController::duplicate(); |
| 596 | 547 | } |
| 597 | 548 | |
| 598 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) && FrmAppHelper::simple_get( 'frm_add_tables' ) ) { | |
| 599 | - self::add_missing_tables(); | |
| 600 | - } | |
| 601 | - | |
| 602 | 549 | if ( FrmAppHelper::is_style_editor_page() && 'save' === FrmAppHelper::get_param( 'frm_action' ) ) { |
| 603 | 550 | // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent. |
| 604 | 551 | FrmStylesController::save_style(); |
| 605 | 552 | } |
| 606 | 553 | |
| 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 | 554 | // Register personal data hooks. |
| 625 | 555 | new FrmPersonalData(); |
| 626 | 556 | |
| 627 | 557 | if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) { |
| @@ -637,14 +567,13 @@ | ||
| 637 | 567 | |
| 638 | 568 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 639 | 569 | // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions. |
| 640 | 570 | // This provides backward compatibility for old addons that use legacy modal templates. |
| 641 | - $action = FrmAppHelper::get_param( 'frm_action' ); | |
| 571 | + $action = FrmAppHelper::get_param( 'frm_action' ); | |
| 642 | 572 | $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' ); |
| 643 | - | |
| 644 | 573 | if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { |
| 645 | 574 | $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' ); |
| 646 | - $url_param = $application_id ? '&applicationId=' . $application_id : ''; | |
| 575 | + $url_param = $application_id ? '&applicationId=' . $application_id : ''; | |
| 647 | 576 | |
| 648 | 577 | wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) ); |
| 649 | 578 | exit; |
| 650 | 579 | } |
| @@ -650,8 +579,10 @@ | ||
| 650 | 579 | } |
| 651 | 580 | |
| 652 | 581 | FrmInbox::maybe_disable_screen_options(); |
| 653 | 582 | } |
| 583 | + | |
| 584 | + self::maybe_add_ip_warning(); | |
| 654 | 585 | } |
| 655 | 586 | |
| 656 | 587 | /** |
| 657 | 588 | * Get the current page and check for a possible function to trigger. |
| @@ -662,9 +593,8 @@ | ||
| 662 | 593 | * @return void |
| 663 | 594 | */ |
| 664 | 595 | private static function trigger_page_load_hooks() { |
| 665 | 596 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 666 | - | |
| 667 | 597 | if ( strpos( $page, 'formidable-' ) !== 0 ) { |
| 668 | 598 | // Only trigger hooks on Formidable pages. |
| 669 | 599 | return; |
| 670 | 600 | } |
| @@ -671,9 +601,8 @@ | ||
| 671 | 601 | |
| 672 | 602 | $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page ); |
| 673 | 603 | $page = str_replace( ' ', '', ucwords( $page ) ); |
| 674 | 604 | $class = 'Frm' . $page . 'Controller'; |
| 675 | - | |
| 676 | 605 | if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) { |
| 677 | 606 | call_user_func( array( $class, 'load_page' ) ); |
| 678 | 607 | } |
| 679 | 608 | } |
| @@ -678,10 +607,69 @@ | ||
| 678 | 607 | } |
| 679 | 608 | } |
| 680 | 609 | |
| 681 | 610 | /** |
| 611 | + * Show a warning for the IP address setting if it hasn't been set. | |
| 612 | + * | |
| 613 | + * @since 6.1 | |
| 614 | + * | |
| 682 | 615 | * @return void |
| 683 | 616 | */ |
| 617 | + private static function maybe_add_ip_warning() { | |
| 618 | + $settings = FrmAppHelper::get_settings(); | |
| 619 | + if ( false !== $settings->custom_header_ip ) { | |
| 620 | + // The setting has been changed from the false default (to either 1 or 0), so stop showing the message. | |
| 621 | + return; | |
| 622 | + } | |
| 623 | + | |
| 624 | + if ( ! self::is_behind_proxy() ) { | |
| 625 | + // This message is only applicable when using a reverse proxy. | |
| 626 | + return; | |
| 627 | + } | |
| 628 | + | |
| 629 | + if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) { | |
| 630 | + // Avoid the message on a POST action. We don't want to show the message if we're saving global settings. | |
| 631 | + return; | |
| 632 | + } | |
| 633 | + | |
| 634 | + $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip'; | |
| 635 | + $message = sprintf( | |
| 636 | + // Translators: 1: Global Settings Link | |
| 637 | + __( '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' ), | |
| 638 | + '<a href="' . esc_url( $global_settings_link ) . '">Global Settings</a>' | |
| 639 | + ); | |
| 640 | + $option_name = 'frm_dismiss_ip_address_notice'; | |
| 641 | + FrmAppHelper::add_dismissable_warning_message( $message, $option_name ); | |
| 642 | + } | |
| 643 | + | |
| 644 | + /** | |
| 645 | + * Check if any reverse proxy headers are set. | |
| 646 | + * | |
| 647 | + * @since 6.1 | |
| 648 | + * | |
| 649 | + * @return bool | |
| 650 | + */ | |
| 651 | + private static function is_behind_proxy() { | |
| 652 | + $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip(); | |
| 653 | + foreach ( $custom_headers as $header ) { | |
| 654 | + if ( 'REMOTE_ADDR' === $header ) { | |
| 655 | + // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers. | |
| 656 | + continue; | |
| 657 | + } | |
| 658 | + | |
| 659 | + $ip = trim( FrmAppHelper::get_server_value( $header ) ); | |
| 660 | + // Return true for anything that isn't empty but ignoring values like ::1. | |
| 661 | + if ( $ip && 0 !== strpos( $ip, '::' ) ) { | |
| 662 | + return true; | |
| 663 | + } | |
| 664 | + } | |
| 665 | + | |
| 666 | + return false; | |
| 667 | + } | |
| 668 | + | |
| 669 | + /** | |
| 670 | + * @return void | |
| 671 | + */ | |
| 684 | 672 | public static function admin_js() { |
| 685 | 673 | $plugin_url = FrmAppHelper::plugin_url(); |
| 686 | 674 | $version = FrmAppHelper::plugin_version(); |
| 687 | 675 | |
| @@ -686,11 +674,8 @@ | ||
| 686 | 674 | $version = FrmAppHelper::plugin_version(); |
| 687 | 675 | |
| 688 | 676 | FrmAppHelper::load_admin_wide_js(); |
| 689 | 677 | |
| 690 | - // Register component assets early to ensure they can be enqueued later in controllers. | |
| 691 | - wp_register_style( 'formidable-animations', $plugin_url . '/css/admin/animations.css', array(), $version ); | |
| 692 | - | |
| 693 | 678 | if ( class_exists( 'FrmOverlayController' ) ) { |
| 694 | 679 | // This should always exist. |
| 695 | 680 | // But it may not have loaded properly when updating the plugin. |
| 696 | 681 | FrmOverlayController::register_assets(); |
| @@ -703,20 +688,24 @@ | ||
| 703 | 688 | wp_register_style( 'formidable-grids', $plugin_url . '/css/frm_grids.css', array(), $version ); |
| 704 | 689 | |
| 705 | 690 | wp_register_script( 'formidable_dom', $plugin_url . '/js/admin/dom.js', array( 'jquery', 'jquery-ui-dialog', 'wp-i18n' ), $version, true ); |
| 706 | 691 | 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 ); | |
| 692 | + self::register_popper1(); | |
| 693 | + wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true ); | |
| 694 | + wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true ); | |
| 709 | 695 | |
| 710 | - $settings_js_vars = array( | |
| 711 | - 'currencies' => FrmCurrencyHelper::get_currencies(), | |
| 712 | - ); | |
| 713 | - wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true ); | |
| 714 | - wp_localize_script( 'formidable_settings', 'frmSettings', $settings_js_vars ); | |
| 696 | + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 715 | 697 | |
| 716 | - if ( self::should_show_floating_links() ) { | |
| 698 | + // Enqueue Floating Links. | |
| 699 | + $is_valid_page = | |
| 700 | + FrmAppHelper::is_formidable_admin() && | |
| 701 | + ! FrmAppHelper::is_style_editor_page() && | |
| 702 | + ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) && | |
| 703 | + ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); | |
| 704 | + if ( $is_valid_page && FrmAppHelper::is_formidable_branding() ) { | |
| 717 | 705 | self::enqueue_floating_links( $plugin_url, $version ); |
| 718 | 706 | } |
| 707 | + unset( $is_valid_page ); | |
| 719 | 708 | |
| 720 | 709 | $dependencies = array( |
| 721 | 710 | 'formidable_admin_global', |
| 722 | 711 | 'jquery', |
| @@ -743,9 +732,9 @@ | ||
| 743 | 732 | // For the existing page dropdown in the Form embed modal. |
| 744 | 733 | wp_enqueue_script( 'jquery-ui-autocomplete' ); |
| 745 | 734 | } |
| 746 | 735 | |
| 747 | - wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '2.0', true ); | |
| 736 | + wp_register_script( 'bootstrap-multiselect', $plugin_url . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip', 'popper' ), '1.1.1', true ); | |
| 748 | 737 | |
| 749 | 738 | if ( ! class_exists( 'FrmTransHooksController', false ) ) { |
| 750 | 739 | /** |
| 751 | 740 | * Gateway fields are included for add-on compatibility but we do not want it to be visible. |
| @@ -756,31 +745,24 @@ | ||
| 756 | 745 | '#frm_builder_page li[data-ftype="gateway"] { display: none; }' |
| 757 | 746 | ); |
| 758 | 747 | } |
| 759 | 748 | |
| 760 | - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 761 | 749 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 762 | 750 | |
| 763 | 751 | global $pagenow; |
| 764 | - | |
| 765 | 752 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) { |
| 766 | - self::enqueue_global_settings_scripts( $page ); | |
| 767 | 753 | |
| 768 | 754 | wp_enqueue_script( 'admin-widgets' ); |
| 769 | 755 | wp_enqueue_style( 'widgets' ); |
| 770 | - self::maybe_deregister_popper1(); | |
| 756 | + self::maybe_deregister_popper2(); | |
| 771 | 757 | wp_enqueue_script( 'formidable_admin' ); |
| 772 | - wp_set_script_translations( 'formidable_admin', 'formidable' ); | |
| 773 | 758 | wp_enqueue_script( 'formidable_embed' ); |
| 774 | - wp_set_script_translations( 'formidable_embed', 'formidable' ); | |
| 775 | 759 | FrmAppHelper::localize_script( 'admin' ); |
| 776 | 760 | |
| 777 | - wp_enqueue_style( 'formidable-animations' ); | |
| 778 | 761 | wp_enqueue_style( 'formidable-admin' ); |
| 779 | - | |
| 780 | 762 | if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) { |
| 781 | 763 | wp_enqueue_style( 'formidable-grids' ); |
| 782 | - self::maybe_enqueue_dropzone_css( $page ); | |
| 764 | + wp_enqueue_style( 'formidable-dropzone' ); | |
| 783 | 765 | } else { |
| 784 | 766 | wp_enqueue_style( 'formidable-grids' ); |
| 785 | 767 | } |
| 786 | 768 | |
| @@ -800,13 +782,11 @@ | ||
| 800 | 782 | if ( isset( $_REQUEST['post_type'] ) ) { |
| 801 | 783 | $post_type = sanitize_title( wp_unslash( $_REQUEST['post_type'] ) ); |
| 802 | 784 | } elseif ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 803 | 785 | $post = get_post( absint( wp_unslash( $_REQUEST['post'] ) ) ); |
| 804 | - | |
| 805 | 786 | if ( ! $post ) { |
| 806 | 787 | return; |
| 807 | 788 | } |
| 808 | - | |
| 809 | 789 | $post_type = $post->post_type; |
| 810 | 790 | } else { |
| 811 | 791 | return; |
| 812 | 792 | } |
| @@ -819,98 +799,11 @@ | ||
| 819 | 799 | if ( 'formidable-addons' === $page ) { |
| 820 | 800 | wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true ); |
| 821 | 801 | wp_enqueue_script( 'formidable_addons' ); |
| 822 | 802 | } |
| 823 | - | |
| 824 | - self::enqueue_builder_assets( $plugin_url, $version ); | |
| 825 | 803 | } |
| 826 | 804 | |
| 827 | 805 | /** |
| 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 | - * The floating links are not shown on every page. | |
| 886 | - * They are also not shown if white labeling is being used. | |
| 887 | - * | |
| 888 | - * @since 6.8.4 | |
| 889 | - * | |
| 890 | - * @return bool | |
| 891 | - */ | |
| 892 | - private static function should_show_floating_links() { | |
| 893 | - if ( ! FrmAppHelper::is_formidable_branding() ) { | |
| 894 | - return false; | |
| 895 | - } | |
| 896 | - | |
| 897 | - $should_show = FrmAppHelper::is_formidable_admin() && | |
| 898 | - ! FrmAppHelper::is_style_editor_page() && | |
| 899 | - ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) && | |
| 900 | - ! 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 | - } | |
| 911 | - | |
| 912 | - /** | |
| 913 | 806 | * @since 6.3.2 |
| 914 | 807 | * |
| 915 | 808 | * @return void |
| 916 | 809 | */ |
| @@ -916,14 +809,8 @@ | ||
| 916 | 809 | */ |
| 917 | 810 | public static function admin_enqueue_scripts() { |
| 918 | 811 | self::load_wp_admin_style(); |
| 919 | 812 | 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 | 813 | } |
| 927 | 814 | |
| 928 | 815 | /** |
| 929 | 816 | * Enqueue required assets for the Legacy Views editor (Views v4.x). |
| @@ -934,9 +821,9 @@ | ||
| 934 | 821 | */ |
| 935 | 822 | private static function enqueue_legacy_views_assets() { |
| 936 | 823 | wp_enqueue_style( 'formidable-grids' ); |
| 937 | 824 | wp_enqueue_script( 'jquery-ui-draggable' ); |
| 938 | - self::maybe_deregister_popper1(); | |
| 825 | + self::maybe_deregister_popper2(); | |
| 939 | 826 | wp_enqueue_script( 'formidable_admin' ); |
| 940 | 827 | wp_add_inline_style( |
| 941 | 828 | 'formidable-admin', |
| 942 | 829 | ' |
| @@ -959,21 +846,20 @@ | ||
| 959 | 846 | } |
| 960 | 847 | ' |
| 961 | 848 | ); |
| 962 | 849 | 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 | 850 | FrmAppHelper::localize_script( 'admin' ); |
| 965 | 851 | self::include_info_overlay(); |
| 966 | 852 | } |
| 967 | 853 | |
| 968 | 854 | /** |
| 969 | - * Unregister Popper if the registered version is outdated. | |
| 855 | + * Fix a Duplicator Pro conflict because it uses Popper 2. See issue #3459. | |
| 970 | 856 | * |
| 971 | - * @since 6.26 | |
| 857 | + * @since 5.2.02.01 | |
| 972 | 858 | * |
| 973 | 859 | * @return void |
| 974 | 860 | */ |
| 975 | - private static function maybe_deregister_popper1() { | |
| 861 | + private static function maybe_deregister_popper2() { | |
| 976 | 862 | global $wp_scripts; |
| 977 | 863 | |
| 978 | 864 | if ( ! array_key_exists( 'popper', $wp_scripts->registered ) ) { |
| 979 | 865 | return; |
| @@ -979,63 +865,26 @@ | ||
| 979 | 865 | return; |
| 980 | 866 | } |
| 981 | 867 | |
| 982 | 868 | $popper = $wp_scripts->registered['popper']; |
| 983 | - | |
| 984 | - if ( version_compare( $popper->ver, '2.0', '<' ) ) { | |
| 869 | + if ( version_compare( $popper->ver, '2.0', '>=' ) ) { | |
| 985 | 870 | wp_deregister_script( 'popper' ); |
| 986 | - self::register_popper2(); | |
| 871 | + self::register_popper1(); | |
| 987 | 872 | } |
| 988 | 873 | } |
| 989 | 874 | |
| 990 | 875 | /** |
| 991 | - * Register Popper required for Bootstrap 5. | |
| 876 | + * Register Popper required for Bootstrap 4. | |
| 992 | 877 | * |
| 993 | - * @since 6.26 | |
| 878 | + * @since 5.2.02.01 | |
| 994 | 879 | * |
| 995 | 880 | * @return void |
| 996 | 881 | */ |
| 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 ); | |
| 882 | + private static function register_popper1() { | |
| 883 | + wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true ); | |
| 1002 | 884 | } |
| 1003 | 885 | |
| 1004 | 886 | /** |
| 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 | 887 | * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set. |
| 1039 | 888 | * |
| 1040 | 889 | * @since 5.2 |
| 1041 | 890 | * |
| @@ -1042,15 +891,13 @@ | ||
| 1042 | 891 | * @return void |
| 1043 | 892 | */ |
| 1044 | 893 | private static function maybe_force_formidable_block_on_gutenberg_page() { |
| 1045 | 894 | global $pagenow; |
| 1046 | - | |
| 1047 | 895 | if ( 'post.php' !== $pagenow ) { |
| 1048 | 896 | return; |
| 1049 | 897 | } |
| 1050 | 898 | |
| 1051 | 899 | $form_id = FrmAppHelper::simple_get( 'frmForm', 'absint' ); |
| 1052 | - | |
| 1053 | 900 | if ( ! $form_id ) { |
| 1054 | 901 | return; |
| 1055 | 902 | } |
| 1056 | 903 | |
| @@ -1096,18 +943,18 @@ | ||
| 1096 | 943 | * @return void |
| 1097 | 944 | */ |
| 1098 | 945 | public static function create_rest_routes() { |
| 1099 | 946 | $args = array( |
| 1100 | - 'methods' => 'GET', | |
| 1101 | - 'callback' => 'FrmAppController::api_install', | |
| 1102 | - 'permission_callback' => self::class . '::can_update_db', | |
| 947 | + 'methods' => 'GET', | |
| 948 | + 'callback' => 'FrmAppController::api_install', | |
| 949 | + 'permission_callback' => __CLASS__ . '::can_update_db', | |
| 1103 | 950 | ); |
| 1104 | 951 | |
| 1105 | 952 | register_rest_route( 'frm-admin/v1', '/install', $args ); |
| 1106 | 953 | |
| 1107 | 954 | $args = array( |
| 1108 | - 'methods' => 'GET', | |
| 1109 | - 'callback' => 'FrmAddonsController::install_addon_api', | |
| 955 | + 'methods' => 'GET', | |
| 956 | + 'callback' => 'FrmAddonsController::install_addon_api', | |
| 1110 | 957 | 'permission_callback' => 'FrmAddonsController::can_install_addon_api', |
| 1111 | 958 | ); |
| 1112 | 959 | |
| 1113 | 960 | register_rest_route( 'frm-admin/v1', '/install-addon', $args ); |
| @@ -1117,10 +964,8 @@ | ||
| 1117 | 964 | * Make sure the install is only being run when we tell it to. |
| 1118 | 965 | * We don't want to run manually by people calling the API. |
| 1119 | 966 | * |
| 1120 | 967 | * @since 4.06.02 |
| 1121 | - * | |
| 1122 | - * @return bool | |
| 1123 | 968 | */ |
| 1124 | 969 | public static function can_update_db() { |
| 1125 | 970 | return get_transient( 'frm_updating_api' ); |
| 1126 | 971 | } |
| @@ -1164,9 +1009,8 @@ | ||
| 1164 | 1009 | */ |
| 1165 | 1010 | private static function maybe_add_wp_site_health() { |
| 1166 | 1011 | if ( ! class_exists( 'WP_Site_Health' ) ) { |
| 1167 | 1012 | $wp_site_health_path = ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; |
| 1168 | - | |
| 1169 | 1013 | if ( file_exists( $wp_site_health_path ) ) { |
| 1170 | 1014 | require_once $wp_site_health_path; |
| 1171 | 1015 | } |
| 1172 | 1016 | } |
| @@ -1178,12 +1022,10 @@ | ||
| 1178 | 1022 | * @return true |
| 1179 | 1023 | */ |
| 1180 | 1024 | public static function api_install() { |
| 1181 | 1025 | delete_transient( 'frm_updating_api' ); |
| 1182 | - | |
| 1183 | 1026 | if ( self::needs_update() ) { |
| 1184 | 1027 | $running = get_option( 'frm_install_running' ); |
| 1185 | - | |
| 1186 | 1028 | if ( false === $running || $running < strtotime( '-5 minutes' ) ) { |
| 1187 | 1029 | update_option( 'frm_install_running', time(), 'no' ); |
| 1188 | 1030 | self::install(); |
| 1189 | 1031 | delete_option( 'frm_install_running' ); |
| @@ -1233,13 +1075,8 @@ | ||
| 1233 | 1075 | |
| 1234 | 1076 | wp_die(); |
| 1235 | 1077 | } |
| 1236 | 1078 | |
| 1237 | - /** | |
| 1238 | - * @param array $tables | |
| 1239 | - * | |
| 1240 | - * @return array | |
| 1241 | - */ | |
| 1242 | 1079 | public static function drop_tables( $tables ) { |
| 1243 | 1080 | global $wpdb; |
| 1244 | 1081 | $tables[] = $wpdb->prefix . 'frm_fields'; |
| 1245 | 1082 | $tables[] = $wpdb->prefix . 'frm_forms'; |
| @@ -1287,13 +1124,8 @@ | ||
| 1287 | 1124 | |
| 1288 | 1125 | FrmTransLiteAppController::maybe_schedule_cron(); |
| 1289 | 1126 | } |
| 1290 | 1127 | |
| 1291 | - /** | |
| 1292 | - * @param string $text | |
| 1293 | - * | |
| 1294 | - * @return string | |
| 1295 | - */ | |
| 1296 | 1128 | public static function set_footer_text( $text ) { |
| 1297 | 1129 | if ( FrmAppHelper::is_formidable_admin() ) { |
| 1298 | 1130 | $text = ''; |
| 1299 | 1131 | } |
| @@ -1308,10 +1140,8 @@ | ||
| 1308 | 1140 | * |
| 1309 | 1141 | * @return void |
| 1310 | 1142 | */ |
| 1311 | 1143 | public static function add_admin_footer_links() { |
| 1312 | - FrmFormsController::include_device_too_small_message(); | |
| 1313 | - | |
| 1314 | 1144 | if ( self::should_show_footer_links() ) { |
| 1315 | 1145 | include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php'; |
| 1316 | 1146 | } |
| 1317 | 1147 | } |
| @@ -1326,9 +1156,8 @@ | ||
| 1326 | 1156 | private static function should_show_footer_links() { |
| 1327 | 1157 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 1328 | 1158 | $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type; |
| 1329 | 1159 | $show_footer_links = $is_formidable_page; |
| 1330 | - | |
| 1331 | 1160 | if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) { |
| 1332 | 1161 | $show_footer_links = false; |
| 1333 | 1162 | } |
| 1334 | 1163 | |
| @@ -1337,9 +1166,8 @@ | ||
| 1337 | 1166 | * |
| 1338 | 1167 | * @since 6.7 |
| 1339 | 1168 | * |
| 1340 | 1169 | * @param bool $show_footer_links |
| 1341 | - * | |
| 1342 | 1170 | * @return bool |
| 1343 | 1171 | */ |
| 1344 | 1172 | return apply_filters( 'frm_show_footer_links', $show_footer_links ); |
| 1345 | 1173 | } |
| @@ -1353,10 +1181,8 @@ | ||
| 1353 | 1181 | * |
| 1354 | 1182 | * @return void |
| 1355 | 1183 | */ |
| 1356 | 1184 | public static function show_error_modal( $error_args ) { |
| 1357 | - add_filter( 'frm_show_footer_links', '__return_false' ); | |
| 1358 | - | |
| 1359 | 1185 | $defaults = array( |
| 1360 | 1186 | 'title' => '', |
| 1361 | 1187 | 'body' => '', |
| 1362 | 1188 | 'cancel_url' => '', |
| @@ -1366,9 +1192,8 @@ | ||
| 1366 | 1192 | 'icon' => 'frm_lock_simple', |
| 1367 | 1193 | ); |
| 1368 | 1194 | |
| 1369 | 1195 | $error_args = wp_parse_args( $error_args, $defaults ); |
| 1370 | - | |
| 1371 | 1196 | if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) { |
| 1372 | 1197 | $error_args['cancel_text'] = __( 'Cancel', 'formidable' ); |
| 1373 | 1198 | } |
| 1374 | 1199 | |
| @@ -1379,302 +1204,79 @@ | ||
| 1379 | 1204 | include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php'; |
| 1380 | 1205 | } |
| 1381 | 1206 | |
| 1382 | 1207 | /** |
| 1383 | - * Handles Floating Links' scripts and styles enqueueing. | |
| 1208 | + * @deprecated 3.0.04 | |
| 1384 | 1209 | * |
| 1385 | - * @since 6.4 | |
| 1210 | + * @codeCoverageIgnore | |
| 1386 | 1211 | * |
| 1387 | - * @param string $plugin_url URL of the plugin. | |
| 1388 | - * @param string $version Current version of the plugin. | |
| 1389 | - * | |
| 1390 | 1212 | * @return void |
| 1391 | 1213 | */ |
| 1392 | - private static function enqueue_floating_links( $plugin_url, $version ) { | |
| 1393 | - if ( ! $plugin_url || ! $version ) { | |
| 1394 | - // If any required parameters are missing, exit early. | |
| 1395 | - return; | |
| 1396 | - } | |
| 1397 | - | |
| 1398 | - // Enqueue the Floating Links styles. | |
| 1399 | - wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version ); | |
| 1400 | - | |
| 1401 | - // 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 ); | |
| 1403 | - | |
| 1404 | - // Enqueue the config script. | |
| 1405 | - wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true ); | |
| 1406 | - | |
| 1407 | - if ( function_exists( 'wp_set_script_translations' ) ) { | |
| 1408 | - wp_set_script_translations( 's11-floating-links-config', 's11-' ); | |
| 1409 | - } | |
| 1410 | - | |
| 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 | - $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/' ), | |
| 1423 | - ); | |
| 1424 | - wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data ); | |
| 1425 | - | |
| 1426 | - /** | |
| 1427 | - * Prompt Pro to load additional floating links scripts. | |
| 1428 | - * This is used to include images in the Inbox SlideIn when Pro is active. | |
| 1429 | - * | |
| 1430 | - * @since 6.8.4 | |
| 1431 | - */ | |
| 1432 | - do_action( 'frm_enqueue_floating_links' ); | |
| 1214 | + public static function activation_install() { | |
| 1215 | + FrmDeprecated::activation_install(); | |
| 1433 | 1216 | } |
| 1434 | 1217 | |
| 1435 | 1218 | /** |
| 1436 | - * Check if we are in our admin pages. | |
| 1437 | - * | |
| 1438 | - * @return bool | |
| 1219 | + * @deprecated 3.0 | |
| 1220 | + * @codeCoverageIgnore | |
| 1439 | 1221 | */ |
| 1440 | - private static function in_our_pages() { | |
| 1441 | - global $current_screen, $pagenow; | |
| 1442 | - | |
| 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; | |
| 1222 | + public static function page_route( $content ) { | |
| 1223 | + return FrmDeprecated::page_route( $content ); | |
| 1456 | 1224 | } |
| 1457 | 1225 | |
| 1458 | 1226 | /** |
| 1459 | - * Handles actions related to the current screen. | |
| 1227 | + * Include icons on page for Embed Form modal. | |
| 1460 | 1228 | * |
| 1461 | - * @since 6.19 | |
| 1229 | + * @since 5.2 | |
| 1462 | 1230 | * |
| 1463 | 1231 | * @return void |
| 1464 | 1232 | */ |
| 1465 | - public static function handle_current_screen() { | |
| 1466 | - if ( ! self::in_our_pages() ) { | |
| 1467 | - return; | |
| 1468 | - } | |
| 1469 | - | |
| 1470 | - self::filter_admin_notices(); | |
| 1471 | - self::remember_custom_sort(); | |
| 1233 | + public static function include_embed_form_icons() { | |
| 1234 | + _deprecated_function( __METHOD__, '5.3' ); | |
| 1472 | 1235 | } |
| 1473 | 1236 | |
| 1474 | 1237 | /** |
| 1475 | - * Hide all third-parties admin notices only in our admin pages. | |
| 1238 | + * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13. | |
| 1239 | + * @codeCoverageIgnore | |
| 1476 | 1240 | * |
| 1477 | - * @return void | |
| 1241 | + * @param array $atts | |
| 1242 | + * @return string | |
| 1478 | 1243 | */ |
| 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; | |
| 1498 | - } | |
| 1499 | - unset( $wp_filter[ $action ]->callbacks[ $priority ][ $callback_name ] ); | |
| 1500 | - } | |
| 1501 | - } | |
| 1502 | - } | |
| 1244 | + public static function get_form_shortcode( $atts ) { | |
| 1245 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' ); | |
| 1246 | + return FrmFormsController::get_form_shortcode( $atts ); | |
| 1503 | 1247 | } |
| 1504 | 1248 | |
| 1505 | 1249 | /** |
| 1506 | - * Remembers and applies user-specific sorting preferences. | |
| 1250 | + * Handles Floating Links' scripts and styles enqueueing. | |
| 1507 | 1251 | * |
| 1252 | + * @since 6.4 | |
| 1253 | + * | |
| 1254 | + * @param string $plugin_url URL of the plugin. | |
| 1255 | + * @param string $version Current version of the plugin. | |
| 1508 | 1256 | * @return void |
| 1509 | 1257 | */ |
| 1510 | - private static function remember_custom_sort() { | |
| 1511 | - $meta_key = self::get_sort_pref_user_meta_key(); | |
| 1512 | - | |
| 1513 | - if ( false === $meta_key ) { | |
| 1258 | + private static function enqueue_floating_links( $plugin_url, $version ) { | |
| 1259 | + if ( ! $plugin_url || ! $version ) { | |
| 1260 | + // If any required parameters are missing, exit early. | |
| 1514 | 1261 | return; |
| 1515 | 1262 | } |
| 1516 | 1263 | |
| 1517 | - $is_form_list = FrmAppHelper::is_admin_list_page(); | |
| 1518 | - $is_entry_list = FrmAppHelper::is_admin_list_page( 'formidable-entries' ); | |
| 1264 | + // Enqueue the Floating Links styles. | |
| 1265 | + wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version ); | |
| 1519 | 1266 | |
| 1520 | - if ( ! $is_form_list && ! $is_entry_list ) { | |
| 1521 | - return; | |
| 1522 | - } | |
| 1267 | + // Enqueue the Floating Links script. | |
| 1268 | + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true ); | |
| 1523 | 1269 | |
| 1524 | - $orderby = FrmAppHelper::get_param( 'orderby' ); | |
| 1270 | + // Enqueue the config script. | |
| 1271 | + wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true ); | |
| 1525 | 1272 | |
| 1526 | - if ( ! $orderby ) { | |
| 1527 | - return; | |
| 1273 | + if ( function_exists( 'wp_set_script_translations' ) ) { | |
| 1274 | + wp_set_script_translations( 's11-floating-links-config', 's11-' ); | |
| 1528 | 1275 | } |
| 1529 | 1276 | |
| 1530 | - $user_id = get_current_user_id(); | |
| 1531 | - $order = FrmAppHelper::get_param( 'order' ); | |
| 1532 | - $new_sort = array( | |
| 1533 | - 'orderby' => $orderby, | |
| 1534 | - 'order' => $order, | |
| 1277 | + $floating_links_data = array( | |
| 1278 | + 'proIsInstalled' => FrmAppHelper::pro_is_installed(), | |
| 1535 | 1279 | ); |
| 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 | - } | |
| 1558 | - | |
| 1559 | - /** | |
| 1560 | - * Retrieve and apply any saved sorting preferences for the current screen. | |
| 1561 | - * | |
| 1562 | - * @since 6.19 | |
| 1563 | - * | |
| 1564 | - * @param string &$orderby Reference to the current 'orderby' parameter. | |
| 1565 | - * @param string &$order Reference to the current 'order' parameter. | |
| 1566 | - * | |
| 1567 | - * @return void | |
| 1568 | - */ | |
| 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 | - } | |
| 1591 | - } | |
| 1592 | - | |
| 1593 | - /** | |
| 1594 | - * Get a simple user meta key that only includes the screen ID. | |
| 1595 | - * | |
| 1596 | - * @since 6.25.1 | |
| 1597 | - * | |
| 1598 | - * @return false|string | |
| 1599 | - */ | |
| 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; | |
| 1607 | - } | |
| 1608 | - | |
| 1609 | - /** | |
| 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 | |
| 1615 | - */ | |
| 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(); | |
| 1280 | + wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data ); | |
| 1679 | 1281 | } |
| 1680 | 1282 | } |