Make WordPress Core


Ignore:
Timestamp:
06/02/2021 01:17:37 AM (5 years ago)
Author:
noisysocks
Message:

Widget block: Add widget_block_content filter

Adds a new 'widget_block_content' filter to the widget block and hooks
run_shortcode, autoembed, do_blocks, and do_shortcode into it by
default. This is simlar to widget_text_content.

Fixes #51566.
Props talldanwp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-widget-block.php

    r50995 r51058  
    6767        );
    6868
    69         // Handle embeds for block widgets.
    70         //
    71         // When this feature is added to core it may need to be implemented
    72         // differently. WP_Widget_Text is a good reference, that applies a
    73         // filter for its content, which WP_Embed uses in its constructor.
    74         // See https://core.trac.wordpress.org/ticket/51566.
    75         global $wp_embed;
    76         $content = $wp_embed->run_shortcode( $instance['content'] );
    77         $content = $wp_embed->autoembed( $content );
    78 
    79         $content = do_blocks( $content );
    80         $content = do_shortcode( $content );
    81 
    82         echo $content;
     69        /**
     70         * Filters the content of the Block widget before output.
     71         *
     72         * @since 5.8.0
     73         *
     74         * @param string         $content  The widget content.
     75         * @param array          $instance Array of settings for the current widget.
     76         * @param WP_Widget_Text $widget   Current Block widget instance.
     77         */
     78        echo apply_filters(
     79            'widget_block_content',
     80            $instance['content'],
     81            $instance,
     82            $this
     83        );
    8384
    8485        echo $args['after_widget'];
Note: See TracChangeset for help on using the changeset viewer.