Ticket #4844: set_post_type.2.diff

File set_post_type.2.diff, 0.6 kB (added by filosofo, 1 year ago)
  • wp-includes/post.php

    old new  
    190190        return false; 
    191191} 
    192192 
     193function set_post_type( $post_id = 0, $post_type = 'post' ) { 
     194        global $wpdb; 
     195        $post_type = sanitize_post_field('post_type', $post_type, $post_id, 'db'); 
     196        $return = $wpdb->query( "UPDATE $wpdb->posts SET post_type = '$post_type' WHERE ID = '$post_id'" ); 
     197        if ( 'page' == $post_type ) { 
     198                clean_page_cache($post_id); 
     199        } else { 
     200                clean_post_cache($post_id); 
     201        } 
     202        return $return; 
     203} 
     204 
    193205function get_posts($args) { 
    194206        global $wpdb; 
    195207