Changeset 58783
- Timestamp:
- 07/23/2024 07:49:54 AM (9 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php
r58466 r58783 328 328 if ( rest_is_field_included( 'title.rendered', $fields ) ) { 329 329 add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 330 add_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 330 331 331 332 $data['title']['rendered'] = get_the_title( $post->ID ); 332 333 333 334 remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 335 remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 334 336 } 335 337 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php
r56415 r58783 511 511 if ( rest_is_field_included( 'title.rendered', $fields ) ) { 512 512 add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 513 add_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 513 514 514 515 /** This filter is documented in wp-includes/post-template.php */ … … 518 519 519 520 remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 521 remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 520 522 } 521 523 -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r58706 r58783 1845 1845 if ( rest_is_field_included( 'title.rendered', $fields ) ) { 1846 1846 add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 1847 add_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 1847 1848 1848 1849 $data['title']['rendered'] = get_the_title( $post->ID ); 1849 1850 1850 1851 remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 1852 remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 1851 1853 } 1852 1854 … … 2048 2050 2049 2051 /** 2050 * Overwrites the default protected title format.2051 * 2052 * By default, WordPress will show password protected posts with a title of2053 * "Protected: %s" , as the REST API communicates the protectedstatus of a post2054 * in a machine-readable format, we remove the "Protected: "prefix.2055 * 2056 * @since 4.7.0 2057 * 2058 * @return string Protected title format.2052 * Overwrites the default protected and private title format. 2053 * 2054 * By default, WordPress will show password protected or private posts with a title of 2055 * "Protected: %s" or "Private: %s", as the REST API communicates the status of a post 2056 * in a machine-readable format, we remove the prefix. 2057 * 2058 * @since 4.7.0 2059 * 2060 * @return string Title format. 2059 2061 */ 2060 2062 public function protected_title_format() { -
trunk/src/wp-includes/rest-api/search/class-wp-rest-post-search-handler.php
r58706 r58783 133 133 if ( post_type_supports( $post->post_type, 'title' ) ) { 134 134 add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 135 add_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 135 136 $data[ WP_REST_Search_Controller::PROP_TITLE ] = get_the_title( $post->ID ); 136 137 remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 138 remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 137 139 } else { 138 140 $data[ WP_REST_Search_Controller::PROP_TITLE ] = ''; … … 184 186 185 187 /** 186 * Overwrites the default protected title format.187 * 188 * By default, WordPress will show password protected posts with a title of189 * "Protected: %s" . As the REST API communicates the protectedstatus of a post190 * in a machine-readable format, we remove the "Protected: "prefix.191 * 192 * @since 5.0.0 193 * 194 * @return string Protected title format.188 * Overwrites the default protected and private title format. 189 * 190 * By default, WordPress will show password protected or private posts with a title of 191 * "Protected: %s" or "Private: %s", as the REST API communicates the status of a post 192 * in a machine-readable format, we remove the prefix. 193 * 194 * @since 5.0.0 195 * 196 * @return string Title format. 195 197 */ 196 198 public function protected_title_format() { -
trunk/tests/phpunit/includes/testcase-rest-post-type-controller.php
r57603 r58783 108 108 if ( post_type_supports( $post->post_type, 'title' ) ) { 109 109 add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 110 add_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 110 111 $this->assertSame( get_the_title( $post->ID ), $data['title']['rendered'] ); 111 112 remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 113 remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 112 114 if ( 'edit' === $context ) { 113 115 $this->assertSame( $post->post_title, $data['title']['raw'] ); -
trunk/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php
r58065 r58783 863 863 if ( post_type_supports( self::POST_TYPE, 'title' ) ) { 864 864 add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 865 add_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 865 866 $this->assertSame( $post->title, $data['title']['rendered'] ); 866 867 remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) ); 868 remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) ); 867 869 if ( 'edit' === $context ) { 868 870 $this->assertSame( $post->title, $data['title']['raw'] );
Note: See TracChangeset
for help on using the changeset viewer.