WordPress.org

Make WordPress Core

Changeset 6337


Ignore:
Timestamp:
11/16/2007 05:39:15 PM (11 years ago)
Author:
ryan
Message:

Update page on front settings when deleting the page on front. Props hailin. fixes #5361

File:
1 edited

Legend:

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

    r6321 r6337  
    505505    $parent_where = array( 'post_parent' => $postid );
    506506
    507     if ( 'page' == $post->post_type )
     507    if ( 'page' == $post->post_type) {
     508        // if the page is defined in option page_on_front or post_for_posts,
     509        // adjust the corresponding options
     510        if ( get_option('page_on_front') == $postid ) {
     511            update_option('show_on_front', 'posts');
     512            delete_option('page_on_front');
     513        }
     514        if ( get_option('page_for_posts') == $postid ) {
     515            delete_option('page_for_posts');
     516        }
     517
     518        // Point children of this page to its parent
    508519        $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'page' ) );
    509 
     520    }
     521
     522    // Point all attachments to this post up one level
    510523    $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
    511524
Note: See TracChangeset for help on using the changeset viewer.