Changeset 373 for trunk/bp-core.php
- Timestamp:
- 10/07/2008 07:16:51 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/bp-core.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core.php
r371 r373 1 1 <?php 2 3 /* Define the protocol to be used, change to https:// if on secure server. */4 define( 'PROTOCOL', 'http://' );5 6 2 /* Define the current version number for checking if DB tables are up to date. */ 7 define( 'BP_CORE_VERSION', '0.2. 4' );3 define( 'BP_CORE_VERSION', '0.2.5' ); 8 4 9 5 /* Require all needed files */ 10 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-catchuri.php' ); 11 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-classes.php' ); 12 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-cssjs.php' ); 13 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-avatars.php' ); 14 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-templatetags.php' ); 15 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-adminbar.php' ); 16 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/admin-mods/bp-core-remove-blogtabs.php' ); 17 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/admin-mods/bp-core-admin-styles.php' ); 18 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/homebase-creation/bp-core-homebase-functions.php' ); 6 require_once( 'bp-core/bp-core-catchuri.php' ); 7 require_once( 'bp-core/bp-core-classes.php' ); 8 require_once( 'bp-core/bp-core-cssjs.php' ); 9 require_once( 'bp-core/bp-core-avatars.php' ); 10 require_once( 'bp-core/bp-core-templatetags.php' ); 11 require_once( 'bp-core/bp-core-adminbar.php' ); 12 require_once( 'bp-core/bp-core-widgets.php' ); 13 require_once( 'bp-core/bp-core-ajax.php' ); 14 require_once( 'bp-core/admin-mods/bp-core-remove-blogtabs.php' ); 15 require_once( 'bp-core/admin-mods/bp-core-admin-styles.php' ); 16 require_once( 'bp-core/homebase-creation/bp-core-homebase-functions.php' ); 17 19 18 20 19 /** … … 102 101 $bp['is_item_admin'] = bp_is_home(); 103 102 103 $bp['core'] = array( 104 'image_base' => site_url() . '/wp-content/mu-plugins/bp-core/images', 105 ); 106 107 104 108 if ( !$bp['current_component'] ) 105 109 $bp['current_component'] = $bp['default_component']; … … 194 198 global $current_blog; 195 199 196 if ( VHOST == 'yes' ) { 197 $current_domain = PROTOCOL . $current_blog->domain . '/'; 198 } else { 199 $current_domain = get_bloginfo('wpurl') . '/'; 200 } 201 202 return $current_domain; 200 return get_blog_option( $current_blog->blog_id, 'siteurl' ) . '/'; 203 201 } 204 202 … … 273 271 * @return false if no, or true if yes. 274 272 */ 275 function bp_core_user_has_home( ) {273 function bp_core_user_has_home( $user_id = false ) { 276 274 global $bp; 277 275 278 if ( $bp['loggedin_homebase_id'] == '' ) 279 return false; 280 281 return true; 276 if ( !$user_id ) { 277 if ( $bp['loggedin_homebase_id'] == '' ) 278 return false; 279 280 return $bp['loggedin_homebase_id']; 281 } else { 282 return get_usermeta( $user_id, 'home_base' ); 283 } 282 284 } 283 285 … … 964 966 // array of time period chunks 965 967 $chunks = array( 966 array( 60 * 60 * 24 * 365 , 'year' ), 967 array( 60 * 60 * 24 * 30 , 'month' ), 968 array( 60 * 60 * 24 * 7, 'week' ), 969 array( 60 * 60 * 24 , 'day' ), 970 array( 60 * 60 , 'hour' ), 971 array( 60 , 'minute' ), 968 array( 60 * 60 * 24 * 365 , __('year') ), 969 array( 60 * 60 * 24 * 30 , __('month') ), 970 array( 60 * 60 * 24 * 7, __('week') ), 971 array( 60 * 60 * 24 , __('day') ), 972 array( 60 * 60 , __('hour') ), 973 array( 60 , __('minute') ), 974 array( 1, __('second') ) 972 975 ); 973 976 … … 1003 1006 $seconds2 = $chunks[$i + 1][0]; 1004 1007 $name2 = $chunks[$i + 1][1]; 1008 1009 if ( $name2 == __('second') ) return $output; 1005 1010 1006 1011 if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) { … … 1018 1023 * Record user activity to the database. Many functions use a "last active" feature to 1019 1024 * show the length of time since the user was last active. 1020 * This function will update that time as a usermeta setting for the user .1025 * This function will update that time as a usermeta setting for the user every 5 minutes. 1021 1026 * 1022 1027 * @package BuddyPress Core … … 1025 1030 */ 1026 1031 function bp_core_record_activity() { 1027 global $userdata; 1028 1029 // Updated last site activity for this user. 1030 update_usermeta( $userdata->ID, 'last_activity', time() ); 1031 } 1032 add_action( 'login_head', 'bp_core_record_activity' ); 1032 global $bp; 1033 1034 if ( !is_user_logged_in() ) 1035 return false; 1036 1037 if ( time() >= strtotime('+5 minutes', get_usermeta( $bp['loggedin_userid'], 'last_activity') ) || get_usermeta( $bp['loggedin_userid'], 'last_activity') == '' ) { 1038 // Updated last site activity for this user. 1039 update_usermeta( $bp['loggedin_userid'], 'last_activity', time() ); 1040 } 1041 } 1042 add_action( 'wp_head', 'bp_core_record_activity' ); 1043 1044 1045 /** 1046 * bp_core_get_last_activity() 1047 * 1048 * Formats last activity based on time since date given. 1049 * 1050 * @package BuddyPress Core 1051 * @param last_activity_date The date of last activity. 1052 * @param $before The text to prepend to the activity time since figure. 1053 * @param $after The text to append to the activity time since figure. 1054 * @uses bp_core_time_since() This function will return an English representation of the time elapsed. 1055 */ 1056 function bp_core_get_last_activity( $last_activity_date, $before, $after ) { 1057 if ( !$last_activity_date || $last_activity_date == '' ) { 1058 $last_active = __('not recently active'); 1059 } else { 1060 $last_active = $before; 1061 1062 if ( strstr( $last_activity_date, '-' ) ) { 1063 $last_active .= bp_core_time_since( strtotime( $last_activity_date ) ); 1064 } else { 1065 $last_active .= bp_core_time_since( $last_activity_date ); 1066 } 1067 1068 $last_active .= $after; 1069 } 1070 1071 return $last_active; 1072 } 1033 1073 1034 1074 /** … … 1130 1170 return $new_nav; 1131 1171 } 1172 1173 function bp_core_remove_data( $user_id ) { 1174 /* When the user is deleted, we must automatically delete their home base blog */ 1175 if ( $home_base_id = bp_core_user_has_home($user_id) ) 1176 wpmu_delete_blog( $home_base_id, true ); 1177 1178 /* Remove usermeta */ 1179 delete_usermeta( $user_id, 'home_base' ); 1180 delete_usermeta( $user_id, 'last_activity' ); 1181 } 1182 add_action( 'wpmu_delete_user', 'bp_core_remove_data', 1 ); 1183 add_action( 'delete_user', 'bp_core_remove_data', 1 ); 1184 1132 1185 ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)