WP_Navigation_Block_Renderer::get_layout_class
Returns the layout class for the navigation block.
Method of the class: WP_Navigation_Block_Renderer{}
No Hooks.
Returns
String. Returns the layout class for the navigation block.
Usage
$result = WP_Navigation_Block_Renderer::get_layout_class( $attributes );
- $attributes(array) (required)
- The block attributes.
Changelog
| Since 6.5.0 | Introduced. |
WP_Navigation_Block_Renderer::get_layout_class() WP Navigation Block Renderer::get layout class code WP 6.9.1
private static function get_layout_class( $attributes ) {
$layout_justification = array(
'left' => 'items-justified-left',
'right' => 'items-justified-right',
'center' => 'items-justified-center',
'space-between' => 'items-justified-space-between',
);
$layout_class = '';
if (
isset( $attributes['layout']['justifyContent'] ) &&
isset( $layout_justification[ $attributes['layout']['justifyContent'] ] )
) {
$layout_class .= $layout_justification[ $attributes['layout']['justifyContent'] ];
}
if ( isset( $attributes['layout']['orientation'] ) && 'vertical' === $attributes['layout']['orientation'] ) {
$layout_class .= ' is-vertical';
}
if ( isset( $attributes['layout']['flexWrap'] ) && 'nowrap' === $attributes['layout']['flexWrap'] ) {
$layout_class .= ' no-wrap';
}
return $layout_class;
}