acf_print_menu_section()
Helper function for looping over the provided menu items and echoing out the necessary markup.
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
acf_print_menu_section( $menu_items, $section );
- $menu_items(массив) (обязательный)
- An array of menu items to print.
- $section(строка)
- The section being printed.
По умолчанию: ''
Список изменений
С версии 6.2 | Введена. |
Код acf_print_menu_section() acf print menu section ACF 6.4.2
function acf_print_menu_section( $menu_items, $section = '' ) { // Bail if no menu items. if ( ! is_array( $menu_items ) || empty( $menu_items ) ) { return; } $section_html = ''; foreach ( $menu_items as $menu_item ) { $class = ! empty( $menu_item['class'] ) ? $menu_item['class'] : $menu_item['text']; $target = ! empty( $menu_item['target'] ) ? ' target="' . esc_attr( $menu_item['target'] ) . '"' : ''; $aria_label = ! empty( $menu_item['aria-label'] ) ? ' aria-label="' . esc_attr( $menu_item['aria-label'] ) . '"' : ''; $li_class = ! empty( $menu_item['li_class'] ) ? esc_attr( $menu_item['li_class'] ) : ''; $html = sprintf( '<a class="acf-tab%s %s" href="%s"%s%s><i class="acf-icon"></i>%s</a>', ! empty( $menu_item['is_active'] ) ? ' is-active' : '', 'acf-header-tab-' . esc_attr( acf_slugify( $class ) ), esc_url( $menu_item['url'] ), $target, $aria_label, acf_esc_html( $menu_item['text'] ) ); if ( 'core' !== $section ) { if ( $li_class === '' ) { $html = '<li>' . $html . '</li>'; } else { $html = sprintf( '<li class="%s">', $li_class ) . $html . '</li>'; } } $section_html .= $html; } echo $section_html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- safely built and escaped HTML above. }