Changeset 39154 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
- Timestamp:
- 11/08/2016 04:28:47 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r39105 r39154 248 248 $prepared_attachment = parent::prepare_item_for_database( $request ); 249 249 250 // Attachment caption (post_excerpt internally) 250 251 if ( isset( $request['caption'] ) ) { 251 $prepared_attachment->post_excerpt = $request['caption']; 252 } 253 252 if ( is_string( $request['caption'] ) ) { 253 $prepared_attachment->post_excerpt = wp_filter_post_kses( $request['caption'] ); 254 } elseif ( isset( $request['caption']['raw'] ) ) { 255 $prepared_attachment->post_excerpt = wp_filter_post_kses( $request['caption']['raw'] ); 256 } 257 } 258 259 // Attachment description (post_content internally) 254 260 if ( isset( $request['description'] ) ) { 255 $prepared_attachment->post_content = $request['description']; 261 if ( is_string( $request['description'] ) ) { 262 $prepared_attachment->post_content = wp_filter_post_kses( $request['description'] ); 263 } elseif ( isset( $request['description']['raw'] ) ) { 264 $prepared_attachment->post_content = wp_filter_post_kses( $request['description']['raw'] ); 265 } 256 266 } 257 267 … … 277 287 $data = $response->get_data(); 278 288 289 $data['description'] = array( 290 'raw' => $post->post_content, 291 /** This filter is documented in wp-includes/post-template.php */ 292 'rendered' => apply_filters( 'the_content', $post->post_content ), 293 ); 294 295 /** This filter is documented in wp-includes/post-template.php */ 296 $caption = apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ) ); 297 $data['caption'] = array( 298 'raw' => $post->post_excerpt, 299 'rendered' => $caption, 300 ); 301 279 302 $data['alt_text'] = get_post_meta( $post->ID, '_wp_attachment_image_alt', true ); 280 $data['caption'] = $post->post_excerpt;281 $data['description'] = $post->post_content;282 303 $data['media_type'] = wp_attachment_is_image( $post->ID ) ? 'image' : 'file'; 283 304 $data['mime_type'] = $post->post_mime_type; … … 367 388 368 389 $schema['properties']['caption'] = array( 369 'description' 370 'type' => 'string',371 'context' => array( 'view', 'edit' ),372 'arg_options' 373 'sanitize_callback' => 'wp_filter_post_kses',390 'description' => __( 'The caption for the resource.' ), 391 'type' => 'object', 392 'context' => array( 'view', 'edit', 'embed' ), 393 'arg_options' => array( 394 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database() 374 395 ), 396 'properties' => array( 397 'raw' => array( 398 'description' => __( 'Caption for the resource, as it exists in the database.' ), 399 'type' => 'string', 400 'context' => array( 'edit' ), 401 ), 402 'rendered' => array( 403 'description' => __( 'HTML caption for the resource, transformed for display.' ), 404 'type' => 'string', 405 'context' => array( 'view', 'edit', 'embed' ), 406 'readonly' => true, 407 ), 408 ), 375 409 ); 376 410 377 411 $schema['properties']['description'] = array( 378 'description' => __( 'The description for the resource.' ), 379 'type' => 'string', 380 'context' => array( 'view', 'edit' ), 381 'arg_options' => array( 382 'sanitize_callback' => 'wp_filter_post_kses', 412 'description' => __( 'The description for the resource.' ), 413 'type' => 'object', 414 'context' => array( 'view', 'edit' ), 415 'arg_options' => array( 416 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database() 417 ), 418 'properties' => array( 419 'raw' => array( 420 'description' => __( 'Description for the object, as it exists in the database.' ), 421 'type' => 'string', 422 'context' => array( 'edit' ), 423 ), 424 'rendered' => array( 425 'description' => __( 'HTML description for the object, transformed for display.' ), 426 'type' => 'string', 427 'context' => array( 'view', 'edit' ), 428 'readonly' => true, 429 ), 383 430 ), 384 431 );
Note: See TracChangeset
for help on using the changeset viewer.