]
* : Render output in a particular format.
* ---
* default: table
* options:
* - table
* - csv
* - json
* - count
* - yaml
* - ids
* ---
*
* ## AVAILABLE FIELDS
*
* These fields will be displayed by default for each location:
*
* * name
* * description
*
* ## EXAMPLES
*
* $ wp menu location list
* +----------+-------------------+
* | location | description |
* +----------+-------------------+
* | primary | Primary Menu |
* | social | Social Links Menu |
* +----------+-------------------+
*
* @subcommand list
*/
public function list_( $args, $assoc_args ) {
$locations = get_registered_nav_menus();
$location_objs = [];
foreach ( $locations as $location => $description ) {
$location_obj = new stdClass();
$location_obj->location = $location;
$location_obj->description = $description;
$location_objs[] = $location_obj;
}
$formatter = new Formatter( $assoc_args, [ 'location', 'description' ] );
if ( 'ids' === $formatter->format ) {
$ids = array_map(
function ( $o ) {
return $o->location;
},
$location_objs
);
$formatter->display_items( $ids );
} else {
$formatter->display_items( $location_objs );
}
}
/**
* Assigns a location to a menu.
*
* ## OPTIONS
*
*