WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/12/2018 02:11:22 AM (3 years ago)
Author:
jeremyfelt
Message:

REST API: Include permalink_template/generated_slug for Posts

In order for clients to present permalink previews, the REST API must share the computed results of get_sample_permalink(). These two values are now exposed as permalink_template and generated_slug for public, viewable post types, but only for context=edit.

Merges [43720] to trunk.

Props danielbachhuber, rahulsprajapati.
Fixes #45017.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php

    r43571 r43980  
    679679        $data       = $response->get_data();
    680680        $properties = $data['schema']['properties'];
    681         $this->assertEquals( 22, count( $properties ) );
     681        $this->assertEquals( 24, count( $properties ) );
    682682        $this->assertArrayHasKey( 'author', $properties );
    683683        $this->assertArrayHasKey( 'comment_status', $properties );
     
    685685        $this->assertArrayHasKey( 'date', $properties );
    686686        $this->assertArrayHasKey( 'date_gmt', $properties );
     687        $this->assertArrayHasKey( 'generated_slug', $properties );
    687688        $this->assertArrayHasKey( 'guid', $properties );
    688689        $this->assertArrayHasKey( 'excerpt', $properties );
     
    696697        $this->assertArrayHasKey( 'parent', $properties );
    697698        $this->assertArrayHasKey( 'password', $properties );
     699        $this->assertArrayHasKey( 'permalink_template', $properties );
    698700        $this->assertArrayHasKey( 'ping_status', $properties );
    699701        $this->assertArrayHasKey( 'slug', $properties );
Note: See TracChangeset for help on using the changeset viewer.