gpp_iframe_hook_cleaner_settings

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Disable all cleanup
    2. Allow theme code to run
    3. Allow a specific plugin
    4. Allow mu-plugins
    5. Keep block library styles
    6. Customize settings for a specific feed
  5. Since

Description

Filter the iframe cleanup settings. This filter controls all aspects of how GP Popups cleans up the iframe environment to prevent third-party scripts from interfering with popups.

Usage

Applied globally

add_filter( 'gpp_iframe_hook_cleaner_settings', 'my_custom_function' );

Parameters

$settings array

The iframe cleanup settings.

enabled bool

Whether to clean hooks at all. Default true.

hide_admin_bar bool

Whether to hide the admin bar. Default true.

disable_debug bool

Whether to disable debug tools (Query Monitor, Debug Bar). Default true.

allow_theme bool

Whether to allow theme code (functions.php, etc.). Default false.

log_blocked bool

Whether to log blocked items to GF logging. Default true.

hooks array<string>

Hooks to clean. Default [‘wp_head’, ‘wp_footer’, ‘wp_enqueue_scripts’].

allowed_paths array<string>

Allowed path patterns (partial matches). See defaults below.

remove_wp_assets array
dashicons bool

Dashicons stylesheet. Default true.

emoji bool

Emoji detection script and styles. Default true.

block_library bool

Gutenberg block library styles. Default true.

global_styles bool

theme.json global styles. Default false.

classic_theme bool

Classic theme styles. Default false.

wp_fonts bool

Theme fonts from theme.json. Default false.

Examples

Disable all cleanup

add_filter( 'gpp_iframe_hook_cleaner_settings', function( $settings ) {
    $settings['enabled'] = false;
    return $settings;
} );

Allow theme code to run

add_filter( 'gpp_iframe_hook_cleaner_settings', function( $settings ) {
    $settings['allow_theme'] = true;
    return $settings;
} );

Allow a specific plugin

add_filter( 'gpp_iframe_hook_cleaner_settings', function( $settings ) {
    $settings['allowed_paths'][] = '/plugins/my-trusted-plugin/';
    return $settings;
} );

Allow mu-plugins

add_filter( 'gpp_iframe_hook_cleaner_settings', function( $settings ) {
    $settings['allowed_paths'][] = '/mu-plugins/';
    return $settings;
} );

Keep block library styles

add_filter( 'gpp_iframe_hook_cleaner_settings', function( $settings ) {
    $settings['remove_wp_assets']['block_library'] = false;
    return $settings;
} );

Customize settings for a specific feed

add_filter( 'gpp_iframe_hook_cleaner_settings', function( $settings, $feed ) {
    if ( $feed['id'] === 123 ) {
        $settings['allow_theme'] = true;
    }
    return $settings;
}, 10, 2 );

Since

  • 1.0.5 Hook added.