Changeset 29090
- Timestamp:
- 07/11/2014 07:00:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r28976 r29090 181 181 * @since 2.0.0 182 182 * 183 * @param int $attachment_id Attachment ID.184 * @param bool $unfiltered Whether to apply filters.183 * @param int $attachment_id Attachment ID. 184 * @param bool $unfiltered Optional. Whether to apply filters. Default false. 185 185 * @return string|bool The file path to where the attached file should be, false otherwise. 186 186 */ 187 187 function get_attached_file( $attachment_id, $unfiltered = false ) { 188 188 $file = get_post_meta( $attachment_id, '_wp_attached_file', true ); 189 // If the file is relative, prepend upload dir 189 // If the file is relative, prepend upload dir. 190 190 if ( $file && 0 !== strpos($file, '/') && !preg_match('|^.:\\\|', $file) && ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) ) 191 191 $file = $uploads['basedir'] . "/$file"; … … 212 212 * @since 2.1.0 213 213 * 214 * @param int $attachment_id Attachment ID215 * @param string $file File path for the attachment214 * @param int $attachment_id Attachment ID. 215 * @param string $file File path for the attachment. 216 216 * @return bool True on success, false on failure. 217 217 */ … … 243 243 * @since 2.9.0 244 244 * 245 * @param string $path Full path to the file 246 * @return string relative path on success, unchanged path on failure.245 * @param string $path Full path to the file. 246 * @return string Relative path on success, unchanged path on failure. 247 247 */ 248 248 function _wp_relative_upload_path( $path ) { … … 305 305 * argument will accept any post status within the write administration panels. 306 306 * 307 * @internal Claims made in the long description might be inaccurate. 308 * @since 2.0.0 309 * 307 310 * @see get_posts() Has additional arguments that can be replaced. 308 * @internal Claims made in the long description might be inaccurate. 309 * 310 * @since 2.0.0 311 * 312 * @param mixed $args Optional. User defined arguments for replacing the defaults. 313 * @param string $output Optional. Constant for return type, either OBJECT (default), ARRAY_A, ARRAY_N. 311 * 312 * @param mixed $args Optional. User defined arguments for replacing the defaults. Default empty. 313 * @param string $output Optional. Constant for return type. Accepts OBJECT, ARRAY_A, ARRAY_N. 314 * Default OBJECt. 314 315 * @return array Array of children, where the type of each element is determined by $output parameter. 315 316 * Empty array on failure. 316 317 */ 317 function get_children( $args = '', $output = OBJECT) {318 function get_children( $args = '', $output = OBJECT ) { 318 319 $kids = array(); 319 320 if ( empty( $args ) ) { … … 380 381 * @return array Post before ('main'), after ('extended'), and custom readmore ('more_text'). 381 382 */ 382 function get_extended( $post) {383 //Match the new style more links 383 function get_extended( $post ) { 384 //Match the new style more links. 384 385 if ( preg_match('/<!--more(.*?)?-->/', $post, $matches) ) { 385 386 list($main, $extended) = explode($matches[0], $post, 2); … … 406 407 * 407 408 * @since 1.5.1 408 * @link http://codex.wordpress.org/Function_Reference/get_post 409 * 410 * @param int|WP_Post $post Optional. Post ID or post object. 411 * @param string $output Optional, default is Object. Either OBJECT, ARRAY_A, or ARRAY_N. 412 * @param string $filter Optional, default is raw. 413 * @return WP_Post|null WP_Post on success or null on failure 409 * 410 * @see http://codex.wordpress.org/Function_Reference/get_post 411 * 412 * @param int|WP_Post $post Optional. Post ID or post object. Defaults to global $post. 413 * @param string $output Optional, default is Object. Accepts OBJECT, ARRAY_A, or ARRAY_N. 414 * Default OBJECT. 415 * @param string $filter Optional. Type of filter to apply. Accepts 'raw', 'edit', 'db', 416 * or 'display'. Default 'raw'. 417 * @return WP_Post|null WP_Post on success or null on failure. 414 418 */ 415 419 function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) { … … 628 632 public $filter; 629 633 634 /** 635 * Retrieve WP_Post instance. 636 * 637 * @static 638 * @access public 639 * 640 * @param int $post_id Post ID. 641 * @return WP_Post|bool Post object, false otherwise. 642 */ 630 643 public static function get_instance( $post_id ) { 631 644 global $wpdb; … … 652 665 } 653 666 667 /** 668 * Constructor. 669 * 670 * @param WP_Post $post Post object. 671 */ 654 672 public function __construct( $post ) { 655 673 foreach ( get_object_vars( $post ) as $key => $value ) … … 657 675 } 658 676 677 /** 678 * Isset-er. 679 * 680 * @param string $key Property to check if set. 681 * @return bool 682 */ 659 683 public function __isset( $key ) { 660 684 if ( 'ancestors' == $key ) … … 673 697 } 674 698 699 /** 700 * Getter. 701 * 702 * @param string $key Key to get. 703 * @return array|mixed 704 */ 675 705 public function __get( $key ) { 676 706 if ( 'page_template' == $key && $this->__isset( $key ) ) { … … 698 728 } 699 729 700 // Rest of the values need filtering 701 730 // Rest of the values need filtering. 702 731 if ( 'ancestors' == $key ) 703 732 $value = get_post_ancestors( $this ); … … 711 740 } 712 741 742 /** 743 * {@Missing Summary} 744 * 745 * @param string $filter Filter. 746 * @return $this|array|bool|object|WP_Post 747 */ 713 748 public function filter( $filter ) { 714 749 if ( $this->filter == $filter ) … … 721 756 } 722 757 758 /** 759 * Convert object to array. 760 * 761 * @return array Object as array. 762 */ 723 763 public function to_array() { 724 764 $post = get_object_vars( $this ); … … 772 812 * 773 813 * @since 2.3.0 774 * @uses sanitize_post_field() See for possible $context values. 775 * 776 * @param string $field Post field name. 777 * @param int|WP_Post $post Post ID or post object. 778 * @param string $context Optional. How to filter the field. Default is 'display'. 814 * 815 * @see sanitize_post_field() 816 * 817 * @param string $field Post field name. 818 * @param int|WP_Post $post Post ID or post object. 819 * @param string $context Optional. How to filter the field. Accepts 'raw', 'edit', 'db', 820 * or 'display'. Default 'display'. 779 821 * @return string The value of the post field on success, empty string on failure. 780 822 */ … … 799 841 * @since 2.0.0 800 842 * 801 * @param int|WP_Post $ID Optional. Post ID or post object. 843 * @param int|WP_Post $ID Optional. Post ID or post object. Default empty. 802 844 * @return string|bool The mime type on success, false on failure. 803 845 */ 804 function get_post_mime_type( $ID = '') {846 function get_post_mime_type( $ID = '' ) { 805 847 $post = get_post($ID); 806 848 … … 819 861 * @since 2.0.0 820 862 * 821 * @param int|WP_Post $ID Optional. Post ID or post object. 863 * @param int|WP_Post $ID Optional. Post ID or post object. Default empty. 822 864 * @return string|bool Post status on success, false on failure. 823 865 */ 824 function get_post_status( $ID = '') {866 function get_post_status( $ID = '' ) { 825 867 $post = get_post($ID); 826 868 … … 863 905 function get_post_statuses() { 864 906 $status = array( 865 'draft' => __('Draft'),866 'pending' => __('Pending Review'),867 'private' => __('Private'),868 'publish' => __('Published')907 'draft' => __( 'Draft' ), 908 'pending' => __( 'Pending Review' ), 909 'private' => __( 'Private' ), 910 'publish' => __( 'Published' ) 869 911 ); 870 912 … … 884 926 function get_page_statuses() { 885 927 $status = array( 886 'draft' => __('Draft'),887 'private' => __('Private'),888 'publish' => __('Published')928 'draft' => __( 'Draft' ), 929 'private' => __( 'Private' ), 930 'publish' => __( 'Published' ) 889 931 ); 890 932 … … 899 941 * parameter), along with a string for the post status name. 900 942 * 901 *902 * Optional $args contents:903 *904 * label - A descriptive name for the post status marked for translation. Defaults to $post_status.905 * public - Whether posts of this status should be shown in the front end of the site. Defaults to true.906 * exclude_from_search - Whether to exclude posts with this post status from search results. Defaults to false.907 * show_in_admin_all_list - Whether to include posts in the edit listing for their post type908 * show_in_admin_status_list - Show in the list of statuses with post counts at the top of the edit909 * listings, e.g. All (12) | Published (9) | My Custom Status (2) ...910 *911 943 * Arguments prefixed with an _underscore shouldn't be used by plugins and themes. 912 944 * … … 915 947 * 916 948 * @param string $post_status Name of the post status. 917 * @param array|string $args See above description. 918 */ 919 function register_post_status($post_status, $args = array()) { 949 * @param array|string $args { 950 * Optional. Array or string of post status arguments. 951 * 952 * @type bool|string $label A descriptive name for the post status marked 953 * for translation. Defaults to value of $post_status. 954 * @type bool|array $label_count Descriptive text to use for nooped plurals. 955 * Default array of $label, twice 956 * @type bool $exclude_from_search Whether to exclude posts with this post status 957 * from search results. Default is value of $internal. 958 * @type bool $_builtin Whether the status is built-in. Core-use only. 959 * Default false. 960 * @type bool $public Whether posts of this status should be shown 961 * in the front end of the site. Default true. 962 * @type bool $internal Whether the status is for internal use only. 963 * Default false. 964 * @type bool $protected Whether posts with this status should be protected. 965 * Default false. 966 * @type bool $private Whether posts with this status should be private. 967 * Default false. 968 * @type bool $publicly_queryable Whether posts with this status should be publicly- 969 * queryable. Default is value of $public. 970 * @type bool $show_in_admin_all_list Whether to include posts in the edit listing for 971 * their post type. Default is value of $internal. 972 * @type bool $show_in_admin_status_list Show in the list of statuses with post counts at 973 * the top of the edit listings, 974 * e.g. All (12) | Published (9) | My Custom Status (2) 975 * Default is value of $internal. 976 * } 977 */ 978 function register_post_status( $post_status, $args = array() ) { 920 979 global $wp_post_statuses; 921 980 … … 943 1002 $args->name = $post_status; 944 1003 1004 // Set various defaults. 945 1005 if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private ) 946 1006 $args->internal = true; … … 982 1042 983 1043 /** 984 * Retrieve a post status object by name 1044 * Retrieve a post status object by name. 985 1045 * 986 1046 * @since 3.0.0 987 * @uses $wp_post_statuses 988 * @see register_post_status 989 * @see get_post_statuses 990 * 991 * @param string $post_status The name of a registered post status 992 * @return object A post status object 1047 * 1048 * @global array $wp_post_statuses List of post statuses. 1049 * 1050 * @see register_post_status() 1051 * 1052 * @param string $post_status The name of a registered post status. 1053 * @return object A post status object. 993 1054 */ 994 1055 function get_post_status_object( $post_status ) { … … 1005 1066 * 1006 1067 * @since 3.0.0 1007 * @uses $wp_post_statuses 1008 * @see register_post_status 1009 * @see get_post_status_object 1010 * 1011 * @param array|string $args An array of key => value arguments to match against the post status objects. 1012 * @param string $output The type of output to return, either post status 'names' or 'objects'. 'names' is the default. 1013 * @param string $operator The logical operation to perform. 'or' means only one element 1014 * from the array needs to match; 'and' means all elements must match. The default is 'and'. 1015 * @return array A list of post status names or objects 1068 * 1069 * @global array $wp_post_statuses List of post statuses. 1070 * 1071 * @see register_post_status() 1072 * 1073 * @param array|string $args Optional. Array or string of post status arguments. Default array. 1074 * @param string $output Optional. The type of output to return. Accepts post status 'names' 1075 * or 'objects'. Default 'names'. 1076 * @param string $operator Optional. The logical operation to perform. 'or' means only one element 1077 * from the array needs to match; 'and' means all elements must match. 1078 * Default 'and'. 1079 * @return array A list of post status names or objects. 1016 1080 */ 1017 1081 function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) { … … 1029 1093 * 1030 1094 * @since 3.0.0 1031 * @see get_post_type_object 1095 * 1096 * @see get_post_type_object() 1032 1097 * 1033 1098 * @param string $post_type Post type name … … 1043 1108 1044 1109 /** 1045 * Check sif a post type is registered.1110 * Check if a post type is registered. 1046 1111 * 1047 1112 * @since 3.0.0 1048 * @uses get_post_type_object() 1049 * 1050 * @param string $post_type Post type name 1113 * 1114 * @see get_post_type_object() 1115 * 1116 * @param string $post_type Post type name. 1051 1117 * @return bool Whether post type is registered. 1052 1118 */ … … 1060 1126 * @since 2.1.0 1061 1127 * 1062 * @param int|WP_Post $post Optional. Post ID or post object. 1128 * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post. 1063 1129 * @return string|bool Post type on success, false on failure. 1064 1130 */ … … 1071 1137 1072 1138 /** 1073 * Retrieve a post type object by name 1139 * Retrieve a post type object by name. 1074 1140 * 1075 1141 * @since 3.0.0 1076 * @uses $wp_post_types 1077 * @see register_post_type 1078 * @see get_post_types 1079 * 1080 * @param string $post_type The name of a registered post type 1081 * @return object A post type object 1142 * 1143 * @global array $wp_post_types List of post types. 1144 * 1145 * @see register_post_type() 1146 * 1147 * @param string $post_type The name of a registered post type. 1148 * @return object A post type object. 1082 1149 */ 1083 1150 function get_post_type_object( $post_type ) { … … 1094 1161 * 1095 1162 * @since 2.9.0 1096 * @uses $wp_post_types 1097 * @see register_post_type 1098 * 1099 * @param array|string $args An array of key => value arguments to match against the post type objects. 1100 * @param string $output The type of output to return, either post type 'names' or 'objects'. 'names' is the default. 1101 * @param string $operator The logical operation to perform. 'or' means only one element 1102 * from the array needs to match; 'and' means all elements must match. The default is 'and'. 1103 * @return array A list of post type names or objects 1163 * 1164 * @global array $wp_post_types List of post types. 1165 * 1166 * @see register_post_type() 1167 * 1168 * @param array|string $args Optional. An array of key => value arguments to match against 1169 * the post type objects. Default empty array. 1170 * @param string $output Optional. The type of output to return. Accepts post type 'names' 1171 * or 'objects'. Default 'names'. 1172 * @param string $operator Optaionl. The logical operation to perform. 'or' means only one 1173 * element from the array needs to match; 'and' means all elements 1174 * must match. Default 'and'. 1175 * @return array A list of post type names or objects. 1104 1176 */ 1105 1177 function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) {
Note: See TracChangeset
for help on using the changeset viewer.