public function list_( $args, $assoc_args ) {

		list( $object_id ) = $args;

		$keys = ! empty( $assoc_args['keys'] ) ? explode( ',', $assoc_args['keys'] ) : [];

		$object_id = $this->check_object_id( $object_id );

		$metadata = $this->get_metadata( $object_id );
		if ( ! $metadata ) {
			$metadata = [];
		}

		$items = [];
		foreach ( $metadata as $key => $values ) {

			// Skip if not requested
			if ( ! empty( $keys ) && ! in_array( $key, $keys, true ) ) {
				continue;
			}

			foreach ( $values as $item_value ) {

				if ( Utils\get_flag_value( $assoc_args, 'unserialize' ) ) {
					$item_value = maybe_unserialize( $item_value );
				}

				$items[] = (object) [
					"{$this->meta_type}_id" => $object_id,
					'meta_key'              => $key,
					'meta_value'            => $item_value,
				];
			}
		}

		$order   = Utils\get_flag_value( $assoc_args, 'order' );
		$orderby = Utils\get_flag_value( $assoc_args, 'orderby' );

		if ( 'id' !== $orderby ) {

			usort(
				$items,
				function ( $a, $b ) use ( $orderby, $order ) {
					// Sort array.
					return 'asc' === $order
						? $a->$orderby > $b->$orderby
						: $a->$orderby < $b->$orderby;
				}
			);

		} elseif ( 'id' === $orderby && 'desc' === $order ) { // Sort by default descending.
			krsort( $items );
		}

		if ( ! empty( $assoc_args['fields'] ) ) {
			$fields = explode( ',', $assoc_args['fields'] );
		} else {
			$fields = $this->get_fields();
		}

		$formatter = new Formatter( $assoc_args, $fields, $this->meta_type );
		$formatter->display_items( $items );

	}
public function list_( $args, $assoc_args ) {

		list( $object_id ) = $args;

		$keys = ! empty( $assoc_args['keys'] ) ? explode( ',', $assoc_args['keys'] ) : [];

		$object_id = $this->check_object_id( $object_id );

		$metadata = $this->get_metadata( $object_id );
		if ( ! $metadata ) {
			$metadata = [];
		}

		$items = [];
		foreach ( $metadata as $key => $values ) {

			// Skip if not requested
			if ( ! empty( $keys ) && ! in_array( $key, $keys, true ) ) {
				continue;
			}

			foreach ( $values as $item_value ) {

				if ( Utils\get_flag_value( $assoc_args, 'unserialize' ) ) {
					$item_value = maybe_unserialize( $item_value );
				}

				$items[] = (object) [
					"{$this->meta_type}_id" => $object_id,
					'meta_key'              => $key,
					'meta_value'            => $item_value,
				];
			}
		}

		$order   = Utils\get_flag_value( $assoc_args, 'order' );
		$orderby = Utils\get_flag_value( $assoc_args, 'orderby' );

		if ( 'id' !== $orderby ) {

			usort(
				$items,
				function ( $a, $b ) use ( $orderby, $order ) {
					// Sort array.
					return 'asc' === $order
						? $a->$orderby > $b->$orderby
						: $a->$orderby < $b->$orderby;
				}
			);

		} elseif ( 'id' === $orderby && 'desc' === $order ) { // Sort by default descending.
			krsort( $items );
		}

		if ( ! empty( $assoc_args['fields'] ) ) {
			$fields = explode( ',', $assoc_args['fields'] );
		} else {
			$fields = $this->get_fields();
		}

		$formatter = new Formatter( $assoc_args, $fields, $this->meta_type );
		$formatter->display_items( $items );

	}
public function list_ ( $ args , $ assoc_args ) { list ( $ object_id ) = $ args ; $ keys = ! empty ( $ assoc_args [ 'keys' ] ) ? explode ( ',' , $ assoc_args [ 'keys' ] ) : [ ] ; $ object_id = $ this -> check_object_id ( $ object_id ) ; $ metadata = $ this -> get_metadata ( $ object_id ) ; if ( ! $ metadata ) { $ metadata = [ ] ; } $ items = [ ] ; foreach ( $ metadata as $ key => $ values ) { // Skip if not requested if ( ! empty ( $ keys ) && ! in_array ( $ key , $ keys , true ) ) { continue ; } foreach ( $ values as $ item_value ) { if ( Utils \ get_flag_value ( $ assoc_args , 'unserialize' ) ) { $ item_value = maybe_unserialize ( $ item_value ) ; } $ items [ ] = ( object ) [ "{$this->meta_type}_id" => $ object_id , 'meta_key' => $ key , 'meta_value' => $ item_value , ] ; } } $ order = Utils \ get_flag_value ( $ assoc_args , 'order' ) ; $ orderby = Utils \ get_flag_value ( $ assoc_args , 'orderby' ) ; if ( 'id' !== $ orderby ) { usort ( $ items , function ( $ a , $ b ) use ( $ orderby , $ order ) { // Sort array. return 'asc' === $ order ? $ a -> $ orderby > $ b -> $ orderby : $ a -> $ orderby < $ b -> $ orderby ; } ) ; } elseif ( 'id' === $ orderby && 'desc' === $ order ) { // Sort by default descending. krsort ( $ items ) ; } if ( ! empty ( $ assoc_args [ 'fields' ] ) ) { $ fields = explode ( ',' , $ assoc_args [ 'fields' ] ) ; } else { $ fields = $ this -> get_fields ( ) ; } $ formatter = new Formatter ( $ assoc_args , $ fields , $ this -> meta_type ) ; $ formatter -> display_items ( $ items ) ; }
List all metadata associated with an object.

## OPTIONS

<id>
: ID for the object.

[--keys=<keys>]
: Limit output to metadata of specific keys.

[--fields=<fields>]
: Limit the output to specific row fields. Defaults to id,meta_key,meta_value.

[--format=<format>]
: Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- yaml
- count
---

[--orderby=<fields>]
: Set orderby which field.
---
default: id
options:
- id
- meta_key
- meta_value
---

[--order=<order>]
: Set ascending or descending order.
---
default: asc
options:
- asc
- desc
---

[--unserialize]
: Unserialize meta_value output.

@subcommand list
List all metadata associated with an object .