Changeset 4183 for trunk/bp-core/bp-core-functions.php
- Timestamp:
- 04/09/2011 05:32:00 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-functions.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-functions.php
r4175 r4183 30 30 * Stores BP pages in the meta table, depending on setup 31 31 * 32 * bp-pages data is stored in the options table of the root blog, except when BP_ENABLE_MULTIBLOG 33 * is turned on. 34 * 32 35 * @package BuddyPress Core 36 * @since 1.3 37 * 38 * @param array $page_ids The IDs of the WP pages corresponding to BP component directories 33 39 */ 34 40 function bp_core_update_page_meta( $page_ids ) { … … 39 45 } 40 46 47 /** 48 * Get bp-pages names and slugs 49 * 50 * @package BuddyPress Core 51 * @since 1.3 52 * 53 * @return obj $pages Page names, IDs, and slugs 54 */ 41 55 function bp_core_get_page_names() { 42 56 global $wpdb, $bp; … … 50 64 $posts_table_name = is_multisite() && !defined( 'BP_ENABLE_MULTIBLOG' ) ? $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'posts' : $wpdb->posts; 51 65 $page_ids_sql = implode( ',', (array)$page_ids ); 52 $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) " ) );66 $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) AND post_status = 'publish' " ) ); 53 67 54 68 foreach ( (array)$page_ids as $key => $page_id ) { … … 222 236 223 237 /** 224 * When BuddyPress is activated we must make sure that mod_rewrite is enabled. 225 * We must also make sure a BuddyPress compatible theme is enabled. This function 226 * will show helpful messages to the administrator. 238 * Verify that some BP prerequisites are set up properly, and notify the admin if not 239 * 240 * On every Dashboard page, this function checks the following: 241 * - that pretty permalinks are enabled 242 * - that a BP-compatible theme is activated 243 * - that every BP component that needs a WP page for a directory has one 244 * - that no directory WP pages are published for deactivated components 245 * The administrator will be shown a notice for each check that fails. 227 246 * 228 247 * @package BuddyPress Core … … 231 250 global $wp_rewrite, $wpdb, $bp; 232 251 252 // Only the super admin gets warnings 253 if ( !is_super_admin() ) 254 return; 255 256 // On multisite installs, don't log on a non-root blog 257 if ( !bp_is_root_blog() ) 258 return; 259 260 /** 261 * Are pretty permalinks enabled? 262 */ 233 263 if ( isset( $_POST['permalink_structure'] ) ) 234 264 return false; … … 237 267 bp_core_add_admin_notice( sprintf( __( '<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress' ), admin_url( 'options-permalink.php' ) ) ); 238 268 } 239 269 270 /** 271 * Are you using a BP-compatible theme? 272 */ 273 240 274 // Get current theme info 241 275 $ct = current_theme_info(); … … 245 279 if ( !defined( 'BP_SILENCE_THEME_NOTICE' ) && !in_array( 'buddypress', (array)$ct->tags ) ) { 246 280 bp_core_add_admin_notice( sprintf( __( "You'll need to <a href='%s'>activate a <strong>BuddyPress-compatible theme</strong></a> to take advantage of all of BuddyPress's features. We've bundled a default theme, but you can always <a href='%s'>install some other compatible themes</a> or <a href='%s'>update your existing WordPress theme</a>.", 'buddypress' ), admin_url( 'themes.php' ), network_admin_url( 'theme-install.php?type=tag&s=buddypress&tab=search' ), network_admin_url( 'plugin-install.php?type=term&tab=search&s=%22bp-template-pack%22' ) ) ); 281 } 282 283 /** 284 * Check for orphaned directory pages (BP component is disabled, WP page exists) 285 */ 286 287 $orphaned_pages = array(); 288 foreach( $bp->pages as $component_id => $page ) { 289 290 // Some members of $bp->pages will not have corresponding $bp->{component}, so we 291 // skip them. Plugins can add themselves here if necessary. 292 $exceptions = apply_filters( 'bp_pages_without_components', array( 'register', 'activate' ) ); 293 if ( in_array( $component_id, $exceptions ) ) 294 continue; 295 296 if ( !isset( $bp->{$component_id} ) ) { 297 // We'll need to get some more information about the page for the notice 298 $page_data = get_post( $page->id ); 299 300 $orphaned_pages[] = array( 301 'id' => $page_data->ID, 302 'title' => $page_data->post_title 303 ); 304 } 305 306 } 307 308 // If orphaned pages are found, post a notice about them. 309 if ( !empty( $orphaned_pages ) ) { 310 311 // Create the string of links to the Edit Page screen for the pages 312 $edit_pages_links = array(); 313 foreach( $orphaned_pages as $op ) { 314 $edit_pages_links[] = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'post.php?action=edit&post=' . $op['id'] ), $op['title'] ); 315 } 316 317 $notice = sprintf( __( 'Some of your WordPress pages are linked to BuddyPress components that have been disabled. These pages may continue to show up in your site navigation. Consider <a href="%1$s">reactivating the components</a>, or unpublishing the pages: <strong>%2$s</strong>', 'buddypress' ), network_admin_url( 'admin.php?page=bp-general-settings' ), implode( ', ', $edit_pages_links ) ); 318 319 bp_core_add_admin_notice( $notice ); 320 } 321 322 /** 323 * Check for orphaned BP components (BP component is enabled, no WP page exists) 324 */ 325 326 $orphaned_components = array(); 327 $wp_page_components = array(); 328 329 // Only some BP components require a WP page to function - those with a non-empty root_slug 330 foreach( $bp->active_components as $component_id => $is_active ) { 331 if ( !empty( $bp->{$component_id}->root_slug ) ) { 332 $wp_page_components[] = array( 333 'id' => $component_id, 334 'name' => $bp->{$component_id}->name 335 ); 336 } 337 } 338 339 // Activate and Register are special cases. They are not components but they need WP pages. 340 // If user registration is disabled, we can skip this step. 341 if ( isset( $bp->site_options['registration'] ) && ( 'user' == $bp->site_options['registration'] || ( 'all' == $bp->site_options['registration'] ) ) ) { 342 $wp_page_components[] = array( 343 'id' => 'activate', 344 'name' => __( 'Activate', 'buddypress' ) 345 ); 346 347 $wp_page_components[] = array( 348 'id' => 'register', 349 'name' => __( 'Register', 'buddypress' ) 350 ); 351 } 352 353 foreach( $wp_page_components as $component ) { 354 if ( !isset( $bp->pages->{$component['id']} ) ) { 355 $orphaned_components[] = $component['name']; 356 } 357 } 358 359 if ( !empty( $orphaned_components ) ) { 360 $notice = sprintf( __( 'Some BuddyPress components must be associated with WordPress pages for your site to work properly. The following components are missing their required WP pages: <strong>%1$s</strong>. Visit the <a href="%2$s">BuddyPress Components</a> panel, where you can either deactivate unused components or complete the page setup.', 'buddypress' ), implode( ', ', $orphaned_components ), network_admin_url( 'admin.php?page=bp-general-settings' ) ); 361 362 bp_core_add_admin_notice( $notice ); 247 363 } 248 364 }
Note: See TracChangeset
for help on using the changeset viewer.