WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/26/2017 01:46:54 PM (3 years ago)
Author:
ocean90
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.

Merge of [39954] to the 4.7 branch.

See #38792.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/rest-api.php

    r39401 r39957  
    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.