wp_filter_out_block_nodes

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

WordPress Version: 6.3

/**
 * Applies a filter to the list of style nodes that comes from WP_Theme_JSON::get_style_nodes().
 *
 * This particular filter removes all of the blocks from the array.
 *
 * We want WP_Theme_JSON to be ignorant of the implementation details of how the CSS is being used.
 * This filter allows us to modify the output of WP_Theme_JSON depending on whether or not we are
 * loading separate assets, without making the class aware of that detail.
 *
 * @since 6.1.0
 *
 * @param array $nodes The nodes to filter.
 * @return array A filtered array of style nodes.
 */
function wp_filter_out_block_nodes($nodes)
{
    return array_filter($nodes, static function ($node) {
        return !in_array('blocks', $node['path'], true);
    }, ARRAY_FILTER_USE_BOTH);
}

WordPress Version: 6.1

/**
 * Applies a filter to the list of style nodes that comes from WP_Theme_JSON::get_style_nodes().
 *
 * This particular filter removes all of the blocks from the array.
 *
 * We want WP_Theme_JSON to be ignorant of the implementation details of how the CSS is being used.
 * This filter allows us to modify the output of WP_Theme_JSON depending on whether or not we are
 * loading separate assets, without making the class aware of that detail.
 *
 * @since 6.1.0
 *
 * @param array $nodes The nodes to filter.
 * @return array A filtered array of style nodes.
 */
function wp_filter_out_block_nodes($nodes)
{
    return array_filter($nodes, function ($node) {
        return !in_array('blocks', $node['path'], true);
    }, ARRAY_FILTER_USE_BOTH);
}