WP_Customize_Nav_Menus::filter_wp_nav_menu()
Prepares wp_nav_menu() calls for partial refresh.
Injects attributes into container element.
Метод класса: WP_Customize_Nav_Menus{}
Хуков нет.
Возвращает
Строку
. Nav menu HTML with selective refresh attributes added if partial can be refreshed.
Использование
$WP_Customize_Nav_Menus = new WP_Customize_Nav_Menus(); $WP_Customize_Nav_Menus->filter_wp_nav_menu( $nav_menu_content, $args );
- $nav_menu_content(строка) (обязательный)
- The HTML content for the navigation menu.
- $args(объект) (обязательный)
- An object containing wp_nav_menu() arguments.
Заметки
- Смотрите: wp_nav_menu()
Список изменений
С версии 4.3.0 | Введена. |
Код WP_Customize_Nav_Menus::filter_wp_nav_menu() WP Customize Nav Menus::filter wp nav menu WP 6.6.2
public function filter_wp_nav_menu( $nav_menu_content, $args ) { if ( isset( $args->customize_preview_nav_menus_args['can_partial_refresh'] ) && $args->customize_preview_nav_menus_args['can_partial_refresh'] ) { $attributes = sprintf( ' data-customize-partial-id="%s"', esc_attr( 'nav_menu_instance[' . $args->customize_preview_nav_menus_args['args_hmac'] . ']' ) ); $attributes .= ' data-customize-partial-type="nav_menu_instance"'; $attributes .= sprintf( ' data-customize-partial-placement-context="%s"', esc_attr( wp_json_encode( $args->customize_preview_nav_menus_args ) ) ); $nav_menu_content = preg_replace( '#^(<\w+)#', '$1 ' . str_replace( '\\', '\\\\', $attributes ), $nav_menu_content, 1 ); } return $nav_menu_content; }