Changeset 8011 for trunk/wp-includes/post.php
- Timestamp:
- 05/29/2008 10:21:36 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r7995 r8011 957 957 // Do raw query. wp_get_post_revisions() is filtered 958 958 $revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) ); 959 // Use wp_delete_post (via wp_delete_ revision) again. Ensures any meta/misplaced data gets cleaned up.959 // Use wp_delete_post (via wp_delete_post_revision) again. Ensures any meta/misplaced data gets cleaned up. 960 960 foreach ( $revision_ids as $revision_id ) 961 wp_delete_ revision( $revision_id );961 wp_delete_post_revision( $revision_id ); 962 962 963 963 // Point all attachments to this post up one level … … 2952 2952 2953 2953 /** 2954 * _wp_ revision_fields() - determines which fields of posts are to be saved in revisions2954 * _wp_post_revision_fields() - determines which fields of posts are to be saved in revisions 2955 2955 * 2956 2956 * Does two things. If passed a post *array*, it will return a post array ready to be … … 2966 2966 * @return array post array ready to be inserted as a post revision or array of fields that can be versioned 2967 2967 */ 2968 function _wp_ revision_fields( $post = null, $autosave = false ) {2968 function _wp_post_revision_fields( $post = null, $autosave = false ) { 2969 2969 static $fields = false; 2970 2970 … … 2979 2979 2980 2980 // Runs only once 2981 $fields = apply_filters( '_wp_ revision_fields', $fields );2981 $fields = apply_filters( '_wp_post_revision_fields', $fields ); 2982 2982 2983 2983 // WP uses these internally either in versioning or elsewhere - they cannot be versioned … … 3004 3004 3005 3005 /** 3006 * wp_save_ revision() - Saves an already existing post as a post revision. Typically used immediately prior to post updates.3006 * wp_save_post_revision() - Saves an already existing post as a post revision. Typically used immediately prior to post updates. 3007 3007 * 3008 3008 * @package WordPress … … 3010 3010 * @since 2.6 3011 3011 * 3012 * @uses _wp_put_ revision()3012 * @uses _wp_put_post_revision() 3013 3013 * 3014 3014 * @param int $post_id The ID of the post to save as a revision 3015 3015 * @return mixed null or 0 if error, new revision ID if success 3016 3016 */ 3017 function wp_save_ revision( $post_id ) {3018 // We do autosaves manually with wp_create_ autosave()3017 function wp_save_post_revision( $post_id ) { 3018 // We do autosaves manually with wp_create_post_autosave() 3019 3019 if ( @constant( 'DOING_AUTOSAVE' ) ) 3020 3020 return; … … 3030 3030 return; 3031 3031 3032 $return = _wp_put_ revision( $post );3032 $return = _wp_put_post_revision( $post ); 3033 3033 3034 3034 // WP_POST_REVISIONS = true (default), -1 … … 3050 3050 if ( false !== strpos( $revisions[$i]->post_name, 'autosave' ) ) 3051 3051 continue; 3052 wp_delete_ revision( $revisions[$i]->ID );3052 wp_delete_post_revision( $revisions[$i]->ID ); 3053 3053 } 3054 3054 … … 3057 3057 3058 3058 /** 3059 * wp_get_ autosave() - returns the autosaved data of the specified post.3059 * wp_get_post_autosave() - returns the autosaved data of the specified post. 3060 3060 * 3061 3061 * Returns a post object containing the information that was autosaved for the specified post. … … 3068 3068 * @return object|bool the autosaved data or false on failure or when no autosave exists 3069 3069 */ 3070 function wp_get_ autosave( $post_id ) {3070 function wp_get_post_autosave( $post_id ) { 3071 3071 global $wpdb; 3072 3072 if ( !$post = get_post( $post_id ) ) … … 3083 3083 $autosave_query = new WP_Query; 3084 3084 3085 add_action( 'parse_query', '_wp_get_ autosave_hack' );3085 add_action( 'parse_query', '_wp_get_post_autosave_hack' ); 3086 3086 $autosave = $autosave_query->query( $q ); 3087 remove_action( 'parse_query', '_wp_get_ autosave_hack' );3087 remove_action( 'parse_query', '_wp_get_post_autosave_hack' ); 3088 3088 3089 3089 if ( $autosave && is_array($autosave) && is_object($autosave[0]) ) … … 3094 3094 3095 3095 // Internally used to hack WP_Query into submission 3096 function _wp_get_ autosave_hack( $query ) {3096 function _wp_get_post_autosave_hack( $query ) { 3097 3097 $query->is_single = false; 3098 3098 } 3099 3099 3100 /** 3101 * _wp_put_revision() - Inserts post data into the posts table as a post revision 3100 3101 /** 3102 * wp_is_post_revision() - Determines if the specified post is a revision. 3103 * 3104 * @package WordPress 3105 * @subpackage Post Revisions 3106 * @since 2.6 3107 * 3108 * @param int|object $post post ID or post object 3109 * @return bool|int false if not a revision, ID of revision's parent otherwise 3110 */ 3111 function wp_is_post_revision( $post ) { 3112 if ( !$post = wp_get_post_revision( $post ) ) 3113 return false; 3114 return (int) $post->post_parent; 3115 } 3116 3117 /** 3118 * wp_is_post_autosave() - Determines if the specified post is an autosave. 3119 * 3120 * @package WordPress 3121 * @subpackage Post Revisions 3122 * @since 2.6 3123 * 3124 * @param int|object $post post ID or post object 3125 * @return bool|int false if not a revision, ID of autosave's parent otherwise 3126 */ 3127 function wp_is_post_autosave( $post ) { 3128 if ( !$post = wp_get_post_revision( $post ) ) 3129 return false; 3130 if ( "{$post->post_parent}-autosave" !== $post->post_name ) 3131 return false; 3132 return (int) $post->post_parent; 3133 } 3134 3135 /** 3136 * _wp_put_post_revision() - Inserts post data into the posts table as a post revision 3102 3137 * 3103 3138 * @package WordPress … … 3111 3146 * @return mixed null or 0 if error, new revision ID if success 3112 3147 */ 3113 function _wp_put_ revision( $post = null, $autosave = false ) {3148 function _wp_put_post_revision( $post = null, $autosave = false ) { 3114 3149 if ( is_object($post) ) 3115 3150 $post = get_object_vars( $post ); … … 3122 3157 return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) ); 3123 3158 3124 $post = _wp_ revision_fields( $post, $autosave );3159 $post = _wp_post_revision_fields( $post, $autosave ); 3125 3160 3126 3161 $revision_id = wp_insert_post( $post ); … … 3129 3164 3130 3165 if ( $revision_id ) 3131 do_action( '_wp_put_ revision', $revision_id );3166 do_action( '_wp_put_post_revision', $revision_id ); 3132 3167 return $revision_id; 3133 3168 } 3134 3169 3135 3170 /** 3136 * wp_get_ revision() - Gets a post revision3171 * wp_get_post_revision() - Gets a post revision 3137 3172 * 3138 3173 * @package WordPress … … 3147 3182 * @return mixed null if error or post object if success 3148 3183 */ 3149 function &wp_get_ revision(&$post, $output = OBJECT, $filter = 'raw') {3184 function &wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') { 3150 3185 $null = null; 3151 3186 if ( !$revision = get_post( $post, OBJECT, $filter ) ) … … 3168 3203 3169 3204 /** 3170 * wp_restore_ revision() - Restores a post to the specified revision3205 * wp_restore_post_revision() - Restores a post to the specified revision 3171 3206 * 3172 3207 * Can restore a past using all fields of the post revision, or only selected fields. … … 3176 3211 * @since 2.6 3177 3212 * 3178 * @uses wp_get_ revision()3213 * @uses wp_get_post_revision() 3179 3214 * @uses wp_update_post() 3180 3215 * … … 3183 3218 * @return mixed null if error, false if no fields to restore, (int) post ID if success 3184 3219 */ 3185 function wp_restore_ revision( $revision_id, $fields = null ) {3186 if ( !$revision = wp_get_ revision( $revision_id, ARRAY_A ) )3220 function wp_restore_post_revision( $revision_id, $fields = null ) { 3221 if ( !$revision = wp_get_post_revision( $revision_id, ARRAY_A ) ) 3187 3222 return $revision; 3188 3223 3189 3224 if ( !is_array( $fields ) ) 3190 $fields = array_keys( _wp_ revision_fields() );3225 $fields = array_keys( _wp_post_revision_fields() ); 3191 3226 3192 3227 $update = array(); … … 3204 3239 3205 3240 if ( $post_id ) 3206 do_action( 'wp_restore_ revision', $post_id, $revision['ID'] );3241 do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] ); 3207 3242 3208 3243 return $post_id; … … 3210 3245 3211 3246 /** 3212 * wp_delete_ revision() - Deletes a revision.3247 * wp_delete_post_revision() - Deletes a revision. 3213 3248 * 3214 3249 * Deletes the row from the posts table corresponding to the specified revision … … 3218 3253 * @since 2.6 3219 3254 * 3220 * @uses wp_get_ revision()3255 * @uses wp_get_post_revision() 3221 3256 * @uses wp_delete_post() 3222 3257 * … … 3225 3260 * @return mixed null if error, false if no fields to restore, (int) post ID if success 3226 3261 */ 3227 function wp_delete_ revision( $revision_id ) {3228 if ( !$revision = wp_get_ revision( $revision_id ) )3262 function wp_delete_post_revision( $revision_id ) { 3263 if ( !$revision = wp_get_post_revision( $revision_id ) ) 3229 3264 return $revision; 3230 3265 … … 3234 3269 3235 3270 if ( $delete ) 3236 do_action( 'wp_delete_ revision', $revision->ID, $revision );3271 do_action( 'wp_delete_post_revision', $revision->ID, $revision ); 3237 3272 3238 3273 return $delete;
Note: See TracChangeset
for help on using the changeset viewer.