Changeset 5797
- Timestamp:
- 07/12/2007 04:00:51 PM (17 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/category-template.php
r5726 r5797 340 340 341 341 if ( 'DESC' == $order ) 342 $counts = array_reverse( $ tag_counts, true );342 $counts = array_reverse( $counts, true ); 343 343 344 344 $a = array(); -
trunk/wp-includes/default-filters.php
r5783 r5797 185 185 add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 ); 186 186 add_action( 'shutdown', 'wp_ob_end_flush_all', 1); 187 add_action('publish_post', '_publish_post_hook', 5, 1); 188 add_action('future_post', '_future_post_hook', 5, 2); 189 add_action('future_page', '_future_post_hook', 5, 2); 190 add_action('save_post', '_save_post_hook', 5, 2); 191 add_action('transition_post_status', '_transition_post_status', 5, 3); 187 192 188 193 ?> -
trunk/wp-includes/post.php
r5796 r5797 140 140 function get_post_field( $field, $post, $context = 'display' ) { 141 141 $post = (int) $post; 142 $post = get_ term( $post );142 $post = get_post( $post ); 143 143 144 144 if ( is_wp_error($post) ) … … 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 423 if ( 'raw' == $context )424 return $post;425 426 423 $do_object = false; 427 424 if ( is_object($post) ) … … 442 439 if ( in_array($field, $int_fields) ) 443 440 $value = (int) $value; 441 442 if ( 'raw' == $context ) 443 return $value; 444 444 445 445 $prefixed = false; … … 587 587 588 588 $postarr = wp_parse_args($postarr, $defaults); 589 590 if ( empty($postarr['no_filter']) ) 591 $postarr = sanitize_post($postarr, 'db'); 589 $postarr = sanitize_post($postarr, 'db'); 592 590 593 591 // export array as variables … … 598 596 if ( !empty($ID) ) { 599 597 $update = true; 600 $post = & get_post($ID); 601 $previous_status = $post->post_status; 598 $previous_status = get_post_field('post_status', $ID); 599 } else { 600 $previous_status = 'new'; 602 601 } 603 602 … … 609 608 $post_category = array(get_option('default_category')); 610 609 } 611 $post_cat = $post_category[0];612 610 613 611 if ( empty($post_author) ) … … 632 630 $post_name = sanitize_title($post_name); 633 631 } 634 635 632 636 633 // If the post date is empty (due to having been new or a draft) and status is not 'draft', set date to now … … 739 736 if ( 'page' == $post_type ) { 740 737 clean_page_cache($post_ID); 741 $wp_rewrite->flush_rules();742 738 } else { 743 739 clean_post_cache($post_ID); … … 748 744 $wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'"); 749 745 750 if ( $update) { 751 if ($previous_status != 'publish' && $post_status == 'publish') { 752 // Reset GUID if transitioning to publish. 753 $wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'"); 754 do_action('private_to_published', $post_ID); 755 } 756 757 do_action('edit_post', $post_ID); 758 } 759 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); 766 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); 785 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); 746 $post = get_post($post_ID); 747 if ( !empty($page_template) ) 748 $post->page_template = $page_template; 749 750 wp_transition_post_status($post_status, $previous_status, $post); 751 752 if ( $update) 753 do_action('edit_post', $post_ID, $post); 754 755 do_action('save_post', $post_ID, $post); 756 do_action('wp_insert_post', $post_ID, $post); 799 757 800 758 return $post_ID; … … 842 800 843 801 function wp_publish_post($post_id) { 802 global $wpdb; 803 844 804 $post = get_post($post_id); 845 805 … … 850 810 return; 851 811 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); 853 821 } 854 822 … … 887 855 return wp_set_object_terms($post_ID, $post_categories, 'category'); 888 856 } // wp_set_post_categories() 857 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 } 889 865 890 866 // … … 1844 1820 } 1845 1821 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 1846 1885 ?>
Note: See TracChangeset
for help on using the changeset viewer.