- Timestamp:
- 04/30/2024 09:31:41 AM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r57648 r58065 98 98 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 99 99 ); 100 if ( isset( $schema['properties']['excerpt'] ) ) { 101 $get_item_args['excerpt_length'] = array( 102 'description' => __( 'Override the default excerpt length.' ), 103 'type' => 'integer', 104 ); 105 } 100 106 if ( isset( $schema['properties']['password'] ) ) { 101 107 $get_item_args['password'] = array( … … 1873 1879 1874 1880 if ( rest_is_field_included( 'excerpt', $fields ) ) { 1881 if ( isset( $request['excerpt_length'] ) ) { 1882 $excerpt_length = $request['excerpt_length']; 1883 $override_excerpt_length = static function () use ( $excerpt_length ) { 1884 return $excerpt_length; 1885 }; 1886 1887 add_filter( 1888 'excerpt_length', 1889 $override_excerpt_length, 1890 20 1891 ); 1892 } 1893 1875 1894 /** This filter is documented in wp-includes/post-template.php */ 1876 1895 $excerpt = apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ); … … 1884 1903 'protected' => (bool) $post->post_password, 1885 1904 ); 1905 1906 if ( isset( $override_excerpt_length ) ) { 1907 remove_filter( 1908 'excerpt_length', 1909 $override_excerpt_length, 1910 20 1911 ); 1912 } 1886 1913 } 1887 1914
Note: See TracChangeset
for help on using the changeset viewer.