woocommerce/plugins/woocommerce-admin/includes/api/class-wc-admin-rest-product...

46 lines
784 B
PHP

<?php
/**
* REST API Products Controller
*
* Handles requests to /products/*
*
* @package WooCommerce Admin/API
*/
defined( 'ABSPATH' ) || exit;
/**
* Products controller.
*
* @package WooCommerce Admin/API
* @extends WC_REST_Products_Controller
*/
class WC_Admin_REST_Products_Controller extends WC_REST_Products_Controller {
/**
* Adds properties that can be embed via ?_embed=1.
*
* @return array
*/
public function get_item_schema() {
$schema = parent::get_item_schema();
$properties_to_embed = array(
'id',
'name',
'slug',
'permalink',
'images',
'description',
'short_description',
);
foreach ( $properties_to_embed as $property ) {
$schema['properties'][ $property ]['context'][] = 'embed';
}
return $schema;
}
}