Make WordPress Core


Ignore:
Timestamp:
08/07/2006 03:50:55 AM (18 years ago)
Author:
ryan
Message:

Rework wp_publish_post() to use wp_update_post() again while turning off filters. Clear the cron schedule for a post when the post timestamp is updated. #2715 #2737

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r4074 r4077  
    497497
    498498    // Get the basics.
    499     $post_content    = apply_filters('content_save_pre',   $post_content);
    500     $post_excerpt    = apply_filters('excerpt_save_pre',   $post_excerpt);
    501     $post_title      = apply_filters('title_save_pre',     $post_title);
    502     $post_category   = apply_filters('category_save_pre',  $post_category);
    503     $post_status     = apply_filters('status_save_pre',    $post_status);
    504     $post_name       = apply_filters('name_save_pre',      $post_name);
    505     $comment_status  = apply_filters('comment_status_pre', $comment_status);
    506     $ping_status     = apply_filters('ping_status_pre',    $ping_status);
     499    if ( empty($no_filter) ) {
     500        $post_content    = apply_filters('content_save_pre',   $post_content);
     501        $post_excerpt    = apply_filters('excerpt_save_pre',   $post_excerpt);
     502        $post_title      = apply_filters('title_save_pre',     $post_title);
     503        $post_category   = apply_filters('category_save_pre',  $post_category);
     504        $post_status     = apply_filters('status_save_pre',    $post_status);
     505        $post_name       = apply_filters('name_save_pre',      $post_name);
     506        $comment_status  = apply_filters('comment_status_pre', $comment_status);
     507        $ping_status     = apply_filters('ping_status_pre',    $ping_status);
     508    }
    507509
    508510    // Make sure we set a valid category
     
    545547            $post_date_gmt = get_gmt_from_date($post_date);
    546548    }
    547 
     549       
    548550    if ( 'publish' == $post_status ) {
    549551        $now = gmdate('Y-m-d H:i:59');
     
    659661
    660662    if ($post_status == 'publish' && $post_type == 'post') {
    661         wp_publish_post($post_ID);
     663        do_action('publish_post', $post_ID);
     664
     665        if ( !defined('WP_IMPORTING') ) {
     666            if ( $post_pingback )
     667                $result = $wpdb->query("
     668                    INSERT INTO $wpdb->postmeta
     669                    (post_id,meta_key,meta_value)
     670                    VALUES ('$post_ID','_pingme','1')
     671                ");
     672            $result = $wpdb->query("
     673                INSERT INTO $wpdb->postmeta
     674                (post_id,meta_key,meta_value)
     675                VALUES ('$post_ID','_encloseme','1')
     676            ");
     677            wp_schedule_single_event(time(), 'do_pings');
     678        }
    662679    } else if ($post_type == 'page') {
    663680        wp_cache_delete('all_page_ids', 'pages');
     
    673690
    674691    if ( 'future' == $post_status ) {
     692        wp_clear_scheduled_hook('publish_future_post', $post_ID);
    675693        wp_schedule_single_event(mysql2date('U', $post_date), 'publish_future_post', $post_ID);
    676694    }
     
    723741
    724742function wp_publish_post($post_id) {
    725     global $wpdb;
    726 
    727743    $post = get_post($post_id);
    728744
     
    730746        return;
    731747
    732     if ( 'publish' != $post->post_status )
    733         $wpdb->query("UPDATE IGNORE $wpdb->posts SET post_status = 'publish' WHERE ID = $post_id");
    734 
    735     do_action('publish_post', $post_id);
    736 
    737     if ( defined('WP_IMPORTING') )
     748    if ( 'publish' == $post->post_status )
    738749        return;
    739750
    740     $post_pingback = get_option('default_pingback_flag');
    741     if ( $post_pingback )
    742         $result = $wpdb->query("
    743             INSERT INTO $wpdb->postmeta
    744             (post_id,meta_key,meta_value)
    745             VALUES ('$post_ID','_pingme','1')
    746         ");
    747 
    748     $result = $wpdb->query("
    749             INSERT INTO $wpdb->postmeta
    750             (post_id,meta_key,meta_value)
    751             VALUES ('$post_ID','_encloseme','1')
    752         ");
    753 
    754     wp_schedule_single_event(time(), 'do_pings');
     751    return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id, 'no_filter' => true));
    755752}
    756753
Note: See TracChangeset for help on using the changeset viewer.