Changeset 6537

Show
Ignore:
Timestamp:
01/02/08 20:06:00 (7 months ago)
Author:
ryan
Message:

set_post_type from filosofo. fixes #4844

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/post.php

    r6501 r6537  
    287287 
    288288    return false; 
     289} 
     290 
     291/** 
     292 * set_post_type() - Set post type 
     293 * 
     294 * {@internal Missing Long Description}} 
     295 * 
     296 * @package WordPress 
     297 * @subpackage Post 
     298 * @since 2.4 
     299 * 
     300 * @uses $wpdb 
     301 * @uses $posts {@internal Missing Description}} 
     302 * 
     303 * @param mixed $post_id post ID 
     304 * @param mixed post type 
     305 * @return bool {@internal Missing Description}} 
     306 */ 
     307function set_post_type( $post_id = 0, $post_type = 'post' ) { 
     308    global $wpdb; 
     309 
     310    $post_type = sanitize_post_field('post_type', $post_type, $post_id, 'db'); 
     311    $return = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_type = %s WHERE ID = %d", $post_type, $post_id) ); 
     312 
     313    if ( 'page' == $post_type ) 
     314        clean_page_cache($post_id); 
     315    else 
     316        clean_post_cache($post_id); 
     317 
     318    return $return; 
    289319} 
    290320