Changeset 5002
- Timestamp:
- 03/09/2007 04:05:28 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r4990 r5002 405 405 $this->init(); 406 406 if ( is_array($query) ) 407 $ qv = &$query;407 $this->query_vars = $query; 408 408 else 409 parse_str($query, $ qv);409 parse_str($query, $this->query_vars); 410 410 $this->query = $query; 411 $this->query_vars = $qv;412 } 413 414 $qv = $this->fill_query_vars($qv);411 } 412 413 $this->query_vars = $this->fill_query_vars($this->query_vars); 414 $qv = &$this->query_vars; 415 415 416 416 if ( ! empty($qv['robots']) ) { … … 427 427 } 428 428 429 $qv['p'] = (int) $qv['p']; 430 $qv['page_id'] = (int) $qv['page_id']; 431 $qv['year'] = (int) $qv['year']; 432 $qv['monthnum'] = (int) $qv['monthnum']; 433 $qv['day'] = (int) $qv['day']; 434 $qv['w'] = (int) $qv['w']; 429 435 $qv['m'] = (int) $qv['m']; 430 $qv['p'] = (int) $qv['p']; 436 if ( '' != $qv['hour'] ) $qv['hour'] = (int) $qv['hour']; 437 if ( '' != $qv['minute'] ) $qv['minute'] = (int) $qv['minute']; 438 if ( '' != $qv['second'] ) $qv['second'] = (int) $qv['second']; 431 439 432 440 // Compat. Map subpost to attachment. … … 436 444 $qv['attachment_id'] = $qv['subpost_id']; 437 445 438 if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) { 446 $qv['attachment_id'] = (int) $qv['attachment_id']; 447 448 if ( ('' != $qv['attachment']) || !empty($qv['attachment_id']) ) { 439 449 $this->is_single = true; 440 450 $this->is_attachment = true; 441 } elseif ( '' != $qv['name']) {451 } elseif ( '' != $qv['name'] ) { 442 452 $this->is_single = true; 443 453 } elseif ( $qv['p'] ) { 444 454 $this->is_single = true; 445 } elseif ( ('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {455 } elseif ( ('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day']) ) { 446 456 // If year, month, day, hour, minute, and second are set, a single 447 457 // post is being queried. 448 458 $this->is_single = true; 449 } elseif ( '' != $qv['static'] || '' != $qv['pagename'] || (int) $qv['page_id']) {459 } elseif ( '' != $qv['static'] || '' != $qv['pagename'] || !empty($qv['page_id']) ) { 450 460 $this->is_page = true; 451 461 $this->is_single = false; 452 } elseif ( !empty($qv['s'])) {462 } elseif ( !empty($qv['s']) ) { 453 463 $this->is_search = true; 454 464 } else { 455 465 // Look for archive queries. Dates, categories, authors. 456 466 457 if ( (int) $qv['second']) {467 if ( '' != $qv['second'] ) { 458 468 $this->is_time = true; 459 469 $this->is_date = true; 460 470 } 461 471 462 if ( (int) $qv['minute']) {472 if ( '' != $qv['minute'] ) { 463 473 $this->is_time = true; 464 474 $this->is_date = true; 465 475 } 466 476 467 if ( (int) $qv['hour']) {477 if ( '' != $qv['hour'] ) { 468 478 $this->is_time = true; 469 479 $this->is_date = true; 470 480 } 471 481 472 if ( (int) $qv['day']) {482 if ( $qv['day'] ) { 473 483 if (! $this->is_date) { 474 484 $this->is_day = true; … … 477 487 } 478 488 479 if ( (int) $qv['monthnum']) {489 if ( $qv['monthnum'] ) { 480 490 if (! $this->is_date) { 481 491 $this->is_month = true; … … 484 494 } 485 495 486 if ( (int) $qv['year']) {496 if ( $qv['year'] ) { 487 497 if (! $this->is_date) { 488 498 $this->is_year = true; … … 491 501 } 492 502 493 if ( (int) $qv['m']) {503 if ( $qv['m'] ) { 494 504 $this->is_date = true; 495 505 if (strlen($qv['m']) > 9) { … … 508 518 } 509 519 510 if ( empty($qv['cat']) || ($qv['cat'] == '0')) {520 if ( empty($qv['cat']) || ($qv['cat'] == '0') ) { 511 521 $this->is_category = false; 512 522 } else { … … 518 528 } 519 529 520 if ( '' != $qv['category_name']) {530 if ( '' != $qv['category_name'] ) { 521 531 $this->is_category = true; 522 532 } 523 533 524 if ( (empty($qv['author'])) || ($qv['author'] == '0')) {534 if ( empty($qv['author']) || ($qv['author'] == '0') ) { 525 535 $this->is_author = false; 526 536 } else { … … 528 538 } 529 539 530 if ( '' != $qv['author_name']) {540 if ( '' != $qv['author_name'] ) { 531 541 $this->is_author = true; 532 542 } 533 543 534 if ( ($this->is_date || $this->is_author || $this->is_category) ) {544 if ( ($this->is_date || $this->is_author || $this->is_category) ) 535 545 $this->is_archive = true; 536 } 537 } 538 539 if ('' != $qv['feed']) { 546 } 547 548 if ( '' != $qv['feed'] ) 540 549 $this->is_feed = true; 541 } 542 543 if ('' != $qv['tb']) { 550 551 if ( '' != $qv['tb'] ) 544 552 $this->is_trackback = true; 545 } 546 547 if ('' != $qv['paged']) { 553 554 if ( '' != $qv['paged'] ) 548 555 $this->is_paged = true; 549 } 550 551 if ('' != $qv['comments_popup']) { 556 557 if ( '' != $qv['comments_popup'] ) 552 558 $this->is_comments_popup = true; 553 } 554 555 //if we're previewing inside the write screen 556 if ('' != $qv['preview']) { 559 560 // if we're previewing inside the write screen 561 if ('' != $qv['preview']) 557 562 $this->is_preview = true; 558 } 559 560 if (strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) { 563 564 if ( strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) 561 565 $this->is_admin = true; 562 }563 566 564 567 if ( false !== strpos($qv['feed'], 'comments-') ) { 565 $ this->query_vars['feed'] = $qv['feed'] = str_replace('comments-', '', $qv['feed']);568 $qv['feed'] = str_replace('comments-', '', $qv['feed']); 566 569 $qv['withcomments'] = 1; 567 570 } … … 572 575 $this->is_comment_feed = true; 573 576 574 if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup ) ) {577 if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup ) ) 575 578 $this->is_home = true; 576 }577 579 578 580 // Correct is_* for page_on_front and page_for_posts … … 580 582 $this->is_page = true; 581 583 $this->is_home = false; 582 $ this->query_vars['page_id'] = get_option('page_on_front');584 $qv['page_id'] = get_option('page_on_front'); 583 585 } 584 586 … … 597 599 } 598 600 599 if ( '' != $qv['page_id'] && 0 != intval($qv['page_id']) ) { 600 $this->query_vars['page_id'] = intval($qv['page_id']); 601 if ( $qv['page_id'] ) { 601 602 if ( 'page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts') ) { 602 603 $this->is_page = false; … … 612 613 // Done correcting is_* for page_on_front and page_for_posts 613 614 614 if ( !empty($query) ) {615 if ( !empty($query) ) 615 616 do_action_ref_array('parse_query', array(&$this)); 616 }617 617 } 618 618 … … 705 705 706 706 // If a month is specified in the querystring, load that month 707 if ( (int)$q['m'] ) {707 if ( $q['m'] ) { 708 708 $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']); 709 709 $where .= ' AND YEAR(post_date)=' . substr($q['m'], 0, 4); … … 720 720 } 721 721 722 if ( (int) $q['hour'] ) { 723 $q['hour'] = '' . intval($q['hour']); 722 if ( '' != $q['hour'] ) 724 723 $where .= " AND HOUR(post_date)='" . $q['hour'] . "'"; 725 } 726 727 if ( (int) $q['minute'] ) { 728 $q['minute'] = '' . intval($q['minute']); 724 725 if ( '' != $q['minute'] ) 729 726 $where .= " AND MINUTE(post_date)='" . $q['minute'] . "'"; 730 } 731 732 if ( (int) $q['second'] ) { 733 $q['second'] = '' . intval($q['second']); 727 728 if ( '' != $q['second'] ) 734 729 $where .= " AND SECOND(post_date)='" . $q['second'] . "'"; 735 } 736 737 if ( (int) $q['year'] ) { 738 $q['year'] = '' . intval($q['year']); 730 731 if ( $q['year'] ) 739 732 $where .= " AND YEAR(post_date)='" . $q['year'] . "'"; 740 } 741 742 if ( (int) $q['monthnum'] ) { 743 $q['monthnum'] = '' . intval($q['monthnum']); 733 734 if ( $q['monthnum'] ) 744 735 $where .= " AND MONTH(post_date)='" . $q['monthnum'] . "'"; 745 } 746 747 if ( (int) $q['day'] ) { 748 $q['day'] = '' . intval($q['day']); 736 737 if ( $q['day'] ) 749 738 $where .= " AND DAYOFMONTH(post_date)='" . $q['day'] . "'"; 750 }751 752 // Compat. Map subpost to attachment.753 if ( '' != $q['subpost'] )754 $q['attachment'] = $q['subpost'];755 if ( '' != $q['subpost_id'] )756 $q['attachment_id'] = $q['subpost_id'];757 739 758 740 if ('' != $q['name']) { … … 785 767 } 786 768 787 if ( (int) $q['w'] ) { 788 $q['w'] = ''.intval($q['w']); 769 if ( $q['w'] ) 789 770 $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'"; 790 }791 771 792 772 if ( intval($q['comments_popup']) ) 793 773 $q['p'] = intval($q['comments_popup']); 794 774 795 // If a attachment is requested by number, let it supercede any post number.796 if ( ($q['attachment_id'] != '') && (intval($q['attachment_id']) != 0))797 $q['p'] = (int)$q['attachment_id'];775 // If an attachment is requested by number, let it supercede any post number. 776 if ( $q['attachment_id'] ) 777 $q['p'] = $q['attachment_id']; 798 778 799 779 // If a post number is specified, load that post 800 if (($q['p'] != '') && intval($q['p']) != 0) { 801 $q['p'] = (int) $q['p']; 780 if ( $q['p'] ) 802 781 $where = ' AND ID = ' . $q['p']; 803 } 804 805 if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) { 806 $q['page_id'] = intval($q['page_id']); 782 783 if ( $q['page_id'] ) { 807 784 if ( ('page' != get_option('show_on_front') ) || ( $q['page_id'] != get_option('page_for_posts') ) ) { 808 785 $q['p'] = $q['page_id']; 809 $where = ' AND ID = ' .$q['page_id'];786 $where = ' AND ID = ' . $q['page_id']; 810 787 } 811 788 } 812 789 813 790 // If a search pattern is specified, load the posts that match 814 if ( !empty($q['s'])) {791 if ( !empty($q['s']) ) { 815 792 // added slashes screw with quote grouping when done early, so done later 816 793 $q['s'] = stripslashes($q['s']); … … 839 816 // Category stuff 840 817 841 if ( (empty($q['cat'])) || ($q['cat'] == '0') ||818 if ( empty($q['cat']) || ($q['cat'] == '0') || 842 819 // Bypass cat checks if fetching specific posts 843 ( $this->is_single || $this->is_page )) {844 $whichcat ='';820 $this->is_singular ) { 821 $whichcat = ''; 845 822 } else { 846 823 $q['cat'] = ''.urldecode($q['cat']).''; … … 879 856 880 857 // Category stuff for nice URLs 881 if ( '' != $q['category_name']) {858 if ( '' != $q['category_name'] ) { 882 859 $reqcat = get_category_by_path($q['category_name']); 883 860 $q['category_name'] = str_replace('%2F', '/', urlencode(urldecode($q['category_name']))); … … 914 891 // Author/user stuff 915 892 916 if ( (empty($q['author'])) || ($q['author'] == '0')) {893 if ( empty($q['author']) || ($q['author'] == '0') ) { 917 894 $whichauthor=''; 918 895 } else { … … 954 931 $where .= $search.$whichcat.$whichauthor; 955 932 956 if ((empty($q['order'])) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC'))) { 957 $q['order']='DESC'; 958 } 933 if ( empty($q['order']) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC')) ) 934 $q['order'] = 'DESC'; 959 935 960 936 // Order by 961 if ( empty($q['orderby'])) {937 if ( empty($q['orderby']) ) { 962 938 $q['orderby'] = 'post_date '.$q['order']; 963 939 } else { … … 1015 991 1016 992 // Paging 1017 if ( empty($q['nopaging']) && !$this->is_singular) {993 if ( empty($q['nopaging']) && !$this->is_singular ) { 1018 994 $page = abs(intval($q['paged'])); 1019 995 if (empty($page)) {
Note: See TracChangeset
for help on using the changeset viewer.