Make WordPress Core


Ignore:
Timestamp:
11/16/2020 12:45:55 AM (6 years ago)
Author:
noisysocks
Message:

Editor: Move pre_render_block, render_block_data, render_block_context

Move the pre_render_block, render_block_data, and render_block_context
filters from render_block() to WP_Block. This ensures that they are
called for all blocks, including nested blocks, not just top-level
blocks.

Fixes #51612.
Props gaambo, gziolo, TimothyBlynJacobs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r49312 r49608  
    663663
    664664        /**
    665          * Allows render_block() to be short-circuited, by returning a non-null value.
     665         * Allows render_block() or WP_Block::render() to be short-circuited, by
     666         * returning a non-null value.
    666667         *
    667668         * @since 5.1.0
     
    675676        }
    676677
    677         $source_block = $parsed_block;
    678 
    679         /**
    680          * Filters the block being rendered in render_block(), before it's processed.
    681          *
    682          * @since 5.1.0
    683          *
    684          * @param array $parsed_block The block being rendered.
    685          * @param array $source_block An un-modified copy of $parsed_block, as it appeared in the source content.
    686          */
    687         $parsed_block = apply_filters( 'render_block_data', $parsed_block, $source_block );
    688 
    689678        $context = array();
    690679
     
    707696                }
    708697        }
    709 
    710         /**
    711          * Filters the default context provided to a rendered block.
    712          *
    713          * @since 5.5.0
    714          *
    715          * @param array $context      Default context.
    716          * @param array $parsed_block Block being rendered, filtered by `render_block_data`.
    717          */
    718         $context = apply_filters( 'render_block_context', $context, $parsed_block );
    719698
    720699        $block = new WP_Block( $parsed_block, $context );
Note: See TracChangeset for help on using the changeset viewer.