将类添加到Wordpress菜单

I add classes to each Wordpress Menu Item but they are not appearing in the code.

My menu:

<?php $wp_custom_nav = array(
        'theme_location'  => 'primary',
    'container'       => 'nav',
        'container_class' => 'nav',
    'echo'            => false,
    'fallback_cb'     => false,
    'items_wrap'      => '%3$s',
    'depth'           => 0
    );
    echo strip_tags(wp_nav_menu( $wp_custom_nav ), '<nav><a>');
    ?>

My function.php include

    register_nav_menus( array(
        'primary' => esc_html__( 'Primary', 'yewtree' ),
    ) );

So I have

<nav>
  <a></a>
  <a></a>
  ...
</nav>

but the doesn't have any class that I added at Wordpress administration menu. Why is that?

wp_nav_menu uses Walker_Nav_Menu by default. And this is the part responsible for printing the classes:

    /**
     * Filters the CSS classes applied to a menu item's list item element.
     *
     * @since 3.0.0
     * @since 4.1.0 The `$depth` parameter was added.
     *
     * @param string[] $classes Array of the CSS classes that are applied to the menu item's `<li>` element.
     * @param WP_Post  $item    The current menu item.
     * @param stdClass $args    An object of wp_nav_menu() arguments.
     * @param int      $depth   Depth of menu item. Used for padding.
     */
    $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
    $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';

    /**
     * Filters the ID applied to a menu item's list item element.
     *
     * @since 3.0.1
     * @since 4.1.0 The `$depth` parameter was added.
     *
     * @param string   $menu_id The ID that is applied to the menu item's `<li>` element.
     * @param WP_Post  $item    The current menu item.
     * @param stdClass $args    An object of wp_nav_menu() arguments.
     * @param int      $depth   Depth of menu item. Used for padding.
     */
    $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
    $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';

    $output .= $indent . '<li' . $id . $class_names . '>';

So, as you can see, the classes are applied to <li> tags and not to <a> tags.

So they are applied, but then... You do this:

echo strip_tags(wp_nav_menu( $wp_custom_nav ), '<nav><a>');

So you strip all tags other than <nav> and <a> - so the <li> tags are stripped (and the classes are gone too).