public function assign( $args, $assoc_args ) {

		list( $menu, $location ) = $args;

		$menu_obj = wp_get_nav_menu_object( $menu );
		if ( ! $menu_obj ) {
			WP_CLI::error( "Invalid menu {$menu}." );
		}

		$locations = get_registered_nav_menus();
		if ( ! array_key_exists( $location, $locations ) ) {
			WP_CLI::error( "Invalid location {$location}." );
		}

		$locations              = get_nav_menu_locations();
		$locations[ $location ] = $menu_obj->term_id;

		set_theme_mod( 'nav_menu_locations', $locations );

		WP_CLI::success( "Assigned location {$location} to menu {$menu}." );
	}
public function assign( $args, $assoc_args ) {

		list( $menu, $location ) = $args;

		$menu_obj = wp_get_nav_menu_object( $menu );
		if ( ! $menu_obj ) {
			WP_CLI::error( "Invalid menu {$menu}." );
		}

		$locations = get_registered_nav_menus();
		if ( ! array_key_exists( $location, $locations ) ) {
			WP_CLI::error( "Invalid location {$location}." );
		}

		$locations              = get_nav_menu_locations();
		$locations[ $location ] = $menu_obj->term_id;

		set_theme_mod( 'nav_menu_locations', $locations );

		WP_CLI::success( "Assigned location {$location} to menu {$menu}." );
	}
public function assign ( $ args , $ assoc_args ) { list ( $ menu , $ location ) = $ args ; $ menu_obj = wp_get_nav_menu_object ( $ menu ) ; if ( ! $ menu_obj ) { WP_CLI :: error ( "Invalid menu {$menu}." ) ; } $ locations = get_registered_nav_menus ( ) ; if ( ! array_key_exists ( $ location , $ locations ) ) { WP_CLI :: error ( "Invalid location {$location}." ) ; } $ locations = get_nav_menu_locations ( ) ; $ locations [ $ location ] = $ menu_obj -> term_id ; set_theme_mod ( 'nav_menu_locations' , $ locations ) ; WP_CLI :: success ( "Assigned location {$location} to menu {$menu}." ) ; }
Assigns a location to a menu.

## OPTIONS

<menu>
: The name, slug, or term ID for the menu.

<location>
: Location's slug.

## EXAMPLES

$ wp menu location assign primary-menu primary
Success: Assigned location primary to menu primary-menu.

@subcommand assign
Assigns a location to a menu .