Changeset 3917 for trunk/bp-core/bp-core-loader.php
- Timestamp:
- 01/25/2011 08:58:56 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-loader.php
r3829 r3917 1 1 <?php 2 2 3 // Load the files containing functions that we globally will need.4 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-hooks.php');5 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php');6 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php');7 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php');8 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php');9 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php');10 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-template.php');11 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-buddybar.php');12 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php');13 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-component.php' );14 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' );3 // Require all of the BuddyPress core libraries 4 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-component.php' ); 5 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); 6 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-hooks.php' ); 7 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' ); 8 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' ); 9 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' ); 10 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' ); 11 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' ); 12 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-template.php' ); 13 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-buddybar.php' ); 14 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' ); 15 15 16 // Do we load deprecated functions?16 // Load deprecated functions 17 17 if ( !defined( 'BP_SKIP_DEPRECATED' ) ) 18 require ( BP_PLUGIN_DIR . '/bp-core/deprecated/1.3.php');18 require_once( BP_PLUGIN_DIR . '/bp-core/deprecated/1.3.php' ); 19 19 20 // If BP_DISABLE_ADMIN_BAR is defined, do not load the globaladmin bar.20 // Load the WP admin bar. 21 21 if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) ) 22 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php');22 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' ); 23 23 24 24 /** "And now for something completely different" ******************************/ 25 25 26 /** 27 * Sets up default global BuddyPress configuration settings and stores 28 * them in a $bp variable. 29 * 30 * @package BuddyPress Core Core 31 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 32 * @uses bp_core_get_user_domain() Returns the domain for a user 33 */ 34 function bp_core_setup_globals() { 35 global $bp; 36 //global $current_action, $current_blog; 37 global $bp_pages; 38 //global $action_variables; 26 class BP_Core extends BP_Component { 39 27 40 // Get the base database prefix 41 $bp->table_prefix = bp_core_get_table_prefix(); 42 43 // The domain for the root of the site where the main blog resides 44 $bp->root_domain = bp_core_get_root_domain(); 45 46 // The names of the core WordPress pages used to display BuddyPress content 47 $bp->pages = $bp_pages; 48 49 /** Component and Action **************************************************/ 50 51 // Used for overriding the 2nd level navigation menu so it can be used to 52 // display custom navigation for an item (for example a group) 53 $bp->is_single_item = false; 54 55 // The default component to use if none are set and someone 56 // visits: http://domain.com/members/andy 57 if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) { 58 if ( isset( $bp->pages->activity ) ) 59 $bp->default_component = $bp->activity->id; 60 else 61 $bp->default_component = $bp->profile->id; 62 } else { 63 $bp->default_component = BP_DEFAULT_COMPONENT; 28 function BP_Core() { 29 parent::start( 30 '_core', 31 __( 'BuddyPress Core', 'buddypress' ) 32 , BP_PLUGIN_DIR 33 ); 64 34 } 65 35 66 // Fetches all of the core BuddyPress settings in one fell swoop67 $bp->site_options = bp_core_get_site_options();36 function _setup_globals() { 37 global $bp, $bp_pages; 68 38 69 // Sets up the array container for the component navigation rendered 70 // by bp_get_nav() 71 $bp->bp_nav = array(); 39 // Setup the BuddyPress theme directory 40 register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' ); 72 41 73 // Sets up the array container for the component options navigation 74 // rendered by bp_get_options_nav() 75 $bp->bp_options_nav = array(); 42 // Get the base database prefix 43 $bp->table_prefix = bp_core_get_table_prefix(); 76 44 77 // Contains an array of all the active components. The key is the slug, 78 // value the internal ID of the component. 79 $bp->active_components = array(); 45 // The domain for the root of the site where the main blog resides 46 $bp->root_domain = bp_core_get_root_domain(); 80 47 81 /** Avatars ***************************************************************/ 48 // The names of the core WordPress pages used to display BuddyPress content 49 $bp->pages = $bp_pages; 82 50 83 // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar 84 $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['avatar_default'] ); 85 $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user ); 86 $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user ); 51 /** Component and Action **************************************************/ 87 52 88 // Notifications Table 89 $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications'; 53 // Used for overriding the 2nd level navigation menu so it can be used to 54 // display custom navigation for an item (for example a group) 55 $bp->is_single_item = false; 90 56 91 do_action( 'bp_core_setup_globals' ); 92 } 93 add_action( 'bp_setup_globals', 'bp_core_setup_globals', 1 ); 57 // The default component to use if none are set and someone 58 // visits: http://domain.com/members/andy 59 if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) { 60 if ( isset( $bp->pages->activity ) ) 61 $bp->default_component = $bp->activity->id; 62 else 63 $bp->default_component = $bp->profile->id; 64 } else { 65 $bp->default_component = BP_DEFAULT_COMPONENT; 66 } 94 67 95 /** 96 * Sets up the profile navigation item if the Xprofile component is not installed. 97 * 98 * @package BuddyPress Core 99 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 100 * @uses bp_core_new_nav_item() Adds a navigation item to the top level buddypress navigation 101 * @uses bp_core_new_subnav_item() Adds a sub navigation item to a nav item 102 * @uses bp_is_my_profile() Returns true if the current user being viewed is equal the logged in user 103 * @uses bp_core_fetch_avatar() Returns the either the thumb or full avatar URL for the user_id passed 104 */ 105 function bp_core_setup_nav() { 106 global $bp; 68 // Fetches all of the core BuddyPress settings in one fell swoop 69 $bp->site_options = bp_core_get_site_options(); 107 70 108 /*** 109 * If the extended profiles component is disabled, we need to revert to using the 110 * built in WordPress profile information 111 */ 112 if ( !bp_is_active( 'profile' ) ) { 71 // Sets up the array container for the component navigation rendered 72 // by bp_get_nav() 73 $bp->bp_nav = array(); 113 74 114 // Fallback values if xprofile is disabled115 $bp->core->profile->slug = 'profile';116 $bp-> active_components[$bp->core->profile->slug] = $bp->core->profile->slug;75 // Sets up the array container for the component options navigation 76 // rendered by bp_get_options_nav() 77 $bp->bp_options_nav = array(); 117 78 118 // Add 'Profile' to the main navigation 119 bp_core_new_nav_item( array( 120 'name' => __( 'Profile', 'buddypress' ), 121 'slug' => $bp->core->profile->slug, 122 'position' => 20, 123 'screen_function' => 'bp_core_catch_profile_uri', 124 'default_subnav_slug' => 'public' 125 ) ); 79 // Contains an array of all the active components. The key is the slug, 80 // value the internal ID of the component. 81 $bp->active_components = array(); 126 82 127 $profile_link = trailingslashit( $bp->loggedin_user->domain . '/' . $bp->core->profile->slug );83 /** Basic current user data ***********************************************/ 128 84 129 // Add the subnav items to the profile 130 bp_core_new_subnav_item( array( 131 'name' => __( 'Public', 'buddypress' ), 132 'slug' => 'public', 133 'parent_url' => $profile_link, 134 'parent_slug' => $bp->core->profile->slug, 135 'screen_function' => 'bp_core_catch_profile_uri' 136 ) ); 85 // Logged in user is the 'current_user' 86 $current_user = wp_get_current_user(); 137 87 138 // Looking at a profile 139 if ( 'profile' == $bp->current_component ) { 140 if ( bp_is_my_profile() ) { 141 $bp->bp_options_title = __( 'My Profile', 'buddypress' ); 142 } else { 143 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 144 'item_id' => $bp->displayed_user->id, 145 'type' => 'thumb' 146 ) ); 147 $bp->bp_options_title = $bp->displayed_user->fullname; 148 } 88 // The user ID of the user who is currently logged in. 89 $bp->loggedin_user->id = $current_user->ID; 90 91 /** Avatars ***************************************************************/ 92 93 // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar 94 $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['avatar_default'] ); 95 $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', $bp->grav_default->user ); 96 $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', $bp->grav_default->user ); 97 98 // Notifications Table 99 $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications'; 100 101 do_action( 'bp_core_setup_globals' ); 102 } 103 104 function _setup_nav() { 105 global $bp; 106 107 /*** 108 * If the extended profiles component is disabled, we need to revert to using the 109 * built in WordPress profile information 110 */ 111 if ( !bp_is_active( 'xprofile' ) ) { 112 113 // Fallback values if xprofile is disabled 114 $bp->core->profile->slug = 'profile'; 115 $bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug; 116 117 // Add 'Profile' to the main navigation 118 $main_nav = array( 119 'name' => __( 'Profile', 'buddypress' ), 120 'slug' => $bp->core->profile->slug, 121 'position' => 20, 122 'screen_function' => 'bp_core_catch_profile_uri', 123 'default_subnav_slug' => 'public' 124 ); 125 126 $profile_link = trailingslashit( $bp->loggedin_user->domain . '/' . $bp->core->profile->slug ); 127 128 // Add the subnav items to the profile 129 $sub_nav[] = array( 130 'name' => __( 'Public', 'buddypress' ), 131 'slug' => 'public', 132 'parent_url' => $profile_link, 133 'parent_slug' => $bp->core->profile->slug, 134 'screen_function' => 'bp_core_catch_profile_uri' 135 ); 149 136 } 150 137 } 151 138 } 152 add_action( 'bp_setup_nav', 'bp_core_setup_nav' ); 153 139 $bp->core = new BP_Core(); 154 140 155 141 ?>
Note: See TracChangeset
for help on using the changeset viewer.