Ticket #9458: 9458-better.diff
| File 9458-better.diff, 9.7 KB (added by , 17 years ago) |
|---|
-
Users/denis/Sites/sem-pro/wp-includes/query.php
22 22 * @return mixed 23 23 */ 24 24 function get_query_var($var) { 25 global $wp_ query;25 global $wp_the_query; 26 26 27 return $wp_ query->get($var);27 return $wp_the_query->get($var); 28 28 } 29 29 30 30 /** … … 39 39 * @return null 40 40 */ 41 41 function set_query_var($var, $value) { 42 global $wp_ query;42 global $wp_the_query; 43 43 44 return $wp_ query->set($var, $value);44 return $wp_the_query->set($var, $value); 45 45 } 46 46 47 47 /** … … 111 111 * @return bool True if page is archive. 112 112 */ 113 113 function is_archive () { 114 global $wp_ query;114 global $wp_the_query; 115 115 116 return $wp_ query->is_archive;116 return $wp_the_query->is_archive; 117 117 } 118 118 119 119 /** … … 125 125 * @return bool True if page is attachment. 126 126 */ 127 127 function is_attachment () { 128 global $wp_ query;128 global $wp_the_query; 129 129 130 return $wp_ query->is_attachment;130 return $wp_the_query->is_attachment; 131 131 } 132 132 133 133 /** … … 151 151 * @return bool True if page is author or $author (if set). 152 152 */ 153 153 function is_author ($author = '') { 154 global $wp_ query;154 global $wp_the_query; 155 155 156 if ( !$wp_ query->is_author )156 if ( !$wp_the_query->is_author ) 157 157 return false; 158 158 159 159 if ( empty($author) ) 160 160 return true; 161 161 162 $author_obj = $wp_ query->get_queried_object();162 $author_obj = $wp_the_query->get_queried_object(); 163 163 164 164 $author = (array) $author; 165 165 … … 186 186 * @return bool 187 187 */ 188 188 function is_category ($category = '') { 189 global $wp_ query;189 global $wp_the_query; 190 190 191 if ( !$wp_ query->is_category )191 if ( !$wp_the_query->is_category ) 192 192 return false; 193 193 194 194 if ( empty($category) ) 195 195 return true; 196 196 197 $cat_obj = $wp_ query->get_queried_object();197 $cat_obj = $wp_the_query->get_queried_object(); 198 198 199 199 $category = (array) $category; 200 200 … … 218 218 * @return bool 219 219 */ 220 220 function is_tag( $slug = '' ) { 221 global $wp_ query;221 global $wp_the_query; 222 222 223 if ( !$wp_ query->is_tag )223 if ( !$wp_the_query->is_tag ) 224 224 return false; 225 225 226 226 if ( empty( $slug ) ) 227 227 return true; 228 228 229 $tag_obj = $wp_ query->get_queried_object();229 $tag_obj = $wp_the_query->get_queried_object(); 230 230 231 231 $slug = (array) $slug; 232 232 … … 246 246 * @return bool 247 247 */ 248 248 function is_tax( $slug = '' ) { 249 global $wp_ query;249 global $wp_the_query; 250 250 251 if ( !$wp_ query->is_tax )251 if ( !$wp_the_query->is_tax ) 252 252 return false; 253 253 254 254 if ( empty($slug) ) 255 255 return true; 256 256 257 $term = $wp_ query->get_queried_object();257 $term = $wp_the_query->get_queried_object(); 258 258 259 259 $slug = (array) $slug; 260 260 … … 273 273 * @return bool 274 274 */ 275 275 function is_comments_popup () { 276 global $wp_ query;276 global $wp_the_query; 277 277 278 return $wp_ query->is_comments_popup;278 return $wp_the_query->is_comments_popup; 279 279 } 280 280 281 281 /** … … 287 287 * @return bool 288 288 */ 289 289 function is_date () { 290 global $wp_ query;290 global $wp_the_query; 291 291 292 return $wp_ query->is_date;292 return $wp_the_query->is_date; 293 293 } 294 294 295 295 /** … … 301 301 * @return bool 302 302 */ 303 303 function is_day () { 304 global $wp_ query;304 global $wp_the_query; 305 305 306 return $wp_ query->is_day;306 return $wp_the_query->is_day; 307 307 } 308 308 309 309 /** … … 315 315 * @return bool 316 316 */ 317 317 function is_feed () { 318 global $wp_ query;318 global $wp_the_query; 319 319 320 return $wp_ query->is_feed;320 return $wp_the_query->is_feed; 321 321 } 322 322 323 323 /** … … 348 348 * @return bool True if blog view homepage. 349 349 */ 350 350 function is_home () { 351 global $wp_ query;351 global $wp_the_query; 352 352 353 return $wp_ query->is_home;353 return $wp_the_query->is_home; 354 354 } 355 355 356 356 /** … … 362 362 * @return bool 363 363 */ 364 364 function is_month () { 365 global $wp_ query;365 global $wp_the_query; 366 366 367 return $wp_ query->is_month;367 return $wp_the_query->is_month; 368 368 } 369 369 370 370 /** … … 385 385 * @return bool 386 386 */ 387 387 function is_page ($page = '') { 388 global $wp_ query;388 global $wp_the_query; 389 389 390 if ( !$wp_ query->is_page )390 if ( !$wp_the_query->is_page ) 391 391 return false; 392 392 393 393 if ( empty($page) ) 394 394 return true; 395 395 396 $page_obj = $wp_ query->get_queried_object();396 $page_obj = $wp_the_query->get_queried_object(); 397 397 398 398 $page = (array) $page; 399 399 … … 416 416 * @return bool 417 417 */ 418 418 function is_paged () { 419 global $wp_ query;419 global $wp_the_query; 420 420 421 return $wp_ query->is_paged;421 return $wp_the_query->is_paged; 422 422 } 423 423 424 424 /** … … 450 450 * @return bool 451 451 */ 452 452 function is_preview() { 453 global $wp_ query;453 global $wp_the_query; 454 454 455 return $wp_ query->is_preview;455 return $wp_the_query->is_preview; 456 456 } 457 457 458 458 /** … … 464 464 * @return bool 465 465 */ 466 466 function is_robots() { 467 global $wp_ query;467 global $wp_the_query; 468 468 469 return $wp_ query->is_robots;469 return $wp_the_query->is_robots; 470 470 } 471 471 472 472 /** … … 478 478 * @return bool 479 479 */ 480 480 function is_search () { 481 global $wp_ query;481 global $wp_the_query; 482 482 483 return $wp_ query->is_search;483 return $wp_the_query->is_search; 484 484 } 485 485 486 486 /** … … 499 499 * @return bool 500 500 */ 501 501 function is_single ($post = '') { 502 global $wp_ query;502 global $wp_the_query; 503 503 504 if ( !$wp_ query->is_single )504 if ( !$wp_the_query->is_single ) 505 505 return false; 506 506 507 507 if ( empty( $post) ) 508 508 return true; 509 509 510 $post_obj = $wp_ query->get_queried_object();510 $post_obj = $wp_the_query->get_queried_object(); 511 511 512 512 $post = (array) $post; 513 513 … … 530 530 * @return bool 531 531 */ 532 532 function is_singular() { 533 global $wp_ query;533 global $wp_the_query; 534 534 535 return $wp_ query->is_singular;535 return $wp_the_query->is_singular; 536 536 } 537 537 538 538 /** … … 544 544 * @return bool 545 545 */ 546 546 function is_time () { 547 global $wp_ query;547 global $wp_the_query; 548 548 549 return $wp_ query->is_time;549 return $wp_the_query->is_time; 550 550 } 551 551 552 552 /** … … 558 558 * @return bool 559 559 */ 560 560 function is_trackback () { 561 global $wp_ query;561 global $wp_the_query; 562 562 563 return $wp_ query->is_trackback;563 return $wp_the_query->is_trackback; 564 564 } 565 565 566 566 /** … … 572 572 * @return bool 573 573 */ 574 574 function is_year () { 575 global $wp_ query;575 global $wp_the_query; 576 576 577 return $wp_ query->is_year;577 return $wp_the_query->is_year; 578 578 } 579 579 580 580 /** … … 586 586 * @return bool True, if nothing is found matching WordPress Query. 587 587 */ 588 588 function is_404 () { 589 global $wp_ query;589 global $wp_the_query; 590 590 591 return $wp_ query->is_404;591 return $wp_the_query->is_404; 592 592 } 593 593 594 594 /* … … 605 605 * @return bool 606 606 */ 607 607 function have_posts() { 608 global $wp_ query;608 global $wp_the_query; 609 609 610 return $wp_ query->have_posts();610 return $wp_the_query->have_posts(); 611 611 } 612 612 613 613 /** … … 619 619 * @return bool True if caller is within loop, false if loop hasn't started or ended. 620 620 */ 621 621 function in_the_loop() { 622 global $wp_ query;622 global $wp_the_query; 623 623 624 return $wp_ query->in_the_loop;624 return $wp_the_query->in_the_loop; 625 625 } 626 626 627 627 /** … … 634 634 * @return null 635 635 */ 636 636 function rewind_posts() { 637 global $wp_ query;637 global $wp_the_query; 638 638 639 return $wp_ query->rewind_posts();639 return $wp_the_query->rewind_posts(); 640 640 } 641 641 642 642 /** … … 647 647 * @uses $wp_query 648 648 */ 649 649 function the_post() { 650 global $wp_ query;650 global $wp_the_query; 651 651 652 $wp_ query->the_post();652 $wp_the_query->the_post(); 653 653 } 654 654 655 655 /* … … 666 666 * @return bool 667 667 */ 668 668 function have_comments() { 669 global $wp_ query;670 return $wp_ query->have_comments();669 global $wp_the_query; 670 return $wp_the_query->have_comments(); 671 671 } 672 672 673 673 /** … … 680 680 * @return object 681 681 */ 682 682 function the_comment() { 683 global $wp_ query;684 return $wp_ query->the_comment();683 global $wp_the_query; 684 return $wp_the_query->the_comment(); 685 685 } 686 686 687 687 /* … … 2369 2369 */ 2370 2370 function the_post() { 2371 2371 global $post; 2372 global $wp_the_query; 2372 2373 $this->in_the_loop = true; 2373 2374 $post = $this->next_post(); 2374 2375 setup_postdata($post); 2375 2376 2376 if ( $this->current_post == 0 ) // loop has just started2377 if ( $this->current_post == 0 && $this === $wp_the_query ) // loop has just started 2377 2378 do_action('loop_start'); 2378 2379 } 2379 2380 … … 2392 2393 if ($this->current_post + 1 < $this->post_count) { 2393 2394 return true; 2394 2395 } 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'); 2396 2399 // Do some cleaning up after the loop 2397 2400 $this->rewind_posts(); 2398 2401 } … … 2604 2607 * @return null If no link is found, null is returned. 2605 2608 */ 2606 2609 function 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'] ) : 2609 2612 global $wpdb; 2610 2613 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'] . "'"; 2612 2615 2613 2616 // if year, monthnum, or day have been specified, make our query more precise 2614 2617 // 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']}'"; 2621 2624 2622 2625 $id = (int) $wpdb->get_var($query); 2623 2626