Make WordPress Core

Changeset 43834


Ignore:
Timestamp:
10/29/2018 12:47:01 AM (6 years ago)
Author:
danielbachhuber
Message:

REST API: Improve performance by avoiding call_user_func().

The get_compact_response_links() method was introduced in WP 4.5, and this conditional is no longer necessary.

Props schlessera, timothyblynjacobs.
Fixes #45189.

Location:
branches/5.0/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/rest-api.php

    r43833 r43834  
    13691369        $server = rest_get_server();
    13701370        $data   = (array) $response->get_data();
    1371         if ( method_exists( $server, 'get_compact_response_links' ) ) {
    1372             $links = call_user_func( array( $server, 'get_compact_response_links' ), $response );
    1373         } else {
    1374             $links = call_user_func( array( $server, 'get_response_links' ), $response );
    1375         }
     1371        $links  = $server->get_compact_response_links( $response );
    13761372        if ( ! empty( $links ) ) {
    13771373            $data['_links'] = $links;
  • branches/5.0/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php

    r43736 r43834  
    213213        $data   = (array) $response->get_data();
    214214        $server = rest_get_server();
    215 
    216         if ( method_exists( $server, 'get_compact_response_links' ) ) {
    217             $links = call_user_func( array( $server, 'get_compact_response_links' ), $response );
    218         } else {
    219             $links = call_user_func( array( $server, 'get_response_links' ), $response );
    220         }
     215        $links  = $server->get_compact_response_links( $response );
    221216
    222217        if ( ! empty( $links ) ) {
Note: See TracChangeset for help on using the changeset viewer.