Ticket #10946: post.php.diff

File post.php.diff, 1.0 KB (added by scribu, 4 years ago)
  • post.php

     
    313313} 
    314314 
    315315/** 
     316 * Update data from a post field based on Post ID. 
     317 * 
     318 * Examples of the post field will be, 'post_type', 'post_status', 'post_content', etc. 
     319 * 
     320 * The context values are based off of the taxonomy filter functions and 
     321 * supported values are found within those functions. 
     322 * 
     323 * @since 2.9.0 
     324 * @uses sanitize_post_field() 
     325 * 
     326 * @param string $field Post field name 
     327 * @param id $post Post ID 
     328 * @return bool Result of UPDATE query 
     329 */ 
     330function set_post_field($field, $value, $post_id) { 
     331        global $wpdb; 
     332 
     333        $post_id = absint($post_id); 
     334        $value = sanitize_post_field($field, $value, $post_id, 'db'); 
     335 
     336        return $wpdb->update($wpdb->posts, array($field => $value), array('ID' => $post_id)); 
     337} 
     338 
     339/** 
    316340 * Retrieve the mime type of an attachment based on the ID. 
    317341 * 
    318342 * This function can be used with any post type, but it makes more sense with