Plugin Directory

Changeset 715357

Timestamp:
05/19/2013 09:25:04 PM (11 years ago)
Author:
jkudish
Message:

REST API: fix metadata bugs

  • When we query posts by meta_value, the value was always being cast to an int, this makes sure it's cast to a string instead; which will still work with numbers.
  • When looping metadata that is being added to a post, make sure it's cast to an object, otherwise some requests will generate an error because the object is actually an array.
  • Fix an inaccurate comment
File:
1 edited

Legend:

Unmodified
Added
Removed
  • jetpack/trunk/class.json-api-endpoints.php

    r713159 r715357  
    11541154            return false;
    11551155
    1156         // whitelist of post types that can be accessed
     1156        // whitelist of that can be accessed
    11571157        if ( in_array( $key, apply_filters( 'rest_api_allowed_public_metadata', array() ) ) )
    11581158            return true;
     
    20102010        if ( ! empty( $metadata ) ) {
    20112011            foreach ( (array) $metadata as $meta ) {
     2012
     2013
    20122014
    20132015                $existing_meta_item = new stdClass;
     
    31123114        'search'   => '(string) Search query',
    31133115        'meta_key'   => '(string) Metadata key that the post should contain',
    3114         'meta_value'   => '(int|string) Metadata value that the post should contain. Will only be applied if a `meta_key` is also given',
     3116        'meta_value'   => '(string) Metadata value that the post should contain. Will only be applied if a `meta_key` is also given',
    31153117    ),
    31163118
Note: See TracChangeset for help on using the changeset viewer.