]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/rest-api.php
WordPress 4.7.2
[autoinstalls/wordpress.git] / wp-includes / rest-api.php
index e5efb74fbe42dc830f3fdb1514aab21ee84ca59a..5b62d96fce1058ac15c17ab7c270988ed880e032 100644 (file)
@@ -46,6 +46,13 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
                return false;
        }
 
+       if ( isset( $args['args'] ) ) {
+               $common_args = $args['args'];
+               unset( $args['args'] );
+       } else {
+               $common_args = array();
+       }
+
        if ( isset( $args['callback'] ) ) {
                // Upgrade a single set to multiple.
                $args = array( $args );
@@ -57,12 +64,13 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f
                'args'            => array(),
        );
        foreach ( $args as $key => &$arg_group ) {
-               if ( ! is_numeric( $arg_group ) ) {
+               if ( ! is_numeric( $key ) ) {
                        // Route option, skip here.
                        continue;
                }
 
                $arg_group = array_merge( $defaults, $arg_group );
+               $arg_group['args'] = array_merge( $common_args, $arg_group['args'] );
        }
 
        $full_route = '/' . trim( $namespace, '/' ) . '/' . trim( $route, '/' );