Changes the way of return attachments

To get attachments of item, do a get by item passing ?fetch_only=attachments
This commit is contained in:
weryques 2018-04-25 09:23:36 -03:00
parent 701b267d3c
commit 7bc0a0affd
3 changed files with 2427 additions and 2427 deletions

4838
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -98,15 +98,15 @@ class REST_Items_Controller extends REST_Controller {
$item_metadata = $item_object->get_fields();
foreach($item_metadata as $index => $me){
$field = $me->get_field();
$slug = $field->get_slug();
$field = $me->get_field();
$slug = $field->get_slug();
$item_metadata_array = $me->__toArray();
$item_array['metadata'][$slug]['name'] = $field->get_name();
$item_array['metadata'][$slug]['value'] = $item_metadata_array['value'];
$item_array['metadata'][$slug]['value_as_html'] = $item_metadata_array['value_as_html'];
$item_array['metadata'][$slug]['value_as_string'] = $item_metadata_array['value_as_string'];
$item_array['metadata'][$slug]['multiple'] = $field->get_multiple();
$item_array['metadata'][ $slug ]['name'] = $field->get_name();
$item_array['metadata'][ $slug ]['value'] = $item_metadata_array['value'];
$item_array['metadata'][ $slug ]['value_as_html'] = $item_metadata_array['value_as_html'];
$item_array['metadata'][ $slug ]['value_as_string'] = $item_metadata_array['value_as_string'];
$item_array['metadata'][ $slug ]['multiple'] = $field->get_multiple();
}
return $item_array;
@ -158,6 +158,7 @@ class REST_Items_Controller extends REST_Controller {
* @param \WP_REST_Request $request
*
* @return \WP_Error|\WP_REST_Response
* @throws \Exception
*/
public function get_items( $request ) {
$args = $this->prepare_filters($request);

View File

@ -54,7 +54,6 @@ class Item extends Entity {
$array_item['featured_image'] = $this->get_featured_image();
$array_item['featured_img_id'] = $this->get_featured_img_id();
$array_item['attachments'] = $this->get_attachments();
$array_item['author_name'] = $this->get_author_name();
return $array_item;