Ticket #19415: 19415.diff
File 19415.diff, 1.6 KB (added by , 10 years ago) |
---|
-
src/wp-includes/default-filters.php
267 267 add_action( 'delete_post', '_wp_delete_post_menu_item' ); 268 268 add_action( 'delete_term', '_wp_delete_tax_menu_item', 10, 3 ); 269 269 add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 ); 270 add_action( 'transition_post_status', '_wp_auto_remove_posts_from_menu', 10, 3 ); 270 271 271 272 // Post Thumbnail CSS class filtering 272 273 add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' ); -
src/wp-includes/nav-menu.php
898 898 wp_update_nav_menu_item( $menu_id, 0, $args ); 899 899 } 900 900 } 901 902 /** 903 * Automatically remove post objects from nav menus when transitioned to a non public status. 904 * 905 * @since 4.2.0 906 * @access private 907 * 908 * @param string $new_status The new status of the post object. 909 * @param string $old_status The old status of the post object. 910 * @param object $post The post object being transitioned from one status to another. 911 * @return void 912 */ 913 function _wp_auto_remove_posts_from_menu( $new_status, $old_status, $post ) { 914 if ( ! in_array( $new_status, array( 'private', 'draft', 'trash', 'future' ) ) ) { 915 return; 916 } 917 918 _wp_delete_post_menu_item( $post->ID ); 919 }