apply_filters( ‘widget_block_content’, string $content, array $instance, WP_Widget_Block $widget )

Filters the content of the Block widget before output.

Parameters

$contentstring
The widget content.
$instancearray
Array of settings for the current widget.
$widgetWP_Widget_Block
Current Block widget instance.

Source

echo apply_filters(
	'widget_block_content',
	$instance['content'],
	$instance,
	$this
);

Changelog

VersionDescription
5.8.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Really useful if, for example, we want to translate a piece of text (or change HTML code).
    Example:

    function wpdocs_translating_widget( $content ) {
        $locale = get_locale();
        if ( is_home() && $locale !== 'es_ES' ) {
            $replace = array(
                'Entradas recientes' => 'Recent entries',
                'BUSCAR' => 'SEARCH',
            );
            $content = str_replace( array_keys( $replace ), $replace, $content );
        }
        return $content;
    }  
    add_filter( 'widget_block_content', 'wpdocs_translating_widget' );

You must log in before being able to contribute a note or feedback.