Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_wp_get_iframed_editor_assets() WordPress Function

The wp_get_iframed_editor_assets() function is used to retrieve the JavaScript and CSS needed to make the editor work in an iframe.

_wp_get_iframed_editor_assets() #

Collect the block editor assets that need to be loaded into the editor’s iframe.


Return

(array) The block editor assets.

  • 'styles'
    (string|false) String containing the HTML for styles.
  • 'scripts'
    (string|false) String containing the HTML for scripts.


Top ↑

Source

File: wp-includes/block-editor.php

305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
function _wp_get_iframed_editor_assets() {
    global $pagenow;
 
    $script_handles = array();
    $style_handles  = array(
        'wp-block-editor',
        'wp-block-library',
        'wp-edit-blocks',
    );
 
    if ( current_theme_supports( 'wp-block-styles' ) ) {
        $style_handles[] = 'wp-block-library-theme';
    }
 
    if ( 'widgets.php' === $pagenow || 'customize.php' === $pagenow ) {
        $style_handles[] = 'wp-widgets';
        $style_handles[] = 'wp-edit-widgets';
    }
 
    $block_registry = WP_Block_Type_Registry::get_instance();
 
    foreach ( $block_registry->get_all_registered() as $block_type ) {
        if ( ! empty( $block_type->style ) ) {
            $style_handles[] = $block_type->style;
        }
 
        if ( ! empty( $block_type->editor_style ) ) {
            $style_handles[] = $block_type->editor_style;
        }
 
        if ( ! empty( $block_type->script ) ) {
            $script_handles[] = $block_type->script;
        }
    }
 
    $style_handles = array_unique( $style_handles );
    $done          = wp_styles()->done;
 
    ob_start();
 
    // We do not need reset styles for the iframed editor.
    wp_styles()->done = array( 'wp-reset-editor-styles' );
    wp_styles()->do_items( $style_handles );
    wp_styles()->done = $done;
 
    $styles = ob_get_clean();
 
    $script_handles = array_unique( $script_handles );
    $done           = wp_scripts()->done;
 
    ob_start();
 
    wp_scripts()->done = array();
    wp_scripts()->do_items( $script_handles );
    wp_scripts()->done = $done;
 
    $scripts = ob_get_clean();
 
    return array(
        'styles'  => $styles,
        'scripts' => $scripts,
    );
}


Top ↑

Changelog

Changelog
VersionDescription
6.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.