wp_enqueue_block_support_styles

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

WordPress Version: 6.1

/**
 * Hooks inline styles in the proper place, depending on the active theme.
 *
 * @since 5.9.1
 * @since 6.1.0 Added the `$priority` parameter.
 *
 * For block themes, styles are loaded in the head.
 * For classic ones, styles are loaded in the body because the wp_head action happens before render_block.
 *
 * @link https://core.trac.wordpress.org/ticket/53494.
 *
 * @param string $style    String containing the CSS styles to be added.
 * @param int    $priority To set the priority for the add_action.
 */
function wp_enqueue_block_support_styles($style, $priority = 10)
{
    $action_hook_name = 'wp_footer';
    if (wp_is_block_theme()) {
        $action_hook_name = 'wp_head';
    }
    add_action($action_hook_name, static function () use ($style) {
        echo "<style>{$style}</style>\n";
    }, $priority);
}

WordPress Version: 9.3

/**
 * This function takes care of adding inline styles
 * in the proper place, depending on the theme in use.
 *
 * @since 5.9.1
 *
 * For block themes, it's loaded in the head.
 * For classic ones, it's loaded in the body
 * because the wp_head action happens before
 * the render_block.
 *
 * @link https://core.trac.wordpress.org/ticket/53494.
 *
 * @param string $style String containing the CSS styles to be added.
 */
function wp_enqueue_block_support_styles($style)
{
    $action_hook_name = 'wp_footer';
    if (wp_is_block_theme()) {
        $action_hook_name = 'wp_head';
    }
    add_action($action_hook_name, static function () use ($style) {
        echo "<style>{$style}</style>\n";
    });
}

WordPress Version: 9.1

/**
 * This function takes care of adding inline styles
 * in the proper place, depending on the theme in use.
 *
 * @since 5.9.1
 *
 * For block themes, it's loaded in the head.
 * For classic ones, it's loaded in the body
 * because the wp_head action (and wp_enqueue_scripts)
 * happens before the render_block.
 *
 * @link https://core.trac.wordpress.org/ticket/53494.
 *
 * @param string $style String containing the CSS styles to be added.
 */
function wp_enqueue_block_support_styles($style)
{
    $action_hook_name = 'wp_footer';
    if (wp_is_block_theme()) {
        $action_hook_name = 'wp_enqueue_scripts';
    }
    add_action($action_hook_name, static function () use ($style) {
        echo "<style>{$style}</style>\n";
    });
}