WordPress.org

Make WordPress Core

Changeset 27327


Ignore:
Timestamp:
02/28/2014 08:54:05 PM (7 years ago)
Author:
johnbillion
Message:

Allow rewrite endpoints to specify a query variable name. Fixes #20905.

File:
1 edited

Legend:

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

    r26644 r27327  
    251251 * @param string $name Name of the endpoint.
    252252 * @param int $places Endpoint mask describing the places the endpoint should be added.
    253  */
    254 function add_rewrite_endpoint( $name, $places ) {
     253 * @param string $query_var Name of the corresponding query variable. Defaults to $name.
     254 */
     255function add_rewrite_endpoint( $name, $places, $query_var = null ) {
    255256    global $wp_rewrite;
    256     $wp_rewrite->add_endpoint( $name, $places );
     257    $wp_rewrite->add_endpoint( $name, $places, $query_var );
    257258}
    258259
     
    12661267                $epmatch = $endpoint[1] . '(/(.*))?/?$';
    12671268                //this will be appended on to the rest of the query for each dir
    1268                 $epquery = '&' . $endpoint[1] . '=';
     1269                $epquery = '&' . $endpoint[2] . '=';
    12691270                $ep_query_append[$epmatch] = array ( $endpoint[0], $epquery );
    12701271            }
     
    18231824     * @see add_rewrite_endpoint()
    18241825     * @since 2.1.0
     1826     * @since 3.9.0 $query_var parameter added.
    18251827     * @access public
    18261828     * @uses WP::add_query_var()
     
    18281830     * @param string $name Name of the endpoint.
    18291831     * @param int $places Endpoint mask describing the places the endpoint should be added.
    1830      */
    1831     function add_endpoint($name, $places) {
     1832     * @param string $query_var Name of the corresponding query variable. Defaults to $name.
     1833     */
     1834    function add_endpoint( $name, $places, $query_var = null ) {
    18321835        global $wp;
    1833         $this->endpoints[] = array ( $places, $name );
    1834         $wp->add_query_var($name);
     1836        if ( null === $query_var ) {
     1837            $query_var = $name;
     1838        }
     1839        $this->endpoints[] = array( $places, $name, $query_var );
     1840        $wp->add_query_var( $query_var );
    18351841    }
    18361842
Note: See TracChangeset for help on using the changeset viewer.