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-menu-items-controller.php

    r56415 r58783  
    511511        if ( rest_is_field_included( 'title.rendered', $fields ) ) {
    512512            add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
     513            add_filter( 'private_title_format', array( $this, 'protected_title_format' ) );
    513514
    514515            /** This filter is documented in wp-includes/post-template.php */
     
    518519
    519520            remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
     521            remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) );
    520522        }
    521523
Note: See TracChangeset for help on using the changeset viewer.