| @@ -61,14 +61,20 @@ | ||
| 61 | 61 | $classes .= ' frm-admin-page-' . $page; |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | + if ( self::is_grey_page() ) { | |
| 66 | + $classes .= ' frm-grey-body '; | |
| 67 | + } | |
| 68 | + | |
| 65 | 69 | if ( FrmAppHelper::is_full_screen() ) { |
| 66 | 70 | $full_screen_on = self::get_full_screen_setting(); |
| 67 | - $add_class = ''; | |
| 71 | + $add_class = ''; | |
| 68 | 72 | if ( $full_screen_on ) { |
| 69 | 73 | $add_class = ' frm-full-screen is-fullscreen-mode'; |
| 70 | - wp_enqueue_style( 'wp-edit-post' ); // Load the CSS for .is-fullscreen-mode. | |
| 74 | + | |
| 75 | + // Load the CSS for .is-fullscreen-mode. | |
| 76 | + wp_enqueue_style( 'wp-edit-post' ); | |
| 71 | 77 | } |
| 72 | 78 | $classes .= apply_filters( 'frm_admin_full_screen_class', $add_class ); |
| 73 | 79 | } |
| 74 | 80 | |
| @@ -75,8 +81,12 @@ | ||
| 75 | 81 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 76 | 82 | $classes .= ' frm-lite '; |
| 77 | 83 | } |
| 78 | 84 | |
| 85 | + if ( get_user_setting( 'unfold' ) && 'f' !== get_user_setting( 'mfold' ) ) { | |
| 86 | + $classes .= ' frm-unfold '; | |
| 87 | + } | |
| 88 | + | |
| 79 | 89 | return $classes; |
| 80 | 90 | } |
| 81 | 91 | |
| 82 | 92 | /** |
| @@ -124,9 +134,8 @@ | ||
| 124 | 134 | 'formidable', |
| 125 | 135 | 'formidable-entries', |
| 126 | 136 | 'formidable-views', |
| 127 | 137 | 'formidable-views-editor', |
| 128 | - 'formidable-pro-upgrade', | |
| 129 | 138 | 'formidable-addons', |
| 130 | 139 | 'formidable-import', |
| 131 | 140 | 'formidable-settings', |
| 132 | 141 | 'formidable-styles', |
| @@ -131,26 +140,25 @@ | ||
| 131 | 140 | 'formidable-settings', |
| 132 | 141 | 'formidable-styles', |
| 133 | 142 | 'formidable-styles2', |
| 134 | 143 | 'formidable-inbox', |
| 135 | - 'formidable-welcome', | |
| 136 | - 'formidable-applications', | |
| 144 | + FrmFormTemplatesController::PAGE_SLUG, | |
| 145 | + FrmOnboardingWizardController::PAGE_SLUG, | |
| 137 | 146 | ); |
| 138 | 147 | |
| 139 | 148 | if ( ! class_exists( 'FrmTransHooksController', false ) && ! FrmTransLiteAppHelper::should_fallback_to_paypal() ) { |
| 140 | 149 | // Only consider the payments page as a "white page" when the Payments submodule is off. |
| 141 | 150 | // Otherwise this causes a lot of styling issues when the Stripe add-on (or Authorize.Net) is active. |
| 142 | - $white_pages[] = 'formidable-payments'; | |
| 151 | + | |
| 152 | + // Add an extra check to avoid white page styling on the PayPal "edit" action. | |
| 153 | + // We fallback to the PayPal add on for the "edit" action since Stripe Lite does not have an edit view. | |
| 154 | + if ( ! in_array( FrmAppHelper::simple_get( 'action' ), array( 'edit', 'new' ), true ) || ! is_callable( 'FrmPaymentsController::route' ) ) { | |
| 155 | + $white_pages[] = 'formidable-payments'; | |
| 156 | + } | |
| 143 | 157 | } |
| 144 | 158 | |
| 145 | - $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 146 | - $is_white_page = in_array( $get_page, $white_pages, true ); | |
| 159 | + $is_white_page = self::is_page_in_list( $white_pages ) || self::is_grey_page() || FrmAppHelper::is_view_builder_page(); | |
| 147 | 160 | |
| 148 | - if ( ! $is_white_page ) { | |
| 149 | - $screen = get_current_screen(); | |
| 150 | - $is_white_page = ( $screen && strpos( $screen->id, 'frm_display' ) !== false ); | |
| 151 | - } | |
| 152 | - | |
| 153 | 161 | /** |
| 154 | 162 | * Allow another add on to style a page as a Formidable "white page", which adds a white background color. |
| 155 | 163 | * |
| 156 | 164 | * @since 5.3 |
| @@ -162,8 +170,45 @@ | ||
| 162 | 170 | return $is_white_page; |
| 163 | 171 | } |
| 164 | 172 | |
| 165 | 173 | /** |
| 174 | + * Add a grey bg instead of white. | |
| 175 | + * | |
| 176 | + * @since 6.8 | |
| 177 | + * | |
| 178 | + * @return bool | |
| 179 | + */ | |
| 180 | + private static function is_grey_page() { | |
| 181 | + $grey_pages = array( | |
| 182 | + 'formidable-applications', | |
| 183 | + 'formidable-dashboard', | |
| 184 | + ); | |
| 185 | + | |
| 186 | + $is_grey_page = self::is_page_in_list( $grey_pages ); | |
| 187 | + | |
| 188 | + /** | |
| 189 | + * Filter to change FF wrapper background to grey. | |
| 190 | + * | |
| 191 | + * @since 6.8 | |
| 192 | + * | |
| 193 | + * @param bool $is_grey_page | |
| 194 | + * @return bool | |
| 195 | + */ | |
| 196 | + return apply_filters( 'frm_is_grey_page', $is_grey_page ); | |
| 197 | + } | |
| 198 | + | |
| 199 | + /** | |
| 200 | + * @since 6.8 | |
| 201 | + * | |
| 202 | + * @param array $pages A list of page names to check. | |
| 203 | + * @return bool | |
| 204 | + */ | |
| 205 | + private static function is_page_in_list( $pages ) { | |
| 206 | + $get_page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 207 | + return in_array( $get_page, $pages, true ); | |
| 208 | + } | |
| 209 | + | |
| 210 | + /** | |
| 166 | 211 | * @return void |
| 167 | 212 | */ |
| 168 | 213 | public static function load_wp_admin_style() { |
| 169 | 214 | FrmAppHelper::load_font_style(); |
| @@ -169,10 +214,11 @@ | ||
| 169 | 214 | FrmAppHelper::load_font_style(); |
| 170 | 215 | } |
| 171 | 216 | |
| 172 | 217 | /** |
| 173 | - * @param bool $show_nav | |
| 174 | - * @param string $title | |
| 218 | + * @param int|object $form | |
| 219 | + * @param bool $show_nav | |
| 220 | + * @param string $title | |
| 175 | 221 | * |
| 176 | 222 | * @psalm-param 'hide'|'show' $title |
| 177 | 223 | * |
| 178 | 224 | * @return void |
| @@ -191,9 +237,9 @@ | ||
| 191 | 237 | $id = $form->id; |
| 192 | 238 | $current_page = self::get_current_page(); |
| 193 | 239 | $nav_items = self::get_form_nav_items( $form ); |
| 194 | 240 | |
| 195 | - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); | |
| 241 | + include FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php'; | |
| 196 | 242 | } |
| 197 | 243 | |
| 198 | 244 | /** |
| 199 | 245 | * @return string |
| @@ -247,18 +293,18 @@ | ||
| 247 | 293 | 'permission' => 'frm_view_entries', |
| 248 | 294 | ), |
| 249 | 295 | ); |
| 250 | 296 | |
| 251 | - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed(); | |
| 297 | + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed(); | |
| 252 | 298 | |
| 253 | 299 | if ( ! $views_installed ) { |
| 254 | 300 | $nav_items[] = array( |
| 255 | - 'link' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $id ) ), | |
| 256 | - 'label' => __( 'Views', 'formidable' ), | |
| 257 | - 'current' => array(), | |
| 258 | - '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', | |
| 259 | 305 | 'permission' => 'frm_view_entries', |
| 260 | - 'atts' => array( | |
| 306 | + 'atts' => array( | |
| 261 | 307 | 'class' => 'frm_noallow', |
| 262 | 308 | ), |
| 263 | 309 | ); |
| 264 | 310 | } |
| @@ -265,14 +311,14 @@ | ||
| 265 | 311 | |
| 266 | 312 | // Let people know reports and views exist. |
| 267 | 313 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 268 | 314 | $nav_items[] = array( |
| 269 | - 'link' => admin_url( 'admin.php?page=formidable&frm_action=lite-reports&form=' . absint( $id ) ), | |
| 270 | - 'label' => __( 'Reports', 'formidable' ), | |
| 271 | - 'current' => array( 'reports' ), | |
| 272 | - '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', | |
| 273 | 319 | 'permission' => 'frm_view_entries', |
| 274 | - 'atts' => array( | |
| 320 | + 'atts' => array( | |
| 275 | 321 | 'class' => 'frm_noallow', |
| 276 | 322 | ), |
| 277 | 323 | ); |
| 278 | 324 | } |
| @@ -306,9 +352,9 @@ | ||
| 306 | 352 | * @return void |
| 307 | 353 | */ |
| 308 | 354 | public static function pro_get_started_headline() { |
| 309 | 355 | self::review_request(); |
| 310 | - FrmAppHelper::min_pro_version_notice( '4.0' ); | |
| 356 | + FrmAppHelper::min_pro_version_notice( '6.0' ); | |
| 311 | 357 | } |
| 312 | 358 | |
| 313 | 359 | /** |
| 314 | 360 | * Add admin notices as needed for reviews |
| @@ -375,66 +421,11 @@ | ||
| 375 | 421 | $shared_path = $plugin_path . '/classes/views/shared/'; |
| 376 | 422 | |
| 377 | 423 | include $shared_path . 'upgrade_overlay.php'; |
| 378 | 424 | include $shared_path . 'confirm-overlay.php'; |
| 379 | - | |
| 380 | - if ( FrmAppHelper::is_admin_page( 'formidable-welcome' ) || FrmAppHelper::on_form_listing_page() ) { | |
| 381 | - self::new_form_overlay_html(); | |
| 382 | - } | |
| 383 | 425 | } |
| 384 | 426 | |
| 385 | 427 | /** |
| 386 | - * @return void | |
| 387 | - */ | |
| 388 | - private static function new_form_overlay_html() { | |
| 389 | - FrmFormsController::before_list_templates(); | |
| 390 | - | |
| 391 | - $plugin_path = FrmAppHelper::plugin_path(); | |
| 392 | - $path = $plugin_path . '/classes/views/frm-forms/'; | |
| 393 | - $expired = FrmFormsController::expired(); | |
| 394 | - $expiring = FrmAddonsController::is_license_expiring(); | |
| 395 | - $user = wp_get_current_user(); // $user used in leave-email.php to determine a default value for field | |
| 396 | - $view_path = $path . 'new-form-overlay/'; | |
| 397 | - $modal_class = ''; | |
| 398 | - $upgrade_link = FrmAppHelper::admin_upgrade_link( | |
| 399 | - array( | |
| 400 | - 'medium' => 'new-template', | |
| 401 | - 'content' => 'upgrade', | |
| 402 | - ) | |
| 403 | - ); | |
| 404 | - $renew_link = FrmAppHelper::admin_upgrade_link( | |
| 405 | - array( | |
| 406 | - 'medium' => 'new-template', | |
| 407 | - 'content' => 'renew', | |
| 408 | - ) | |
| 409 | - ); | |
| 410 | - $blocks_to_render = array(); | |
| 411 | - | |
| 412 | - if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 413 | - // avoid rendering the email and code blocks for users who have upgraded or have a free license already | |
| 414 | - $api = new FrmFormTemplateApi(); | |
| 415 | - if ( ! $api->has_free_access() ) { | |
| 416 | - array_push( $blocks_to_render, 'email', 'code' ); | |
| 417 | - } | |
| 418 | - } | |
| 419 | - | |
| 420 | - // avoid rendering the upgrade block for users with elite | |
| 421 | - if ( 'elite' !== FrmAddonsController::license_type() ) { | |
| 422 | - $blocks_to_render[] = 'upgrade'; | |
| 423 | - } | |
| 424 | - | |
| 425 | - // avoid rendering the renew block for users who are not currently expired | |
| 426 | - if ( $expired ) { | |
| 427 | - $blocks_to_render[] = 'renew'; | |
| 428 | - $modal_class = 'frm-expired'; | |
| 429 | - } elseif ( $expiring ) { | |
| 430 | - $modal_class = 'frm-expiring'; | |
| 431 | - } | |
| 432 | - | |
| 433 | - include $path . 'new-form-overlay.php'; | |
| 434 | - } | |
| 435 | - | |
| 436 | - /** | |
| 437 | 428 | * Create a basic form with an email field. |
| 438 | 429 | * |
| 439 | 430 | * @param string $form_key |
| 440 | 431 | * @param string $title |
| @@ -440,13 +431,16 @@ | ||
| 440 | 431 | * @param string $title |
| 441 | 432 | * @param string $description |
| 442 | 433 | * @return void |
| 443 | 434 | */ |
| 444 | - public static function api_email_form( $form_key, $title, $description ) { | |
| 445 | - $url = 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css'; | |
| 446 | - $view_path = FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new-form-overlay/'; | |
| 447 | - $user = wp_get_current_user(); | |
| 448 | - require $view_path . 'leave-email.php'; | |
| 435 | + public static function api_email_form( $form_key, $title = '', $description = '' ) { | |
| 436 | + $user = wp_get_current_user(); | |
| 437 | + $args = array( | |
| 438 | + 'api_url' => 'https://sandbox.formidableforms.com/api/wp-json/frm/v2/forms/' . $form_key . '?return=html&exclude_script=jquery&exclude_style=formidable-css', | |
| 439 | + 'title' => $title, | |
| 440 | + 'description' => $description, | |
| 441 | + ); | |
| 442 | + require FrmAppHelper::plugin_path() . '/classes/views/form-templates/modals/leave-email-modal.php'; | |
| 449 | 443 | } |
| 450 | 444 | |
| 451 | 445 | /** |
| 452 | 446 | * @return void |
| @@ -470,9 +464,8 @@ | ||
| 470 | 464 | */ |
| 471 | 465 | public static function remove_upsells() { |
| 472 | 466 | remove_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
| 473 | 467 | remove_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' ); |
| 474 | - remove_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' ); | |
| 475 | 468 | remove_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' ); |
| 476 | 469 | } |
| 477 | 470 | |
| 478 | 471 | /** |
| @@ -494,9 +487,9 @@ | ||
| 494 | 487 | /** |
| 495 | 488 | * Check if the database is outdated |
| 496 | 489 | * |
| 497 | 490 | * @since 2.0.1 |
| 498 | - * @return boolean | |
| 491 | + * @return bool | |
| 499 | 492 | */ |
| 500 | 493 | public static function needs_update() { |
| 501 | 494 | $needs_upgrade = self::compare_for_update( |
| 502 | 495 | array( |
| @@ -543,8 +536,12 @@ | ||
| 543 | 536 | * |
| 544 | 537 | * @return void |
| 545 | 538 | */ |
| 546 | 539 | public static function admin_init() { |
| 540 | + if ( FrmAppHelper::get_param( 'delete_all' ) && FrmAppHelper::is_admin_page( 'formidable' ) && 'trash' === FrmAppHelper::get_param( 'form_type' ) ) { | |
| 541 | + FrmFormsController::delete_all(); | |
| 542 | + } | |
| 543 | + | |
| 547 | 544 | if ( FrmAppHelper::is_admin_page( 'formidable' ) && 'duplicate' === FrmAppHelper::get_param( 'frm_action' ) ) { |
| 548 | 545 | FrmFormsController::duplicate(); |
| 549 | 546 | } |
| 550 | 547 | |
| @@ -552,10 +549,23 @@ | ||
| 552 | 549 | // Hook in earlier than FrmStylesController::route so we can redirect before the headers have been sent. |
| 553 | 550 | FrmStylesController::save_style(); |
| 554 | 551 | } |
| 555 | 552 | |
| 556 | - new FrmPersonalData(); // register personal data hooks | |
| 553 | + if ( 'formidable-pro-upgrade' === FrmAppHelper::get_param( 'page' ) && ! FrmAppHelper::pro_is_installed() && current_user_can( 'frm_view_forms' ) ) { | |
| 554 | + wp_redirect( | |
| 555 | + FrmAppHelper::admin_upgrade_link( | |
| 556 | + array( | |
| 557 | + 'medium' => 'upgrade', | |
| 558 | + 'content' => 'submenu-upgrade', | |
| 559 | + ) | |
| 560 | + ) | |
| 561 | + ); | |
| 562 | + die(); | |
| 563 | + } | |
| 557 | 564 | |
| 565 | + // Register personal data hooks. | |
| 566 | + new FrmPersonalData(); | |
| 567 | + | |
| 558 | 568 | if ( ! FrmAppHelper::doing_ajax() && self::needs_update() ) { |
| 559 | 569 | self::network_upgrade_site(); |
| 560 | 570 | } |
| 561 | 571 | |
| @@ -563,82 +573,51 @@ | ||
| 563 | 573 | // don't continue during ajax calls |
| 564 | 574 | self::admin_js(); |
| 565 | 575 | } |
| 566 | 576 | |
| 577 | + self::trigger_page_load_hooks(); | |
| 578 | + | |
| 567 | 579 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 568 | - $action = FrmAppHelper::get_param( 'frm_action' ); | |
| 580 | + // Redirect to the "Form Templates" page if the 'frm_action' parameter matches specific actions. | |
| 581 | + // This provides backward compatibility for old addons that use legacy modal templates. | |
| 582 | + $action = FrmAppHelper::get_param( 'frm_action' ); | |
| 583 | + $trigger_name_modal = FrmAppHelper::get_param( 'triggerNewFormModal' ); | |
| 584 | + if ( $trigger_name_modal || in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { | |
| 585 | + $application_id = FrmAppHelper::simple_get( 'applicationId', 'absint' ); | |
| 586 | + $url_param = $application_id ? '&applicationId=' . $application_id : ''; | |
| 569 | 587 | |
| 570 | - if ( in_array( $action, array( 'add_new', 'list_templates' ), true ) ) { | |
| 571 | - wp_safe_redirect( admin_url( 'admin.php?page=formidable&triggerNewFormModal=1' ) ); | |
| 588 | + wp_safe_redirect( admin_url( 'admin.php?page=' . FrmFormTemplatesController::PAGE_SLUG . $url_param ) ); | |
| 572 | 589 | exit; |
| 573 | 590 | } |
| 574 | 591 | |
| 575 | 592 | FrmInbox::maybe_disable_screen_options(); |
| 576 | 593 | } |
| 577 | - | |
| 578 | - self::maybe_add_ip_warning(); | |
| 579 | 594 | } |
| 580 | 595 | |
| 581 | 596 | /** |
| 582 | - * Show a warning for the IP address setting if it hasn't been set. | |
| 597 | + * Get the current page and check for a possible function to trigger. | |
| 598 | + * If a class name matches the page name, and the class has a load_page() method, trigger it. | |
| 583 | 599 | * |
| 584 | - * @since 6.1 | |
| 600 | + * @since 6.8 | |
| 585 | 601 | * |
| 586 | 602 | * @return void |
| 587 | 603 | */ |
| 588 | - private static function maybe_add_ip_warning() { | |
| 589 | - $settings = FrmAppHelper::get_settings(); | |
| 590 | - if ( false !== $settings->custom_header_ip ) { | |
| 591 | - // The setting has been changed from the false default (to either 1 or 0), so stop showing the message. | |
| 604 | + private static function trigger_page_load_hooks() { | |
| 605 | + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 606 | + if ( strpos( $page, 'formidable-' ) !== 0 ) { | |
| 607 | + // Only trigger hooks on Formidable pages. | |
| 592 | 608 | return; |
| 593 | 609 | } |
| 594 | 610 | |
| 595 | - if ( ! self::is_behind_proxy() ) { | |
| 596 | - // This message is only applicable when using a reverse proxy. | |
| 597 | - return; | |
| 611 | + $page = str_replace( array( 'formidable-', '-' ), array( '', ' ' ), $page ); | |
| 612 | + $page = str_replace( ' ', '', ucwords( $page ) ); | |
| 613 | + $class = 'Frm' . $page . 'Controller'; | |
| 614 | + if ( class_exists( $class ) && method_exists( $class, 'load_page' ) ) { | |
| 615 | + call_user_func( array( $class, 'load_page' ) ); | |
| 598 | 616 | } |
| 599 | - | |
| 600 | - if ( FrmAppHelper::get_post_param( 'frm_action', '', 'sanitize_text_field' ) ) { | |
| 601 | - // Avoid the message on a POST action. We don't want to show the message if we're saving global settings. | |
| 602 | - return; | |
| 603 | - } | |
| 604 | - | |
| 605 | - $global_settings_link = admin_url( 'admin.php?page=formidable-settings' ) . '#frm_custom_header_ip'; | |
| 606 | - $message = sprintf( | |
| 607 | - // Translators: 1: Global Settings Link | |
| 608 | - __( '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' ), | |
| 609 | - '<a href="' . esc_url( $global_settings_link ) . '">Global Settings</a>' | |
| 610 | - ); | |
| 611 | - $option_name = 'frm_dismiss_ip_address_notice'; | |
| 612 | - FrmAppHelper::add_dismissable_warning_message( $message, $option_name ); | |
| 613 | 617 | } |
| 614 | 618 | |
| 615 | 619 | /** |
| 616 | - * Check if any reverse proxy headers are set. | |
| 617 | - * | |
| 618 | - * @since 6.1 | |
| 619 | - * | |
| 620 | - * @return bool | |
| 621 | - */ | |
| 622 | - private static function is_behind_proxy() { | |
| 623 | - $custom_headers = FrmAppHelper::get_custom_header_keys_for_ip(); | |
| 624 | - foreach ( $custom_headers as $header ) { | |
| 625 | - if ( 'REMOTE_ADDR' === $header ) { | |
| 626 | - // We want to check every key but REMOTE_ADDR. REMOTE_ATTR is not unique to reverse proxy servers. | |
| 627 | - continue; | |
| 628 | - } | |
| 629 | - | |
| 630 | - $ip = trim( FrmAppHelper::get_server_value( $header ) ); | |
| 631 | - // Return true for anything that isn't empty but ignoring values like ::1. | |
| 632 | - if ( $ip && 0 !== strpos( $ip, '::' ) ) { | |
| 633 | - return true; | |
| 634 | - } | |
| 635 | - } | |
| 636 | - | |
| 637 | - return false; | |
| 638 | - } | |
| 639 | - | |
| 640 | - /** | |
| 641 | 620 | * @return void |
| 642 | 621 | */ |
| 643 | 622 | public static function admin_js() { |
| 644 | 623 | $plugin_url = FrmAppHelper::plugin_url(); |
| @@ -645,8 +624,11 @@ | ||
| 645 | 624 | $version = FrmAppHelper::plugin_version(); |
| 646 | 625 | |
| 647 | 626 | FrmAppHelper::load_admin_wide_js(); |
| 648 | 627 | |
| 628 | + // Register component assets early to ensure they can be enqueued later in controllers. | |
| 629 | + wp_register_style( 'formidable-animations', $plugin_url . '/css/admin/animations.css', array(), $version ); | |
| 630 | + | |
| 649 | 631 | if ( class_exists( 'FrmOverlayController' ) ) { |
| 650 | 632 | // This should always exist. |
| 651 | 633 | // But it may not have loaded properly when updating the plugin. |
| 652 | 634 | FrmOverlayController::register_assets(); |
| @@ -663,26 +645,12 @@ | ||
| 663 | 645 | self::register_popper1(); |
| 664 | 646 | wp_register_script( 'bootstrap_tooltip', $plugin_url . '/js/bootstrap.min.js', array( 'jquery', 'popper' ), '4.6.1', true ); |
| 665 | 647 | wp_register_script( 'formidable_settings', $plugin_url . '/js/admin/settings.js', array(), $version, true ); |
| 666 | 648 | |
| 667 | - $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 668 | - | |
| 669 | - // Enqueue Floating Links. | |
| 670 | - $is_valid_page = | |
| 671 | - FrmAppHelper::is_formidable_admin() && | |
| 672 | - ! FrmAppHelper::is_style_editor_page() && | |
| 673 | - ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) && | |
| 674 | - ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); | |
| 675 | - if ( $is_valid_page && FrmAppHelper::is_formidable_branding() ) { | |
| 649 | + if ( self::should_show_floating_links() ) { | |
| 676 | 650 | self::enqueue_floating_links( $plugin_url, $version ); |
| 677 | 651 | } |
| 678 | - unset( $is_valid_page ); | |
| 679 | 652 | |
| 680 | - if ( 'formidable-applications' === $page ) { | |
| 681 | - FrmApplicationsController::load_assets(); | |
| 682 | - return; | |
| 683 | - } | |
| 684 | - | |
| 685 | 653 | $dependencies = array( |
| 686 | 654 | 'formidable_admin_global', |
| 687 | 655 | 'jquery', |
| 688 | 656 | 'jquery-ui-core', |
| @@ -690,9 +658,10 @@ | ||
| 690 | 658 | 'jquery-ui-sortable', |
| 691 | 659 | 'bootstrap_tooltip', |
| 692 | 660 | 'bootstrap-multiselect', |
| 693 | 661 | 'wp-i18n', |
| 694 | - 'wp-hooks', // Required in WP versions older than 5.7 | |
| 662 | + // Required in WP versions older than 5.7 | |
| 663 | + 'wp-hooks', | |
| 695 | 664 | 'formidable_dom', |
| 696 | 665 | 'formidable_embed', |
| 697 | 666 | ); |
| 698 | 667 | |
| @@ -720,8 +689,9 @@ | ||
| 720 | 689 | '#frm_builder_page li[data-ftype="gateway"] { display: none; }' |
| 721 | 690 | ); |
| 722 | 691 | } |
| 723 | 692 | |
| 693 | + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 724 | 694 | $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); |
| 725 | 695 | |
| 726 | 696 | global $pagenow; |
| 727 | 697 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) { |
| @@ -729,15 +699,18 @@ | ||
| 729 | 699 | wp_enqueue_script( 'admin-widgets' ); |
| 730 | 700 | wp_enqueue_style( 'widgets' ); |
| 731 | 701 | self::maybe_deregister_popper2(); |
| 732 | 702 | wp_enqueue_script( 'formidable_admin' ); |
| 703 | + wp_set_script_translations( 'formidable_admin', 'formidable' ); | |
| 733 | 704 | wp_enqueue_script( 'formidable_embed' ); |
| 705 | + wp_set_script_translations( 'formidable_embed', 'formidable' ); | |
| 734 | 706 | FrmAppHelper::localize_script( 'admin' ); |
| 735 | 707 | |
| 708 | + wp_enqueue_style( 'formidable-animations' ); | |
| 736 | 709 | wp_enqueue_style( 'formidable-admin' ); |
| 737 | 710 | if ( 'formidable-styles' !== $page && 'formidable-styles2' !== $page ) { |
| 738 | 711 | wp_enqueue_style( 'formidable-grids' ); |
| 739 | - wp_enqueue_style( 'formidable-dropzone' ); | |
| 712 | + self::maybe_enqueue_dropzone_css( $page ); | |
| 740 | 713 | } else { |
| 741 | 714 | wp_enqueue_style( 'formidable-grids' ); |
| 742 | 715 | } |
| 743 | 716 | |
| @@ -743,8 +716,12 @@ | ||
| 743 | 716 | |
| 744 | 717 | if ( 'formidable-entries' === $page ) { |
| 745 | 718 | // Load front end js for entries. |
| 746 | 719 | wp_enqueue_script( 'formidable' ); |
| 720 | + | |
| 721 | + // Registers and enqueues the entries page scripts. | |
| 722 | + wp_register_script( 'formidable_entries', $plugin_url . '/js/admin/entries.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true ); | |
| 723 | + wp_enqueue_script( 'formidable_entries' ); | |
| 747 | 724 | } |
| 748 | 725 | |
| 749 | 726 | do_action( 'frm_enqueue_builder_scripts' ); |
| 750 | 727 | self::include_upgrade_overlay(); |
| @@ -764,13 +741,55 @@ | ||
| 764 | 741 | |
| 765 | 742 | if ( $post_type === 'frm_display' ) { |
| 766 | 743 | self::enqueue_legacy_views_assets(); |
| 767 | 744 | } |
| 745 | + }//end if | |
| 746 | + | |
| 747 | + if ( 'formidable-addons' === $page ) { | |
| 748 | + wp_register_script( 'formidable_addons', $plugin_url . '/js/admin/addons.js', array( 'formidable_admin', 'wp-dom-ready' ), $version, true ); | |
| 749 | + wp_enqueue_script( 'formidable_addons' ); | |
| 768 | 750 | } |
| 751 | + } | |
| 769 | 752 | |
| 753 | + /** | |
| 754 | + * Avoid loading dropzone CSS on the form list page. It isn't required there. | |
| 755 | + * | |
| 756 | + * @since 6.11 | |
| 757 | + * | |
| 758 | + * @param string $page | |
| 759 | + * @return void | |
| 760 | + */ | |
| 761 | + private static function maybe_enqueue_dropzone_css( $page ) { | |
| 762 | + if ( ! FrmAppHelper::pro_is_installed() ) { | |
| 763 | + return; | |
| 764 | + } | |
| 765 | + | |
| 766 | + $should_avoid_loading_dropzone = 'formidable' === $page && ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); | |
| 767 | + if ( ! $should_avoid_loading_dropzone ) { | |
| 768 | + wp_enqueue_style( 'formidable-dropzone' ); | |
| 769 | + } | |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | /** |
| 773 | + * The floating links are not shown on every page. | |
| 774 | + * They are also not shown if white labeling is being used. | |
| 775 | + * | |
| 776 | + * @since 6.8.4 | |
| 777 | + * | |
| 778 | + * @return bool | |
| 779 | + */ | |
| 780 | + private static function should_show_floating_links() { | |
| 781 | + if ( ! FrmAppHelper::is_formidable_branding() ) { | |
| 782 | + return false; | |
| 783 | + } | |
| 784 | + | |
| 785 | + return FrmAppHelper::is_formidable_admin() && | |
| 786 | + ! FrmAppHelper::is_style_editor_page() && | |
| 787 | + ! FrmAppHelper::is_admin_page( 'formidable-views-editor' ) && | |
| 788 | + ! FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); | |
| 789 | + } | |
| 790 | + | |
| 791 | + /** | |
| 773 | 792 | * @since 6.3.2 |
| 774 | 793 | * |
| 775 | 794 | * @return void |
| 776 | 795 | */ |
| @@ -776,8 +795,9 @@ | ||
| 776 | 795 | */ |
| 777 | 796 | public static function admin_enqueue_scripts() { |
| 778 | 797 | self::load_wp_admin_style(); |
| 779 | 798 | self::maybe_force_formidable_block_on_gutenberg_page(); |
| 799 | + FrmUsageController::load_scripts(); | |
| 780 | 800 | } |
| 781 | 801 | |
| 782 | 802 | /** |
| 783 | 803 | * Enqueue required assets for the Legacy Views editor (Views v4.x). |
| @@ -846,12 +866,45 @@ | ||
| 846 | 866 | * |
| 847 | 867 | * @return void |
| 848 | 868 | */ |
| 849 | 869 | private static function register_popper1() { |
| 870 | + if ( ! self::should_register_popper() ) { | |
| 871 | + return; | |
| 872 | + } | |
| 850 | 873 | wp_register_script( 'popper', FrmAppHelper::plugin_url() . '/js/popper.min.js', array( 'jquery' ), '1.16.0', true ); |
| 851 | 874 | } |
| 852 | 875 | |
| 853 | 876 | /** |
| 877 | + * Only register popper on Formidable pages. | |
| 878 | + * This helps to avoid popper conflicts on other plugin pages, including the WP Bakery page editor. | |
| 879 | + * | |
| 880 | + * @since 6.11.1 | |
| 881 | + * | |
| 882 | + * @return bool | |
| 883 | + */ | |
| 884 | + private static function should_register_popper() { | |
| 885 | + global $pagenow; | |
| 886 | + | |
| 887 | + $post_id = FrmAppHelper::simple_get( 'post', 'absint' ); | |
| 888 | + if ( 'post.php' === $pagenow && $post_id && 'frm_display' === get_post_type( $post_id ) ) { | |
| 889 | + return true; | |
| 890 | + } | |
| 891 | + | |
| 892 | + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); | |
| 893 | + $is_views_post_type = 'frm_display' === $post_type; | |
| 894 | + if ( in_array( $pagenow, array( 'post-new.php', 'edit.php' ), true ) && $is_views_post_type ) { | |
| 895 | + return true; | |
| 896 | + } | |
| 897 | + | |
| 898 | + $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); | |
| 899 | + if ( strpos( $page, 'formidable' ) === 0 ) { | |
| 900 | + return true; | |
| 901 | + } | |
| 902 | + | |
| 903 | + return in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && FrmAppHelper::simple_get( 'taxonomy' ) === 'frm_application'; | |
| 904 | + } | |
| 905 | + | |
| 906 | + /** | |
| 854 | 907 | * Automatically insert a Formidable block when loading Gutenberg when $_GET['frmForm' is set. |
| 855 | 908 | * |
| 856 | 909 | * @since 5.2 |
| 857 | 910 | * |
| @@ -910,10 +963,10 @@ | ||
| 910 | 963 | * @return void |
| 911 | 964 | */ |
| 912 | 965 | public static function create_rest_routes() { |
| 913 | 966 | $args = array( |
| 914 | - 'methods' => 'GET', | |
| 915 | - 'callback' => 'FrmAppController::api_install', | |
| 967 | + 'methods' => 'GET', | |
| 968 | + 'callback' => 'FrmAppController::api_install', | |
| 916 | 969 | 'permission_callback' => __CLASS__ . '::can_update_db', |
| 917 | 970 | ); |
| 918 | 971 | |
| 919 | 972 | register_rest_route( 'frm-admin/v1', '/install', $args ); |
| @@ -918,10 +971,10 @@ | ||
| 918 | 971 | |
| 919 | 972 | register_rest_route( 'frm-admin/v1', '/install', $args ); |
| 920 | 973 | |
| 921 | 974 | $args = array( |
| 922 | - 'methods' => 'GET', | |
| 923 | - 'callback' => 'FrmAddonsController::install_addon_api', | |
| 975 | + 'methods' => 'GET', | |
| 976 | + 'callback' => 'FrmAddonsController::install_addon_api', | |
| 924 | 977 | 'permission_callback' => 'FrmAddonsController::can_install_addon_api', |
| 925 | 978 | ); |
| 926 | 979 | |
| 927 | 980 | register_rest_route( 'frm-admin/v1', '/install-addon', $args ); |
| @@ -1034,9 +1087,9 @@ | ||
| 1034 | 1087 | |
| 1035 | 1088 | $frmdb = new FrmMigrate(); |
| 1036 | 1089 | $frmdb->uninstall(); |
| 1037 | 1090 | |
| 1038 | - //disable the plugin and redirect after uninstall so the tables don't get added right back | |
| 1091 | + // Disable the plugin and redirect after uninstall so the tables don't get added right back. | |
| 1039 | 1092 | $plugins = array( FrmAppHelper::plugin_folder() . '/formidable.php', 'formidable-pro/formidable-pro.php' ); |
| 1040 | 1093 | deactivate_plugins( $plugins, false, false ); |
| 1041 | 1094 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 1042 | 1095 | |
| @@ -1107,63 +1160,71 @@ | ||
| 1107 | 1160 | * |
| 1108 | 1161 | * @return void |
| 1109 | 1162 | */ |
| 1110 | 1163 | public static function add_admin_footer_links() { |
| 1111 | - $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); | |
| 1112 | - | |
| 1113 | - // Check admin privileges, screen mode, and branding | |
| 1114 | - $is_not_admin = ! FrmAppHelper::is_formidable_admin() && $post_type !== 'frm_logs'; | |
| 1115 | - $is_full_screen = FrmAppHelper::is_full_screen(); | |
| 1116 | - $is_not_formidable_branding = ! FrmAppHelper::is_formidable_branding(); | |
| 1117 | - | |
| 1118 | - // Exit if any of the above conditions are met | |
| 1119 | - if ( $is_not_admin || $is_full_screen || $is_not_formidable_branding ) { | |
| 1120 | - return; | |
| 1164 | + if ( self::should_show_footer_links() ) { | |
| 1165 | + include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php'; | |
| 1121 | 1166 | } |
| 1122 | - | |
| 1123 | - include FrmAppHelper::plugin_path() . '/classes/views/shared/admin-footer-links.php'; | |
| 1124 | 1167 | } |
| 1125 | 1168 | |
| 1126 | 1169 | /** |
| 1127 | - * @deprecated 3.0.04 | |
| 1170 | + * Check if the footer links should be shown. | |
| 1128 | 1171 | * |
| 1129 | - * @codeCoverageIgnore | |
| 1172 | + * @since 6.7 | |
| 1130 | 1173 | * |
| 1131 | - * @return void | |
| 1174 | + * @return bool | |
| 1132 | 1175 | */ |
| 1133 | - public static function activation_install() { | |
| 1134 | - FrmDeprecated::activation_install(); | |
| 1135 | - } | |
| 1176 | + private static function should_show_footer_links() { | |
| 1177 | + $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' ); | |
| 1178 | + $is_formidable_page = FrmAppHelper::is_formidable_admin() || 'frm_logs' === $post_type; | |
| 1179 | + $show_footer_links = $is_formidable_page; | |
| 1180 | + if ( FrmAppHelper::is_full_screen() || ! FrmAppHelper::is_formidable_branding() ) { | |
| 1181 | + $show_footer_links = false; | |
| 1182 | + } | |
| 1136 | 1183 | |
| 1137 | - /** | |
| 1138 | - * @deprecated 3.0 | |
| 1139 | - * @codeCoverageIgnore | |
| 1140 | - */ | |
| 1141 | - public static function page_route( $content ) { | |
| 1142 | - return FrmDeprecated::page_route( $content ); | |
| 1184 | + /** | |
| 1185 | + * Filter whether to show the Formidable footer links. | |
| 1186 | + * | |
| 1187 | + * @since 6.7 | |
| 1188 | + * | |
| 1189 | + * @param bool $show_footer_links | |
| 1190 | + * @return bool | |
| 1191 | + */ | |
| 1192 | + return apply_filters( 'frm_show_footer_links', $show_footer_links ); | |
| 1143 | 1193 | } |
| 1144 | 1194 | |
| 1145 | 1195 | /** |
| 1146 | - * Include icons on page for Embed Form modal. | |
| 1196 | + * Show an error modal and terminate the script execution. | |
| 1147 | 1197 | * |
| 1148 | - * @since 5.2 | |
| 1198 | + * @since 6.7 | |
| 1149 | 1199 | * |
| 1200 | + * @param array $error_args Arguments that control the behavior of the error modal. | |
| 1201 | + * | |
| 1150 | 1202 | * @return void |
| 1151 | 1203 | */ |
| 1152 | - public static function include_embed_form_icons() { | |
| 1153 | - _deprecated_function( __METHOD__, '5.3' ); | |
| 1154 | - } | |
| 1204 | + public static function show_error_modal( $error_args ) { | |
| 1205 | + add_filter( 'frm_show_footer_links', '__return_false' ); | |
| 1155 | 1206 | |
| 1156 | - /** | |
| 1157 | - * @deprecated 1.07.05 This is still referenced in the API add on as of v1.13. | |
| 1158 | - * @codeCoverageIgnore | |
| 1159 | - * | |
| 1160 | - * @param array $atts | |
| 1161 | - * @return string | |
| 1162 | - */ | |
| 1163 | - public static function get_form_shortcode( $atts ) { | |
| 1164 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode' ); | |
| 1165 | - return FrmFormsController::get_form_shortcode( $atts ); | |
| 1207 | + $defaults = array( | |
| 1208 | + 'title' => '', | |
| 1209 | + 'body' => '', | |
| 1210 | + 'cancel_url' => '', | |
| 1211 | + 'cancel_classes' => '', | |
| 1212 | + 'continue_url' => '', | |
| 1213 | + 'continue_classes' => '', | |
| 1214 | + 'icon' => 'frm_lock_simple', | |
| 1215 | + ); | |
| 1216 | + | |
| 1217 | + $error_args = wp_parse_args( $error_args, $defaults ); | |
| 1218 | + if ( ! isset( $error_args['cancel_text'] ) && ! empty( $error_args['cancel_url'] ) ) { | |
| 1219 | + $error_args['cancel_text'] = __( 'Cancel', 'formidable' ); | |
| 1220 | + } | |
| 1221 | + | |
| 1222 | + if ( ! isset( $error_args['continue_text'] ) && ! empty( $error_args['continue_url'] ) ) { | |
| 1223 | + $error_args['continue_text'] = __( 'Continue', 'formidable' ); | |
| 1224 | + } | |
| 1225 | + | |
| 1226 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/error-modal.php'; | |
| 1166 | 1227 | } |
| 1167 | 1228 | |
| 1168 | 1229 | /** |
| 1169 | 1230 | * Handles Floating Links' scripts and styles enqueueing. |
| @@ -1183,9 +1244,9 @@ | ||
| 1183 | 1244 | // Enqueue the Floating Links styles. |
| 1184 | 1245 | wp_enqueue_style( 's11-floating-links', $plugin_url . '/css/packages/s11-floating-links.css', array(), $version ); |
| 1185 | 1246 | |
| 1186 | 1247 | // Enqueue the Floating Links script. |
| 1187 | - wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array(), $version, true ); | |
| 1248 | + wp_enqueue_script( 's11-floating-links', $plugin_url . '/js/packages/floating-links/s11-floating-links.js', array( 'formidable_admin' ), $version, true ); | |
| 1188 | 1249 | |
| 1189 | 1250 | // Enqueue the config script. |
| 1190 | 1251 | wp_enqueue_script( 's11-floating-links-config', $plugin_url . '/js/packages/floating-links/config.js', array( 'wp-i18n' ), $version, true ); |
| 1191 | 1252 | |
| @@ -1196,6 +1257,95 @@ | ||
| 1196 | 1257 | $floating_links_data = array( |
| 1197 | 1258 | 'proIsInstalled' => FrmAppHelper::pro_is_installed(), |
| 1198 | 1259 | ); |
| 1199 | 1260 | wp_localize_script( 's11-floating-links-config', 's11FloatingLinksData', $floating_links_data ); |
| 1261 | + | |
| 1262 | + /** | |
| 1263 | + * Prompt Pro to load additional floating links scripts. | |
| 1264 | + * This is used to include images in the Inbox SlideIn when Pro is active. | |
| 1265 | + * | |
| 1266 | + * @since 6.8.4 | |
| 1267 | + */ | |
| 1268 | + do_action( 'frm_enqueue_floating_links' ); | |
| 1269 | + } | |
| 1270 | + | |
| 1271 | + /** | |
| 1272 | + * Check if we are in our admin pages. | |
| 1273 | + * | |
| 1274 | + * @return bool | |
| 1275 | + */ | |
| 1276 | + private static function in_our_pages() { | |
| 1277 | + global $current_screen, $pagenow; | |
| 1278 | + if ( FrmAppHelper::is_formidable_admin() ) { | |
| 1279 | + return true; | |
| 1280 | + } | |
| 1281 | + | |
| 1282 | + if ( ! empty( $current_screen->post_type ) && 'frm_logs' === $current_screen->post_type ) { | |
| 1283 | + return true; | |
| 1284 | + } | |
| 1285 | + | |
| 1286 | + if ( in_array( $pagenow, array( 'term.php', 'edit-tags.php' ), true ) && 'frm_application' === FrmAppHelper::simple_get( 'taxonomy' ) ) { | |
| 1287 | + return true; | |
| 1288 | + } | |
| 1289 | + | |
| 1290 | + return false; | |
| 1291 | + } | |
| 1292 | + | |
| 1293 | + /** | |
| 1294 | + * Hide all third-parties admin notices only in our admin pages. | |
| 1295 | + * | |
| 1296 | + * @return void | |
| 1297 | + */ | |
| 1298 | + public static function filter_admin_notices() { | |
| 1299 | + if ( ! self::in_our_pages() ) { | |
| 1300 | + return; | |
| 1301 | + } | |
| 1302 | + | |
| 1303 | + $actions = array( | |
| 1304 | + 'admin_notices', | |
| 1305 | + 'network_admin_notices', | |
| 1306 | + 'user_admin_notices', | |
| 1307 | + 'all_admin_notices', | |
| 1308 | + ); | |
| 1309 | + | |
| 1310 | + global $wp_filter; | |
| 1311 | + | |
| 1312 | + foreach ( $actions as $action ) { | |
| 1313 | + if ( empty( $wp_filter[ $action ]->callbacks ) ) { | |
| 1314 | + continue; | |
| 1315 | + } | |
| 1316 | + foreach ( $wp_filter[ $action ]->callbacks as $priority => $callbacks ) { | |
| 1317 | + foreach ( $callbacks as $callback_name => $callback ) { | |
| 1318 | + if ( self::is_our_callback_string( $callback_name ) || self::is_our_callback_array( $callback ) ) { | |
| 1319 | + continue; | |
| 1320 | + } | |
| 1321 | + unset( $wp_filter[ $action ]->callbacks[ $priority ][ $callback_name ] ); | |
| 1322 | + } | |
| 1323 | + } | |
| 1324 | + } | |
| 1325 | + } | |
| 1326 | + | |
| 1327 | + /** | |
| 1328 | + * Validate that the callback name is ours not from third-party. | |
| 1329 | + * | |
| 1330 | + * @param string $callback_name WordPress callback name. | |
| 1331 | + * | |
| 1332 | + * @return bool | |
| 1333 | + */ | |
| 1334 | + private static function is_our_callback_string( $callback_name ) { | |
| 1335 | + return 0 === stripos( $callback_name, 'frm' ); | |
| 1336 | + } | |
| 1337 | + | |
| 1338 | + /** | |
| 1339 | + * Validate that the callback array is ours not from third-party. | |
| 1340 | + * | |
| 1341 | + * @param array $callback WordPress callback array. | |
| 1342 | + * | |
| 1343 | + * @return bool | |
| 1344 | + */ | |
| 1345 | + private static function is_our_callback_array( $callback ) { | |
| 1346 | + return ! empty( $callback['function'] ) && | |
| 1347 | + is_array( $callback['function'] ) && | |
| 1348 | + ! empty( $callback['function'][0] ) && | |
| 1349 | + self::is_our_callback_string( is_object( $callback['function'][0] ) ? get_class( $callback['function'][0] ) : $callback['function'][0] ); | |
| 1200 | 1350 | } |
| 1201 | 1351 | } |