| 420 | 420 | // TODO: Use array keys instead of hard coded list |
| 421 | 421 | $fields = array('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_date', 'post_date_gmt', 'post_parent', 'menu_order', 'post_mime_type'); |
| 422 | 422 | |
| 760 | | if ($post_status == 'publish' && $post_type == 'post') { |
| 761 | | do_action('publish_post', $post_ID); |
| 762 | | if ( defined('XMLRPC_REQUEST') ) |
| 763 | | do_action('xmlrpc_publish_post', $post_ID); |
| 764 | | if ( defined('APP_REQUEST') ) |
| 765 | | do_action('app_publish_post', $post_ID); |
| | 752 | if ( $update) |
| | 753 | do_action('edit_post', $post_ID, $post); |
| 767 | | if ( !defined('WP_IMPORTING') ) { |
| 768 | | if ( $post_pingback ) |
| 769 | | $result = $wpdb->query(" |
| 770 | | INSERT INTO $wpdb->postmeta |
| 771 | | (post_id,meta_key,meta_value) |
| 772 | | VALUES ('$post_ID','_pingme','1') |
| 773 | | "); |
| 774 | | $result = $wpdb->query(" |
| 775 | | INSERT INTO $wpdb->postmeta |
| 776 | | (post_id,meta_key,meta_value) |
| 777 | | VALUES ('$post_ID','_encloseme','1') |
| 778 | | "); |
| 779 | | wp_schedule_single_event(time(), 'do_pings'); |
| 780 | | } |
| 781 | | } else if ($post_type == 'page') { |
| 782 | | if ( !empty($page_template) ) |
| 783 | | if ( ! update_post_meta($post_ID, '_wp_page_template', $page_template)) |
| 784 | | add_post_meta($post_ID, '_wp_page_template', $page_template, true); |
| | 755 | do_action('save_post', $post_ID, $post); |
| | 756 | do_action('wp_insert_post', $post_ID, $post); |
| 786 | | if ( $post_status == 'publish' ) |
| 787 | | do_action('publish_page', $post_ID); |
| 788 | | } |
| 789 | | |
| 790 | | // Always clears the hook in case the post status bounced from future to draft. |
| 791 | | wp_clear_scheduled_hook('publish_future_post', $post_ID); |
| 792 | | |
| 793 | | // Schedule publication. |
| 794 | | if ( 'future' == $post_status ) |
| 795 | | wp_schedule_single_event(strtotime($post_date_gmt. ' GMT'), 'publish_future_post', array($post_ID)); |
| 796 | | |
| 797 | | do_action('save_post', $post_ID); |
| 798 | | do_action('wp_insert_post', $post_ID); |
| 799 | | |
| 852 | | return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id, 'no_filter' => true)); |
| | 812 | $wpdb->query( "UPDATE $wpdb->posts SET post_status = 'publish' WHERE ID = '$post_id'" ); |
| | 813 | |
| | 814 | $old_status = $post->post_status; |
| | 815 | $post->post_status = 'publish'; |
| | 816 | wp_transition_post_status('publish', $old_status, $post); |
| | 817 | |
| | 818 | do_action('edit_post', $post_id, $post); |
| | 819 | do_action('save_post', $post_id, $post); |
| | 820 | do_action('wp_insert_post', $post_id, $post); |
| | 858 | function wp_transition_post_status($new_status, $old_status, $post) { |
| | 859 | if ( $new_status != $old_status ) { |
| | 860 | do_action('transition_post_status', $new_status, $old_status, $post); |
| | 861 | do_action("${old_status}_to_$new_status", $post); |
| | 862 | } |
| | 863 | do_action("${new_status}_$post->post_type", $post->ID, $post); |
| | 864 | } |
| | 865 | |
| | 1822 | // |
| | 1823 | // Hooks |
| | 1824 | // |
| | 1825 | |
| | 1826 | function _transition_post_status($new_status, $old_status, $post) { |
| | 1827 | global $wpdb; |
| | 1828 | |
| | 1829 | if ( $old_status != 'publish' && $new_status == 'publish' ) { |
| | 1830 | // Reset GUID if transitioning to publish. |
| | 1831 | $wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post->ID) . "' WHERE ID = '$post->ID'"); |
| | 1832 | do_action('private_to_published', $post->ID); // Deprecated, use private_to_publish |
| | 1833 | } |
| | 1834 | |
| | 1835 | // Always clears the hook in case the post status bounced from future to draft. |
| | 1836 | wp_clear_scheduled_hook('publish_future_post', $post->ID); |
| | 1837 | } |
| | 1838 | |
| | 1839 | function _future_post_hook($post_id, $post) { |
| | 1840 | // Schedule publication. |
| | 1841 | wp_schedule_single_event(strtotime($post->post_date_gmt. ' GMT'), 'publish_future_post', array($post->ID)); |
| | 1842 | } |
| | 1843 | |
| | 1844 | function _publish_post_hook($post_id) { |
| | 1845 | global $wpdb; |
| | 1846 | |
| | 1847 | if ( defined('XMLRPC_REQUEST') ) |
| | 1848 | do_action('xmlrpc_publish_post', $post_id); |
| | 1849 | if ( defined('APP_REQUEST') ) |
| | 1850 | do_action('app_publish_post', $post_id); |
| | 1851 | |
| | 1852 | if ( defined('WP_IMPORTING') ) |
| | 1853 | return; |
| | 1854 | |
| | 1855 | $post = get_post($post_id); |
| | 1856 | |
| | 1857 | if ( $post->post_pingback ) |
| | 1858 | $result = $wpdb->query(" |
| | 1859 | INSERT INTO $wpdb->postmeta |
| | 1860 | (post_id,meta_key,meta_value) |
| | 1861 | VALUES ('$post_id','_pingme','1') |
| | 1862 | "); |
| | 1863 | $result = $wpdb->query(" |
| | 1864 | INSERT INTO $wpdb->postmeta |
| | 1865 | (post_id,meta_key,meta_value) |
| | 1866 | VALUES ('$post_id','_encloseme','1') |
| | 1867 | "); |
| | 1868 | wp_schedule_single_event(time(), 'do_pings'); |
| | 1869 | } |
| | 1870 | |
| | 1871 | function _save_post_hook($post_id, $post) { |
| | 1872 | if ( $post->post_type == 'page' ) { |
| | 1873 | if ( !empty($post->page_template) ) |
| | 1874 | if ( ! update_post_meta($post_id, '_wp_page_template', $post->page_template)) |
| | 1875 | add_post_meta($post_id, '_wp_page_template', $post->page_template, true); |
| | 1876 | |
| | 1877 | clean_page_cache($post_id); |
| | 1878 | global $wp_rewrite; |
| | 1879 | $wp_rewrite->flush_rules(); |
| | 1880 | } else { |
| | 1881 | clean_post_cache($post_id); |
| | 1882 | } |
| | 1883 | } |
| | 1884 | |