Fixed use of get_term_meta in REST API endpoints

Part of #23408
This commit is contained in:
Claudio Sanches 2019-04-23 12:48:03 -03:00
parent f20a48b1e4
commit 0fdf47294a
4 changed files with 8 additions and 8 deletions

View File

@ -34,10 +34,10 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Product_Categories_V
*/
public function prepare_item_for_response( $item, $request ) {
// Get category display type.
$display_type = get_term_meta( $item->term_id, 'display_type' );
$display_type = get_term_meta( $item->term_id, 'display_type', true );
// Get category order.
$menu_order = get_term_meta( $item->term_id, 'order' );
$menu_order = get_term_meta( $item->term_id, 'order', true );
$data = array(
'id' => (int) $item->term_id,
@ -52,7 +52,7 @@ class WC_REST_Product_Categories_Controller extends WC_REST_Product_Categories_V
);
// Get category image.
$image_id = get_term_meta( $item->term_id, 'thumbnail_id' );
$image_id = get_term_meta( $item->term_id, 'thumbnail_id', true );
if ( $image_id ) {
$attachment = get_post( $image_id );

View File

@ -607,11 +607,11 @@ class WC_API_Products extends WC_API_Resource {
$term_id = intval( $term->term_id );
// Get category display type
$display_type = get_term_meta( $term_id, 'display_type' );
$display_type = get_term_meta( $term_id, 'display_type', true );
// Get category image
$image = '';
if ( $image_id = get_term_meta( $term_id, 'thumbnail_id' ) ) {
if ( $image_id = get_term_meta( $term_id, 'thumbnail_id', true ) ) {
$image = wp_get_attachment_url( $image_id );
}

View File

@ -666,11 +666,11 @@ class WC_API_Products extends WC_API_Resource {
$term_id = intval( $term->term_id );
// Get category display type
$display_type = get_term_meta( $term_id, 'display_type' );
$display_type = get_term_meta( $term_id, 'display_type', true );
// Get category image
$image = '';
if ( $image_id = get_term_meta( $term_id, 'thumbnail_id' ) ) {
if ( $image_id = get_term_meta( $term_id, 'thumbnail_id', true ) ) {
$image = wp_get_attachment_url( $image_id );
}

View File

@ -134,7 +134,7 @@ class WC_REST_Product_Attribute_Terms_V1_Controller extends WC_REST_Terms_Contro
*/
public function prepare_item_for_response( $item, $request ) {
// Get term order.
$menu_order = get_term_meta( $item->term_id, 'order_' . $this->taxonomy );
$menu_order = get_term_meta( $item->term_id, 'order_' . $this->taxonomy, true );
$data = array(
'id' => (int) $item->term_id,