wp_common_block_scripts_and_styles

The timeline below displays how wordpress function wp_common_block_scripts_and_styles has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Handles the enqueueing of block scripts and styles that are common to both
 * the editor and the front-end.
 *
 * @since 5.0.0
 */
function wp_common_block_scripts_and_styles()
{
    if (is_admin() && !wp_should_load_block_editor_scripts_and_styles()) {
        return;
    }
    wp_enqueue_style('wp-block-library');
    if (current_theme_supports('wp-block-styles') && !wp_should_load_separate_core_block_assets()) {
        wp_enqueue_style('wp-block-library-theme');
    }
    /**
     * Fires after enqueuing block assets for both editor and front-end.
     *
     * Call `add_action` on any hook before 'wp_enqueue_scripts'.
     *
     * In the function call you supply, simply use `wp_enqueue_script` and
     * `wp_enqueue_style` to add your functionality to the Gutenberg editor.
     *
     * @since 5.0.0
     */
    do_action('enqueue_block_assets');
}

WordPress Version: 5.9

/**
 * Handles the enqueueing of block scripts and styles that are common to both
 * the editor and the front-end.
 *
 * @since 5.0.0
 */
function wp_common_block_scripts_and_styles()
{
    if (is_admin() && !wp_should_load_block_editor_scripts_and_styles()) {
        return;
    }
    wp_enqueue_style('wp-block-library');
    if (current_theme_supports('wp-block-styles')) {
        if (wp_should_load_separate_core_block_assets()) {
            $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? 'css' : 'min.css';
            $files = glob(__DIR__ . "/blocks/**/theme.{$suffix}");
            foreach ($files as $path) {
                $block_name = basename(dirname($path));
                if (is_rtl() && file_exists(__DIR__ . "/blocks/{$block_name}/theme-rtl.{$suffix}")) {
                    $path = __DIR__ . "/blocks/{$block_name}/theme-rtl.{$suffix}";
                }
                wp_add_inline_style("wp-block-{$block_name}", file_get_contents($path));
            }
        } else {
            wp_enqueue_style('wp-block-library-theme');
        }
    }
    /**
     * Fires after enqueuing block assets for both editor and front-end.
     *
     * Call `add_action` on any hook before 'wp_enqueue_scripts'.
     *
     * In the function call you supply, simply use `wp_enqueue_script` and
     * `wp_enqueue_style` to add your functionality to the Gutenberg editor.
     *
     * @since 5.0.0
     */
    do_action('enqueue_block_assets');
}

WordPress Version: 5.6

/**
 * Handles the enqueueing of block scripts and styles that are common to both
 * the editor and the front-end.
 *
 * @since 5.0.0
 *
 * @global WP_Screen $current_screen WordPress current screen object.
 */
function wp_common_block_scripts_and_styles()
{
    if (is_admin() && !wp_should_load_block_editor_scripts_and_styles()) {
        return;
    }
    wp_enqueue_style('wp-block-library');
    if (current_theme_supports('wp-block-styles')) {
        wp_enqueue_style('wp-block-library-theme');
    }
    /**
     * Fires after enqueuing block assets for both editor and front-end.
     *
     * Call `add_action` on any hook before 'wp_enqueue_scripts'.
     *
     * In the function call you supply, simply use `wp_enqueue_script` and
     * `wp_enqueue_style` to add your functionality to the Gutenberg editor.
     *
     * @since 5.0.0
     */
    do_action('enqueue_block_assets');
}

WordPress Version: 5.3

/**
 * Handles the enqueueing of block scripts and styles that are common to both
 * the editor and the front-end.
 *
 * @since 5.0.0
 *
 * @global WP_Screen $current_screen WordPress current screen object.
 */
function wp_common_block_scripts_and_styles()
{
    global $current_screen;
    if (is_admin() && $current_screen instanceof WP_Screen && !$current_screen->is_block_editor()) {
        return;
    }
    wp_enqueue_style('wp-block-library');
    if (current_theme_supports('wp-block-styles')) {
        wp_enqueue_style('wp-block-library-theme');
    }
    /**
     * Fires after enqueuing block assets for both editor and front-end.
     *
     * Call `add_action` on any hook before 'wp_enqueue_scripts'.
     *
     * In the function call you supply, simply use `wp_enqueue_script` and
     * `wp_enqueue_style` to add your functionality to the Gutenberg editor.
     *
     * @since 5.0.0
     */
    do_action('enqueue_block_assets');
}

WordPress Version: 5.0

/**
 * Handles the enqueueing of block scripts and styles that are common to both
 * the editor and the front-end.
 *
 * @since 5.0.0
 *
 * @global WP_Screen $current_screen
 */
function wp_common_block_scripts_and_styles()
{
    global $current_screen;
    if (is_admin() && $current_screen instanceof WP_Screen && !$current_screen->is_block_editor()) {
        return;
    }
    wp_enqueue_style('wp-block-library');
    if (current_theme_supports('wp-block-styles')) {
        wp_enqueue_style('wp-block-library-theme');
    }
    /**
     * Fires after enqueuing block assets for both editor and front-end.
     *
     * Call `add_action` on any hook before 'wp_enqueue_scripts'.
     *
     * In the function call you supply, simply use `wp_enqueue_script` and
     * `wp_enqueue_style` to add your functionality to the Gutenberg editor.
     *
     * @since 5.0.0
     */
    do_action('enqueue_block_assets');
}