Make WordPress Core

Changeset 4129


Ignore:
Timestamp:
08/30/2006 05:41:38 AM (19 years ago)
Author:
ryan
Message:

Deprecate query_string. Add 'request' filter to filter the array of query vars. Pass around arrays instead of query strings. fixes #2777

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/classes.php

    r4122 r4129  
    9595        $this->query_vars = array();
    9696
    97         if (! empty($extra_query_vars))
     97        if ( is_array($extra_query_vars) )
     98            $this->extra_query_vars = & $extra_query_vars;
     99        else if (! empty($extra_query_vars))
    98100            parse_str($extra_query_vars, $this->extra_query_vars);
    99101
     
    213215            elseif (!empty($perma_query_vars[$wpvar]))
    214216                $this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
    215             else
    216                 $this->query_vars[$wpvar] = '';
    217         }
    218 
    219         for ($i=0; $i<count($this->private_query_vars); $i += 1) {
    220             $wpvar = $this->private_query_vars[$i];
    221             if (isset($this->extra_query_vars[$wpvar]))
    222                 $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];       
     217        }
     218
     219        foreach ($this->private_query_vars as $var) {
     220            if (isset($GLOBALS[$var]) && '' != $GLOBALS[$var] && ! isset($this->extra_query_vars[$var]) )
     221                $this->query_vars[$var] = $GLOBALS[$var];
    223222        }
    224223
    225224        if ( isset($error) )
    226225            $this->query_vars['error'] = $error;
     226
     227        $this->query_vars = apply_filters('request', $this->query_vars);
    227228
    228229        do_action('parse_request', array(&$this));
     
    273274    function build_query_string() {
    274275        $this->query_string = '';
    275 
    276276        foreach (array_keys($this->query_vars) as $wpvar) {
    277277            if ( '' != $this->query_vars[$wpvar] ) {
     
    281281        }
    282282
    283         foreach ($this->private_query_vars as $wpvar) {
    284             if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar] && ! isset($this->extra_query_vars[$wpvar]) ) {
    285                 $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
    286                 $this->query_string .= $wpvar . '=' . rawurlencode($GLOBALS[$wpvar]);
    287             }
    288         }
    289 
    290         $this->query_string = apply_filters('query_string', $this->query_string);
     283        // query_string filter deprecated.  Use request filter instead.
     284        global $wp_filter;
     285        if ( isset($wp_filter['query_string']) ) {  // Don't bother filtering and parsing if no plugins are hooked in.
     286            $this->query_string = apply_filters('query_string', $this->query_string);
     287            parse_str($this->query_string, $this->query_vars);
     288        }
    291289    }
    292290
     
    315313    function query_posts() {
    316314        $this->build_query_string();
    317         query_posts($this->query_string);
     315        query_posts($this->query_vars);
    318316    }
    319317
Note: See TracChangeset for help on using the changeset viewer.