Make WordPress Core


Ignore:
Timestamp:
07/23/2024 07:49:54 AM (10 months ago)
Author:
youknowriad
Message:

REST API: Remove post status prefix from REST API responses.

When using the /posts or /pages endpoints, for private posts or pages, you get the following title property: { raw: "Some title", rendered: "Private: Some title" }
this commit removes the prefix from rendered private posts titles (just like what we do for protected posts)

Props youknowriad, swissspidy, timothyblynjacobs, sergeybiryukov, ramonopoly.
Fixes #61639.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php

    r58466 r58783  
    328328        if ( rest_is_field_included( 'title.rendered', $fields ) ) {
    329329            add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
     330            add_filter( 'private_title_format', array( $this, 'protected_title_format' ) );
    330331
    331332            $data['title']['rendered'] = get_the_title( $post->ID );
    332333
    333334            remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
     335            remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) );
    334336        }
    335337
Note: See TracChangeset for help on using the changeset viewer.