WordPress.org

Make WordPress Core

Ticket #22944: 22944.2.patch

File 22944.2.patch, 1.0 KB (added by SergeyBiryukov, 3 years ago)
  • wp-includes/post.php

     
    30103010 * Publish a post by transitioning the post status. 
    30113011 * 
    30123012 * @since 2.1.0 
    3013  * @uses wp_update_post() 
     3013 * @uses $wpdb 
     3014 * @uses do_action() Calls 'edit_post', 'save_post', and 'wp_insert_post' on post_id and post data. 
    30143015 * 
    30153016 * @param mixed $post Post ID or object. 
    30163017 */ 
    30173018function wp_publish_post( $post ) { 
     3019        global $wpdb; 
     3020 
    30183021        if ( ! $post = get_post( $post ) ) 
    30193022                return; 
     3023 
    30203024        if ( 'publish' == $post->post_status ) 
    30213025                return; 
    30223026 
     3027        $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) ); 
     3028 
     3029        $old_status = $post->post_status; 
    30233030        $post->post_status = 'publish'; 
    3024         wp_update_post( $post ); 
     3031        wp_transition_post_status( 'publish', $old_status, $post ); 
     3032 
     3033        do_action( 'edit_post', $post->ID, $post ); 
     3034        do_action( 'save_post', $post->ID, $post ); 
     3035        do_action( 'wp_insert_post', $post->ID, $post ); 
    30253036} 
    30263037 
    30273038/**