protected function get_terms_for_post( $prepared_args ) {
		$query_result = get_the_terms( $prepared_args['post'], $this->taxonomy );
		if ( empty( $query_result ) ) {
			$this->total_terms = 0;
			return array();
		}

		/*
		 * get_items() verifies that we don't have `include` set, and default
		 * ordering is by `name`.
		 */
		if ( ! in_array( $prepared_args['orderby'], array( 'name', 'none', 'include' ), true ) ) {
			switch ( $prepared_args['orderby'] ) {
				case 'id':
					$this->sort_column = 'term_id';
					break;

				case 'slug':
				case 'term_group':
				case 'description':
				case 'count':
					$this->sort_column = $prepared_args['orderby'];
					break;
			}
			usort( $query_result, array( $this, 'compare_terms' ) );
		}
		if ( strtolower( $prepared_args['order'] ) !== 'asc' ) {
			$query_result = array_reverse( $query_result );
		}

		// Pagination.
		$this->total_terms = count( $query_result );
		$query_result = array_slice( $query_result, $prepared_args['offset'], $prepared_args['number'] );

		return $query_result;
	}
protected function get_terms_for_post( $prepared_args ) {
		$query_result = get_the_terms( $prepared_args['post'], $this->taxonomy );
		if ( empty( $query_result ) ) {
			$this->total_terms = 0;
			return array();
		}

		/*
		 * get_items() verifies that we don't have `include` set, and default
		 * ordering is by `name`.
		 */
		if ( ! in_array( $prepared_args['orderby'], array( 'name', 'none', 'include' ), true ) ) {
			switch ( $prepared_args['orderby'] ) {
				case 'id':
					$this->sort_column = 'term_id';
					break;

				case 'slug':
				case 'term_group':
				case 'description':
				case 'count':
					$this->sort_column = $prepared_args['orderby'];
					break;
			}
			usort( $query_result, array( $this, 'compare_terms' ) );
		}
		if ( strtolower( $prepared_args['order'] ) !== 'asc' ) {
			$query_result = array_reverse( $query_result );
		}

		// Pagination.
		$this->total_terms = count( $query_result );
		$query_result = array_slice( $query_result, $prepared_args['offset'], $prepared_args['number'] );

		return $query_result;
	}
protected function get_terms_for_post ( $ prepared_args ) { $ query_result = get_the_terms ( $ prepared_args [ 'post' ] , $ this -> taxonomy ) ; if ( empty ( $ query_result ) ) { $ this -> total_terms = 0 ; return array ( ) ; } /*
		 * get_items() verifies that we don't have `include` set, and default
		 * ordering is by `name`.
		 */ if ( ! in_array ( $ prepared_args [ 'orderby' ] , array ( 'name' , 'none' , 'include' ) , true ) ) { switch ( $ prepared_args [ 'orderby' ] ) { case 'id' : $ this -> sort_column = 'term_id' ; break ; case 'slug' : case 'term_group' : case 'description' : case 'count' : $ this -> sort_column = $ prepared_args [ 'orderby' ] ; break ; } usort ( $ query_result , array ( $ this , 'compare_terms' ) ) ; } if ( strtolower ( $ prepared_args [ 'order' ] ) !== 'asc' ) { $ query_result = array_reverse ( $ query_result ) ; } // Pagination. $ this -> total_terms = count ( $ query_result ) ; $ query_result = array_slice ( $ query_result , $ prepared_args [ 'offset' ] , $ prepared_args [ 'number' ] ) ; return $ query_result ; }
Gets the terms attached to a post.

This is an alternative to get_terms() that uses get_the_terms()
instead, which hits the object cache. There are a few things not
supported, notably `include`, `exclude`. In `self::get_items()` these
are instead treated as a full query.

@param array $prepared_args Arguments for get_terms().
@return array List of term objects. (Total count in `$this->total_terms`)
Gets the terms attached to a post .