Make WordPress Core

Ticket #24171: 24171.diff

File 24171.diff, 2.1 KB (added by nacin, 13 years ago)
  • wp-includes/post.php

     
    22792279                $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => $post->post_type ) );
    22802280        }
    22812281
    2282         if ( 'page' == $post->post_type) {
    2283                 // if the page is defined in option page_on_front or post_for_posts,
    2284                 // adjust the corresponding options
    2285                 if ( get_option('page_on_front') == $postid ) {
    2286                         update_option('show_on_front', 'posts');
    2287                         delete_option('page_on_front');
    2288                 }
    2289                 if ( get_option('page_for_posts') == $postid ) {
    2290                         delete_option('page_for_posts');
    2291                 }
    2292         } else {
    2293                 unstick_post($postid);
    2294         }
    2295 
    22962282        // Do raw query. wp_get_post_revisions() is filtered
    22972283        $revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) );
    22982284        // Use wp_delete_post (via wp_delete_post_revision) again. Ensures any meta/misplaced data gets cleaned up.
     
    23292315}
    23302316
    23312317/**
     2318 * Resets the page_on_front, show_on_front, and page_for_post settings when a
     2319 * linked page is deleted or trashed.
     2320 *
     2321 * Also ensures the post is no longer sticky.
     2322 *
     2323 * @access private
     2324 * @since 3.7.0
     2325 * @param $post_id
     2326 */
     2327function _reset_front_page_settings_for_post( $post_id ) {
     2328        $post = get_post( $post_id );
     2329        if ( 'page' == $post->post_type ) {
     2330                // If the page is defined in option page_on_front or post_for_posts,
     2331                // adjust the corresponding options
     2332                if ( get_option( 'page_on_front' ) == $post->ID ) {
     2333                        update_option( 'show_on_front', 'posts' );
     2334                        update_option( 'page_on_front', 0 );
     2335                }
     2336                if ( get_option( 'page_for_posts' ) == $post->ID ) {
     2337                        delete_option( 'page_for_posts', 0 );
     2338                }
     2339        }
     2340        unstick_post( $post->ID );
     2341}
     2342add_action( 'before_delete_post', '_reset_front_page_settings_for_post' );
     2343add_action( 'wp_trash_post',      '_reset_front_page_settings_for_post' );
     2344
     2345/**
    23322346 * Moves a post or page to the Trash
    23332347 *
    23342348 * If trash is disabled, the post or page is permanently deleted.