Ticket #7538: post.phpdoc.r8662.diff
| File post.phpdoc.r8662.diff, 55.5 KB (added by , 17 years ago) |
|---|
-
post.php
2 2 /** 3 3 * Post functions and post utility function. 4 4 * 5 * Warning: The inline documentation for the functions contained6 * in this file might be inaccurate, so the documentation is not7 * authoritative at the moment.8 *9 5 * @package WordPress 10 6 * @subpackage Post 11 * @since 1.5 7 * @since 1.5.0 12 8 */ 13 9 14 10 /** … … 22 18 * prevent looking up the meta name and provide a mechanism for sending the 23 19 * attached filename through a filter. 24 20 * 25 * @package WordPress 26 * @subpackage Post 27 * @since 2.0 28 * @uses apply_filters() Calls 'get_attached_file' on file path and attachment ID 21 * @since 2.0.0 22 * @uses apply_filters() Calls 'get_attached_file' on file path and attachment ID. 29 23 * 30 24 * @param int $attachment_id Attachment ID 31 25 * @param bool $unfiltered Whether to apply filters or not … … 44 38 * Used to update the file path of the attachment, which uses post meta name 45 39 * '_wp_attached_file' to store the path of the attachment. 46 40 * 47 * @package WordPress 48 * @subpackage Post 49 * @since 2.1 50 * @uses apply_filters() Calls 'update_attached_file' on file path and attachment ID 41 * @since 2.1.0 42 * @uses apply_filters() Calls 'update_attached_file' on file path and attachment ID. 51 43 * 52 44 * @param int $attachment_id Attachment ID 53 45 * @param string $file File path for the attachment … … 79 71 * example of what is possible. 80 72 * 81 73 * The arguments listed as defaults are for this function and also of the 82 * get_posts() function. The arguments are combined with the get_children 83 * defaults and are then passed to the get_posts() function, which accepts 84 * additional arguments. You can replace the defaults in this function, listed 85 * below and the additional arguments listed in the get_posts() function. 74 * {@link get_posts()} function. The arguments are combined with the 75 * get_children defaults and are then passed to the {@link get_posts()} 76 * function, which accepts additional arguments. You can replace the defaults in 77 * this function, listed below and the additional arguments listed in the 78 * {@link get_posts()} function. 86 79 * 87 80 * The 'post_parent' is the most important argument and important attention 88 81 * needs to be paid to the $args parameter. If you pass either an object or an … … 103 96 * @see get_posts() Has additional arguments that can be replaced. 104 97 * @internal Claims made in the long description might be inaccurate. 105 98 * 106 * @package WordPress 107 * @subpackage Post 108 * @since 2.0 99 * @since 2.0.0 109 100 * 110 101 * @param mixed $args Optional. User defined arguments for replacing the defaults. 111 102 * @param string $output Optional. Constant for return type, either OBJECT (default), ARRAY_A, ARRAY_N. … … 156 147 } 157 148 158 149 /** 159 * get_extended() - Get extended entry info (<!--more-->)150 * Get extended entry info (<!--more-->). 160 151 * 161 * {@internal Missing Long Description}} 152 * There should not be any space after the second dash and before the word 153 * 'more'. There can be text or space(s) after the word 'more', but won't be 154 * referenced. 162 155 * 163 * @package WordPress 164 * @subpackage Post 156 * The returned array has 'main' and 'extended' keys. Main has the text before 157 * the <code><!--more--></code>. The 'extended' key has the content after the 158 * <code><!--more--></code> comment. 159 * 165 160 * @since 1.0.0 166 161 * 167 * @param string $post {@internal Missing Description}}168 * @return array {@internal Missing Description}}162 * @param string $post Post content. 163 * @return array Post before ('main') and after ('extended'). 169 164 */ 170 165 function get_extended($post) { 171 166 //Match the new style more links … … 184 179 } 185 180 186 181 /** 187 * get_post() -Retrieves post data given a post ID or post object.182 * Retrieves post data given a post ID or post object. 188 183 * 189 * {@internal Missing Long Description}} 184 * See {@link sanitize_post()} for optional $filter values. Also, the parameter 185 * $post, must be given as a variable, since it is passed by reference. 190 186 * 191 * @package WordPress192 * @subpackage Post193 187 * @since 1.5.1 194 188 * @uses $wpdb 195 189 * @link http://codex.wordpress.org/Function_Reference/get_post 196 190 * 197 * @param int|object &$post post ID or post object198 * @param string $output {@internal Missing Description}}199 * @param string $filter {@internal Missing Description}}200 * @return mixed {@internal Missing Description}}191 * @param int|object $post Post ID or post object. 192 * @param string $output Optional, default is Object. Either OBJECT, ARRAY_A, or ARRAY_N. 193 * @param string $filter Optional, default is raw. 194 * @return mixed Post data 201 195 */ 202 196 function &get_post(&$post, $output = OBJECT, $filter = 'raw') { 203 197 global $wpdb; … … 241 235 /** 242 236 * Retrieve ancestors of a post. 243 237 * 244 * @package WordPress 245 * @subpackage Post 246 * @since 2.5 238 * @since 2.5.0 247 239 * 248 240 * @param int|object $post Post ID or post object 249 241 * @return array Ancestor IDs or empty array if none are found. … … 266 258 * The context values are based off of the taxonomy filter functions and 267 259 * supported values are found within those functions. 268 260 * 269 * @package WordPress 270 * @subpackage Post 271 * @since 2.3 261 * @since 2.3.0 272 262 * @uses sanitize_post_field() See for possible $context values. 273 263 * 274 264 * @param string $field Post field name … … 298 288 * This function can be used with any post type, but it makes more sense with 299 289 * attachments. 300 290 * 301 * @package WordPress 302 * @subpackage Post 303 * @since 2.0 291 * @since 2.0.0 304 292 * 305 293 * @param int $ID Optional. Post ID. 306 294 * @return bool|string False on failure or returns the mime type … … 320 308 * If the post ID is of an attachment, then the parent post status will be given 321 309 * instead. 322 310 * 323 * @package WordPress 324 * @subpackage Post 325 * @since 2.0 311 * @since 2.0.0 326 312 * 327 313 * @param int $ID Post ID 328 314 * @return string|bool Post status or false on failure. … … 346 332 * Posts have a limited set of valid status values, this provides the 347 333 * post_status values and descriptions. 348 334 * 349 * @package WordPress 350 * @subpackage Post 351 * @since 2.5 335 * @since 2.5.0 352 336 * 353 337 * @return array List of post statuses. 354 338 */ … … 369 353 * Pages have a limited set of valid status values, this provides the 370 354 * post_status values and descriptions. 371 355 * 372 * @package WordPress 373 * @subpackage Page 374 * @since 2.5 356 * @since 2.5.0 375 357 * 376 358 * @return array List of page statuses. 377 359 */ … … 386 368 } 387 369 388 370 /** 389 * get_post_type() - Returns post type371 * Retrieve the post type of the current post or of a given post. 390 372 * 391 * {@internal Missing Long Description}}373 * @since 2.1.0 392 374 * 393 * @package WordPress394 * @subpackage Post395 * @since 2.1396 *397 375 * @uses $wpdb 398 * @uses $posts {@internal Missing Description}}376 * @uses $posts The Loop post global 399 377 * 400 * @param mixed $post post object or post ID401 * @return mixed post type or false378 * @param mixed $post Optional. Post object or post ID. 379 * @return bool|string post type or false on failure. 402 380 */ 403 381 function get_post_type($post = false) { 404 382 global $posts; … … 415 393 } 416 394 417 395 /** 418 * set_post_type() - Set post type396 * Updates the post type for the post ID. 419 397 * 420 * {@internal Missing Long Description}}398 * The page or post cache will be cleaned for the post ID. 421 399 * 422 * @package WordPress 423 * @subpackage Post 424 * @since 2.5 400 * @since 2.5.0 425 401 * 426 402 * @uses $wpdb 427 * @uses $posts {@internal Missing Description}}428 403 * 429 * @param mixed $post_id post ID430 * @param mixed post type431 * @return bool {@internal Missing Description}}404 * @param int $post_id Post ID to change post type. Not actually optional. 405 * @param string $post_type Optional, default is post. Supported values are 'post' or 'page' to name a few. 406 * @return int Amount of rows changed. Should be 1 for success and 0 for failure. 432 407 */ 433 408 function set_post_type( $post_id = 0, $post_type = 'post' ) { 434 409 global $wpdb; … … 445 420 } 446 421 447 422 /** 448 * get_posts() - Returns a number of posts423 * Retrieve list of latest posts or posts matching criteria. 449 424 * 450 425 * {@internal Missing Long Description}} 451 426 * 452 * @package WordPress 453 * @subpackage Post 454 * @since 1.2 427 * @since 1.2.0 455 428 * @uses $wpdb 456 429 * @link http://codex.wordpress.org/Template_Tags/get_posts 457 430 * 458 * @param array $args {@internal Missing Description}}459 * @return array {@internal Missing Description}}431 * @param array $args Optional. Override defaults. 432 * @return array List of posts. 460 433 */ 461 434 function get_posts($args = null) { 462 435 $defaults = array( … … 494 467 // 495 468 496 469 /** 497 * add_post_meta() - adds metadata for post470 * Add meta data field to a post. 498 471 * 499 * {@internal Missing Long Description}}472 * Post meta data is called "Custom Fields" on the Administration Panels. 500 473 * 501 * @package WordPress 502 * @subpackage Post 503 * @since 1.5 474 * @since 1.5.0 504 475 * @uses $wpdb 505 476 * @link http://codex.wordpress.org/Function_Reference/add_post_meta 506 477 * 507 * @param int $post_id post ID508 * @param string $key {@internal Missing Description}}509 * @param mixed $value {@internal Missing Description}}510 * @param bool $unique whether to check for a value with the same key511 * @return bool {@internal Missing Description}}478 * @param int $post_id Post ID. 479 * @param string $key Metadata name. 480 * @param mixed $value Metadata value. 481 * @param bool $unique Optional, default is false. Whether the same key should not be added. 482 * @return bool False for failure. True for success. 512 483 */ 513 484 function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) { 514 485 global $wpdb; … … 533 504 } 534 505 535 506 /** 536 * delete_post_meta() - delete post metadata507 * Remove metadata matching criteria from a post. 537 508 * 538 * {@internal Missing Long Description}} 509 * You can match based on the key, or key and value. Removing based on key and 510 * value, will keep from removing duplicate metadata with the same key. It also 511 * allows removing all metadata matching key, if needed. 539 512 * 540 * @package WordPress 541 * @subpackage Post 542 * @since 1.5 513 * @since 1.5.0 543 514 * @uses $wpdb 544 515 * @link http://codex.wordpress.org/Function_Reference/delete_post_meta 545 516 * 546 517 * @param int $post_id post ID 547 * @param string $key {@internal Missing Description}}548 * @param mixed $value {@internal Missing Description}}549 * @return bool {@internal Missing Description}}518 * @param string $key Metadata name. 519 * @param mixed $value Optional. Metadata value. 520 * @return bool False for failure. True for success. 550 521 */ 551 522 function delete_post_meta($post_id, $key, $value = '') { 552 523 global $wpdb; … … 576 547 } 577 548 578 549 /** 579 * get_post_meta() - Get a post meta field550 * Retrieve post meta field for a post. 580 551 * 581 * {@internal Missing Long Description}} 582 * 583 * @package WordPress 584 * @subpackage Post 585 * @since 1.5 552 * @since 1.5.0 586 553 * @uses $wpdb 587 554 * @link http://codex.wordpress.org/Function_Reference/get_post_meta 588 555 * 589 * @param int $post_id post ID590 * @param string $key The meta key to retrieve 591 * @param bool $single Whether to return a single value 592 * @return mixed {@internal Missing Description}}556 * @param int $post_id Post ID. 557 * @param string $key The meta key to retrieve. 558 * @param bool $single Whether to return a single value. 559 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. 593 560 */ 594 561 function get_post_meta($post_id, $key, $single = false) { 595 562 $post_id = (int) $post_id; … … 620 587 } 621 588 622 589 /** 623 * update_post_meta() - Update a post meta field590 * Update post meta field based on post ID. 624 591 * 625 * {@internal Missing Long Description}} 592 * Use the $prev_value parameter to differentiate between meta fields with the 593 * same key and post ID. 626 594 * 627 * @package WordPress628 * @subpackage Post595 * If the meta field for the post does not exist, it will be added. 596 * 629 597 * @since 1.5 630 598 * @uses $wpdb 631 599 * @link http://codex.wordpress.org/Function_Reference/update_post_meta 632 600 * 633 * @param int $post_id post ID634 * @param string $key {@internal Missing Description}}635 * @param mixed $value {@internal Missing Description}}636 * @param mixed $prev_value previous value (for differentiating between meta fields with the same key and post ID)637 * @return bool {@internal Missing Description}}601 * @param int $post_id Post ID. 602 * @param string $key Metadata key. 603 * @param mixed $value Metadata value. 604 * @param mixed $prev_value Optional. Previous value to check before removing. 605 * @return bool False on failure, true if success. 638 606 */ 639 607 function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') { 640 608 global $wpdb; … … 662 630 } 663 631 664 632 /** 665 * delete_post_meta_by_key() - Delete everything from post meta matching $post_meta_key633 * Delete everything from post meta matching meta key. 666 634 * 667 * @package WordPress 668 * @subpackage Post 669 * @since 2.3 635 * @since 2.3.0 670 636 * @uses $wpdb 671 637 * 672 * @param string $post_meta_key What to search for when deleting638 * @param string $post_meta_key Key to search for when deleting. 673 639 * @return bool Whether the post meta key was deleted from the database 674 640 */ 675 641 function delete_post_meta_by_key($post_meta_key) { … … 683 649 } 684 650 685 651 /** 686 * get_post_custom() - Retrieve post custom fields652 * Retrieve post meta fields, based on post ID. 687 653 * 688 * {@internal Missing Long Description}} 654 * The post meta fields are retrieved from the cache, so the function is 655 * optimized to be called more than once. It also applies to the functions, that 656 * use this function. 689 657 * 690 * @package WordPress 691 * @subpackage Post 692 * @since 1.2 658 * @since 1.2.0 693 659 * @link http://codex.wordpress.org/Function_Reference/get_post_custom 694 660 * 695 * @uses $id 696 * @uses $wpdb 661 * @uses $id Current Loop Post ID 697 662 * 698 663 * @param int $post_id post ID 699 664 * @return array {@internal Missing Description}} … … 713 678 } 714 679 715 680 /** 716 * get_post_custom_keys() - Retrieve post custom field names681 * Retrieve meta field names for a post. 717 682 * 718 * @package WordPress719 * @subpackage Post720 * @since 1.2 683 * If there are no meta fields, then nothing (null) will be returned. 684 * 685 * @since 1.2.0 721 686 * @link http://codex.wordpress.org/Function_Reference/get_post_custom_keys 722 687 * 723 688 * @param int $post_id post ID 724 * @return array|null Either array of the keys, or null if keys would not be retrieved689 * @return array|null Either array of the keys, or null if keys could not be retrieved. 725 690 */ 726 691 function get_post_custom_keys( $post_id = 0 ) { 727 692 $custom = get_post_custom( $post_id ); … … 734 699 } 735 700 736 701 /** 737 * get_post_custom_values() - Retrieve values for a custom post field702 * Retrieve values for a custom post field. 738 703 * 739 * @package WordPress 740 * @subpackage Post 741 * @since 1.2 704 * The parameters must not be considered optional. All of the post meta fields 705 * will be retrieved and only the meta field key values returned. 706 * 707 * @since 1.2.0 742 708 * @link http://codex.wordpress.org/Function_Reference/get_post_custom_values 743 709 * 744 * @param string $key field name745 * @param int $post_id post ID746 * @return mixed {@internal Missing Description}}710 * @param string $key Meta field key. 711 * @param int $post_id Post ID 712 * @return array Meta field values. 747 713 */ 748 714 function get_post_custom_values( $key = '', $post_id = 0 ) { 749 715 $custom = get_post_custom($post_id); … … 752 718 } 753 719 754 720 /** 755 * is_sticky() - Check if post is sticky721 * Check if post is sticky. 756 722 * 757 * {@internal Missing Long Description}} 723 * Sticky posts should remain at the top of The Loop. If the post ID is not 724 * given, then The Loop ID for the current post will be used. 758 725 * 759 * @package WordPress 760 * @subpackage Post 761 * @since 2.7 726 * @since 2.7.0 762 727 * 763 * @param int $post_id A post ID764 * @return bool 728 * @param int $post_id Optional. Post ID. 729 * @return bool Whether post is sticky (true) or not sticky (false). 765 730 */ 766 731 function is_sticky($post_id = null) { 767 732 global $id; … … 782 747 return false; 783 748 } 784 749 785 786 750 /** 787 * sanitize_post() - Sanitize every post field751 * Sanitize every post field. 788 752 * 789 * {@internal Missing Long Description}}753 * If the context is 'raw', then the post object or array will just be returned. 790 754 * 791 * @package WordPress 792 * @subpackage Post 793 * @since 2.3 755 * @since 2.3.0 756 * @uses sanitize_post_field() Used to sanitize the fields. 794 757 * 795 758 * @param object|array $post The Post Object or Array 796 * @param string $context How to sanitize post fields759 * @param string $context Optional, default is 'display'. How to sanitize post fields. 797 760 * @return object|array The now sanitized Post Object or Array (will be the same type as $post) 798 761 */ 799 762 function sanitize_post($post, $context = 'display') { … … 810 773 } 811 774 812 775 /** 813 * sanitize_post_field() - Sanitize post field based on context776 * Sanitize post field based on context. 814 777 * 815 * {@internal Missing Long Description}} 778 * Possible context values are: raw, edit, db, attribute, js, and display. The 779 * display context is used by default. 816 780 * 817 * @package WordPress 818 * @subpackage Post 819 * @since 2.3 781 * @since 2.3.0 820 782 * 821 * @param string $field The Post Object field name 822 * @param string $value The Post Object value823 * @param int $post id Post ID824 * @param string $context How to sanitize post fields 825 * @return string Sanitized value783 * @param string $field The Post Object field name. 784 * @param mixed $value The Post Object value. 785 * @param int $post_id Post ID. 786 * @param string $context How to sanitize post fields. 787 * @return mixed Sanitized value. 826 788 */ 827 789 function sanitize_post_field($field, $value, $post_id, $context) { 828 790 $int_fields = array('ID', 'post_parent', 'menu_order'); … … 882 844 } 883 845 884 846 /** 885 * Make a post sticky 847 * Make a post sticky. 886 848 * 887 * Makes a post stick to the top of the front page849 * Sticky posts should be displayed at the top of the front page. 888 850 * 889 * @package WordPress 890 * @subpackage Post 891 * @since 2.7 851 * @since 2.7.0 892 852 * 893 * @param int $post_id A post ID853 * @param int $post_id Post ID. 894 854 */ 895 855 function stick_post($post_id) { 896 856 $stickies = get_option('sticky_posts'); … … 905 865 } 906 866 907 867 /** 908 * Unstick a post 868 * Unstick a post. 909 869 * 910 * Unstick a post from the front page870 * Sticky posts should be displayed at the top of the front page. 911 871 * 912 * @package WordPress 913 * @subpackage Post 914 * @since 2.7 872 * @since 2.7.0 915 873 * 916 * @param int $post_id A post ID874 * @param int $post_id Post ID. 917 875 */ 918 876 function unstick_post($post_id) { 919 877 $stickies = get_option('sticky_posts'); … … 944 902 * The $perm parameter checks for 'readable' value and if the user can read 945 903 * private posts, it will display that for the user that is signed in. 946 904 * 947 * @package WordPress 948 * @subpackage Post 949 * @since 2.5 905 * @since 2.5.0 950 906 * @link http://codex.wordpress.org/Template_Tags/wp_count_posts 951 907 * 952 908 * @param string $type Optional. Post type to retrieve count … … 988 944 989 945 990 946 /** 991 * wp_count_attachments() - Count number of attachments947 * Count number of attachments for the mime type(s). 992 948 * 993 * {@internal Missing Long Description}} 949 * If you set the optional mime_type parameter, then an array will still be 950 * returned, but will only have the item you are looking for. It does not give 951 * you the number of attachments that are children of a post. You can get that 952 * by counting the number of children that post has. 994 953 * 995 * @package WordPress 996 * @subpackage Post 997 * @since 2.5 954 * @since 2.5.0 998 955 * 999 * @param string|array $ post_mime_type Array or comma-separated list of MIME patterns1000 * @return array Number of posts for each post_mime_type956 * @param string|array $mime_type Optional. Array or comma-separated list of MIME patterns. 957 * @return array Number of posts for each mime type. 1001 958 */ 1002 1003 959 function wp_count_attachments( $mime_type = '' ) { 1004 960 global $wpdb; 1005 961 … … 1015 971 } 1016 972 1017 973 /** 1018 * wp_match_mime_type() - Check a MIME-Type against a list974 * Check a MIME-Type against a list. 1019 975 * 1020 * {@internal Missing Long Description}} 976 * If the wildcard_mime_types parameter is a string, it must be comma separated 977 * list. If the real_mime_types is a string, it is also comma separated to 978 * create the list. 1021 979 * 1022 * @package WordPress 1023 * @subpackage Post 1024 * @since 2.5 980 * @since 2.5.0 1025 981 * 1026 982 * @param string|array $wildcard_mime_types e.g. audio/mpeg or image (same as image/*) or flash (same as *flash*) 1027 983 * @param string|array $real_mime_types post_mime_type values … … 1052 1008 } 1053 1009 1054 1010 /** 1055 * wp_get_post_mime_type_where() - Convert MIME types into SQL1011 * Convert MIME types into SQL. 1056 1012 * 1057 * @package WordPress 1058 * @subpackage Post 1059 * @since 2.5 1013 * @since 2.5.0 1060 1014 * 1061 * @param string|array $mime_types MIME types1062 * @return string SQL AND clause1015 * @param string|array $mime_types List of mime types or comma separated string of mime types. 1016 * @return string The SQL AND clause for mime searching. 1063 1017 */ 1064 1018 function wp_post_mime_type_where($post_mime_types) { 1065 1019 $where = ''; … … 1099 1053 } 1100 1054 1101 1055 /** 1102 * wp_delete_post() - Deletes a Post1056 * Removes a post, attachment, or page post type. 1103 1057 * 1104 * {@internal Missing Long Description}}1105 *1106 * @package WordPress1107 * @subpackage Post1108 1058 * @since 1.0.0 1059 * @uses do_action() Calls 'deleted_post' hook on post ID. 1109 1060 * 1110 * @param int $postid post ID1111 * @return mixed {@internal Missing Description}}1061 * @param int $postid Post ID. 1062 * @return mixed 1112 1063 */ 1113 1064 function wp_delete_post($postid = 0) { 1114 1065 global $wpdb, $wp_rewrite; … … 1177 1128 } 1178 1129 1179 1130 /** 1180 * wp_get_post_categories() - Retrieve the list of categories for a post1131 * Retrieve the list of categories for a post. 1181 1132 * 1182 1133 * Compatibility layer for themes and plugins. Also an easy layer of abstraction 1183 1134 * away from the complexity of the taxonomy layer. 1184 1135 * 1185 * @package WordPress 1186 * @subpackage Post 1187 * @since 2.1 1136 * @since 2.1.0 1188 1137 * 1189 1138 * @uses wp_get_object_terms() Retrieves the categories. Args details can be found here 1190 1139 * … … 1203 1152 } 1204 1153 1205 1154 /** 1206 * wp_get_post_tags() - Retrieve the post tags1155 * Retrieve the tags for a post. 1207 1156 * 1157 * There is only one default for this function, called 'fields' and by default 1158 * is set to 'all'. There are other defaults that can be override in 1159 * {@link wp_get_object_terms()}. 1160 * 1208 1161 * @package WordPress 1209 1162 * @subpackage Post 1210 * @since 2.3 1163 * @since 2.3.0 1211 1164 * 1212 1165 * @uses wp_get_object_terms() Gets the tags for returning. Args can be found here 1213 1166 * 1214 1167 * @param int $post_id Optional. The Post ID 1215 1168 * @param array $args Optional. Overwrite the defaults 1216 * @return mixed The tags the post has currently1169 * @return array List of post tags. 1217 1170 */ 1218 1171 function wp_get_post_tags( $post_id = 0, $args = array() ) { 1219 1172 $post_id = (int) $post_id; … … 1227 1180 } 1228 1181 1229 1182 /** 1230 * wp_get_recent_posts() - Get the $num most recent posts1183 * Retrieve number of recent posts. 1231 1184 * 1232 * {@internal Missing Long Description}}1233 *1234 * @package WordPress1235 * @subpackage Post1236 1185 * @since 1.0.0 1186 * @uses $wpdb 1237 1187 * 1238 * @param int $num number of posts to get1239 * @return array {@internal Missing Description}}1188 * @param int $num Optional, default is 10. Number of posts to get. 1189 * @return array List of posts. 1240 1190 */ 1241 1191 function wp_get_recent_posts($num = 10) { 1242 1192 global $wpdb; … … 1250 1200 $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC $limit"; 1251 1201 $result = $wpdb->get_results($sql,ARRAY_A); 1252 1202 1253 return $result ?$result:array();1203 return $result ? $result : array(); 1254 1204 } 1255 1205 1256 1206 /** 1257 * wp_get_single_post() - Get one post1207 * Retrieve a single post, based on post ID. 1258 1208 * 1259 * {@internal Missing Long Description}} 1209 * Has categories in 'post_category' property or key. Has tags in 'tags_input' 1210 * property or key. 1260 1211 * 1261 * @package WordPress1262 * @subpackage Post1263 1212 * @since 1.0.0 1264 * @uses $wpdb1265 1213 * 1266 * @param int $postid post ID1267 * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A 1214 * @param int $postid Post ID 1215 * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A. 1268 1216 * @return object|array Post object or array holding post contents and information 1269 1217 */ 1270 1218 function wp_get_single_post($postid = 0, $mode = OBJECT) { … … 1286 1234 } 1287 1235 1288 1236 /** 1289 * wp_insert_post() - Insert a post1237 * wp_insert_post() - 1290 1238 * 1291 * {@internal Missing Long Description}}1292 *1293 1239 * @package WordPress 1294 1240 * @subpackage Post 1295 * @since 1.0.01296 1241 * 1242 * @uses $allowedtags 1243 * 1244 * @param array $postarr 1245 * @return int post ID or 0 on error 1246 */ 1247 /** 1248 * Insert a post. 1249 * 1250 * {@internal Missing Long Description}} 1251 * 1252 * @since 1.0.0 1297 1253 * @uses $wpdb 1298 1254 * @uses $wp_rewrite 1299 1255 * @uses $user_ID 1300 * @uses $allowedtags1301 1256 * 1302 * @param array $postarr post contents 1303 * @return int post ID or 0 on error 1257 * @param array $postarr Optional. Override defaults. 1258 * @param bool $wp_error Optional. Allow return of WP_Error on failure. 1259 * @return int|WP_Error {@internal Missing Description}} 1304 1260 */ 1305 1261 function wp_insert_post($postarr = array(), $wp_error = false) { 1306 1262 global $wpdb, $wp_rewrite, $user_ID; … … 1511 1467 * 1512 1468 * {@internal Missing Long Description}} 1513 1469 * 1514 * @package WordPress1515 * @subpackage Post1516 1470 * @since 1.0.0 1517 1471 * @uses $wpdb 1518 1472 * 1519 * @param array $postarr post data1473 * @param array|object $postarr post data 1520 1474 * @return int {@internal Missing Description}} 1521 1475 */ 1522 1476 function wp_update_post($postarr = array()) { … … 1558 1512 } 1559 1513 1560 1514 /** 1561 * wp_publish_post() - Mark a post as "published"1515 * Publish a post by transitioning the post status. 1562 1516 * 1563 * {@internal Missing Long Description}} 1564 * 1565 * @package WordPress 1566 * @subpackage Post 1567 * @since 2.1 1517 * @since 2.1.0 1568 1518 * @uses $wpdb 1519 * @uses do_action() Calls 'edit_post', 'save_post', and 'wp_insert_post' on post_id and post data. 1569 1520 * 1570 1521 * @param int $post_id Post ID 1571 1522 * @return int|null {@internal Missing Description}} … … 1599 1550 } 1600 1551 1601 1552 /** 1602 * check_and_publish_future_post() - check to make sure post has correct status before 1603 * passing it on to be published. Invoked by cron 'publish_future_post' event 1604 * This safeguard prevents cron from publishing drafts, etc. 1553 * Publish future post and make sure post ID has future post status. 1605 1554 * 1606 * {@internal Missing Long Description}} 1555 * Invoked by cron 'publish_future_post' event. This safeguard prevents cron 1556 * from publishing drafts, etc. 1607 1557 * 1608 * @package WordPress 1609 * @subpackage Post 1610 * @since 2.5 1611 * @uses $wpdb 1558 * @since 2.5.0 1612 1559 * 1613 * @param int $post_id Post ID 1614 * @return int|null {@internal Missing Description}}1560 * @param int $post_id Post ID. 1561 * @return null Nothing is returned. Which can mean that no action is required or post was published. 1615 1562 */ 1616 1563 function check_and_publish_future_post($post_id) { 1617 1564 … … 1627 1574 } 1628 1575 1629 1576 /** 1630 * wp_add_post_tags() - Adds the tags to a post1577 * Adds tags to a post. 1631 1578 * 1632 * @uses wp_set_post_tags() Same first two para eters, but the last parameter is always set to true.1579 * @uses wp_set_post_tags() Same first two parameters, but the last parameter is always set to true. 1633 1580 * 1634 1581 * @package WordPress 1635 1582 * @subpackage Post 1636 * @since 2.3 1583 * @since 2.3.0 1637 1584 * 1638 * @param int $post_id Optional.Post ID1639 * @param string $tags The tags to set for the post 1585 * @param int $post_id Post ID 1586 * @param string $tags The tags to set for the post, separated by commas. 1640 1587 * @return bool|null Will return false if $post_id is not an integer or is 0. Will return null otherwise 1641 1588 */ 1642 1589 function wp_add_post_tags($post_id = 0, $tags = '') { 1643 1590 return wp_set_post_tags($post_id, $tags, true); 1644 1591 } 1645 1592 1593 1646 1594 /** 1647 * wp_set_post_tags() - Set the tags for a post1595 * Set the tags for a post. 1648 1596 * 1649 * {@internal Missing Long Description}} 1597 * @since 2.3.0 1598 * @uses wp_set_object_terms() Sets the tags for the post. 1650 1599 * 1651 * @package WordPress 1652 * @subpackage Post 1653 * @since 2.3 1654 * @uses $wpdb 1655 * 1656 * @param int $post_id post ID 1657 * @param string $tags The tags to set for the post 1600 * @param int $post_id Post ID. 1601 * @param string $tags The tags to set for the post, separated by commas. 1658 1602 * @param bool $append If true, don't delete existing tags, just add on. If false, replace the tags with the new tags. 1659 1603 * @return bool|null Will return false if $post_id is not an integer or is 0. Will return null otherwise 1660 1604 */ … … 1672 1616 } 1673 1617 1674 1618 /** 1675 * wp_set_post_categories() - Set categories for a post1619 * Set categories for a post. 1676 1620 * 1677 * {@internal Missing Long Description}} 1621 * If the post categories parameter is not set, then the default category is 1622 * going used. 1678 1623 * 1679 * @package WordPress 1680 * @subpackage Post 1681 * @since 2.1 1682 * @uses $wpdb 1624 * @since 2.1.0 1683 1625 * 1684 * @param int $post_ID post ID1685 * @param array $post_categories 1686 * @return bool|mixed {@internal Missing Description}}1626 * @param int $post_ID Post ID. 1627 * @param array $post_categories Optional. List of categories. 1628 * @return bool|mixed 1687 1629 */ 1688 1630 function wp_set_post_categories($post_ID = 0, $post_categories = array()) { 1689 1631 $post_ID = (int) $post_ID; … … 1697 1639 $post_categories = array_unique($post_categories); 1698 1640 1699 1641 return wp_set_object_terms($post_ID, $post_categories, 'category'); 1700 } // wp_set_post_categories()1642 } 1701 1643 1702 1644 /** 1703 * wp_transition_post_status() - Change the post transition status1645 * Transition the post status of a post. 1704 1646 * 1705 * {@internal Missing Long Description}} 1647 * Calls hooks to transition post status. If the new post status is not the same 1648 * as the previous post status, then two hooks will be ran, the first is 1649 * 'transition_post_status' with new status, old status, and post data. The 1650 * next action called is 'OLDSTATUS_to_NEWSTATUS' the NEWSTATUS is the 1651 * $new_status parameter and the OLDSTATUS is $old_status parameter; it has the 1652 * post data. 1706 1653 * 1707 * @package WordPress1708 * @subpackage Post1709 * @since 2.31654 * The final action will run whether or not the post statuses are the same. The 1655 * action is named 'NEWSTATUS_POSTTYPE', NEWSTATUS is from the $new_status 1656 * parameter and POSTTYPE is post_type post data. 1710 1657 * 1711 * @param string $new_status {@internal Missing Description}} 1712 * @param string $old_status {@internal Missing Description}} 1713 * @param int $post {@internal Missing Description}} 1658 * @since 2.3.0 1659 * 1660 * @param string $new_status Transition to this post status. 1661 * @param string $old_status Previous post status. 1662 * @param object $post Post data. 1714 1663 */ 1715 1664 function wp_transition_post_status($new_status, $old_status, $post) { 1716 1665 if ( $new_status != $old_status ) { … … 1725 1674 // 1726 1675 1727 1676 /** 1728 * add_ping() - Add a URL to those already pung1677 * Add a URL to those already pung. 1729 1678 * 1730 * {@internal Missing Long Description}} 1731 * 1732 * @package WordPress 1733 * @subpackage Post 1734 * @since 1.5 1679 * @since 1.5.0 1735 1680 * @uses $wpdb 1736 1681 * 1737 * @param int $post_id post ID1738 * @param string $uri {@internal Missing Description}}1739 * @return mixed {@internal Missing Description}}1682 * @param int $post_id Post ID. 1683 * @param string $uri Ping URI. 1684 * @return int How many rows were updated. 1740 1685 */ 1741 1686 function add_ping($post_id, $uri) { 1742 1687 global $wpdb; … … 1752 1697 } 1753 1698 1754 1699 /** 1755 * get_enclosed() - Get enclosures already enclosed for a post1700 * Retrieve enclosures already enclosed for a post. 1756 1701 * 1757 * {@internal Missing Long Description}} 1758 * 1759 * @package WordPress 1760 * @subpackage Post 1761 * @since 1.5 1702 * @since 1.5.0 1762 1703 * @uses $wpdb 1763 1704 * 1764 * @param int $post_id post ID1765 * @return array {@internal Missing Description}}1705 * @param int $post_id Post ID. 1706 * @return array List of enclosures 1766 1707 */ 1767 1708 function get_enclosed($post_id) { 1768 1709 $custom_fields = get_post_custom( $post_id ); … … 1783 1724 } 1784 1725 1785 1726 /** 1786 * get_pung() - Get URLs already pinged for a post1727 * Retrieve URLs already pinged for a post. 1787 1728 * 1788 * {@internal Missing Long Description}} 1789 * 1790 * @package WordPress 1791 * @subpackage Post 1792 * @since 1.5 1729 * @since 1.5.0 1793 1730 * @uses $wpdb 1794 1731 * 1795 * @param int $post_id post ID1796 * @return array {@internal Missing Description}}1732 * @param int $post_id Post ID. 1733 * @return array 1797 1734 */ 1798 1735 function get_pung($post_id) { 1799 1736 global $wpdb; … … 1805 1742 } 1806 1743 1807 1744 /** 1808 * get_to_ping() - Get any URLs in the todo list1745 * Retrieve URLs that need to be pinged. 1809 1746 * 1810 * {@internal Missing Long Description}} 1811 * 1812 * @package WordPress 1813 * @subpackage Post 1814 * @since 1.5 1747 * @since 1.5.0 1815 1748 * @uses $wpdb 1816 1749 * 1817 * @param int $post_id post ID1818 * @return array {@internal Missing Description}}1750 * @param int $post_id Post ID 1751 * @return array 1819 1752 */ 1820 1753 function get_to_ping($post_id) { 1821 1754 global $wpdb; … … 1827 1760 } 1828 1761 1829 1762 /** 1830 * trackback_url_list() - Do trackbacks for a list of urls1763 * Do trackbacks for a list of URLs. 1831 1764 * 1832 * {@internal Missing Long Description}}1833 *1834 * @package WordPress1835 * @subpackage Post1836 1765 * @since 1.0.0 1837 1766 * 1838 * @param string $tb_list comma separated list of URLs1839 * @param int $post_id post ID1767 * @param string $tb_list Comma separated list of URLs 1768 * @param int $post_id Post ID 1840 1769 */ 1841 1770 function trackback_url_list($tb_list, $post_id) { 1842 if ( !empty($tb_list)) {1771 if ( ! empty( $tb_list ) ) { 1843 1772 // get post data 1844 1773 $postdata = wp_get_single_post($post_id, ARRAY_A); 1845 1774 … … 1847 1776 extract($postdata, EXTR_SKIP); 1848 1777 1849 1778 // form an excerpt 1850 $excerpt = strip_tags($post_excerpt ?$post_excerpt:$post_content);1779 $excerpt = strip_tags($post_excerpt ? $post_excerpt : $post_content); 1851 1780 1852 1781 if (strlen($excerpt) > 255) { 1853 1782 $excerpt = substr($excerpt,0,252) . '...'; … … 1855 1784 1856 1785 $trackback_urls = explode(',', $tb_list); 1857 1786 foreach( (array) $trackback_urls as $tb_url) { 1858 $tb_url = trim($tb_url);1859 trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);1787 $tb_url = trim($tb_url); 1788 trackback($tb_url, stripslashes($post_title), $excerpt, $post_id); 1860 1789 } 1861 }1790 } 1862 1791 } 1863 1792 1864 1793 // … … 1866 1795 // 1867 1796 1868 1797 /** 1869 * get_all_page_ids() - Get a list of page IDs1798 * Get a list of page IDs. 1870 1799 * 1871 * {@internal Missing Long Description}} 1872 * 1873 * @package WordPress 1874 * @subpackage Post 1875 * @since 2.0 1800 * @since 2.0.0 1876 1801 * @uses $wpdb 1877 1802 * 1878 * @return array {@internal Missing Description}}1803 * @return array List of page IDs. 1879 1804 */ 1880 1805 function get_all_page_ids() { 1881 1806 global $wpdb; … … 1889 1814 } 1890 1815 1891 1816 /** 1892 * get_page() - Retrieves page data given a page ID or page object1817 * Retrieves page data given a page ID or page object. 1893 1818 * 1894 * {@internal Missing Long Description}}1895 *1896 * @package WordPress1897 * @subpackage Post1898 1819 * @since 1.5.1 1899 1820 * 1900 * @param mixed &$page page object or page ID1901 * @param string $output what to output1821 * @param mixed $page Page object or page ID. Passed by reference. 1822 * @param string $output What to output. OBJECT, ARRAY_A, or ARRAY_N. 1902 1823 * @param string $filter How the return value should be filtered. 1903 * @return mixed {@internal Missing Description}}1824 * @return mixed Page data. 1904 1825 */ 1905 1826 function &get_page(&$page, $output = OBJECT, $filter = 'raw') { 1906 1827 if ( empty($page) ) { … … 1916 1837 } 1917 1838 1918 1839 /** 1919 * get_page_by_path() - Retrieves a page given its path1840 * Retrieves a page given its path. 1920 1841 * 1921 * {@internal Missing Long Description}} 1922 * 1923 * @package WordPress 1924 * @subpackage Post 1925 * @since 2.1 1842 * @since 2.1.0 1926 1843 * @uses $wpdb 1927 1844 * 1928 * @param string $page_path page path1929 * @param string $output output type1930 * @return mixed {@internal Missing Description}}1845 * @param string $page_path Page path 1846 * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. 1847 * @return mixed Null when complete. 1931 1848 */ 1932 1849 function get_page_by_path($page_path, $output = OBJECT) { 1933 1850 global $wpdb; … … 1944 1861 $pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND (post_type = 'page' OR post_type = 'attachment')", $leaf_path )); 1945 1862 1946 1863 if ( empty($pages) ) 1947 return NULL;1864 return null; 1948 1865 1949 1866 foreach ($pages as $page) { 1950 1867 $path = '/' . $leaf_path; … … 1958 1875 return get_page($page->ID, $output); 1959 1876 } 1960 1877 1961 return NULL;1878 return null; 1962 1879 } 1963 1880 1964 1881 /** 1965 * get_page_by_title() - Retrieve a page given its title1882 * Retrieve a page given its title. 1966 1883 * 1967 * {@internal Missing Long Description}} 1968 * 1969 * @package WordPress 1970 * @subpackage Post 1971 * @since 2.1 1884 * @since 2.1.0 1972 1885 * @uses $wpdb 1973 1886 * 1974 * @param string $page_title page title1975 * @param string $output output type1976 * @return mixed {@internal Missing Description}}1887 * @param string $page_title Page title 1888 * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. 1889 * @return mixed 1977 1890 */ 1978 1891 function get_page_by_title($page_title, $output = OBJECT) { 1979 1892 global $wpdb; … … 1981 1894 if ( $page ) 1982 1895 return get_page($page, $output); 1983 1896 1984 return NULL;1897 return null; 1985 1898 } 1986 1899 1987 1900 /** … … 1989 1902 * 1990 1903 * {@internal Missing Long Description}} 1991 1904 * 1992 * @package WordPress1993 * @subpackage Post1994 1905 * @since 1.5.1 1995 1906 * 1996 1907 * @param int $page_id page ID … … 2036 1947 } 2037 1948 2038 1949 /** 2039 * get_page_uri() - Builds a page URI1950 * Builds a page URI. 2040 1951 * 2041 * {@internal Missing Long Description}}1952 * @since 1.5.0 2042 1953 * 2043 * @package WordPress 2044 * @subpackage Post 2045 * @since 1.5 2046 * 2047 * @param int $page_id page ID 2048 * @return string {@internal Missing Description}} 1954 * @param int $page_id Page ID. 1955 * @return string Page URI. 2049 1956 */ 2050 1957 function get_page_uri($page_id) { 2051 1958 $page = get_page($page_id); … … 2064 1971 } 2065 1972 2066 1973 /** 2067 * get_pages() - Retrieve a list of pages1974 * Retrieve a list of pages. 2068 1975 * 2069 1976 * {@internal Missing Long Description}} 2070 1977 * 2071 * @package WordPress 2072 * @subpackage Post 2073 * @since 1.5 1978 * @since 1.5.0 2074 1979 * @uses $wpdb 2075 1980 * 2076 * @param mixed $args Optional. Array or string of options 1981 * @param mixed $args Optional. Array or string of options that overrides defaults. 2077 1982 * @return array List of pages matching defaults or $args 2078 1983 */ 2079 1984 function &get_pages($args = '') { … … 2198 2103 // 2199 2104 2200 2105 /** 2201 * is_local_attachment() -Check if the attachment URI is local one and is really an attachment.2106 * Check if the attachment URI is local one and is really an attachment. 2202 2107 * 2203 * {@internal Missing Long Description}}2108 * @since 2.0.0 2204 2109 * 2205 * @package WordPress2206 * @subpackage Post2207 * @since 2.02208 *2209 2110 * @param string $url URL to check 2210 * @return bool {@internal Missing Description}}2111 * @return bool True on success, false on failure. 2211 2112 */ 2212 2113 function is_local_attachment($url) { 2213 2114 if (strpos($url, get_bloginfo('url')) === false) … … 2223 2124 } 2224 2125 2225 2126 /** 2226 * wp_insert_attachment() - Insert an attachment2127 * Insert an attachment. 2227 2128 * 2228 2129 * {@internal Missing Long Description}} 2229 2130 * 2230 * @package WordPress 2231 * @subpackage Post 2232 * @since 2.0 2233 * 2131 * @since 2.0.0 2234 2132 * @uses $wpdb 2235 2133 * @uses $user_ID 2236 2134 * 2237 * @param object $object attachment object2238 * @param string $file filename2239 * @param int $post_parent parent post ID2135 * @param object $object Attachment object. 2136 * @param string $file Optional filename. 2137 * @param int $post_parent Parent post ID. 2240 2138 * @return int {@internal Missing Description}} 2241 2139 */ 2242 2140 function wp_insert_attachment($object, $file = false, $parent = 0) { … … 2367 2265 } 2368 2266 2369 2267 /** 2370 * wp_delete_attachment() - Delete an attachment2268 * Delete an attachment. 2371 2269 * 2372 * {@internal Missing Long Description}}2270 * Will remove the file also, when the attachment is removed. 2373 2271 * 2374 * @package WordPress 2375 * @subpackage Post 2376 * @since 2.0 2272 * @since 2.0.0 2377 2273 * @uses $wpdb 2378 2274 * 2379 * @param int $postid attachment Id2380 * @return mixed {@internal Missing Description}}2275 * @param int $postid Attachment ID 2276 * @return mixed False on failure. Post data on success. 2381 2277 */ 2382 2278 function wp_delete_attachment($postid) { 2383 2279 global $wpdb; … … 2431 2327 } 2432 2328 2433 2329 /** 2434 * wp_get_attachment_metadata() - Retrieve metadata for an attachment2330 * Retrieve attachment meta field for attachment ID. 2435 2331 * 2436 * {@internal Missing Long Description}}2332 * @since 2.1.0 2437 2333 * 2438 * @package WordPress 2439 * @subpackage Post 2440 * @since 2.1 2441 * 2442 * @param int $post_id attachment ID 2443 * @param bool $unfiltered Optional, default is false. If true, filters are not run 2444 * @return array {@internal Missing Description}} 2334 * @param int $post_id Attachment ID 2335 * @param bool $unfiltered Optional, default is false. If true, filters are not run. 2336 * @return string|bool Attachment meta field. False on failure. 2445 2337 */ 2446 2338 function wp_get_attachment_metadata( $post_id, $unfiltered = false ) { 2447 2339 $post_id = (int) $post_id; … … 2455 2347 } 2456 2348 2457 2349 /** 2458 * wp_update_attachment_metadata() - Update metadata for an attachment2350 * Update metadata for an attachment. 2459 2351 * 2460 * {@internal Missing Long Description}}2352 * @since 2.1.0 2461 2353 * 2462 * @package WordPress2463 * @subpackage Post2464 * @since 2.12465 *2466 2354 * @param int $post_id attachment ID 2467 2355 * @param array $data attachment data 2468 * @return int {@internal Missing Description}}2356 * @return int 2469 2357 */ 2470 2358 function wp_update_attachment_metadata( $post_id, $data ) { 2471 2359 $post_id = (int) $post_id; … … 2478 2366 } 2479 2367 2480 2368 /** 2481 * wp_get_attachment_url() - Retrieve the URL for an attachment2369 * Retrieve the URL for an attachment. 2482 2370 * 2483 * {@internal Missing Long Description}}2371 * @since 2.1.0 2484 2372 * 2485 * @package WordPress 2486 * @subpackage Post 2487 * @since 2.1 2488 * 2489 * @param int $post_id attachment ID 2490 * @return string {@internal Missing Description}} 2373 * @param int $post_id Attachment ID. 2374 * @return string 2491 2375 */ 2492 2376 function wp_get_attachment_url( $post_id = 0 ) { 2493 2377 $post_id = (int) $post_id; … … 2503 2387 } 2504 2388 2505 2389 /** 2506 * wp_get_attachment_thumb_file() - Retrieve thumbnail for an attachment2390 * Retrieve thumbnail for an attachment. 2507 2391 * 2508 * {@internal Missing Long Description}}2392 * @since 2.1.0 2509 2393 * 2510 * @package WordPress 2511 * @subpackage Post 2512 * @since 2.1 2513 * 2514 * @param int $post_id attachment ID 2515 * @return mixed {@internal Missing Description}} 2394 * @param int $post_id Attachment ID. 2395 * @return mixed False on failure. Thumbnail file path on success. 2516 2396 */ 2517 2397 function wp_get_attachment_thumb_file( $post_id = 0 ) { 2518 2398 $post_id = (int) $post_id; … … 2529 2409 } 2530 2410 2531 2411 /** 2532 * wp_get_attachment_thumb_url() - Retrieve URL for an attachment thumbnail2412 * Retrieve URL for an attachment thumbnail. 2533 2413 * 2534 * {@internal Missing Long Description}}2414 * @since 2.1.0 2535 2415 * 2536 * @package WordPress 2537 * @subpackage Post 2538 * @since 2.1 2539 * 2540 * @param int $post_id attachment ID 2541 * @return string {@internal Missing Description}} 2416 * @param int $post_id Attachment ID 2417 * @return string|bool False on failure. Thumbnail URL on success. 2542 2418 */ 2543 2419 function wp_get_attachment_thumb_url( $post_id = 0 ) { 2544 2420 $post_id = (int) $post_id; … … 2560 2436 } 2561 2437 2562 2438 /** 2563 * wp_attachment_is_image() - Check if the attachment is an image2439 * Check if the attachment is an image. 2564 2440 * 2565 * {@internal Missing Long Description}}2441 * @since 2.1.0 2566 2442 * 2567 * @package WordPress 2568 * @subpackage Post 2569 * @since 2.1 2570 * 2571 * @param int $post_id attachment ID 2572 * @return bool {@internal Missing Description}} 2443 * @param int $post_id Attachment ID 2444 * @return bool 2573 2445 */ 2574 2446 function wp_attachment_is_image( $post_id = 0 ) { 2575 2447 $post_id = (int) $post_id; … … 2589 2461 } 2590 2462 2591 2463 /** 2592 * wp_mime_type_icon() - Retrieve the icon for a MIME type2464 * Retrieve the icon for a MIME type. 2593 2465 * 2594 2466 * {@internal Missing Long Description}} 2595 2467 * 2596 * @package WordPress 2597 * @subpackage Post 2598 * @since 2.1 2468 * @since 2.1.0 2599 2469 * 2600 2470 * @param string $mime MIME type 2601 2471 * @return string|bool {@internal Missing Description}} … … 2679 2549 } 2680 2550 2681 2551 /** 2682 * wp_check_for_changed_slugs() -{@internal Missing Short Description}}2552 * {@internal Missing Short Description}} 2683 2553 * 2684 2554 * {@internal Missing Long Description}} 2685 2555 * 2686 * @package WordPress2687 * @subpackage Post2688 2556 * @since 2.1 2689 2557 * 2690 * @param int $post_id The Post ID2558 * @param int $post_id Post ID. 2691 2559 * @return int Same as $post_id 2692 2560 */ 2693 2561 function wp_check_for_changed_slugs($post_id) { … … 2718 2586 } 2719 2587 2720 2588 /** 2721 * get_private_posts_cap_sql() -{@internal Missing Short Description}}2589 * {@internal Missing Short Description}} 2722 2590 * 2723 * This function provides a standardized way to appropriately select on 2724 * the post_status of posts/pages. The function will return a piece of 2725 * SQL code that can be added to a WHERE clause; this SQL is constructed 2726 * to allow all published posts, and all private posts to which the user 2727 * has access. 2591 * This function provides a standardized way to appropriately select on the 2592 * post_status of posts/pages. The function will return a piece of SQL code that 2593 * can be added to a WHERE clause; this SQL is constructed to allow all 2594 * published posts, and all private posts to which the user has access. 2728 2595 * 2729 * @package WordPress 2730 * @subpackage Post 2731 * @since 2.2 2596 * @since 2.2.0 2732 2597 * 2733 2598 * @uses $user_ID 2734 2599 * @uses apply_filters() Call 'pub_priv_sql_capability' filter for plugins with different post types … … 2859 2724 } 2860 2725 2861 2726 /** 2862 * update_post_cache() - Updates posts in cache2727 * Updates posts in cache. 2863 2728 * 2864 * @usedby update_page_cache() update_page_cache() aliased by this function.2729 * @usedby update_page_cache() Aliased by this function. 2865 2730 * 2866 2731 * @package WordPress 2867 2732 * @subpackage Cache … … 2878 2743 } 2879 2744 2880 2745 /** 2881 * clean_post_cache() - Will clean the post in the cache2746 * Will clean the post in the cache. 2882 2747 * 2883 * Cleaning means delete from the cache of the post. Will call to clean 2884 * the termobject cache associated with the post ID.2748 * Cleaning means delete from the cache of the post. Will call to clean the term 2749 * object cache associated with the post ID. 2885 2750 * 2886 2751 * @package WordPress 2887 2752 * @subpackage Cache 2888 * @since 2.0 2753 * @since 2.0.0 2889 2754 * 2890 2755 * @uses do_action() Will call the 'clean_post_cache' hook action. 2891 2756 * … … 2911 2776 } 2912 2777 2913 2778 /** 2914 * update_page_cache() - Alias of update_post_cache()2779 * Alias of update_post_cache(). 2915 2780 * 2916 2781 * @see update_post_cache() Posts and pages are the same, alias is intentional 2917 2782 * … … 2926 2791 } 2927 2792 2928 2793 /** 2929 * clean_page_cache() - Will clean the page in the cache2794 * Will clean the page in the cache. 2930 2795 * 2931 * Clean (read: delete) page from cache that matches $id. Will also clean 2932 * cacheassociated with 'all_page_ids' and 'get_pages'.2796 * Clean (read: delete) page from cache that matches $id. Will also clean cache 2797 * associated with 'all_page_ids' and 'get_pages'. 2933 2798 * 2934 2799 * @package WordPress 2935 2800 * @subpackage Cache … … 2949 2814 } 2950 2815 2951 2816 /** 2952 * update_post_caches() -Call major cache updating functions for list of Post objects.2817 * Call major cache updating functions for list of Post objects. 2953 2818 * 2954 2819 * @package WordPress 2955 2820 * @subpackage Cache 2956 * @since 1.5 2821 * @since 1.5.0 2957 2822 * 2958 2823 * @uses $wpdb 2959 2824 * @uses update_post_cache() … … 3080 2945 } 3081 2946 3082 2947 /** 3083 * _future_post_hook() -Hook used to schedule publication for a post marked for the future.2948 * Hook used to schedule publication for a post marked for the future. 3084 2949 * 3085 2950 * The $post properties used and must exist are 'ID' and 'post_date_gmt'. 3086 2951 * 3087 2952 * @package WordPress 3088 2953 * @subpackage Post 3089 * @since 2.3 2954 * @since 2.3.0 3090 2955 * 3091 2956 * @param int $post_id Not Used. Can be set to null. 3092 2957 * @param object $post Object type containing the post information … … 3132 2997 } 3133 2998 3134 2999 /** 3135 * _save_post_hook() - Hook used to prevent page/post cache and rewrite rules from staying dirty3000 * Hook used to prevent page/post cache and rewrite rules from staying dirty. 3136 3001 * 3137 3002 * Does two things. If the post is a page and has a template then it will update/add that 3138 3003 * template to the meta. For both pages and posts, it will clean the post cache to make sure … … 3143 3008 * 3144 3009 * @package WordPress 3145 3010 * @subpackage Post 3146 * @since 2.3 3011 * @since 2.3.0 3147 3012 * 3148 3013 * @uses $wp_rewrite Flushes Rewrite Rules. 3149 3014 * … … 3164 3029 // Private 3165 3030 // 3166 3031 3032 /** 3033 * 3034 * 3035 * @param unknown_type $_post 3036 */ 3167 3037 function _get_post_ancestors(&$_post) { 3168 3038 global $wpdb; 3169 3039 … … 3183 3053 } 3184 3054 } 3185 3055 3186 /* Post Revisions */3187 3188 3056 /** 3189 * _wp_post_revision_fields() - determines which fields of posts are to be saved in revisions3057 * Determines which fields of posts are to be saved in revisions. 3190 3058 * 3191 * Does two things. If passed a post *array*, it will return a post array ready to be3192 * insterted into the posts table as a post revision.3193 * Otherwise, returnsan array whose keys are the post fields to be saved for post revisions.3059 * Does two things. If passed a post *array*, it will return a post array ready 3060 * to be insterted into the posts table as a post revision. Otherwise, returns 3061 * an array whose keys are the post fields to be saved for post revisions. 3194 3062 * 3195 3063 * @package WordPress 3196 * @subpackage Post Revisions 3197 * @since 2.6 3064 * @subpackage Post_Revisions 3065 * @since 2.6.0 3066 * @access private 3198 3067 * 3199 * @param array $post optional a post array to be processed for insertion as a post revision3068 * @param array $post Optional a post array to be processed for insertion as a post revision. 3200 3069 * @param bool $autosave optional Is the revision an autosave? 3201 * @return array post array ready to be inserted as a post revision or array of fields that can be versioned3070 * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned. 3202 3071 */ 3203 3072 function _wp_post_revision_fields( $post = null, $autosave = false ) { 3204 3073 static $fields = false; … … 3237 3106 } 3238 3107 3239 3108 /** 3240 * wp_save_post_revision() - Saves an already existing post as a post revision. Typically used immediately prior to post updates.3109 * Saves an already existing post as a post revision. 3241 3110 * 3111 * Typically used immediately prior to post updates. 3112 * 3242 3113 * @package WordPress 3243 * @subpackage Post Revisions3244 * @since 2.6 3114 * @subpackage Post_Revisions 3115 * @since 2.6.0 3245 3116 * 3246 3117 * @uses _wp_put_post_revision() 3247 3118 * 3248 * @param int $post_id The ID of the post to save as a revision 3249 * @return mixed null or 0 if error, new revision ID if success3119 * @param int $post_id The ID of the post to save as a revision. 3120 * @return mixed Null or 0 if error, new revision ID, if success. 3250 3121 */ 3251 3122 function wp_save_post_revision( $post_id ) { 3252 3123 // We do autosaves manually with wp_create_post_autosave() … … 3290 3161 } 3291 3162 3292 3163 /** 3293 * wp_get_post_autosave() - returnsthe autosaved data of the specified post.3164 * Retrieve the autosaved data of the specified post. 3294 3165 * 3295 * Returns a post object containing the information that was autosaved for the specified post. 3166 * Returns a post object containing the information that was autosaved for the 3167 * specified post. 3296 3168 * 3297 3169 * @package WordPress 3298 * @subpackage Post Revisions3299 * @since 2.6 3170 * @subpackage Post_Revisions 3171 * @since 2.6.0 3300 3172 * 3301 * @param int $post_id The post ID 3302 * @return object|bool the autosaved data or false on failure or when no autosave exists3173 * @param int $post_id The post ID. 3174 * @return object|bool The autosaved data or false on failure or when no autosave exists. 3303 3175 */ 3304 3176 function wp_get_post_autosave( $post_id ) { 3305 3177 global $wpdb; … … 3326 3198 return false; 3327 3199 } 3328 3200 3329 // Internally used to hack WP_Query into submission 3201 /** 3202 * Internally used to hack WP_Query into submission. 3203 * 3204 * @package WordPress 3205 * @subpackage Post_Revisions 3206 * @since 2.6.0 3207 * 3208 * @param object $query WP_Query object 3209 */ 3330 3210 function _wp_get_post_autosave_hack( $query ) { 3331 3211 $query->is_single = false; 3332 3212 } 3333 3213 3334 3335 3214 /** 3336 * wp_is_post_revision() -Determines if the specified post is a revision.3215 * Determines if the specified post is a revision. 3337 3216 * 3338 3217 * @package WordPress 3339 * @subpackage Post Revisions3340 * @since 2.6 3218 * @subpackage Post_Revisions 3219 * @since 2.6.0 3341 3220 * 3342 * @param int|object $post post ID or post object3343 * @return bool|int false if not a revision, ID of revision's parent otherwise3221 * @param int|object $post Post ID or post object. 3222 * @return bool|int False if not a revision, ID of revision's parent otherwise. 3344 3223 */ 3345 3224 function wp_is_post_revision( $post ) { 3346 3225 if ( !$post = wp_get_post_revision( $post ) ) … … 3349 3228 } 3350 3229 3351 3230 /** 3352 * wp_is_post_autosave() -Determines if the specified post is an autosave.3231 * Determines if the specified post is an autosave. 3353 3232 * 3354 3233 * @package WordPress 3355 * @subpackage Post Revisions3356 * @since 2.6 3234 * @subpackage Post_Revisions 3235 * @since 2.6.0 3357 3236 * 3358 * @param int|object $post post ID or post object3359 * @return bool|int false if not a revision, ID of autosave's parent otherwise3237 * @param int|object $post Post ID or post object. 3238 * @return bool|int False if not a revision, ID of autosave's parent otherwise 3360 3239 */ 3361 3240 function wp_is_post_autosave( $post ) { 3362 3241 if ( !$post = wp_get_post_revision( $post ) ) … … 3367 3246 } 3368 3247 3369 3248 /** 3370 * _wp_put_post_revision() - Inserts post data into the posts table as a post revision3249 * Inserts post data into the posts table as a post revision. 3371 3250 * 3372 3251 * @package WordPress 3373 * @subpackage Post Revisions3374 * @since 2.6 3252 * @subpackage Post_Revisions 3253 * @since 2.6.0 3375 3254 * 3376 3255 * @uses wp_insert_post() 3377 3256 * 3378 * @param int|object|array $post post ID, post object OR post array3379 * @param bool $autosave optionalIs the revision an autosave?3380 * @return mixed null or 0 if error, new revision ID if success3257 * @param int|object|array $post Post ID, post object OR post array. 3258 * @param bool $autosave Optional. Is the revision an autosave? 3259 * @return mixed Null or 0 if error, new revision ID if success. 3381 3260 */ 3382 3261 function _wp_put_post_revision( $post = null, $autosave = false ) { 3383 3262 if ( is_object($post) ) … … 3402 3281 } 3403 3282 3404 3283 /** 3405 * wp_get_post_revision() - Gets a post revision3284 * Gets a post revision. 3406 3285 * 3407 3286 * @package WordPress 3408 * @subpackage Post Revisions3409 * @since 2.6 3287 * @subpackage Post_Revisions 3288 * @since 2.6.0 3410 3289 * 3411 3290 * @uses get_post() 3412 3291 * 3413 * @param int|object $post post ID or post object3414 * @param $output optional OBJECT, ARRAY_A, or ARRAY_N3415 * @param string $filter optional sanitation filter. @see sanitize_post()3416 * @return mixed null if error or post object if success3292 * @param int|object $post Post ID or post object 3293 * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. 3294 * @param string $filter Optional sanitation filter. @see sanitize_post() 3295 * @return mixed Null if error or post object if success 3417 3296 */ 3418 3297 function &wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') { 3419 3298 $null = null; … … 3436 3315 } 3437 3316 3438 3317 /** 3439 * wp_restore_post_revision() - Restores a post to the specified revision3318 * Restores a post to the specified revision. 3440 3319 * 3441 * Can restore a past using all fields of the post revision, or only selected fields. 3320 * Can restore a past using all fields of the post revision, or only selected 3321 * fields. 3442 3322 * 3443 3323 * @package WordPress 3444 * @subpackage Post Revisions3445 * @since 2.6 3324 * @subpackage Post_Revisions 3325 * @since 2.6.0 3446 3326 * 3447 3327 * @uses wp_get_post_revision() 3448 3328 * @uses wp_update_post() 3449 3329 * 3450 * @param int|object $revision_id revision ID or revision object3451 * @param array $fields optionalWhat fields to restore from. Defaults to all.3452 * @return mixed null if error, false if no fields to restore, (int) post ID if success3330 * @param int|object $revision_id Revision ID or revision object. 3331 * @param array $fields Optional. What fields to restore from. Defaults to all. 3332 * @return mixed Null if error, false if no fields to restore, (int) post ID if success. 3453 3333 */ 3454 3334 function wp_restore_post_revision( $revision_id, $fields = null ) { 3455 3335 if ( !$revision = wp_get_post_revision( $revision_id, ARRAY_A ) ) … … 3478 3358 } 3479 3359 3480 3360 /** 3481 * wp_delete_post_revision() -Deletes a revision.3361 * Deletes a revision. 3482 3362 * 3483 * Deletes the row from the posts table corresponding to the specified revision 3363 * Deletes the row from the posts table corresponding to the specified revision. 3484 3364 * 3485 3365 * @package WordPress 3486 * @subpackage Post Revisions3487 * @since 2.6 3366 * @subpackage Post_Revisions 3367 * @since 2.6.0 3488 3368 * 3489 3369 * @uses wp_get_post_revision() 3490 3370 * @uses wp_delete_post() 3491 3371 * 3492 * @param int|object $revision_id revision ID or revision object3493 * @param array $fields optionalWhat fields to restore from. Defaults to all.3494 * @return mixed null if error, false if no fields to restore, (int) post ID if success3372 * @param int|object $revision_id Revision ID or revision object. 3373 * @param array $fields Optional. What fields to restore from. Defaults to all. 3374 * @return mixed Null if error, false if no fields to restore, (int) post ID if success. 3495 3375 */ 3496 3376 function wp_delete_post_revision( $revision_id ) { 3497 3377 if ( !$revision = wp_get_post_revision( $revision_id ) ) … … 3508 3388 } 3509 3389 3510 3390 /** 3511 * wp_get_post_revisions() - Returns all revisions of specified post3391 * Returns all revisions of specified post. 3512 3392 * 3513 3393 * @package WordPress 3514 * @subpackage Post Revisions3515 * @since 2.6 3394 * @subpackage Post_Revisions 3395 * @since 2.6.0 3516 3396 * 3517 3397 * @uses get_children() 3518 3398 * 3519 * @param int|object $post_id post ID or post object3399 * @param int|object $post_id Post ID or post object 3520 3400 * @return array empty if no revisions 3521 3401 */ 3522 3402 function wp_get_post_revisions( $post_id = 0, $args = null ) {