widget_block_dynamic_classname WordPress Filter Hook

The widget_block_dynamic_classname hook allows you to dynamically set the class name for a widget block. This can be useful if you want to change the appearance of a widget block based on certain conditions. For example, you could use this hook to change the class name of a widget block when the user is logged in or when the current page is a certain page template.

apply_filters( 'widget_block_dynamic_classname', string $classname, string $block_name ) #

The classname used in the block widget’s container HTML.


Description

This can be set according to the name of the block contained by the block widget.


Top ↑

Parameters

$classname

(string)The classname to be used in the block widget's container HTML, e.g. 'widget_block widget_text'.

$block_name

(string)The name of the block contained by the block widget, e.g. 'core/paragraph'.


Top ↑

Source

File: wp-includes/widgets/class-wp-widget-block.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.