Skip to content

Commit de8f096

Browse files
kmanijakkmanijakntsekourasSirLouen
authored
Add block_core_breadcrumbs_items filter to Breadcrumbs allowing to filter final items array (#74169)
Co-authored-by: kmanijak <[email protected]> Co-authored-by: ntsekouras <[email protected]> Co-authored-by: SirLouen <[email protected]>
1 parent f398e78 commit de8f096

File tree

1 file changed

+20
-0
lines changed
  • packages/block-library/src/breadcrumbs

1 file changed

+20
-0
lines changed

packages/block-library/src/breadcrumbs/index.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,26 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
159159
array_pop( $breadcrumb_items );
160160
}
161161

162+
/**
163+
* Filters the breadcrumb items array before rendering.
164+
*
165+
* Allows developers to modify, add, or remove breadcrumb items.
166+
*
167+
* @since 7.0.0
168+
*
169+
* @param array[] $breadcrumb_items {
170+
* Array of breadcrumb item data.
171+
*
172+
* @type string $label The breadcrumb text.
173+
* @type string $url Optional. The breadcrumb link URL.
174+
* @type bool $allow_html Optional. Whether to allow HTML in the label.
175+
* When true, the label will be sanitized with wp_kses_post(),
176+
* allowing only safe HTML tags. When false or omitted, all HTML
177+
* will be escaped with esc_html(). Default false.
178+
* }
179+
*/
180+
$breadcrumb_items = apply_filters( 'block_core_breadcrumbs_items', $breadcrumb_items );
181+
162182
if ( empty( $breadcrumb_items ) ) {
163183
return '';
164184
}

0 commit comments

Comments
 (0)