Changeset 3742 for trunk/bp-core.php
- Timestamp:
- 01/19/2011 08:31:10 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core.php
r3736 r3742 253 253 } 254 254 255 256 255 function bp_core_get_page_names() { 257 global $wpdb; 258 259 $page_ids = bp_core_get_page_meta(); 260 256 global $wpdb, $bp; 257 258 // Set pages as standard class 261 259 $pages = new stdClass; 262 260 263 // When upgrading to BP 1.3+ from a version of BP that does not use WP pages, $bp->pages 264 // must be populated with dummy info to avoid crashing the site while the db is upgraded 265 if ( empty( $page_ids ) ) { 266 $dummy_components = array( 267 'members', 268 'groups', 269 'activity', 270 'forums', 271 'activate', 272 'register', 273 'blogs' 274 ); 275 276 foreach ( $dummy_components as $dc ) { 277 $pages->{$dc}->name = $dc; 278 $pages->{$dc}->slug = $dc; 279 $pages->{$dc}->id = $dc; 261 // When upgrading to BP 1.3+ from a version of BP that does not use WP 262 // pages, $bp->pages must be populated with dummy info to avoid crashing the 263 // site while the db is upgraded. 264 if ( !$page_ids = bp_core_get_page_meta() ) { 265 foreach ( $bp->active_components as $component ) { 266 $pages->{$component->id}->name = $component->id; 267 $pages->{$component->id}->slug = $component->id; 268 $pages->{$component->id}->id = $component->id; 280 269 } 281 270 … … 284 273 285 274 $posts_table_name = is_multisite() && !defined( 'BP_ENABLE_MULTIBLOG' ) ? $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'posts' : $wpdb->posts; 286 287 $page_ids_sql = implode( ',', (array)$page_ids ); 288 289 $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) " ) ); 275 $page_ids_sql = implode( ',', (array)$page_ids ); 276 $page_names = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) " ) ); 290 277 291 278 foreach ( (array)$page_ids as $key => $page_id ) { … … 293 280 if ( $page_name->ID == $page_id ) { 294 281 $pages->{$key}->name = $page_name->post_name; 295 $pages->{$key}->id = $page_name->ID; 296 297 $slug[] = $page_name->post_name; 298 299 /* Get the slug */ 282 $pages->{$key}->id = $page_name->ID; 283 $slug[] = $page_name->post_name; 284 285 // Get the slug 300 286 while ( $page_name->post_parent != 0 ) { 301 $parent = $wpdb->get_results( $wpdb->prepare( "SELECT post_name, post_parent FROM {$posts_table_name} WHERE ID = %d", $page_name->post_parent ) );302 $slug[] = $parent[0]->post_name;287 $parent = $wpdb->get_results( $wpdb->prepare( "SELECT post_name, post_parent FROM {$posts_table_name} WHERE ID = %d", $page_name->post_parent ) ); 288 $slug[] = $parent[0]->post_name; 303 289 $page_name->post_parent = $parent[0]->post_parent; 304 290 } … … 377 363 // Add the administration tab under the "Site Admin" tab for site administrators 378 364 $hook = bp_core_add_admin_menu_page( array( 379 'menu_title' 380 'page_title' 381 'capability' 382 'file' 383 'function' 384 'position' 365 'menu_title' => __( 'BuddyPress', 'buddypress' ), 366 'page_title' => __( 'BuddyPress', 'buddypress' ), 367 'capability' => 'manage_options', 368 'file' => 'bp-general-settings', 369 'function' => 'bp_core_admin_dashboard', 370 'position' => 2 385 371 ) ); 386 372 … … 411 397 */ 412 398 if ( !bp_is_active( 'xprofile' ) ) { 413 / * Fallback values if xprofile is disabled */399 // Fallback values if xprofile is disabled 414 400 $bp->core->profile->slug = 'profile'; 415 401 $bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug; 416 402 417 / * Add 'Profile' to the main navigation */403 // Add 'Profile' to the main navigation 418 404 bp_core_new_nav_item( array( 419 405 'name' => __('Profile', 'buddypress'), … … 426 412 $profile_link = $bp->loggedin_user->domain . '/profile/'; 427 413 428 / * Add the subnav items to the profile */414 // Add the subnav items to the profile 429 415 bp_core_new_subnav_item( array( 430 416 'name' => __( 'Public', 'buddypress' ), … … 1444 1430 1445 1431 if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) { 1446 / * Add to output var */1432 // Add to output var 1447 1433 $output .= ( 1 == $count2 ) ? _x( ',', 'Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _x( ',', 'Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2]; 1448 1434 } … … 1697 1683 bp_core_redirect( apply_filters( 'bp_core_search_site', site_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) ); 1698 1684 } 1699 add_action( ' init', 'bp_core_action_search_site', 5);1685 add_action( 'bp_init', 'bp_core_action_search_site', 7 ); 1700 1686 1701 1687 /** … … 1865 1851 return false; 1866 1852 } 1867 add_action ( 'bp_ loaded', 'bp_core_load_buddypress_textdomain', 2 );1853 add_action ( 'bp_init', 'bp_core_load_buddypress_textdomain', 2 ); 1868 1854 1869 1855 function bp_core_add_ajax_hook() { … … 1872 1858 do_action( 'wp_ajax_' . $_REQUEST['action'] ); 1873 1859 } 1874 add_action( ' init', 'bp_core_add_ajax_hook' );1860 add_action( 'bp_init', 'bp_core_add_ajax_hook' ); 1875 1861 1876 1862 /** … … 1957 1943 } 1958 1944 1959 /******************************************************************************** 1960 * Custom Actions 1961 * 1962 * Functions to set up custom BuddyPress actions that all other components can 1963 * hook in to. 1964 */ 1965 1966 /** 1967 * Allow plugins to include their files ahead of core filters 1968 */ 1969 function bp_include() { 1970 do_action( 'bp_include' ); 1971 } 1972 add_action( 'bp_loaded', 'bp_include', 2 ); 1973 1974 /** 1975 * Allow core components and dependent plugins to set root components 1976 */ 1977 function bp_setup_root_components() { 1978 do_action( 'bp_setup_root_components' ); 1979 } 1980 add_action( 'bp_loaded', 'bp_setup_root_components', 2 ); 1981 1982 /** 1983 * Allow core components and dependent plugins to set globals 1984 */ 1985 function bp_setup_globals() { 1986 do_action( 'bp_setup_globals' ); 1987 } 1988 add_action( 'bp_loaded', 'bp_setup_globals', 6 ); 1989 1990 /** 1991 * Allow core components and dependent plugins to set their nav 1992 */ 1993 function bp_setup_nav() { 1994 do_action( 'bp_setup_nav' ); 1995 } 1996 add_action( 'bp_loaded', 'bp_setup_nav', 8 ); 1997 1998 /** 1999 * Allow core components and dependent plugins to register widgets 2000 */ 2001 function bp_setup_widgets() { 2002 do_action( 'bp_register_widgets' ); 2003 } 2004 add_action( 'bp_loaded', 'bp_setup_widgets', 8 ); 2005 2006 /** 2007 * Allow components to initialize themselves cleanly 2008 */ 2009 function bp_init() { 2010 do_action( 'bp_init' ); 2011 } 2012 add_action( 'bp_loaded', 'bp_init' ); 2013 1945 /** 1946 * BuddyPress uses site options to store configuration settings. Many of these settings are needed 1947 * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch 1948 * them all in one go. 1949 * 1950 * @package BuddyPress Core 1951 */ 1952 function bp_core_get_site_options() { 1953 global $bp, $wpdb; 1954 1955 // These options come from the options table in WP single, and sitemeta in MS 1956 $site_options = apply_filters( 'bp_core_site_options', array( 1957 'bp-deactivated-components', 1958 'bp-blogs-first-install', 1959 'bp-disable-blog-forum-comments', 1960 'bp-xprofile-base-group-name', 1961 'bp-xprofile-fullname-field-name', 1962 'bp-disable-profile-sync', 1963 'bp-disable-avatar-uploads', 1964 'bp-disable-account-deletion', 1965 'bp-disable-forum-directory', 1966 'bp-disable-blogforum-comments', 1967 'bb-config-location', 1968 'hide-loggedout-adminbar', 1969 1970 // Useful WordPress settings used often 1971 'tags_blog_id', 1972 'registration', 1973 'fileupload_maxk' 1974 ) ); 1975 1976 // These options always come from the options table of BP_ROOT_BLOG 1977 $root_blog_options = apply_filters( 'bp_core_root_blog_options', array( 1978 'avatar_default' 1979 ) ); 1980 1981 $meta_keys = "'" . implode( "','", (array)$site_options ) ."'"; 1982 1983 if ( is_multisite() ) 1984 $site_meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb->siteid}" ); 1985 else 1986 $site_meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" ); 1987 1988 $root_blog_meta_keys = "'" . implode( "','", (array)$root_blog_options ) ."'"; 1989 $root_blog_meta_table = $wpdb->get_blog_prefix( BP_ROOT_BLOG ) . 'options'; 1990 $root_blog_meta = $wpdb->get_results( $wpdb->prepare( "SELECT option_name AS name, option_value AS value FROM {$root_blog_meta_table} WHERE option_name IN ({$root_blog_meta_keys})" ) ); 1991 1992 $site_options = array(); 1993 foreach( array( $site_meta, $root_blog_meta ) as $meta ) { 1994 if ( !empty( $meta ) ) { 1995 foreach( (array)$meta as $meta_item ) 1996 $site_options[$meta_item->name] = $meta_item->value; 1997 } 1998 } 1999 return apply_filters( 'bp_core_get_site_options', $site_options ); 2000 } 2014 2001 2015 2002 /******************************************************************************** … … 2031 2018 wp_cache_add_global_groups( array( 'bp' ) ); 2032 2019 } 2033 add_action( ' init', 'bp_core_add_global_group' );2020 add_action( 'bp_loaded', 'bp_core_add_global_group' ); 2034 2021 2035 2022 /**
Note: See TracChangeset
for help on using the changeset viewer.