Make WordPress Core


Ignore:
Timestamp:
11/10/2016 02:20:09 AM (10 years ago)
Author:
joehoyle
Message:

REST API: Add rest_base to response objects of wp/v2/taxonomies and wp/v2/types

Though we have the _links.collection available, having this value can be useful to know post type / taxonomy urls if you need to build them another way.

Props youknowriad, jnylen0.
Fixes #38607.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php

    r38832 r39191  
    4646                $this->assertEquals( 'post_tag', $data['post_tag']['slug'] );
    4747                $this->assertEquals( false, $data['post_tag']['hierarchical'] );
     48                $this->assertEquals( 'tags', $data['post_tag']['rest_base'] );
    4849        }
    4950
    … …  
    135136                $data = $response->get_data();
    136137                $properties = $data['schema']['properties'];
    137                 $this->assertEquals( 8, count( $properties ) );
     138                $this->assertEquals( 9, count( $properties ) );
    138139                $this->assertArrayHasKey( 'capabilities', $properties );
    139140                $this->assertArrayHasKey( 'description', $properties );
    … …  
    144145                $this->assertArrayHasKey( 'show_cloud', $properties );
    145146                $this->assertArrayHasKey( 'types', $properties );
     147                $this->assertArrayHasKey( 'rest_base', $properties );
    146148        }
    147149
    … …  
    169171                $this->assertEquals( $tax_obj->description, $data['description'] );
    170172                $this->assertEquals( $tax_obj->hierarchical, $data['hierarchical'] );
     173                $this->assertEquals( $tax_obj->rest_base, $data['rest_base'] );
    171174                $this->assertEquals( rest_url( 'wp/v2/taxonomies' ), $links['collection'][0]['href'] );
    172175                $this->assertArrayHasKey( 'https://api.w.org/items', $links );
Note: See TracChangeset for help on using the changeset viewer.