Changeset 25686
- Timestamp:
- 10/03/2013 03:50:26 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r25669 r25686 2318 2318 } 2319 2319 2320 if ( 'page' == $post->post_type) {2321 // if the page is defined in option page_on_front or post_for_posts,2322 // adjust the corresponding options2323 if ( get_option('page_on_front') == $postid ) {2324 update_option('show_on_front', 'posts');2325 delete_option('page_on_front');2326 }2327 if ( get_option('page_for_posts') == $postid ) {2328 delete_option('page_for_posts');2329 }2330 } else {2331 unstick_post($postid);2332 }2333 2334 2320 // Do raw query. wp_get_post_revisions() is filtered 2335 2321 $revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) ); … … 2366 2352 return $post; 2367 2353 } 2354 2355 /** 2356 * Resets the page_on_front, show_on_front, and page_for_post settings when a 2357 * linked page is deleted or trashed. 2358 * 2359 * Also ensures the post is no longer sticky. 2360 * 2361 * @access private 2362 * @since 3.7.0 2363 * @param $post_id 2364 */ 2365 function _reset_front_page_settings_for_post( $post_id ) { 2366 $post = get_post( $post_id ); 2367 if ( 'page' == $post->post_type ) { 2368 // If the page is defined in option page_on_front or post_for_posts, 2369 // adjust the corresponding options 2370 if ( get_option( 'page_on_front' ) == $post->ID ) { 2371 update_option( 'show_on_front', 'posts' ); 2372 update_option( 'page_on_front', 0 ); 2373 } 2374 if ( get_option( 'page_for_posts' ) == $post->ID ) { 2375 delete_option( 'page_for_posts', 0 ); 2376 } 2377 } 2378 unstick_post( $post->ID ); 2379 } 2380 add_action( 'before_delete_post', '_reset_front_page_settings_for_post' ); 2381 add_action( 'wp_trash_post', '_reset_front_page_settings_for_post' ); 2368 2382 2369 2383 /**
Note: See TracChangeset
for help on using the changeset viewer.