Make WordPress Core

Ticket #39473: 39473-3.patch

File 39473-3.patch, 2.1 KB (added by ruud@…, 9 years ago)

Methods now public, added clarification about use of $route_map vs $endpoints

  • wp-includes/rest-api/class-wp-rest-server.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    7272         */
    7373        protected $endpoints = array();
    7474
     75        /**
     76         * The route map is an associative array with path regexes as the keys. The
     77         * value is an indexed array with the callback function/method as the first
     78         * item, and a bitmask of HTTP methods as the second item (see the class
     79         * constants).
     80         * $endpoints is the raw endpoints
     81         * $route_map is the  parsed, filtered and sanitized map from a regex to an endpoint.
     82         *
     83         * @access protected
     84         * @var array Route map of the routes
     85         */
     86        protected $route_map = array();
     87
    7588        /**
    7689         * Options defined for the routes.
    7790         *
     
    673686                }
    674687        }
    675688
     689        /**
     690         * Retrieves the internally stored route map.
     691         *
     692         * @access public
     693         *
     694         * @return array Route map of the routes.
     695         */
     696        public function get_route_map() {
     697                return $this->route_map;
     698        }
     699
     700        /**
     701         * Sets the internally stored route map.
     702         *
     703         * @access public
     704         *
     705         * @param array $route_map Route map of the routes.
     706         */
     707        public function set_route_map( $route_map ) {
     708                $this->route_map = $route_map;
     709        }
     710
    676711        /**
    677712         * Retrieves the route map.
    678713         *
     714         * Caches the results internally.
     715         * see $route_map
     716         *
    679717         * The route map is an associative array with path regexes as the keys. The
    680718         * value is an indexed array with the callback function/method as the first
    681719         * item, and a bitmask of HTTP methods as the second item (see the class
     
    695733         *               `'/path/regex' => array( array( $callback, $bitmask ), ...)`.
    696734         */
    697735        public function get_routes() {
     736                $endpoints = $this->get_route_map();
     737
     738                if ( ! empty( $endpoints ) ) {
     739                        return $endpoints;
     740                }
    698741
    699742                /**
    700743                 * Filters the array of available endpoints.
     
    756799                                }
    757800                        }
    758801                }
     802                $this->set_route_map( $endpoints );
    759803
    760804                return $endpoints;
    761805        }