Make WordPress Core


Ignore:
Timestamp:
01/26/2017 01:38:27 PM (7 years ago)
Author:
joehoyle
Message:

REST API: Unify object access handling for simplicity.

Rather than repeating ourselves, unifying the access into a single method keeps everything tidy. While we're at it, add in additional schema handling for common parameters.

See #38792.

File:
1 edited

Legend:

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

    r39923 r39954  
    4747    }
    4848
     49    if ( isset( $args['args'] ) ) {
     50        $common_args = $args['args'];
     51        unset( $args['args'] );
     52    } else {
     53        $common_args = array();
     54    }
     55
    4956    if ( isset( $args['callback'] ) ) {
    5057        // Upgrade a single set to multiple.
     
    5865    );
    5966    foreach ( $args as $key => &$arg_group ) {
    60         if ( ! is_numeric( $arg_group ) ) {
     67        if ( ! is_numeric( $key ) ) {
    6168            // Route option, skip here.
    6269            continue;
     
    6471
    6572        $arg_group = array_merge( $defaults, $arg_group );
     73        $arg_group['args'] = array_merge( $common_args, $arg_group['args'] );
    6674    }
    6775
Note: See TracChangeset for help on using the changeset viewer.