Changeset 8807 for trunk/wp-includes/query.php
- Timestamp:
- 09/04/2008 07:19:32 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r8788 r8807 1 1 <?php 2 3 /* 4 * The Big Query. 5 */ 6 2 /** 3 * WordPress Query API 4 * 5 * The query API attempts to get which part of WordPress to the user is on. It 6 * also provides functionality to getting URL query information. 7 * 8 * @link http://codex.wordpress.org/The_Loop More information on The Loop. 9 * 10 * @package WordPress 11 * @subpackage Query 12 */ 13 14 /** 15 * Retrieve variable in the WP_Query class. 16 * 17 * @see WP_Query::get() 18 * @since 1.5.0 19 * @uses $wp_query 20 * 21 * @param string $var The variable key to retrieve. 22 * @return mixed 23 */ 7 24 function get_query_var($var) { 8 25 global $wp_query; … … 11 28 } 12 29 30 /** 31 * Set query variable. 32 * 33 * @see WP_Query::set() 34 * @since 2.2.0 35 * @uses $wp_query 36 * 37 * @param string $var Query variable key. 38 * @param mixed $value 39 * @return null 40 */ 13 41 function set_query_var($var, $value) { 14 42 global $wp_query; … … 17 45 } 18 46 47 /** 48 * Setup The Loop with query parameters. 49 * 50 * This will override the current WordPress Loop and shouldn't be used more than 51 * once. This must not be used within the WordPress Loop. 52 * 53 * @since 1.5.0 54 * @uses $wp_query 55 * 56 * @param string $query 57 * @return array List of posts 58 */ 19 59 function &query_posts($query) { 20 60 unset($GLOBALS['wp_query']); … … 23 63 } 24 64 65 /** 66 * Destroy the previous query and setup a new query. 67 * 68 * This should be used after {@link query_posts()} and before another {@link 69 * query_posts()}. This will remove obscure bugs that occur when the previous 70 * wp_query object is not destroyed properly before another is setup. 71 * 72 * @since 2.3.0 73 * @uses $wp_query 74 */ 25 75 function wp_reset_query() { 26 76 unset($GLOBALS['wp_query']); … … 37 87 */ 38 88 89 /** 90 * Whether the current request is in WordPress admin Panel 91 * 92 * Does not inform on whether the user is an admin! Use capability checks to 93 * tell if the user should be accessing a section or not. 94 * 95 * @since 1.5.1 96 * 97 * @return bool True if inside WordPress administration pages. 98 */ 39 99 function is_admin () { 40 100 if ( defined('WP_ADMIN') ) … … 43 103 } 44 104 105 /** 106 * Is query requesting an archive page. 107 * 108 * @since 1.5.0 109 * @uses $wp_query 110 * 111 * @return bool True if page is archive. 112 */ 45 113 function is_archive () { 46 114 global $wp_query; … … 49 117 } 50 118 119 /** 120 * Is query requesting an attachment page. 121 * 122 * @since 2.0.0 123 * @uses $wp_query 124 * 125 * @return bool True if page is attachment. 126 */ 51 127 function is_attachment () { 52 128 global $wp_query; … … 55 131 } 56 132 133 /** 134 * Is query requesting an author page. 135 * 136 * If the $author parameter is specified then the check will be expanded to 137 * include whether the queried author matches the one given in the parameter. 138 * You can match against integers and against strings. 139 * 140 * If matching against an integer, the ID should be used of the author for the 141 * test. If the $author is an ID and matches the author page user ID, then 142 * 'true' will be returned. 143 * 144 * If matching against strings, then the test will be matched against both the 145 * nickname and user nicename and will return true on success. 146 * 147 * @since 1.5.0 148 * @uses $wp_query 149 * 150 * @param string|int $author Optional. Is current page this author. 151 * @return bool True if page is author or $author (if set). 152 */ 57 153 function is_author ($author = '') { 58 154 global $wp_query; … … 78 174 } 79 175 176 /** 177 * Whether current page query contains a category name or given category name. 178 * 179 * The category list can contain category IDs, names, or category slugs. If any 180 * of them are part of the query, then it will return true. 181 * 182 * @since 1.5.0 183 * @uses $wp_query 184 * 185 * @param string|array $category Optional. 186 * @return bool 187 */ 80 188 function is_category ($category = '') { 81 189 global $wp_query; … … 101 209 } 102 210 211 /** 212 * Whether the current page query has the given tag slug or contains tag. 213 * 214 * @since 2.3.0 215 * @uses $wp_query 216 * 217 * @param string|array $slug Optional. Single tag or list of tags to check for. 218 * @return bool 219 */ 103 220 function is_tag( $slug = '' ) { 104 221 global $wp_query; … … 120 237 } 121 238 239 /** 240 * Whether the current page query has the given taxonomy slug or contains taxonomy. 241 * 242 * @since 2.5.0 243 * @uses $wp_query 244 * 245 * @param string|array $slug Optional. Slug or slugs to check in current query. 246 * @return bool 247 */ 122 248 function is_tax( $slug = '' ) { 123 249 global $wp_query; … … 139 265 } 140 266 267 /** 268 * Whether the current URL is within the comments popup window. 269 * 270 * @since 1.5.0 271 * @uses $wp_query 272 * 273 * @return bool 274 */ 141 275 function is_comments_popup () { 142 276 global $wp_query; … … 145 279 } 146 280 281 /** 282 * Whether current URL is based on a date. 283 * 284 * @since 1.5.0 285 * @uses $wp_query 286 * 287 * @return bool 288 */ 147 289 function is_date () { 148 290 global $wp_query; … … 151 293 } 152 294 295 /** 296 * Whether current blog URL contains a day. 297 * 298 * @since 1.5.0 299 * @uses $wp_query 300 * 301 * @return bool 302 */ 153 303 function is_day () { 154 304 global $wp_query; … … 157 307 } 158 308 309 /** 310 * Whether current page query is feed URL. 311 * 312 * @since 1.5.0 313 * @uses $wp_query 314 * 315 * @return bool 316 */ 159 317 function is_feed () { 160 318 global $wp_query; … … 164 322 165 323 /** 166 * is_front_page() - Is it the front of the site, whether blog view or a WP Page?167 * 168 * @since 2.5 169 * @uses is_home 170 * @uses get_option 171 * 172 * @return bool True if front of site324 * Whether current page query is the front of the site. 325 * 326 * @since 2.5.0 327 * @uses is_home() 328 * @uses get_option() 329 * 330 * @return bool True, if front of site. 173 331 */ 174 332 function is_front_page () { … … 183 341 184 342 /** 185 * is_home() - Is it the blog view homepage?186 * 187 * @since 2.1188 * @ global object$wp_query189 * 190 * @return bool True if blog view homepage 343 * Whether current page view is the blog homepage. 344 * 345 * @since 1.5.0 346 * @uses $wp_query 347 * 348 * @return bool True if blog view homepage. 191 349 */ 192 350 function is_home () { … … 196 354 } 197 355 356 /** 357 * Whether current page query contains a month. 358 * 359 * @since 1.5.0 360 * @uses $wp_query 361 * 362 * @return bool 363 */ 198 364 function is_month () { 199 365 global $wp_query; … … 202 368 } 203 369 370 /** 371 * Whether query is page or contains given page(s). 372 * 373 * Calls the function without any parameters will only test whether the current 374 * query is of the page type. Either a list or a single item can be tested 375 * against for whether the query is a page and also is the value or one of the 376 * values in the page parameter. 377 * 378 * The parameter can contain the page ID, page title, or page name. The 379 * parameter can also be an array of those three values. 380 * 381 * @since 1.5.0 382 * @uses $wp_query 383 * 384 * @param mixed $page Either page or list of pages to test against. 385 * @return bool 386 */ 204 387 function is_page ($page = '') { 205 388 global $wp_query; … … 225 408 } 226 409 410 /** 411 * Whether query contains multiple pages for the results. 412 * 413 * @since 1.5.0 414 * @uses $wp_query 415 * 416 * @return bool 417 */ 227 418 function is_paged () { 228 419 global $wp_query; … … 231 422 } 232 423 424 /** 425 * Whether the current page was created by a plugin. 426 * 427 * The plugin can set this by using the global $plugin_page and setting it to 428 * true. 429 * 430 * @since 1.5.0 431 * @global bool $plugin_page Used by plugins to tell the query that current is a plugin page. 432 * 433 * @return bool 434 */ 233 435 function is_plugin_page() { 234 436 global $plugin_page; … … 240 442 } 241 443 444 /** 445 * Whether the current query is preview of post or page. 446 * 447 * @since 2.0.0 448 * @uses $wp_query 449 * 450 * @return bool 451 */ 242 452 function is_preview() { 243 453 global $wp_query; … … 246 456 } 247 457 458 /** 459 * Whether the current query post is robots. 460 * 461 * @since 2.1.0 462 * @uses $wp_query 463 * 464 * @return bool 465 */ 248 466 function is_robots() { 249 467 global $wp_query; … … 252 470 } 253 471 472 /** 473 * Whether current query is the result of a user search. 474 * 475 * @since 1.5.0 476 * @uses $wp_query 477 * 478 * @return bool 479 */ 254 480 function is_search () { 255 481 global $wp_query; … … 258 484 } 259 485 486 /** 487 * Whether the current page query is single page. 488 * 489 * The parameter can contain the post ID, post title, or post name. The 490 * parameter can also be an array of those three values. 491 * 492 * This applies to other post types, attachments, pages, posts. Just means that 493 * the current query has only a single object. 494 * 495 * @since 1.5.0 496 * @uses $wp_query 497 * 498 * @param mixed $post Either post or list of posts to test against. 499 * @return bool 500 */ 260 501 function is_single ($post = '') { 261 502 global $wp_query; … … 281 522 } 282 523 524 /** 525 * Whether is single post, is a page, or is an attachment. 526 * 527 * @since 1.5.0 528 * @uses $wp_query 529 * 530 * @return bool 531 */ 283 532 function is_singular() { 284 533 global $wp_query; … … 287 536 } 288 537 538 /** 539 * Whether the query contains a time. 540 * 541 * @since 1.5.0 542 * @uses $wp_query 543 * 544 * @return bool 545 */ 289 546 function is_time () { 290 547 global $wp_query; … … 293 550 } 294 551 552 /** 553 * Whether the query is a trackback. 554 * 555 * @since 1.5.0 556 * @uses $wp_query 557 * 558 * @return bool 559 */ 295 560 function is_trackback () { 296 561 global $wp_query; … … 299 564 } 300 565 566 /** 567 * Whether the query contains a year. 568 * 569 * @since 1.5.0 570 * @uses $wp_query 571 * 572 * @return bool 573 */ 301 574 function is_year () { 302 575 global $wp_query; … … 305 578 } 306 579 580 /** 581 * Whether current page query is a 404 and no results for WordPress query. 582 * 583 * @since 1.5.0 584 * @uses $wp_query 585 * 586 * @return bool True, if nothing is found matching WordPress Query. 587 */ 307 588 function is_404 () { 308 589 global $wp_query; … … 315 596 */ 316 597 598 /** 599 * Whether current WordPress query has results to loop over. 600 * 601 * @see WP_Query::have_posts() 602 * @since 1.5.0 603 * @uses $wp_query 604 * 605 * @return bool 606 */ 317 607 function have_posts() { 318 608 global $wp_query; … … 321 611 } 322 612 613 /** 614 * Whether the caller is in the Loop. 615 * 616 * @since 2.0.0 617 * @uses $wp_query 618 * 619 * @return bool True if caller is within loop, false if loop hasn't started or ended. 620 */ 323 621 function in_the_loop() { 324 622 global $wp_query; … … 327 625 } 328 626 627 /** 628 * Rewind the loop posts. 629 * 630 * @see WP_Query::rewind_posts() 631 * @since 1.5.0 632 * @uses $wp_query 633 * 634 * @return null 635 */ 329 636 function rewind_posts() { 330 637 global $wp_query; … … 333 640 } 334 641 642 /** 643 * Iterate the post index in the loop. 644 * 645 * @see WP_Query::the_post() 646 * @since 1.5.0 647 * @uses $wp_query 648 */ 335 649 function the_post() { 336 650 global $wp_query; … … 343 657 */ 344 658 659 /** 660 * Whether there are comments to loop over. 661 * 662 * @see WP_Query::have_comments() 663 * @since 2.2.0 664 * @uses $wp_query 665 * 666 * @return bool 667 */ 345 668 function have_comments() { 346 669 global $wp_query; … … 348 671 } 349 672 673 /** 674 * Iterate comment index in the comment loop. 675 * 676 * @see WP_Query::the_comment() 677 * @since 2.2.0 678 * @uses $wp_query 679 * 680 * @return object 681 */ 350 682 function the_comment() { 351 683 global $wp_query; … … 357 689 */ 358 690 691 /** 692 * The WordPress Query class. 693 * 694 * @link http://codex.wordpress.org/Function_Reference/WP_Query Codex page. 695 * 696 * @since 1.5.0 697 */ 359 698 class WP_Query { 699 700 /** 701 * Query string 702 * 703 * @since 1.5.0 704 * @access public 705 * @var string 706 */ 360 707 var $query; 708 709 /** 710 * Query search variables set by the user. 711 * 712 * @since 1.5.0 713 * @access public 714 * @var array 715 */ 361 716 var $query_vars = array(); 717 718 /** 719 * Holds the data for a single object that is queried. 720 * 721 * Holds the contents of a post, page, category, attachment. 722 * 723 * @since 1.5.0 724 * @access public 725 * @var object|array 726 */ 362 727 var $queried_object; 728 729 /** 730 * The ID of the queried object. 731 * 732 * @since 1.5.0 733 * @access public 734 * @var int 735 */ 363 736 var $queried_object_id; 737 738 /** 739 * Get post database query. 740 * 741 * @since 2.0.1 742 * @access public 743 * @var string 744 */ 364 745 var $request; 365 746 747 /** 748 * List of posts. 749 * 750 * @since 1.5.0 751 * @access public 752 * @var array 753 */ 366 754 var $posts; 755 756 /** 757 * The amount of posts for the current query. 758 * 759 * @since 1.5.0 760 * @access public 761 * @var int 762 */ 367 763 var $post_count = 0; 764 765 /** 766 * Index of the current item in the loop. 767 * 768 * @since 1.5.0 769 * @access public 770 * @var int 771 */ 368 772 var $current_post = -1; 773 774 /** 775 * Whether the loop has started and the caller is in the loop. 776 * 777 * @since 2.0.0 778 * @access public 779 * @var bool 780 */ 369 781 var $in_the_loop = false; 782 783 /** 784 * The current post ID. 785 * 786 * @since 1.5.0 787 * @access public 788 * @var int 789 */ 370 790 var $post; 371 791 792 /** 793 * The list of comments for current post. 794 * 795 * @since 2.2.0 796 * @access public 797 * @var array 798 */ 372 799 var $comments; 800 801 /** 802 * The amount of comments for the posts. 803 * 804 * @since 2.2.0 805 * @access public 806 * @var int 807 */ 373 808 var $comment_count = 0; 809 810 /** 811 * The index of the comment in the comment loop. 812 * 813 * @since 2.2.0 814 * @access public 815 * @var int 816 */ 374 817 var $current_comment = -1; 818 819 /** 820 * Current comment ID. 821 * 822 * @since 2.2.0 823 * @access public 824 * @var int 825 */ 375 826 var $comment; 376 827 828 /** 829 * Amount of posts if limit clause was not used. 830 * 831 * @since 2.1.0 832 * @access public 833 * @var int 834 */ 377 835 var $found_posts = 0; 836 837 /** 838 * The amount of pages. 839 * 840 * @since 2.1.0 841 * @access public 842 * @var int 843 */ 378 844 var $max_num_pages = 0; 379 845 846 /** 847 * Set if query is single post. 848 * 849 * @since 1.5.0 850 * @access public 851 * @var bool 852 */ 380 853 var $is_single = false; 854 855 /** 856 * Set if query is preview of blog. 857 * 858 * @since 2.0.0 859 * @access public 860 * @var bool 861 */ 381 862 var $is_preview = false; 863 864 /** 865 * Set if query returns a page. 866 * 867 * @since 1.5.0 868 * @access public 869 * @var bool 870 */ 382 871 var $is_page = false; 872 873 /** 874 * Set if query is an archive list. 875 * 876 * @since 1.5.0 877 * @access public 878 * @var bool 879 */ 383 880 var $is_archive = false; 881 882 /** 883 * Set if query is part of a date. 884 * 885 * @since 1.5.0 886 * @access public 887 * @var bool 888 */ 384 889 var $is_date = false; 890 891 /** 892 * Set if query contains a year. 893 * 894 * @since 1.5.0 895 * @access public 896 * @var bool 897 */ 385 898 var $is_year = false; 899 900 /** 901 * Set if query contains a month. 902 * 903 * @since 1.5.0 904 * @access public 905 * @var bool 906 */ 386 907 var $is_month = false; 908 909 /** 910 * Set if query contains a day. 911 * 912 * @since 1.5.0 913 * @access public 914 * @var bool 915 */ 387 916 var $is_day = false; 917 918 /** 919 * Set if query contains time. 920 * 921 * @since 1.5.0 922 * @access public 923 * @var bool 924 */ 388 925 var $is_time = false; 926 927 /** 928 * Set if query contains an author. 929 * 930 * @since 1.5.0 931 * @access public 932 * @var bool 933 */ 389 934 var $is_author = false; 935 936 /** 937 * Set if query contains category. 938 * 939 * @since 1.5.0 940 * @access public 941 * @var bool 942 */ 390 943 var $is_category = false; 944 945 /** 946 * Set if query contains tag. 947 * 948 * @since 2.3.0 949 * @access public 950 * @var bool 951 */ 391 952 var $is_tag = false; 953 954 /** 955 * Set if query contains taxonomy. 956 * 957 * @since 2.5.0 958 * @access public 959 * @var bool 960 */ 392 961 var $is_tax = false; 962 963 /** 964 * Set if query was part of a search result. 965 * 966 * @since 1.5.0 967 * @access public 968 * @var bool 969 */ 393 970 var $is_search = false; 971 972 /** 973 * Set if query is feed display. 974 * 975 * @since 1.5.0 976 * @access public 977 * @var bool 978 */ 394 979 var $is_feed = false; 980 981 /** 982 * Set if query is comment feed display. 983 * 984 * @since 2.2.0 985 * @access public 986 * @var bool 987 */ 395 988 var $is_comment_feed = false; 989 990 /** 991 * Set if query is trackback. 992 * 993 * @since 1.5.0 994 * @access public 995 * @var bool 996 */ 396 997 var $is_trackback = false; 998 999 /** 1000 * Set if query is blog homepage. 1001 * 1002 * @since 1.5.0 1003 * @access public 1004 * @var bool 1005 */ 397 1006 var $is_home = false; 1007 1008 /** 1009 * Set if query couldn't found anything. 1010 * 1011 * @since 1.5.0 1012 * @access public 1013 * @var bool 1014 */ 398 1015 var $is_404 = false; 1016 1017 /** 1018 * Set if query is within comments popup window. 1019 * 1020 * @since 1.5.0 1021 * @access public 1022 * @var bool 1023 */ 399 1024 var $is_comments_popup = false; 1025 1026 /** 1027 * Set if query is part of administration page. 1028 * 1029 * @since 1.5.0 1030 * @access public 1031 * @var bool 1032 */ 400 1033 var $is_admin = false; 1034 1035 /** 1036 * Set if query is an attachment. 1037 * 1038 * @since 2.0.0 1039 * @access public 1040 * @var bool 1041 */ 401 1042 var $is_attachment = false; 1043 1044 /** 1045 * Set if is single, is a page, or is an attachment. 1046 * 1047 * @since 2.1.0 1048 * @access public 1049 * @var bool 1050 */ 402 1051 var $is_singular = false; 1052 1053 /** 1054 * Set if query is for robots. 1055 * 1056 * @since 2.1.0 1057 * @access public 1058 * @var bool 1059 */ 403 1060 var $is_robots = false; 1061 1062 /** 1063 * Set if query contains posts. 1064 * 1065 * Basically, the homepage if the option isn't set for the static homepage. 1066 * 1067 * @since 2.1.0 1068 * @access public 1069 * @var bool 1070 */ 404 1071 var $is_posts_page = false; 405 1072 1073 /** 1074 * Resets query flags to false. 1075 * 1076 * The query flags are what page info WordPress was able to figure out. 1077 * 1078 * @since 2.0.0 1079 * @access private 1080 */ 406 1081 function init_query_flags() { 407 1082 $this->is_single = false; … … 431 1106 } 432 1107 1108 /** 1109 * Initiates object properties and sets default values. 1110 * 1111 * @since 1.5.0 1112 * @access public 1113 */ 433 1114 function init () { 434 1115 unset($this->posts); … … 444 1125 } 445 1126 446 // Reparse the query vars. 1127 /** 1128 * Reparse the query vars. 1129 * 1130 * @since 1.5.0 1131 * @access public 1132 */ 447 1133 function parse_query_vars() { 448 1134 $this->parse_query(''); 449 1135 } 450 1136 1137 /** 1138 * Fills in the query variables, which do not exist within the parameter. 1139 * 1140 * @since 2.1.0 1141 * @access public 1142 * 1143 * @param array $array Defined query variables. 1144 * @return array Complete query variables with undefined ones filled in empty. 1145 */ 451 1146 function fill_query_vars($array) { 452 1147 $keys = array( … … 500 1195 } 501 1196 502 // Parse a query string and set query type booleans. 1197 /** 1198 * Parse a query string and set query type booleans. 1199 * 1200 * @since 1.5.0 1201 * @access public 1202 * 1203 * @param string|array $query 1204 */ 503 1205 function parse_query ($query) { 504 1206 if ( !empty($query) || !isset($this->query) ) { … … 708 1410 } 709 1411 710 if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax) )1412 if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag ) ) 711 1413 $this->is_archive = true; 712 1414 } … … 792 1494 } 793 1495 1496 /** 1497 * Sets the 404 property and saves whether query is feed. 1498 * 1499 * @since 2.0.0 1500 * @access public 1501 */ 794 1502 function set_404() { 795 1503 $is_feed = $this->is_feed; … … 801 1509 } 802 1510 1511 /** 1512 * Retrieve query variable. 1513 * 1514 * @since 1.5.0 1515 * @access public 1516 * 1517 * @param string $query_var Query variable key. 1518 * @return mixed 1519 */ 803 1520 function get($query_var) { 804 1521 if (isset($this->query_vars[$query_var])) { … … 809 1526 } 810 1527 1528 /** 1529 * Set query variable. 1530 * 1531 * @since 1.5.0 1532 * @access public 1533 * 1534 * @param string $query_var Query variable key. 1535 * @param mixed $value Query variable value. 1536 */ 811 1537 function set($query_var, $value) { 812 1538 $this->query_vars[$query_var] = $value; 813 1539 } 814 1540 1541 /** 1542 * Retrieve the posts based on query variables. 1543 * 1544 * There are a few filters and actions that can be used to modify the post 1545 * database query. 1546 * 1547 * @since 1.5.0 1548 * @access public 1549 * @uses do_action_ref_array() Calls 'pre_get_posts' hook before retrieving posts. 1550 * 1551 * @return array List of posts. 1552 */ 815 1553 function &get_posts() { 816 1554 global $wpdb, $user_ID; … … 1550 2288 $stickies__in = implode(',', array_map( 'absint', $sticky_posts )); 1551 2289 $stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in)" ); 1552 / / TODO Make sure post is published or viewable by the current user2290 /** @todo Make sure post is published or viewable by the current user */ 1553 2291 foreach ( $stickies as $sticky_post ) { 1554 2292 if ( 'publish' != $sticky_post->post_status ) … … 1573 2311 } 1574 2312 2313 /** 2314 * Setup the next post and iterate current post index. 2315 * 2316 * @since 1.5.0 2317 * @access public 2318 * 2319 * @return object Next post. 2320 */ 1575 2321 function next_post() { 1576 2322 … … 1581 2327 } 1582 2328 2329 /** 2330 * Sets up the current post. 2331 * 2332 * Retrieves the next post, sets up the post, sets the 'in the loop' 2333 * property to true. 2334 * 2335 * @since 1.5.0 2336 * @access public 2337 * @uses $post 2338 * @uses do_action() Calls 'loop_start' if loop has just started 2339 */ 1583 2340 function the_post() { 1584 2341 global $post; … … 1591 2348 } 1592 2349 2350 /** 2351 * Whether there are more posts available in the loop. 2352 * 2353 * Calls action 'loop_end', when the loop is complete. 2354 * 2355 * @since 1.5.0 2356 * @access public 2357 * @uses do_action() Calls 'loop_start' if loop has just started 2358 * 2359 * @return bool True if posts are available, false if end of loop. 2360 */ 1593 2361 function have_posts() { 1594 2362 if ($this->current_post + 1 < $this->post_count) { … … 1604 2372 } 1605 2373 2374 /** 2375 * Rewind the posts and reset post index. 2376 * 2377 * @since 1.5.0 2378 * @access public 2379 */ 1606 2380 function rewind_posts() { 1607 2381 $this->current_post = -1; … … 1611 2385 } 1612 2386 2387 /** 2388 * Iterate current comment index and return comment object. 2389 * 2390 * @since 2.2.0 2391 * @access public 2392 * 2393 * @return object Comment object. 2394 */ 1613 2395 function next_comment() { 1614 2396 $this->current_comment++; … … 1618 2400 } 1619 2401 2402 /** 2403 * Sets up the current comment. 2404 * 2405 * @since 2.2.0 2406 * @access public 2407 * @global object $comment Current comment. 2408 * @uses do_action() Calls 'comment_loop_start' hook when first comment is processed. 2409 */ 1620 2410 function the_comment() { 1621 2411 global $comment; … … 1628 2418 } 1629 2419 2420 /** 2421 * Whether there are more comments available. 2422 * 2423 * Automatically rewinds comments when finished. 2424 * 2425 * @since 2.2.0 2426 * @access public 2427 * 2428 * @return bool True, if more comments. False, if no more posts. 2429 */ 1630 2430 function have_comments() { 1631 2431 if ($this->current_comment + 1 < $this->comment_count) { … … 1638 2438 } 1639 2439 2440 /** 2441 * Rewind the comments, resets the comment index and comment to first. 2442 * 2443 * @since 2.2.0 2444 * @access public 2445 */ 1640 2446 function rewind_comments() { 1641 2447 $this->current_comment = -1; … … 1645 2451 } 1646 2452 2453 /** 2454 * Sets up the WordPress query by parsing query string. 2455 * 2456 * @since 1.5.0 2457 * @access public 2458 * 2459 * @param string $query URL query string. 2460 * @return array List of posts. 2461 */ 1647 2462 function &query($query) { 1648 2463 $this->parse_query($query); … … 1650 2465 } 1651 2466 2467 /** 2468 * Retrieve queried object. 2469 * 2470 * If queried object is not set, then the queried object will be set from 2471 * the category, tag, taxonomy, posts page, single post, page, or author 2472 * query variable. After it is set up, it will be returned. 2473 * 2474 * @since 1.5.0 2475 * @access public 2476 * 2477 * @return object 2478 */ 1652 2479 function get_queried_object() { 1653 2480 if (isset($this->queried_object)) { … … 1698 2525 } 1699 2526 2527 /** 2528 * Retrieve ID of the current queried object. 2529 * 2530 * @since 1.5.0 2531 * @access public 2532 * 2533 * @return int 2534 */ 1700 2535 function get_queried_object_id() { 1701 2536 $this->get_queried_object(); … … 1708 2543 } 1709 2544 2545 /** 2546 * PHP4 type constructor. 2547 * 2548 * Sets up the WordPress query, if parameter is not empty. 2549 * 2550 * @since 1.5.0 2551 * @access public 2552 * 2553 * @param string $query URL query string. 2554 * @return WP_Query 2555 */ 1710 2556 function WP_Query ($query = '') { 1711 2557 if (! empty($query)) { … … 1715 2561 } 1716 2562 1717 1718 // Redirect old slugs 2563 /** 2564 * Redirect old slugs to the correct permalink. 2565 * 2566 * Attempts to find the current slug from the past slugs. 2567 * 2568 * @since 2.1.0 2569 * @uses $wp_query 2570 * @uses $wpdb 2571 * 2572 * @return null If no link is found, null is returned. 2573 */ 1719 2574 function wp_old_slug_redirect () { 1720 2575 global $wp_query; … … 1748 2603 } 1749 2604 1750 1751 // 1752 // Private helper functions 1753 // 1754 1755 // Setup global post data. 2605 /** 2606 * Setup global post data. 2607 * 2608 * @since 1.5.0 2609 * 2610 * @param object $post Post data. 2611 * @return bool True when finished. 2612 */ 1756 2613 function setup_postdata($post) { 1757 2614 global $id, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages;
Note: See TracChangeset
for help on using the changeset viewer.