WordPress.org

Make WordPress Core

Ticket #20905: 20905.patch

File 20905.patch, 1.7 KB (added by johnbillion, 6 years ago)
  • wp-includes/rewrite.php

     
    243243 *
    244244 * @param string $name Name of the endpoint.
    245245 * @param int $places Endpoint mask describing the places the endpoint should be added.
     246 * @param string $query_var Name of the corresponding query variable. Defaults to $name.
    246247 */
    247 function add_rewrite_endpoint( $name, $places ) {
     248function add_rewrite_endpoint( $name, $places, $query_var = null ) {
    248249        global $wp_rewrite;
    249         $wp_rewrite->add_endpoint( $name, $places );
     250        $wp_rewrite->add_endpoint( $name, $places, $query_var );
    250251}
    251252
    252253/**
     
    12461247                                //match everything after the endpoint name, but allow for nothing to appear there
    12471248                                $epmatch = $endpoint[1] . '(/(.*))?/?$';
    12481249                                //this will be appended on to the rest of the query for each dir
    1249                                 $epquery = '&' . $endpoint[1] . '=';
     1250                                $epquery = '&' . $endpoint[2] . '=';
    12501251                                $ep_query_append[$epmatch] = array ( $endpoint[0], $epquery );
    12511252                        }
    12521253                }
     
    18631864         *
    18641865         * @param string $name Name of the endpoint.
    18651866         * @param int $places Endpoint mask describing the places the endpoint should be added.
     1867         * @param string $query_var Name of the corresponding query variable. Defaults to $name.
    18661868         */
    1867         function add_endpoint($name, $places) {
     1869        function add_endpoint( $name, $places, $query_var = null ) {
    18681870                global $wp;
    1869                 $this->endpoints[] = array ( $places, $name );
    1870                 $wp->add_query_var($name);
     1871                if ( empty( $query_var ) )
     1872                        $query_var = $name;
     1873                $this->endpoints[] = array ( $places, $name, $query_var );
     1874                $wp->add_query_var( $query_var );
    18711875        }
    18721876
    18731877        /**