[wp-trac] [WordPress Trac] #45017: REST API: Expose permalink_template in the Posts controller
WordPress Trac
noreply at wordpress.org
Wed Oct 3 12:12:57 UTC 2018
#45017: REST API: Expose permalink_template in the Posts controller
------------------------------------------+-----------------------
Reporter: danielbachhuber | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 5.0
Component: REST API | Version:
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses: rest-api
------------------------------------------+-----------------------
Description changed by danielbachhuber:
Old description:
> In [https://github.com/WordPress/gutenberg/pull/5756
> WordPress/gutenberg#5756], editable permalink previews landed in
> Gutenberg.
>
> We need to take this same information and expose it on the Posts
> controller:
>
> {{{
> function gutenberg_add_permalink_template_to_posts( $response, $post,
> $request ) {
> if ( 'edit' !== $request['context'] ) {
> return $response;
> }
>
> if ( ! function_exists( 'get_sample_permalink' ) ) {
> require_once ABSPATH . '/wp-admin/includes/post.php';
> }
>
> $sample_permalink = get_sample_permalink( $post->ID,
> $post->post_title, '' );
>
> $response->data['permalink_template'] = $sample_permalink[0];
> $response->data['generated_slug'] = $sample_permalink[1];
>
> return $response;
> }
> }}}
>
> This data should reflect the assumptions already established in `edit-
> form-advanced.php` (e.g. post type must be viewable and public).
New description:
In [https://github.com/WordPress/gutenberg/pull/5756
WordPress/gutenberg#5756], editable permalink previews landed in
Gutenberg.
We need to take this same information and expose it on the Posts
controller:
{{{
function gutenberg_add_permalink_template_to_posts( $response, $post,
$request ) {
if ( 'edit' !== $request['context'] ) {
return $response;
}
if ( ! function_exists( 'get_sample_permalink' ) ) {
require_once ABSPATH . '/wp-admin/includes/post.php';
}
$sample_permalink = get_sample_permalink( $post->ID,
$post->post_title, '' );
$response->data['permalink_template'] = $sample_permalink[0];
$response->data['generated_slug'] = $sample_permalink[1];
return $response;
}
}}}
This data should reflect the assumptions already established in `edit-
form-advanced.php` (e.g. post type must be viewable and public).
Related #41014
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45017#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list