Ticket #16603: wp_count_posts_hooks.diff
File wp_count_posts_hooks.diff, 1.7 KB (added by , 14 years ago) |
---|
-
wp-includes/post.php
1793 1793 if ( false !== $count ) 1794 1794 return $count; 1795 1795 1796 $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 1796 $query = apply_filters( 'wp_count_posts_sql', $wpdb->prepare( $query, $type ), $type, $perm ); 1797 $count = $wpdb->get_results( $query, ARRAY_A ); 1797 1798 1798 1799 $stats = array(); 1799 1800 foreach ( get_post_stati() as $state ) … … 1805 1806 $stats = (object) $stats; 1806 1807 wp_cache_set($cache_key, $stats, 'counts'); 1807 1808 1808 return $stats;1809 return apply_filters( 'wp_count_posts', $stats, $type, $perm ); 1809 1810 } 1810 1811 1811 1812 … … 5012 5013 * @uses wp_find_hierarchy_loop() 5013 5014 * 5014 5015 * @param int $post_parent ID of the parent for the post we're checking. 5015 * @par em int $post_ID ID of the post we're checking.5016 * @param int $post_ID ID of the post we're checking. 5016 5017 * 5017 5018 * @return int The new post_parent for the post. 5018 5019 */ … … 5236 5237 } 5237 5238 add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' ); 5238 5239 5239 ?> 5240 No newline at end of file 5240 /** 5241 * Return array of posts for post_type='page' for those pages with the given page template. 5242 * 5243 * @param string $template Filename of the assigned template for a page. 5244 * 5245 * @return array The posts that have a template matching the one passed. 5246 */ 5247 function get_pages_by_template( $template, $args ) { 5248 global $wpdb; 5249 $args = wp_parse_args($args,array( 5250 'post_type' => 'page', 5251 'posts_per_page' => -1, 5252 'meta_key' => '_wp_page_template', 5253 'meta_value' => $template, 5254 'suppress_filters' => true, 5255 )); 5256 $result = new WP_Query($args); 5257 return apply_filters( 'get_pages_by_template', $result->posts ); 5258 } 5259 ?>