Changeset 4920 for trunk/bp-core/bp-core-functions.php
- Timestamp:
- 08/03/2011 09:03:41 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-functions.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-functions.php
r4919 r4920 79 79 * people running trunk installations. Leave for a version or two, then remove. 80 80 */ 81 function bp_core_get_ page_meta() {81 function bp_core_get_directory_page_ids() { 82 82 $page_ids = bp_get_option( 'bp-pages' ); 83 83 … … 93 93 } 94 94 95 return apply_filters( 'bp_core_get_page_meta', $page_ids ); 95 foreach( $page_ids as $component_name => $page_id ) { 96 if ( empty( $component_name ) || empty( $page_id ) ) { 97 unset( $page_ids[$component_name] ); 98 } 99 } 100 101 return apply_filters( 'bp_core_get_directory_page_ids', $page_ids ); 96 102 } 97 103 … … 107 113 * @param array $blog_page_ids The IDs of the WP pages corresponding to BP component directories 108 114 */ 109 function bp_core_update_ page_meta( $blog_page_ids ) {115 function bp_core_update_directory_page_ids( $blog_page_ids ) { 110 116 bp_update_option( 'bp-pages', $blog_page_ids ); 111 117 } … … 119 125 * @return obj $pages Page names, IDs, and slugs 120 126 */ 121 function bp_core_get_ page_names() {127 function bp_core_get_directory_pages() { 122 128 global $wpdb, $bp; 123 129 124 // Set pages as standard class125 $pages = new stdClass;126 127 130 // Get pages and IDs 128 if ( $page_ids = bp_core_get_page_meta() ) { 131 if ( $page_ids = bp_core_get_directory_page_ids() ) { 132 133 // Set pages as standard class 134 $pages = new stdClass; 129 135 130 136 $posts_table_name = bp_is_multiblog_mode() ? $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'posts' : $wpdb->posts; … … 132 138 $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent, post_title FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) AND post_status = 'publish' " ) ); 133 139 134 foreach ( (array)$page_ids as $ key=> $page_id ) {140 foreach ( (array)$page_ids as $component_id => $page_id ) { 135 141 foreach ( (array)$page_names as $page_name ) { 136 142 if ( $page_name->ID == $page_id ) { 137 $pages->{$ key}->name = $page_name->post_name;138 $pages->{$ key}->id = $page_name->ID;139 $pages->{$ key}->title = $page_name->post_title;140 $slug[] = $page_name->post_name;143 $pages->{$component_id}->name = $page_name->post_name; 144 $pages->{$component_id}->id = $page_name->ID; 145 $pages->{$component_id}->title = $page_name->post_title; 146 $slug[] = $page_name->post_name; 141 147 142 148 // Get the slug … … 147 153 } 148 154 149 $pages->{$ key}->slug = implode( '/', array_reverse( (array)$slug ) );155 $pages->{$component_id}->slug = implode( '/', array_reverse( (array)$slug ) ); 150 156 } 151 157 … … 155 161 } 156 162 157 return apply_filters( 'bp_core_get_ page_names', $pages );163 return apply_filters( 'bp_core_get_directory_pages', $pages ); 158 164 } 159 165 … … 392 398 393 399 $orphaned_pages[] = array( 394 'id' => $page_data->ID,395 'title' => $page_data->post_title400 'id' => $page_data->ID, 401 'title' => $page_data->post_title 396 402 ); 397 403 } … … 420 426 $wp_page_components = array(); 421 427 422 // Only some BP components require a WP page to function - those with a non-empty root_slug423 foreach( $bp-> active_components as $component_id => $is_active ) {424 if ( !empty( $bp->{$component_id}-> root_slug) ) {428 // Only components with 'has_directory' require a WP page to function 429 foreach( $bp->loaded_components as $component_id => $is_active ) { 430 if ( !empty( $bp->{$component_id}->has_directory ) ) { 425 431 $wp_page_components[] = array( 426 'id' => $component_id,427 'name' => $bp->{$component_id}->name432 'id' => $component_id, 433 'name' => isset( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $bp->{$component_id}->id ) 428 434 ); 429 435 } … … 434 440 if ( isset( $bp->site_options['registration'] ) && ( 'user' == $bp->site_options['registration'] || ( 'all' == $bp->site_options['registration'] ) ) ) { 435 441 $wp_page_components[] = array( 436 'id' => 'activate',437 'name' => __( 'Activate', 'buddypress' )442 'id' => 'activate', 443 'name' => __( 'Activate', 'buddypress' ) 438 444 ); 439 445 440 446 $wp_page_components[] = array( 441 'id' => 'register',442 'name' => __( 'Register', 'buddypress' )447 'id' => 'register', 448 'name' => __( 'Register', 'buddypress' ) 443 449 ); 444 450 } … … 1000 1006 if ( is_multisite() ) { 1001 1007 $network_options = apply_filters( 'bp_core_network_options', array( 1002 'tags_blog_id' => '0',1008 'tags_blog_id' => '0', 1003 1009 'registration' => '0', 1004 1010 'fileupload_maxk' => '1500' … … 1068 1074 1069 1075 if ( empty( $bp->pages ) ) 1070 $bp->pages = bp_core_get_ page_names();1076 $bp->pages = bp_core_get_directory_pages(); 1071 1077 1072 1078 $match = false; … … 1081 1087 if ( empty( $match ) ) { 1082 1088 $bp->add_root[] = $slug; 1083 add_action( 'bp_init', 'bp_core_create_root_component_page' ); 1089 } 1090 1091 // Make sure that this component is registered as requiring a top-level directory 1092 if ( isset( $bp->{$slug} ) ) { 1093 $bp->loaded_components[$bp->{$slug}->slug] = $bp->{$slug}->id; 1094 $bp->{$slug}->has_directory = true; 1084 1095 } 1085 1096 } … … 1093 1104 $new_page_ids[$slug] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $slug ), 'post_status' => 'publish', 'post_type' => 'page' ) ); 1094 1105 1095 $page_ids = array_merge( (array) $new_page_ids, (array) bp_core_get_ page_meta() );1096 bp_core_update_ page_meta( $page_ids );1106 $page_ids = array_merge( (array) $new_page_ids, (array) bp_core_get_directory_page_ids() ); 1107 bp_core_update_directory_page_ids( $page_ids ); 1097 1108 } 1098 1109
Note: See TracChangeset
for help on using the changeset viewer.