Ticket #14389: 14389.diff
File 14389.diff, 2.0 KB (added by , 15 years ago) |
---|
-
wp-includes/post.php
2040 2040 * Retrieve number of recent posts. 2041 2041 * 2042 2042 * @since 1.0.0 2043 * @uses $wpdb 2043 * @uses wp_parse_args() 2044 * @uses get_posts() 2044 2045 * 2045 * @param int $num Optional, default is 10. Number of posts to get. 2046 * @return array List of posts. 2046 * @param string $deprecated Deprecated. 2047 * @param array $args Optional. Overrides defaults. 2048 * @param string $output Optional. 2049 * @return unknown. 2047 2050 */ 2048 function wp_get_recent_posts( $num = 10) {2051 function wp_get_recent_posts( $deprecated = '', $args = null, $output = ARRAY_A ) { 2049 2052 global $wpdb; 2050 2053 2051 // Set the limit clause, if we got a limit2052 $num = (int) $num;2053 if ( $num ) {2054 $ limit = "LIMIT $num";2054 if ( !empty( $deprecated ) ) { 2055 if ( function_exists( 'deprecated_argument' ) ) 2056 _deprecated_argument( __FUNCTION__, '3.1' ); 2057 $args['numberposts'] = $deprecated; 2055 2058 } 2056 2059 2057 $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status IN ( 'draft', 'publish', 'future', 'pending', 'private' ) ORDER BY post_date DESC $limit"; 2058 $result = $wpdb->get_results($sql, ARRAY_A); 2060 // Set default arguments 2061 $defaults = array( 2062 'numberposts' => 10, 'offset' => 0, 2063 'category' => 0, 'orderby' => 'post_date', 2064 'order' => 'DESC', 'include' => '', 2065 'exclude' => '', 'meta_key' => '', 2066 'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending, private', 2067 'suppress_filters' => true 2068 ); 2069 2070 $r = wp_parse_args( $args, $defaults ); 2059 2071 2060 return $result ? $result : array(); 2072 $results = get_posts( $r ); 2073 2074 // Backward compatibility. Prior to 3.1 expected posts to be returned in array 2075 if ( ARRAY_A == $output ){ 2076 foreach( $results as $key => $result ) { 2077 $results[$key] = (array) $result; 2078 } 2079 return $results ? $results : array(); 2080 } 2081 2082 return $results ? $results : false; 2083 2061 2084 } 2062 2085 2063 2086 /**