Changeset 36533 for trunk/src/wp-includes/rest-api/class-wp-rest-server.php
- Timestamp:
- 02/16/2016 02:18:34 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r35773 r36533 461 461 // Convert links to part of the data. 462 462 $data = array(); 463 $curies = $response->get_curies(); 464 $used_curies = array(); 465 463 466 foreach ( $links as $rel => $items ) { 467 468 // Convert $rel URIs to their compact versions if they exist. 469 foreach ( $curies as $curie ) { 470 $href_prefix = substr( $curie['href'], 0, strpos( $curie['href'], '{rel}' ) ); 471 if ( strpos( $rel, $href_prefix ) !== 0 ) { 472 continue; 473 } 474 $used_curies[ $curie['name'] ] = $curie; 475 476 // Relation now changes from '$uri' to '$curie:$relation' 477 $rel_regex = str_replace( '\{rel\}', '([\w]+)', preg_quote( $curie['href'], '!' ) ); 478 preg_match( '!' . $rel_regex . '!', $rel, $matches ); 479 if ( $matches ) { 480 $rel = $curie['name'] . ':' . $matches[1]; 481 } 482 break; 483 } 484 464 485 $data[ $rel ] = array(); 465 486 … … 469 490 $data[ $rel ][] = $attributes; 470 491 } 492 } 493 494 // Push the curies onto the start of the links array. 495 if ( $used_curies ) { 496 $data = array_merge( array( 'curies' => array_values( $used_curies ) ), $data ); 471 497 } 472 498
Note: See TracChangeset
for help on using the changeset viewer.