Make WordPress Core

Ticket #9458: 9458-better.diff

File 9458-better.diff, 9.7 KB (added by Denis-de-Bernardy, 17 years ago)
  • Users/denis/Sites/sem-pro/wp-includes/query.php

     
    2222 * @return mixed
    2323 */
    2424function get_query_var($var) {
    25         global $wp_query;
     25        global $wp_the_query;
    2626
    27         return $wp_query->get($var);
     27        return $wp_the_query->get($var);
    2828}
    2929
    3030/**
     
    3939 * @return null
    4040 */
    4141function set_query_var($var, $value) {
    42         global $wp_query;
     42        global $wp_the_query;
    4343
    44         return $wp_query->set($var, $value);
     44        return $wp_the_query->set($var, $value);
    4545}
    4646
    4747/**
     
    111111 * @return bool True if page is archive.
    112112 */
    113113function is_archive () {
    114         global $wp_query;
     114        global $wp_the_query;
    115115
    116         return $wp_query->is_archive;
     116        return $wp_the_query->is_archive;
    117117}
    118118
    119119/**
     
    125125 * @return bool True if page is attachment.
    126126 */
    127127function is_attachment () {
    128         global $wp_query;
     128        global $wp_the_query;
    129129
    130         return $wp_query->is_attachment;
     130        return $wp_the_query->is_attachment;
    131131}
    132132
    133133/**
     
    151151 * @return bool True if page is author or $author (if set).
    152152 */
    153153function is_author ($author = '') {
    154         global $wp_query;
     154        global $wp_the_query;
    155155
    156         if ( !$wp_query->is_author )
     156        if ( !$wp_the_query->is_author )
    157157                return false;
    158158
    159159        if ( empty($author) )
    160160                return true;
    161161
    162         $author_obj = $wp_query->get_queried_object();
     162        $author_obj = $wp_the_query->get_queried_object();
    163163
    164164        $author = (array) $author;
    165165
     
    186186 * @return bool
    187187 */
    188188function is_category ($category = '') {
    189         global $wp_query;
     189        global $wp_the_query;
    190190
    191         if ( !$wp_query->is_category )
     191        if ( !$wp_the_query->is_category )
    192192                return false;
    193193
    194194        if ( empty($category) )
    195195                return true;
    196196
    197         $cat_obj = $wp_query->get_queried_object();
     197        $cat_obj = $wp_the_query->get_queried_object();
    198198
    199199        $category = (array) $category;
    200200
     
    218218 * @return bool
    219219 */
    220220function is_tag( $slug = '' ) {
    221         global $wp_query;
     221        global $wp_the_query;
    222222
    223         if ( !$wp_query->is_tag )
     223        if ( !$wp_the_query->is_tag )
    224224                return false;
    225225
    226226        if ( empty( $slug ) )
    227227                return true;
    228228
    229         $tag_obj = $wp_query->get_queried_object();
     229        $tag_obj = $wp_the_query->get_queried_object();
    230230
    231231        $slug = (array) $slug;
    232232
     
    246246 * @return bool
    247247 */
    248248function is_tax( $slug = '' ) {
    249         global $wp_query;
     249        global $wp_the_query;
    250250
    251         if ( !$wp_query->is_tax )
     251        if ( !$wp_the_query->is_tax )
    252252                return false;
    253253
    254254        if ( empty($slug) )
    255255                return true;
    256256
    257         $term = $wp_query->get_queried_object();
     257        $term = $wp_the_query->get_queried_object();
    258258
    259259        $slug = (array) $slug;
    260260
     
    273273 * @return bool
    274274 */
    275275function is_comments_popup () {
    276         global $wp_query;
     276        global $wp_the_query;
    277277
    278         return $wp_query->is_comments_popup;
     278        return $wp_the_query->is_comments_popup;
    279279}
    280280
    281281/**
     
    287287 * @return bool
    288288 */
    289289function is_date () {
    290         global $wp_query;
     290        global $wp_the_query;
    291291
    292         return $wp_query->is_date;
     292        return $wp_the_query->is_date;
    293293}
    294294
    295295/**
     
    301301 * @return bool
    302302 */
    303303function is_day () {
    304         global $wp_query;
     304        global $wp_the_query;
    305305
    306         return $wp_query->is_day;
     306        return $wp_the_query->is_day;
    307307}
    308308
    309309/**
     
    315315 * @return bool
    316316 */
    317317function is_feed () {
    318         global $wp_query;
     318        global $wp_the_query;
    319319
    320         return $wp_query->is_feed;
     320        return $wp_the_query->is_feed;
    321321}
    322322
    323323/**
     
    348348 * @return bool True if blog view homepage.
    349349 */
    350350function is_home () {
    351         global $wp_query;
     351        global $wp_the_query;
    352352
    353         return $wp_query->is_home;
     353        return $wp_the_query->is_home;
    354354}
    355355
    356356/**
     
    362362 * @return bool
    363363 */
    364364function is_month () {
    365         global $wp_query;
     365        global $wp_the_query;
    366366
    367         return $wp_query->is_month;
     367        return $wp_the_query->is_month;
    368368}
    369369
    370370/**
     
    385385 * @return bool
    386386 */
    387387function is_page ($page = '') {
    388         global $wp_query;
     388        global $wp_the_query;
    389389
    390         if ( !$wp_query->is_page )
     390        if ( !$wp_the_query->is_page )
    391391                return false;
    392392
    393393        if ( empty($page) )
    394394                return true;
    395395
    396         $page_obj = $wp_query->get_queried_object();
     396        $page_obj = $wp_the_query->get_queried_object();
    397397
    398398        $page = (array) $page;
    399399
     
    416416 * @return bool
    417417 */
    418418function is_paged () {
    419         global $wp_query;
     419        global $wp_the_query;
    420420
    421         return $wp_query->is_paged;
     421        return $wp_the_query->is_paged;
    422422}
    423423
    424424/**
     
    450450 * @return bool
    451451 */
    452452function is_preview() {
    453         global $wp_query;
     453        global $wp_the_query;
    454454
    455         return $wp_query->is_preview;
     455        return $wp_the_query->is_preview;
    456456}
    457457
    458458/**
     
    464464 * @return bool
    465465 */
    466466function is_robots() {
    467         global $wp_query;
     467        global $wp_the_query;
    468468
    469         return $wp_query->is_robots;
     469        return $wp_the_query->is_robots;
    470470}
    471471
    472472/**
     
    478478 * @return bool
    479479 */
    480480function is_search () {
    481         global $wp_query;
     481        global $wp_the_query;
    482482
    483         return $wp_query->is_search;
     483        return $wp_the_query->is_search;
    484484}
    485485
    486486/**
     
    499499 * @return bool
    500500 */
    501501function is_single ($post = '') {
    502         global $wp_query;
     502        global $wp_the_query;
    503503
    504         if ( !$wp_query->is_single )
     504        if ( !$wp_the_query->is_single )
    505505                return false;
    506506
    507507        if ( empty( $post) )
    508508                return true;
    509509
    510         $post_obj = $wp_query->get_queried_object();
     510        $post_obj = $wp_the_query->get_queried_object();
    511511
    512512        $post = (array) $post;
    513513
     
    530530 * @return bool
    531531 */
    532532function is_singular() {
    533         global $wp_query;
     533        global $wp_the_query;
    534534
    535         return $wp_query->is_singular;
     535        return $wp_the_query->is_singular;
    536536}
    537537
    538538/**
     
    544544 * @return bool
    545545 */
    546546function is_time () {
    547         global $wp_query;
     547        global $wp_the_query;
    548548
    549         return $wp_query->is_time;
     549        return $wp_the_query->is_time;
    550550}
    551551
    552552/**
     
    558558 * @return bool
    559559 */
    560560function is_trackback () {
    561         global $wp_query;
     561        global $wp_the_query;
    562562
    563         return $wp_query->is_trackback;
     563        return $wp_the_query->is_trackback;
    564564}
    565565
    566566/**
     
    572572 * @return bool
    573573 */
    574574function is_year () {
    575         global $wp_query;
     575        global $wp_the_query;
    576576
    577         return $wp_query->is_year;
     577        return $wp_the_query->is_year;
    578578}
    579579
    580580/**
     
    586586 * @return bool True, if nothing is found matching WordPress Query.
    587587 */
    588588function is_404 () {
    589         global $wp_query;
     589        global $wp_the_query;
    590590
    591         return $wp_query->is_404;
     591        return $wp_the_query->is_404;
    592592}
    593593
    594594/*
     
    605605 * @return bool
    606606 */
    607607function have_posts() {
    608         global $wp_query;
     608        global $wp_the_query;
    609609
    610         return $wp_query->have_posts();
     610        return $wp_the_query->have_posts();
    611611}
    612612
    613613/**
     
    619619 * @return bool True if caller is within loop, false if loop hasn't started or ended.
    620620 */
    621621function in_the_loop() {
    622         global $wp_query;
     622        global $wp_the_query;
    623623
    624         return $wp_query->in_the_loop;
     624        return $wp_the_query->in_the_loop;
    625625}
    626626
    627627/**
     
    634634 * @return null
    635635 */
    636636function rewind_posts() {
    637         global $wp_query;
     637        global $wp_the_query;
    638638
    639         return $wp_query->rewind_posts();
     639        return $wp_the_query->rewind_posts();
    640640}
    641641
    642642/**
     
    647647 * @uses $wp_query
    648648 */
    649649function the_post() {
    650         global $wp_query;
     650        global $wp_the_query;
    651651
    652         $wp_query->the_post();
     652        $wp_the_query->the_post();
    653653}
    654654
    655655/*
     
    666666 * @return bool
    667667 */
    668668function have_comments() {
    669         global $wp_query;
    670         return $wp_query->have_comments();
     669        global $wp_the_query;
     670        return $wp_the_query->have_comments();
    671671}
    672672
    673673/**
     
    680680 * @return object
    681681 */
    682682function the_comment() {
    683         global $wp_query;
    684         return $wp_query->the_comment();
     683        global $wp_the_query;
     684        return $wp_the_query->the_comment();
    685685}
    686686
    687687/*
     
    23692369         */
    23702370        function the_post() {
    23712371                global $post;
     2372                global $wp_the_query;
    23722373                $this->in_the_loop = true;
    23732374                $post = $this->next_post();
    23742375                setup_postdata($post);
    23752376
    2376                 if ( $this->current_post == 0 ) // loop has just started
     2377                if ( $this->current_post == 0 && $this === $wp_the_query ) // loop has just started
    23772378                        do_action('loop_start');
    23782379        }
    23792380
     
    23922393                if ($this->current_post + 1 < $this->post_count) {
    23932394                        return true;
    23942395                } elseif ($this->current_post + 1 == $this->post_count && $this->post_count > 0) {
    2395                         do_action('loop_end');
     2396                        global $wp_the_query;
     2397                        if ( $this === $wp_the_query )
     2398                                do_action('loop_end');
    23962399                        // Do some cleaning up after the loop
    23972400                        $this->rewind_posts();
    23982401                }
     
    26042607 * @return null If no link is found, null is returned.
    26052608 */
    26062609function wp_old_slug_redirect () {
    2607         global $wp_query;
    2608         if ( is_404() && '' != $wp_query->query_vars['name'] ) :
     2610        global $wp_the_query;
     2611        if ( is_404() && '' != $wp_the_query->query_vars['name'] ) :
    26092612                global $wpdb;
    26102613
    2611                 $query = "SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND meta_key = '_wp_old_slug' AND meta_value='" . $wp_query->query_vars['name'] . "'";
     2614                $query = "SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND meta_key = '_wp_old_slug' AND meta_value='" . $wp_the_query->query_vars['name'] . "'";
    26122615
    26132616                // if year, monthnum, or day have been specified, make our query more precise
    26142617                // just in case there are multiple identical _wp_old_slug values
    2615                 if ( '' != $wp_query->query_vars['year'] )
    2616                         $query .= " AND YEAR(post_date) = '{$wp_query->query_vars['year']}'";
    2617                 if ( '' != $wp_query->query_vars['monthnum'] )
    2618                         $query .= " AND MONTH(post_date) = '{$wp_query->query_vars['monthnum']}'";
    2619                 if ( '' != $wp_query->query_vars['day'] )
    2620                         $query .= " AND DAYOFMONTH(post_date) = '{$wp_query->query_vars['day']}'";
     2618                if ( '' != $wp_the_query->query_vars['year'] )
     2619                        $query .= " AND YEAR(post_date) = '{$wp_the_query->query_vars['year']}'";
     2620                if ( '' != $wp_the_query->query_vars['monthnum'] )
     2621                        $query .= " AND MONTH(post_date) = '{$wp_the_query->query_vars['monthnum']}'";
     2622                if ( '' != $wp_the_query->query_vars['day'] )
     2623                        $query .= " AND DAYOFMONTH(post_date) = '{$wp_the_query->query_vars['day']}'";
    26212624
    26222625                $id = (int) $wpdb->get_var($query);
    26232626