block_core_navigation_add_directives_to_overlay_close()
Add Interactivity API directives to the navigation-overlay-close block markup using the Tag Processor.
No Hooks.
Returns
String. Overlay close markup with the directives injected.
Usage
block_core_navigation_add_directives_to_overlay_close( $tags );
- $tags(WP_HTML_Tag_Processor) (required)
- Markup of the navigation block.
Changelog
| Since 6.5.0 | Introduced. |
block_core_navigation_add_directives_to_overlay_close() block core navigation add directives to overlay close code WP 7.0
function block_core_navigation_add_directives_to_overlay_close( $tags ) {
// Find all navigation-overlay-close buttons.
while ( $tags->next_tag(
array(
'tag_name' => 'BUTTON',
'class_name' => 'wp-block-navigation-overlay-close',
)
) ) {
// Add the same close directive as the default close button.
$tags->set_attribute( 'data-wp-on--click', 'actions.closeMenuOnClick' );
}
return $tags->get_updated_html();
}