| 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 | | |
| | 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 | */ |
| | 2327 | function _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 | } |
| | 2342 | add_action( 'before_delete_post', '_reset_front_page_settings_for_post' ); |
| | 2343 | add_action( 'wp_trash_post', '_reset_front_page_settings_for_post' ); |
| | 2344 | |
| | 2345 | /** |