Changeset 13431
- Timestamp:
- 02/24/2023 09:37:44 AM (19 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-functions.php
r13405 r13431 117 117 118 118 // Truncate user blogs table. 119 $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name}" ); 119 if ( $bp->is_phpunit_running ) { 120 $query_part = 'DELETE FROM'; 121 } else { 122 $query_part = 'TRUNCATE'; 123 } 124 125 $truncate = $wpdb->query( "{$query_part} {$bp->blogs->table_name}" ); 120 126 if ( is_wp_error( $truncate ) ) { 121 127 return false; … … 123 129 124 130 // Truncate user blogmeta table. 125 $truncate = $wpdb->query( " TRUNCATE{$bp->blogs->table_name_blogmeta}" );131 $truncate = $wpdb->query( "{$query_part} {$bp->blogs->table_name_blogmeta}" ); 126 132 if ( is_wp_error( $truncate ) ) { 127 133 return false; -
trunk/src/bp-core/admin/bp-core-admin-functions.php
r13395 r13431 310 310 311 311 if ( ! empty( $orphaned_components ) ) { 312 $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ); 313 $notice = sprintf( 314 '%1$s <a href="%2$s">%3$s</a>', 315 sprintf( 316 // Translators: %s is the comma separated list of components needing a directory page. 317 __( 'The following active BuddyPress Components do not have associated WordPress Pages: %s.', 'buddypress' ), 318 '<strong>' . implode( '</strong>, <strong>', array_map( 'esc_html', $orphaned_components ) ) . '</strong>' 319 ), 320 esc_url( $admin_url ), 321 __( 'Repair', 'buddypress' ) 312 $notice = sprintf( 313 // Translators: %s is the comma separated list of components needing a directory page. 314 __( 'The following active BuddyPress Components do not have associated BuddyPress Pages: %s.', 'buddypress' ), 315 '<strong>' . implode( '</strong>, <strong>', array_map( 'esc_html', $orphaned_components ) ) . '</strong>' 322 316 ); 323 317 … … 341 335 // If there are duplicates, post a message about them. 342 336 if ( ! empty( $dupe_names ) ) { 343 $admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ); 344 $notice = sprintf( 345 '%1$s <a href="%2$s">%3$s</a>', 346 sprintf( 347 // Translators: %s is the list of directory pages associated to more than one component. 348 __( 'Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %s.', 'buddypress' ), 349 '<strong>' . implode( '</strong>, <strong>', array_map( 'esc_html', $dupe_names ) ) . '</strong>' 350 ), 351 esc_url( $admin_url ), 352 __( 'Repair', 'buddypress' ) 337 $notice = ssprintf( 338 // Translators: %s is the list of directory pages associated to more than one component. 339 __( 'Each BuddyPress Component needs its own BuddyPress page. The following BuddyPress Pages have more than one component associated with them: %s.', 'buddypress' ), 340 '<strong>' . implode( '</strong>, <strong>', array_map( 'esc_html', $dupe_names ) ) . '</strong>' 353 341 ); 354 342 … … 506 494 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ), 507 495 'name' => __( 'Options', 'buddypress' ), 508 ),509 '1' => array(510 'id' => 'bp-page-settings',511 'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ),512 'name' => __( 'Pages', 'buddypress' ),513 496 ), 514 497 '3' => array( -
trunk/src/bp-core/admin/bp-core-admin-slugs.php
r13138 r13431 6 6 * @subpackage CoreAdministration 7 7 * @since 2.3.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 13 13 /** 14 * Renders the page mapping admin panel. 15 * 16 * @since 1.6.0 17 * @todo Use settings API 18 */ 19 function bp_core_admin_slugs_settings() { 20 bp_core_admin_tabbed_screen_header( __( 'BuddyPress Settings', 'buddypress' ), __( 'Pages', 'buddypress' ) ); 21 ?> 22 23 <div class="buddypress-body"> 24 <form action="" method="post" id="bp-admin-page-form"> 25 26 <?php bp_core_admin_slugs_options(); ?> 27 28 <p class="submit clear"> 29 <input class="button-primary" type="submit" name="bp-admin-pages-submit" id="bp-admin-pages-submit" value="<?php esc_attr_e( 'Save Settings', 'buddypress' ) ?>"/> 30 </p> 31 32 <?php wp_nonce_field( 'bp-admin-pages-setup' ); ?> 33 34 </form> 35 </div> 36 37 <?php 38 } 39 40 /** 41 * Generate a list of directory pages, for use when building Components panel markup. 42 * 43 * @since 2.4.1 44 * 45 * @return array 46 */ 47 function bp_core_admin_get_directory_pages() { 48 $bp = buddypress(); 49 $directory_pages = array(); 50 51 // Loop through loaded components and collect directories. 52 if ( is_array( $bp->loaded_components ) ) { 53 foreach( $bp->loaded_components as $component_slug => $component_id ) { 54 55 // Only components that need directories should be listed here. 56 if ( isset( $bp->{$component_id} ) && !empty( $bp->{$component_id}->has_directory ) ) { 57 58 // The component->name property was introduced in BP 1.5, so we must provide a fallback. 59 $directory_pages[$component_id] = !empty( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $component_id ); 60 } 61 } 62 } 63 64 /** Directory Display *****************************************************/ 65 66 /** 67 * Filters the loaded components needing directory page association to a WordPress page. 68 * 69 * @since 1.5.0 70 * 71 * @param array $directory_pages Array of available components to set associations for. 72 */ 73 return apply_filters( 'bp_directory_pages', $directory_pages ); 74 } 75 76 /** 77 * Generate a list of static pages, for use when building Components panel markup. 78 * 79 * By default, this list contains 'register' and 'activate'. 80 * 81 * @since 2.4.1 82 * 83 * @return array 84 */ 85 function bp_core_admin_get_static_pages() { 86 $static_pages = array( 87 'register' => __( 'Register', 'buddypress' ), 88 'activate' => __( 'Activate', 'buddypress' ), 89 ); 90 91 /** 92 * Filters the default static pages for BuddyPress setup. 93 * 94 * @since 1.6.0 95 * 96 * @param array $static_pages Array of static default static pages. 97 */ 98 return apply_filters( 'bp_static_pages', $static_pages ); 99 } 100 101 /** 102 * Creates reusable markup for page setup on the Components and Pages dashboard panel. 103 * 104 * @package BuddyPress 105 * @since 1.6.0 106 * @todo Use settings API 107 */ 108 function bp_core_admin_slugs_options() { 109 110 // Get the existing WP pages. 111 $existing_pages = bp_core_get_directory_page_ids(); 112 113 // Set up an array of components (along with component names) that have directory pages. 114 $directory_pages = bp_core_admin_get_directory_pages(); 115 116 if ( ! empty( $directory_pages ) ) : ?> 117 118 <h3><?php esc_html_e( 'Directories', 'buddypress' ); ?></h3> 119 120 <p><?php esc_html_e( 'Associate a WordPress Page with each BuddyPress component directory.', 'buddypress' ); ?></p> 121 122 <table class="form-table"> 123 <tbody> 124 125 <?php foreach ( $directory_pages as $name => $label ) : ?> 126 127 <tr valign="top"> 128 <th scope="row"> 129 <label for="bp_pages[<?php echo esc_attr( $name ) ?>]"><?php echo esc_html( $label ) ?></label> 130 </th> 131 132 <td> 133 134 <?php if ( ! bp_is_root_blog() ) switch_to_blog( bp_get_root_blog_id() ); ?> 135 136 <?php echo wp_dropdown_pages( array( 137 'name' => 'bp_pages[' . esc_attr( $name ) . ']', 138 'echo' => false, 139 'show_option_none' => __( '- None -', 'buddypress' ), 140 'selected' => ! empty( $existing_pages[$name] ) ? $existing_pages[$name] : false 141 ) ); ?> 142 143 <?php if ( ! empty( $existing_pages[ $name ] ) && get_post( $existing_pages[ $name ] ) ) : ?> 144 145 <a href="<?php echo esc_url( get_permalink( $existing_pages[$name] ) ); ?>" class="button-secondary" target="_bp"> 146 <?php esc_html_e( 'View', 'buddypress' ); ?> <span class="dashicons dashicons-external" aria-hidden="true"></span> 147 <span class="screen-reader-text"><?php esc_html_e( '(opens in a new tab)', 'buddypress' ); ?></span> 148 </a> 149 150 <?php endif; ?> 151 152 <?php if ( ! bp_is_root_blog() ) restore_current_blog(); ?> 153 154 </td> 155 </tr> 156 157 158 <?php endforeach ?> 159 160 <?php 161 162 /** 163 * Fires after the display of default directories. 164 * 165 * Allows plugins to add their own directory associations. 166 * 167 * @since 1.5.0 168 */ 169 do_action( 'bp_active_external_directories' ); ?> 170 171 </tbody> 172 </table> 173 174 <?php 175 176 endif; 177 178 /** Static Display ********************************************************/ 179 180 $static_pages = bp_core_admin_get_static_pages(); 181 182 if ( ! empty( $static_pages ) ) : ?> 183 184 <h3><?php esc_html_e( 'Registration', 'buddypress' ); ?></h3> 185 186 <?php if ( bp_allow_access_to_registration_pages() ) : ?> 187 <p> 188 <?php esc_html_e( 'Associate WordPress Pages with the following BuddyPress Registration pages.', 'buddypress' ); ?> 189 <?php esc_html_e( 'These pages will only be reachable by users who are not logged in.', 'buddypress' ); ?> 190 </p> 191 192 <table class="form-table"> 193 <tbody> 194 195 <?php foreach ( $static_pages as $name => $label ) : ?> 196 197 <tr valign="top"> 198 <th scope="row"> 199 <label for="bp_pages[<?php echo esc_attr( $name ) ?>]"><?php echo esc_html( $label ) ?></label> 200 </th> 201 202 <td> 203 204 <?php if ( ! bp_is_root_blog() ) switch_to_blog( bp_get_root_blog_id() ); ?> 205 206 <?php echo wp_dropdown_pages( array( 207 'name' => 'bp_pages[' . esc_attr( $name ) . ']', 208 'echo' => false, 209 'show_option_none' => __( '- None -', 'buddypress' ), 210 'selected' => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false 211 ) ) ?> 212 213 <?php if ( ! bp_is_root_blog() ) restore_current_blog(); ?> 214 215 </td> 216 </tr> 217 218 <?php endforeach; ?> 219 220 <?php 221 222 /** 223 * Fires after the display of default static pages for BuddyPress setup. 224 * 225 * @since 1.5.0 226 */ 227 do_action( 'bp_active_external_pages' ); ?> 228 229 </tbody> 230 </table> 231 <?php else : ?> 232 <?php if ( is_multisite() ) : ?> 233 <p> 234 <?php 235 printf( 236 /* translators: %s: the link to the Network settings page */ 237 esc_html_x( 'Registration is currently disabled. Before associating a page is allowed, please enable registration by selecting either the "User accounts may be registered" or "Both sites and user accounts can be registered" option on %s.', 'Disabled registration message for multisite config', 'buddypress' ), 238 sprintf( 239 '<a href="%1$s">%2$s</a>', 240 esc_url( network_admin_url( 'settings.php' ) ), 241 esc_html_x( 'this page', 'Link text for the Multisite’s network settings page', 'buddypress' ) 242 ) 243 ); 244 ?> 245 </p> 246 <?php else : ?> 247 <p> 248 <?php 249 printf( 250 /* translators: %s: the link to the Site general options page */ 251 esc_html_x( 'Registration is currently disabled. Before associating a page is allowed, please enable registration by clicking on the "Anyone can register" checkbox on %s.', 'Disabled registration message for regular site config', 'buddypress' ), 252 sprintf( 253 '<a href="%1$s">%2$s</a>', 254 esc_url( admin_url( 'options-general.php' ) ), 255 esc_html_x( 'this page', 'Link text for the Site’s general options page', 'buddypress' ) 256 ) 257 ); 258 ?> 259 </p> 260 <?php endif; ?> 261 <?php endif; 262 endif; 263 } 264 265 /** 266 * Handle saving of the BuddyPress slugs. 267 * 268 * @since 1.6.0 269 * @todo Use settings API 270 */ 271 function bp_core_admin_slugs_setup_handler() { 272 273 if ( isset( $_POST['bp-admin-pages-submit'] ) ) { 274 if ( ! check_admin_referer( 'bp-admin-pages-setup' ) ) { 275 return false; 276 } 277 278 // Then, update the directory pages. 279 if ( isset( $_POST['bp_pages'] ) ) { 280 $valid_pages = array_merge( bp_core_admin_get_directory_pages(), bp_core_admin_get_static_pages() ); 281 282 $new_directory_pages = array(); 283 foreach ( (array) $_POST['bp_pages'] as $key => $value ) { 284 if ( isset( $valid_pages[ $key ] ) ) { 285 $new_directory_pages[ $key ] = (int) $value; 286 } 287 } 288 bp_core_update_directory_page_ids( $new_directory_pages ); 289 } 290 291 $base_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings', 'updated' => 'true' ), 'admin.php' ) ); 292 293 wp_redirect( $base_url ); 294 } 295 } 296 add_action( 'bp_admin_init', 'bp_core_admin_slugs_setup_handler' ); 14 _deprecated_file( basename( __FILE__ ), '12.0.0', '', __( 'BuddyPress does not used page association anymore, you can restore it using the BP Classic plugin', 'buddypress' ) ); -
trunk/src/bp-core/bp-core-actions.php
r13306 r13431 70 70 */ 71 71 add_action( 'bp_init', 'bp_register_post_types', 2 ); 72 add_action( 'bp_init', 'bp_register_post_statuses', 2 ); 72 73 add_action( 'bp_init', 'bp_register_taxonomies', 2 ); 73 74 add_action( 'bp_init', 'bp_core_set_uri_globals', 2 ); -
trunk/src/bp-core/bp-core-dependency.php
r13418 r13431 124 124 */ 125 125 do_action( 'bp_register_post_types' ); 126 } 127 128 /** 129 * Fire the 'bp_register_post_statuses' action, where plugins should register post statuses. 130 * 131 * @since 12.0.0 132 */ 133 function bp_register_post_statuses() { 134 135 /** 136 * Fires inside the 'bp_register_post_statuses' function, where plugins should register post statuses. 137 * 138 * @since 12.0.0 139 */ 140 do_action( 'bp_register_post_statuses' ); 126 141 } 127 142 -
trunk/src/bp-core/bp-core-functions.php
r13377 r13431 698 698 699 699 /** 700 * Get the directory pages post type. 701 * 702 * @since 12.0.0 703 * 704 * @return string The post type to use for directory pages. 705 */ 706 function bp_core_get_directory_post_type() { 707 $post_type = 'buddypress'; 708 709 /** 710 * Filter here to edit the post type to use for directory pages. 711 * 712 * @since 12.0.0 713 * 714 * @param string $post_type The post type to use for directory pages. 715 */ 716 return apply_filters( 'bp_core_get_directory_post_type', $post_type ); 717 } 718 719 /** 700 720 * Get names and slugs for BuddyPress component directory pages. 701 721 * … … 834 854 // Create the pages. 835 855 foreach ( $pages_to_create as $component_name => $page_name ) { 836 $exist s = get_page_by_path( $component_name );856 $existing_id = bp_core_get_directory_page_id( $component_name ); 837 857 838 858 // If page already exists, use it. 839 if ( ! empty( $exist s) ) {840 $pages[ $component_name ] = $exists->ID;859 if ( ! empty( $existing_id ) ) { 860 $pages[ $component_name ] = (int) $existing_id; 841 861 } else { 842 862 $pages[ $component_name ] = wp_insert_post( array( … … 845 865 'post_status' => 'publish', 846 866 'post_title' => $page_name, 847 'post_type' => 'page',867 'post_type' => bp_core_get_directory_post_type(), 848 868 ) ); 849 869 } … … 887 907 888 908 /** 909 * Make sure Components directory page `post_name` are unique. 910 * 911 * Goal is to avoid a slug conflict between a Page and a Component's directory page `post_name`. 912 * 913 * @since 12.0.0 914 * 915 * @param string $slug The post slug. 916 * @param int $post_ID Post ID. 917 * @param string $post_status The post status. 918 * @param string $post_type Post type. 919 * @param int $post_parent Post parent ID. 920 * @param string $original_slug The original post slug. 921 */ 922 function bp_core_set_unique_directory_page_slug( $slug = '', $post_ID = 0, $post_status = '', $post_type = '', $post_parent = 0, $original_slug = '' ) { 923 if ( ( 'buddypress' === $post_type || 'page' === $post_type ) && $slug === $original_slug ) { 924 $pages = get_posts( 925 array( 926 'post__not_in' => array( $post_ID ), 927 'post_status' => array( 'publish', 'bp_restricted' ), 928 'post_type' => array( 'buddypress', 'page' ), 929 ) 930 ); 931 932 $illegal_names = wp_list_pluck( $pages, 'post_name' ); 933 if ( is_multisite() && ! is_subdomain_install() ) { 934 $current_site = get_current_site(); 935 $site = get_site_by_path( $current_site->domain, trailingslashit( $current_site->path ) . $slug ); 936 937 if ( isset( $site->blog_id ) && 1 !== $site->blog_id ) { 938 $illegal_names[] = $slug; 939 } 940 } 941 942 if ( in_array( $slug, $illegal_names, true ) ) { 943 $suffix = 2; 944 do { 945 $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 946 $post_name_check = in_array( $alt_post_name, $illegal_names, true ); 947 $suffix++; 948 } while ( $post_name_check ); 949 $slug = $alt_post_name; 950 } 951 } 952 953 return $slug; 954 } 955 add_filter( 'wp_unique_post_slug', 'bp_core_set_unique_directory_page_slug', 10, 6 ); 956 957 /** 889 958 * Remove the entry from bp_pages when the corresponding WP page is deleted. 890 959 * … … 914 983 } 915 984 add_action( 'delete_post', 'bp_core_on_directory_page_delete' ); 916 917 /**918 * Create a default component slug from a WP page root_slug.919 *920 * Since 1.5, BP components get their root_slug (the slug used immediately921 * following the root domain) from the slug of a corresponding WP page.922 *923 * E.g. if your BP installation at example.com has its members page at924 * example.com/community/people, $bp->members->root_slug will be925 * 'community/people'.926 *927 * By default, this function creates a shorter version of the root_slug for928 * use elsewhere in the URL, by returning the content after the final '/'929 * in the root_slug ('people' in the example above).930 *931 * Filter on 'bp_core_component_slug_from_root_slug' to override this method932 * in general, or define a specific component slug constant (e.g.933 * BP_MEMBERS_SLUG) to override specific component slugs.934 *935 * @since 1.5.0936 *937 * @param string $root_slug The root slug, which comes from $bp->pages->[component]->slug.938 * @return string The short slug for use in the middle of URLs.939 */940 function bp_core_component_slug_from_root_slug( $root_slug ) {941 $slug_chunks = explode( '/', $root_slug );942 $slug = array_pop( $slug_chunks );943 944 /**945 * Filters the default component slug from a WP page root_slug.946 *947 * @since 1.5.0948 *949 * @param string $slug Short slug for use in the middle of URLs.950 * @param string $root_slug The root slug which comes from $bp->pages-[component]->slug.951 */952 return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug );953 }954 955 /**956 * Add support for a top-level ("root") component.957 *958 * This function originally (pre-1.5) let plugins add support for pages in the959 * root of the install. These root level pages are now handled by actual960 * WordPress pages and this function is now a convenience for compatibility961 * with the new method.962 *963 * @since 1.0.0964 *965 * @param string $slug The slug of the component being added to the root list.966 */967 function bp_core_add_root_component( $slug ) {968 $bp = buddypress();969 970 if ( empty( $bp->pages ) ) {971 $bp->pages = bp_core_get_directory_pages();972 }973 974 $match = false;975 976 // Check if the slug is registered in the $bp->pages global.977 foreach ( (array) $bp->pages as $key => $page ) {978 if ( $key == $slug || $page->slug == $slug ) {979 $match = true;980 }981 }982 983 // Maybe create the add_root array.984 if ( empty( $bp->add_root ) ) {985 $bp->add_root = array();986 }987 988 // If there was no match, add a page for this root component.989 if ( empty( $match ) ) {990 $add_root_items = $bp->add_root;991 $add_root_items[] = $slug;992 $bp->add_root = $add_root_items;993 }994 995 // Make sure that this component is registered as requiring a top-level directory.996 if ( isset( $bp->{$slug} ) ) {997 $bp->loaded_components[$bp->{$slug}->slug] = $bp->{$slug}->id;998 $bp->{$slug}->has_directory = true;999 }1000 }1001 1002 /**1003 * Create WordPress pages to be used as BP component directories.1004 *1005 * @since 1.5.01006 */1007 function bp_core_create_root_component_page() {1008 1009 // Get BuddyPress.1010 $bp = buddypress();1011 1012 $new_page_ids = array();1013 1014 foreach ( (array) $bp->add_root as $slug ) {1015 $new_page_ids[ $slug ] = wp_insert_post( array(1016 'comment_status' => 'closed',1017 'ping_status' => 'closed',1018 'post_title' => ucwords( $slug ),1019 'post_status' => 'publish',1020 'post_type' => 'page'1021 ) );1022 }1023 1024 $page_ids = array_merge( $new_page_ids, bp_core_get_directory_page_ids( 'all' ) );1025 bp_core_update_directory_page_ids( $page_ids );1026 }1027 985 1028 986 /** … … 4820 4778 '10.0', 4821 4779 '11.0', 4780 '12.0', 4822 4781 ); 4823 4782 … … 4892 4851 return $latest_deprecated_functions_versions; 4893 4852 } 4853 4854 /** 4855 * Get the BuddyPress Post Type site ID. 4856 * 4857 * @since 12.0.0 4858 * 4859 * @return int The site ID the BuddyPress Post Type should be registered on. 4860 */ 4861 function bp_get_post_type_site_id() { 4862 $site_id = bp_get_root_blog_id(); 4863 4864 /** 4865 * Filter here to edit the site ID. 4866 * 4867 * @todo This will need to be improved to take in account 4868 * specific configurations like multiblog. 4869 * 4870 * @since 12.0.0 4871 * 4872 * @param integer $site_id The site ID to register the post type on. 4873 */ 4874 return (int) apply_filters( 'bp_get_post_type_site_id', $site_id ); 4875 } -
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 -
trunk/src/bp-core/classes/class-bp-admin.php
r13414 r13431 147 147 require( $this->admin_dir . 'bp-core-admin-functions.php' ); 148 148 require( $this->admin_dir . 'bp-core-admin-components.php' ); 149 require( $this->admin_dir . 'bp-core-admin-slugs.php' );150 149 require( $this->admin_dir . 'bp-core-admin-tools.php' ); 151 150 require( $this->admin_dir . 'bp-core-admin-optouts.php' ); … … 275 274 $this->submenu_pages['settings']['bp-components'] = $bp_components_page; 276 275 $hooks[] = $bp_components_page; 277 278 $bp_page_settings_page = add_submenu_page(279 $this->settings_page,280 __( 'BuddyPress Pages', 'buddypress' ),281 __( 'BuddyPress Pages', 'buddypress' ),282 $this->capability,283 'bp-page-settings',284 'bp_core_admin_slugs_settings'285 );286 287 $this->submenu_pages['settings']['bp-page-settings'] = $bp_page_settings_page;288 $hooks[] = $bp_page_settings_page;289 276 290 277 $bp_settings_page = add_submenu_page( … … 627 614 628 615 // Settings pages. 629 remove_submenu_page( $this->settings_page, 'bp-page-settings' );630 616 remove_submenu_page( $this->settings_page, 'bp-settings' ); 631 617 remove_submenu_page( $this->settings_page, 'bp-credits' ); -
trunk/src/bp-core/classes/class-bp-component.php
r13422 r13431 543 543 add_action( 'bp_register_post_types', array( $this, 'register_post_types' ), 10 ); 544 544 545 // Register post statuses. 546 add_action( 'bp_register_post_statuses', array( $this, 'register_post_statuses' ), 10 ); 547 545 548 // Register taxonomies. 546 549 add_action( 'bp_register_taxonomies', array( $this, 'register_taxonomies' ), 10 ); … … 856 859 */ 857 860 do_action( 'bp_' . $this->id . '_register_post_types' ); 861 } 862 863 /** 864 * Set up the component post statuses. 865 * 866 * @since 12.0.0 867 */ 868 public function register_post_statuses() { 869 870 /** 871 * Fires in the `register_post_statuses` method inside BP_Component. 872 * 873 * This is a dynamic hook that is based on the component string ID. 874 * 875 * @since 12.0.0 876 */ 877 do_action( 'bp_' . $this->id . '_register_post_statuses' ); 858 878 } 859 879 -
trunk/src/bp-core/classes/class-bp-core.php
r13414 r13431 324 324 * Set up post types. 325 325 * 326 * @since BuddyPress (2.4.0) 326 * @since 2.4.0 327 * @since 12.0.0 Registers the 'buddypress' post type for component directories. 327 328 */ 328 329 public function register_post_types() { 329 330 // Emails 330 // Component directories. 331 if ( (int) get_current_blog_id() === bp_get_post_type_site_id() ) { 332 register_post_type( 333 'buddypress', 334 array( 335 'label' => _x( 'BuddyPress Directories', 'Post Type label', 'buddypress' ), 336 'labels' => array( 337 'singular_name' => _x( 'BuddyPress Directory', 'Post Type singular name', 'buddypress' ), 338 ), 339 'description' => __( 'The BuddyPress Post Type used for component directories.', 'buddypress' ), 340 'public' => false, 341 'hierarchical' => true, 342 'exclude_from_search' => true, 343 'publicly_queryable' => false, 344 'show_ui' => false, 345 'show_in_nav_menus' => true, 346 'show_in_rest' => false, 347 'supports' => array( 'title' ), 348 'has_archive' => false, 349 'rewrite' => false, 350 'query_var' => false, 351 'delete_with_user' => false, 352 ) 353 ); 354 } 355 356 // Emails. 331 357 if ( bp_is_root_blog() && ! is_network_admin() ) { 332 358 register_post_type( … … 357 383 358 384 parent::register_post_types(); 385 } 386 387 /** 388 * Set up the component post statuses. 389 * 390 * @since 12.0.0 391 */ 392 public function register_post_statuses() { 393 register_post_status( 394 'bp_restricted', 395 array( 396 'label' => _x( 'Restricted to members', '`buddypress` post type post status', 'buddypress' ), 397 'public' => false, 398 'internal' => true, 399 ) 400 ); 401 402 parent::register_post_statuses(); 359 403 } 360 404 -
trunk/src/class-buddypress.php
r13422 r13431 442 442 443 443 $this->version = '12.0.0-alpha'; 444 $this->db_version = 13 271;444 $this->db_version = 13422; 445 445 446 446 /** Loading */ -
trunk/tests/phpunit/testcases/core/functions.php
r13417 r13431 566 566 restore_current_blog(); 567 567 568 $this->assertFalse( wp_cache_get( 'directory_pages', 'bp ' ) );568 $this->assertFalse( wp_cache_get( 'directory_pages', 'bp_pages' ) ); 569 569 } 570 570 … … 631 631 632 632 /** 633 * @group bp_core_add_root_component634 */635 public function test_add_root_component_not_in_bp_pages() {636 buddypress()->foo = new stdClass;637 buddypress()->foo->id = 'foo';638 buddypress()->foo->slug = 'foo';639 640 bp_core_add_root_component( 'foo' );641 642 $this->assertTrue( in_array( 'foo', buddypress()->add_root ) );643 $this->assertTrue( buddypress()->foo->has_directory );644 $this->assertNotEmpty( buddypress()->loaded_components['foo'] );645 }646 647 /**648 633 * @group bp_core_time_since 649 634 * @group bp_core_current_time … … 841 826 /** 842 827 * @group bp_core_add_page_mappings 843 * @ticket 8187828 * @ticket BP8187 844 829 */ 845 830 public function test_bp_core_add_page_mappings_in_multisite_subdirectory() { -
trunk/tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageIds.php
r13159 r13431 250 250 bp_update_option( 'bp-pages', 'foo' ); 251 251 252 $this->assertFalse( wp_cache_get( 'directory_pages', 'bp ' ) );252 $this->assertFalse( wp_cache_get( 'directory_pages', 'bp_pages' ) ); 253 253 254 254 bp_update_option( 'bp-pages', $v ); -
trunk/tests/phpunit/testcases/members/functions.php
r13414 r13431 124 124 $pages = bp_core_get_directory_pages(); 125 125 $members_page = get_post( $pages->members->id ); 126 $members_page->post_name = 'new-members-slug'; 127 wp_update_post( $members_page ); 126 $new_members_slug = 'new-members-slug'; 127 $members_page->post_name = $new_members_slug; 128 $p = wp_update_post( $members_page ); 129 130 // Weird! 131 if ( is_multisite() ) { 132 $new_members_slug = get_post_field( 'post_name', $p ); 133 } 128 134 129 135 // Go back to members directory page and recheck user domain 130 $this->go_to( trailingslashit( home_url( 'new-members-slug') ) );136 $this->go_to( trailingslashit( home_url( $new_members_slug ) ) ); 131 137 $user = new WP_User( $user_id ); 132 138 133 $this->assertSame( home_url( 'new-members-slug') . '/' . $user->user_nicename . '/', bp_core_get_user_domain( $user_id ) );139 $this->assertSame( home_url( $new_members_slug ) . '/' . $user->user_nicename . '/', bp_core_get_user_domain( $user_id ) ); 134 140 } 135 141 -
trunk/tests/phpunit/testcases/routing/activity.php
r13314 r13431 21 21 function test_activity_directory() { 22 22 $this->go_to( bp_get_activity_directory_permalink() ); 23 $this->assertEquals( bp_get_activity_root_slug(), bp_current_component() ); 23 24 $pages = bp_core_get_directory_pages(); 25 $component_id = bp_current_component(); 26 27 $this->assertEquals( bp_get_activity_root_slug(), $pages->{$component_id}->slug ); 24 28 } 25 29 -
trunk/tests/phpunit/testcases/routing/members.php
r13314 r13431 22 22 function test_members_directory() { 23 23 $this->go_to( bp_get_members_directory_permalink() ); 24 $this->assertEquals( bp_get_members_root_slug(), bp_current_component() ); 24 25 $pages = bp_core_get_directory_pages(); 26 $component_id = bp_current_component(); 27 28 $this->assertEquals( bp_get_members_root_slug(), $pages->{$component_id}->slug ); 25 29 } 26 30 … … 28 32 $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) ); 29 33 $this->assertTrue( bp_is_my_profile() ); 30 }31 32 /**33 * @ticket BP647534 */35 public function test_member_directory_when_nested_under_wp_page() {36 $p = self::factory()->post->create( array(37 'post_type' => 'page',38 'post_name' => 'foo',39 ) );40 41 $members_page = get_page_by_path( 'members' );42 43 wp_update_post( array(44 'ID' => $members_page->ID,45 'post_parent' => $p,46 ) );47 48 $members_page_permalink = bp_get_root_domain() . '/foo/members/';49 $this->go_to( $members_page_permalink );50 51 $this->assertTrue( bp_is_members_component() );52 $this->assertEquals( '', bp_current_action() );53 34 } 54 35 -
trunk/tests/phpunit/testcases/routing/root-profiles.php
r13314 r13431 31 31 public function test_members_directory() { 32 32 $this->go_to( home_url( bp_get_members_root_slug() ) ); 33 $this->assertEquals( bp_get_members_root_slug(), bp_current_component() ); 33 34 $pages = bp_core_get_directory_pages(); 35 $component_id = bp_current_component(); 36 37 $this->assertEquals( bp_get_members_root_slug(), $pages->{$component_id}->slug ); 34 38 } 35 39 … … 52 56 ) ); 53 57 54 $members_page = get_page_by_path( 'members' );58 $members_page_id = bp_core_get_directory_page_id( 'members' ); 55 59 wp_update_post( array( 56 'ID' => $members_page->ID,60 'ID' => $members_page_id, 57 61 'post_parent' => $p, 58 62 ) );
Note: See TracChangeset
for help on using the changeset viewer.