Changeset 7074 for trunk/wp-includes/post.php
- Timestamp:
- 02/27/2008 11:28:18 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r7045 r7074 176 176 } 177 177 178 // Populate the ancestors field. 179 // Not cached since we don't clear cache for ancestors when a post changes. 180 _get_post_ancestors($_post); 181 178 182 $_post = sanitize_post($_post, $filter); 179 183 … … 189 193 return $_post; 190 194 } 195 } 196 197 /** 198 * get_post_ancestors() - Retrieve ancestors for a post 199 * 200 * @package WordPress 201 * @subpackage Post 202 * @since 2.5 203 * 204 * @param string $field {@internal Missing Description}} 205 * @param int|object &$post post ID or post object 206 * @return array of ancestor IDs 207 */ 208 function get_post_ancestors($post) { 209 $post = get_post(); 210 211 if ( !empty($post->ancestors) ) 212 return $post->ancestors; 213 214 return array(); 191 215 } 192 216 … … 2885 2909 } 2886 2910 2911 // 2912 // Private 2913 // 2914 2915 function _get_post_ancestors(&$_post) { 2916 global $wpdb; 2917 2918 if ( !empty($_post->ancestors) ) 2919 return; 2920 2921 $_post->ancestors = array(); 2922 2923 if ( empty($_post->post_parent) || $_post->ID == $_post->post_parent ) 2924 return; 2925 2926 $id = $_post->ancestors[] = $_post->post_parent; 2927 while ( $ancestor = $wpdb->get_var("SELECT `post_parent` FROM $wpdb->posts WHERE ID= '{$id}' LIMIT 1") ) { 2928 if ( $id == $ancestor ) 2929 break; 2930 $id = $_post->ancestors[] = $ancestor; 2931 } 2932 } 2933 2887 2934 ?>
Note: See TracChangeset
for help on using the changeset viewer.