Changeset 13431 for trunk/src/bp-core/bp-core-update.php
- Timestamp:
- 02/24/2023 09:37:44 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-update.php
r13395 r13431 292 292 } 293 293 294 // Version 12.0.0. 295 if ( $raw_db_version < 13422 ){ 296 bp_update_to_12_0(); 297 } 294 298 } 295 299 … … 792 796 793 797 return $new_emails; 798 } 799 800 /** 801 * 12.0.0 update routine. 802 * 803 * - Swith directory page post type from "page" to "buddypress". 804 * 805 * @since 12.0.0 806 */ 807 function bp_update_to_12_0() { 808 $post_type = bp_core_get_directory_post_type(); 809 810 if ( 'page' !== $post_type ) { 811 $directory_pages = bp_core_get_directory_pages(); 812 $nav_menu_item_ids = array(); 813 814 // Do not check post slugs nor post types. 815 remove_filter( 'wp_unique_post_slug', 'bp_core_set_unique_directory_page_slug', 10 ); 816 817 // Update Directory pages post types. 818 foreach ( $directory_pages as $directory_page ) { 819 $nav_menu_item_ids[] = $directory_page->id; 820 821 // Switch the post type. 822 wp_update_post( 823 array( 824 'ID' => $directory_page->id, 825 'post_type' => $post_type, 826 'post_status' => 'publish', 827 ) 828 ); 829 } 830 831 // Update nav menu items! 832 $nav_menus = wp_get_nav_menus( array( 'hide_empty' => true ) ); 833 foreach ( $nav_menus as $nav_menu ) { 834 $items = wp_get_nav_menu_items( $nav_menu->term_id ); 835 foreach ( $items as $item ) { 836 if ( 'page' !== $item->object || ! in_array( $item->object_id, $nav_menu_item_ids, true ) ) { 837 continue; 838 } 839 840 wp_update_nav_menu_item( 841 $nav_menu->term_id, 842 $item->ID, 843 array( 844 'menu-item-db-id' => $item->db_id, 845 'menu-item-object-id' => $item->object_id, 846 'menu-item-object' => $post_type, 847 'menu-item-parent-id' => $item->menu_item_parent, 848 'menu-item-position' => $item->menu_order, 849 'menu-item-type' => 'post_type', 850 'menu-item-title' => $item->title, 851 'menu-item-url' => $item->url, 852 'menu-item-description' => $item->description, 853 'menu-item-attr-title' => $item->attr_title, 854 'menu-item-target' => $item->target, 855 'menu-item-classes' => implode( ' ', (array) $item->classes ), 856 'menu-item-xfn' => $item->xfn, 857 'menu-item-status' => 'publish', 858 ) 859 ); 860 } 861 } 862 863 // Finally make sure to rebuilt permalinks at next page load. 864 delete_option( 'rewrite_rules' ); 865 } 794 866 } 795 867
Note: See TracChangeset
for help on using the changeset viewer.