protected function updatePost( $post_id, $status ) {

		$post = get_post( $post_id, 'ARRAY_A' );
		if ( empty( $post ) ) {
			return;
		}

		global $wpdb;
		$menu_order = $wpdb->get_var(
			$wpdb->prepare(
				"SELECT MAX(menu_order) FROM {$wpdb->posts} WHERE post_type = %s AND post_parent = %d AND ID != %d ",
				$post['post_type'],
				$post['post_parent'],
				$post_id
			)
		);
		if ( $menu_order !== null ) {
			$post['menu_order'] = $menu_order + 1;
		}

		$post['post_status'] = $status;

		wp_update_post( $post );
	}
protected function updatePost( $post_id, $status ) {

		$post = get_post( $post_id, 'ARRAY_A' );
		if ( empty( $post ) ) {
			return;
		}

		global $wpdb;
		$menu_order = $wpdb->get_var(
			$wpdb->prepare(
				"SELECT MAX(menu_order) FROM {$wpdb->posts} WHERE post_type = %s AND post_parent = %d AND ID != %d ",
				$post['post_type'],
				$post['post_parent'],
				$post_id
			)
		);
		if ( $menu_order !== null ) {
			$post['menu_order'] = $menu_order + 1;
		}

		$post['post_status'] = $status;

		wp_update_post( $post );
	}
protected function updatePost ( $ post_id , $ status ) { $ post = get_post ( $ post_id , 'ARRAY_A' ) ; if ( empty ( $ post ) ) { return ; } global $ wpdb ; $ menu_order = $ wpdb -> get_var ( $ wpdb -> prepare ( "SELECT MAX(menu_order) FROM {$wpdb->posts} WHERE post_type = %s AND post_parent = %d AND ID != %d " , $ post [ 'post_type' ] , $ post [ 'post_parent' ] , $ post_id ) ) ; if ( $ menu_order !== null ) { $ post [ 'menu_order' ] = $ menu_order + 1 ; } $ post [ 'post_status' ] = $ status ; wp_update_post ( $ post ) ; }
Update post status

@param int $post_id
@param string $status
Update post status