Changeset 5683
- Timestamp:
- 02/09/2012 09:38:45 PM (13 years ago)
- Location:
- trunk/bp-core
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/admin/bp-core-components.php
r5524 r5683 211 211 * @since BuddyPress (1.6) 212 212 * @todo Use settings API 213 * @global WPDB $wpdb214 213 * @global BuddyPress $bp 215 214 * @return false On failure 216 215 */ 217 216 function bp_core_admin_components_settings_handler() { 218 global $ wpdb, $bp;217 global $bp; 219 218 220 219 if ( isset( $_POST['bp-admin-component-submit'] ) ) { -
trunk/bp-core/admin/bp-core-schema.php
r5259 r5683 16 16 17 17 function bp_core_install_notifications() { 18 global $wpdb; 19 20 $charset_collate = bp_core_set_charset(); 21 $bp_prefix = bp_core_get_table_prefix();18 19 $sql = array(); 20 $charset_collate = bp_core_set_charset(); 21 $bp_prefix = bp_core_get_table_prefix(); 22 22 23 23 $sql[] = "CREATE TABLE {$bp_prefix}bp_notifications ( … … 39 39 ) {$charset_collate};"; 40 40 41 dbDelta( $sql);41 dbDelta( $sql ); 42 42 } 43 43 44 44 function bp_core_install_activity_streams() { 45 global $wpdb; 46 47 $charset_collate = bp_core_set_charset(); 48 $bp_prefix = bp_core_get_table_prefix();45 46 $sql = array(); 47 $charset_collate = bp_core_set_charset(); 48 $bp_prefix = bp_core_get_table_prefix(); 49 49 50 50 $sql[] = "CREATE TABLE {$bp_prefix}bp_activity ( … … 84 84 ) {$charset_collate};"; 85 85 86 dbDelta( $sql);86 dbDelta( $sql ); 87 87 } 88 88 89 89 function bp_core_install_friends() { 90 global $wpdb; 91 92 $charset_collate = bp_core_set_charset(); 93 $bp_prefix = bp_core_get_table_prefix();90 91 $sql = array(); 92 $charset_collate = bp_core_set_charset(); 93 $bp_prefix = bp_core_get_table_prefix(); 94 94 95 95 $sql[] = "CREATE TABLE {$bp_prefix}bp_friends ( … … 104 104 ) {$charset_collate};"; 105 105 106 dbDelta( $sql);106 dbDelta( $sql ); 107 107 } 108 108 109 109 function bp_core_install_groups() { 110 global $wpdb; 111 112 $charset_collate = bp_core_set_charset(); 113 $bp_prefix = bp_core_get_table_prefix();110 111 $sql = array(); 112 $charset_collate = bp_core_set_charset(); 113 $bp_prefix = bp_core_get_table_prefix(); 114 114 115 115 $sql[] = "CREATE TABLE {$bp_prefix}bp_groups ( … … 156 156 ) {$charset_collate};"; 157 157 158 dbDelta( $sql);158 dbDelta( $sql ); 159 159 } 160 160 161 161 function bp_core_install_private_messaging() { 162 global $wpdb; 163 164 $charset_collate = bp_core_set_charset(); 165 $bp_prefix = bp_core_get_table_prefix();162 163 $sql = array(); 164 $charset_collate = bp_core_set_charset(); 165 $bp_prefix = bp_core_get_table_prefix(); 166 166 167 167 $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_messages ( … … 199 199 ) {$charset_collate};"; 200 200 201 dbDelta( $sql);201 dbDelta( $sql ); 202 202 } 203 203 … … 205 205 global $wpdb; 206 206 207 $charset_collate = bp_core_set_charset(); 208 $bp_prefix = bp_core_get_table_prefix(); 207 $sql = array(); 208 $charset_collate = bp_core_set_charset(); 209 $bp_prefix = bp_core_get_table_prefix(); 209 210 210 211 bp_update_option( 'bp-xprofile-base-group-name', _x( 'Base', 'First XProfile group name', 'buddypress' ) ); … … 275 276 276 277 function bp_core_install_blog_tracking() { 277 global $wpdb; 278 279 $charset_collate = bp_core_set_charset(); 280 $bp_prefix = bp_core_get_table_prefix();278 279 $sql = array(); 280 $charset_collate = bp_core_set_charset(); 281 $bp_prefix = bp_core_get_table_prefix(); 281 282 282 283 $sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs ( … … 297 298 ) {$charset_collate};"; 298 299 299 dbDelta( $sql);300 dbDelta( $sql ); 300 301 } 301 302 -
trunk/bp-core/admin/bp-core-slugs.php
r5575 r5683 183 183 * @since BuddyPress (1.6) 184 184 * @todo Use settings API 185 * @global WPDB $wpdb 186 * @global BuddyPress $bp 187 * @return type 185 * @return False if referer does not check out 188 186 */ 189 187 function bp_core_admin_slugs_setup_handler() { 190 global $wpdb, $bp;191 188 192 189 if ( isset( $_POST['bp-admin-pages-submit'] ) || isset( $_POST['bp-admin-pages-single'] ) ) { -
trunk/bp-core/admin/bp-core-update.php
r5659 r5683 89 89 90 90 function add_steps() { 91 global $wp_rewrite;92 91 93 92 // Setup wizard steps … … 1171 1170 1172 1171 function setup_pages( $pages ) { 1172 1173 $bp_pages = array(); 1174 1173 1175 foreach ( $pages as $key => $value ) { 1174 1176 if ( 'page' == $value ) { … … 1214 1216 1215 1217 function bp_core_install( $active_components = false ) { 1216 global $wpdb;1217 1218 1218 1219 if ( empty( $active_components ) ) … … 1250 1251 1251 1252 function bp_core_update( $disabled ) { 1252 global $wpdb;1253 1254 1253 require( dirname( __FILE__ ) . '/bp-core-schema.php' ); 1255 1254 } -
trunk/bp-core/bp-core-avatars.php
r5666 r5683 390 390 extract( $args, EXTR_SKIP ); 391 391 392 if ( !$item_id) {392 if ( empty( $item_id ) ) { 393 393 if ( 'user' == $object ) 394 394 $item_id = bp_displayed_user_id(); … … 403 403 } 404 404 405 if ( !$avatar_dir) {405 if ( empty( $avatar_dir ) ) { 406 406 if ( 'user' == $object ) 407 407 $avatar_dir = 'avatars'; … … 548 548 * crop_y - The vertical starting point of the crop 549 549 * 550 * @global object $bp BuddyPress global settings551 550 * @param mixed $args 552 551 * @return bool Success/failure 553 552 */ 554 553 function bp_core_avatar_handle_crop( $args = '' ) { 555 global $bp;556 554 557 555 $defaults = array( -
trunk/bp-core/bp-core-buddybar.php
r5672 r5683 429 429 // **** Default BuddyPress admin bar logo ******** 430 430 function bp_adminbar_logo() { 431 global $bp;432 433 431 echo '<a href="' . bp_get_root_domain() . '" id="admin-bar-logo">' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . '</a>'; 434 432 } … … 436 434 // **** "Log In" and "Sign Up" links (Visible when not logged in) ******** 437 435 function bp_adminbar_login_menu() { 438 global $bp;439 436 440 437 if ( is_user_logged_in() ) … … 525 522 // **** "Random" Menu (visible when not logged in) ******** 526 523 function bp_adminbar_random_menu() { 527 global $bp;?>524 ?> 528 525 529 526 <li class="align-right" id="bp-adminbar-visitrandom-menu"> … … 653 650 } 654 651 add_action( 'bp_init', 'bp_core_load_buddybar_css' ); 652 655 653 ?> -
trunk/bp-core/bp-core-cache.php
r5663 r5683 49 49 * 50 50 * @since 1.6 51 * @uses $wpdb WordPress database object for queries. 52 * @uses $bp BuddyPress global object. 53 * 51 * @global $wpdb WordPress database object for queries. 54 52 * @param array $args See $defaults definition for more details 55 53 * @return mixed Metadata cache for the specified objects, or false on failure. 56 54 */ 57 55 function bp_update_meta_cache( $args = array() ) { 58 global $ bp, $wpdb;56 global $wpdb; 59 57 60 58 $defaults = array( -
trunk/bp-core/bp-core-catchuri.php
r5636 r5683 38 38 */ 39 39 function bp_core_set_uri_globals() { 40 global $bp, $current_blog , $wpdb;40 global $bp, $current_blog; 41 41 42 42 // Don't catch URIs on non-root blogs unless multiblog mode is on -
trunk/bp-core/bp-core-classes.php
r5595 r5683 137 137 * Populate the instantiated class with data based on the User ID provided. 138 138 * 139 * @global object $bp Global BuddyPress settings object140 139 * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id 141 140 * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text … … 146 145 */ 147 146 function populate() { 148 global $bp;149 147 150 148 if ( bp_is_active( 'xprofile' ) ) … … 178 176 /** 179 177 * Populates extra fields such as group and friendship counts. 180 *181 * @global object $bp Global BuddyPress settings object182 178 */ 183 179 function populate_extras() { 184 global $bp; 185 186 if ( bp_is_active( 'friends' ) ) 180 181 if ( bp_is_active( 'friends' ) ) { 187 182 $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id ); 183 } 188 184 189 185 if ( bp_is_active( 'groups' ) ) { … … 206 202 $sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email"; 207 203 208 if ( 'active' == $type || 'online' == $type || 'newest' == $type ) 204 if ( 'active' == $type || 'online' == $type || 'newest' == $type ) { 209 205 $sql['select_active'] = ", um.meta_value as last_activity"; 210 211 if ( 'popular' == $type ) 206 } 207 208 if ( 'popular' == $type ) { 212 209 $sql['select_popular'] = ", um.meta_value as total_friend_count"; 213 214 if ( 'alphabetical' == $type ) 210 } 211 212 if ( 'alphabetical' == $type ) { 215 213 $sql['select_alpha'] = ", pd.value as fullname"; 214 } 216 215 217 216 if ( $meta_key ) { 218 217 $sql['select_meta'] = ", umm.meta_key"; 219 218 220 if ( $meta_value ) 219 if ( $meta_value ) { 221 220 $sql['select_meta'] .= ", umm.meta_value"; 221 } 222 222 } 223 223 … … 225 225 226 226 // We search against xprofile fields, so we must join the table 227 if ( $search_terms && bp_is_active( 'xprofile' ) ) 227 if ( $search_terms && bp_is_active( 'xprofile' ) ) { 228 228 $sql['join_profiledata_search'] = "LEFT JOIN {$bp->profile->table_name_data} spd ON u.ID = spd.user_id"; 229 } 229 230 230 231 // Alphabetical sorting is done by the xprofile Full Name field 231 if ( 'alphabetical' == $type ) 232 if ( 'alphabetical' == $type ) { 232 233 $sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id"; 233 234 if ( $meta_key ) 234 } 235 236 if ( $meta_key ) { 235 237 $sql['join_meta'] = "LEFT JOIN {$wpdb->usermeta} umm ON umm.user_id = u.ID"; 238 } 236 239 237 240 $sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' ); 238 241 239 if ( 'active' == $type || 'online' == $type || 'newest' == $type ) 242 if ( 'active' == $type || 'online' == $type || 'newest' == $type ) { 240 243 $sql['where_active'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) ); 241 242 if ( 'popular' == $type ) 244 } 245 246 if ( 'popular' == $type ) { 243 247 $sql['where_popular'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) ); 244 245 if ( 'online' == $type ) 248 } 249 250 if ( 'online' == $type ) { 246 251 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()"; 247 248 if ( 'alphabetical' == $type ) 252 } 253 254 if ( 'alphabetical' == $type ) { 249 255 $sql['where_alpha'] = "AND pd.field_id = 1"; 250 251 if ( !empty( $exclude ) ) 256 } 257 258 if ( !empty( $exclude ) ) { 252 259 $sql['where_exclude'] = "AND u.ID NOT IN ({$exclude})"; 260 } 253 261 254 262 if ( $include ) { 255 if ( is_array( $include ) ) 263 if ( is_array( $include ) ) { 256 264 $uids = $wpdb->escape( implode( ',', (array)$include ) ); 257 else265 } else { 258 266 $uids = $wpdb->escape( $include ); 259 260 if ( !empty( $uids ) ) 267 } 268 269 if ( !empty( $uids ) ) { 261 270 $sql['where_users'] = "AND u.ID IN ({$uids})"; 262 } 263 264 else if ( $user_id && bp_is_active( 'friends' ) ) { 271 } 272 } elseif ( $user_id && bp_is_active( 'friends' ) ) { 265 273 $friend_ids = friends_get_friend_user_ids( $user_id ); 266 274 $friend_ids = $wpdb->escape( implode( ',', (array)$friend_ids ) ); 267 275 268 if ( !empty( $friend_ids ) ) 276 if ( !empty( $friend_ids ) ) { 269 277 $sql['where_friends'] = "AND u.ID IN ({$friend_ids})"; 270 278 271 279 // User has no friends, return false since there will be no users to fetch. 272 else280 } else { 273 281 return false; 274 282 } 275 283 } 276 284 … … 307 315 } 308 316 309 if ( $limit && $page ) 317 if ( $limit && $page ) { 310 318 $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 319 } 311 320 312 321 // Get paginated results … … 317 326 unset( $sql['select_main'] ); 318 327 319 if ( !empty( $sql['select_active'] ) ) 328 if ( !empty( $sql['select_active'] ) ) { 320 329 unset( $sql['select_active'] ); 321 322 if ( !empty( $sql['select_popular'] ) ) 330 } 331 332 if ( !empty( $sql['select_popular'] ) ) { 323 333 unset( $sql['select_popular'] ); 324 325 if ( !empty( $sql['select_alpha'] ) ) 334 } 335 336 if ( !empty( $sql['select_alpha'] ) ) { 326 337 unset( $sql['select_alpha'] ); 327 328 if ( !empty( $sql['pagination'] ) ) 338 } 339 340 if ( !empty( $sql['pagination'] ) ) { 329 341 unset( $sql['pagination'] ); 342 } 330 343 331 344 array_unshift( $sql, "SELECT COUNT(DISTINCT u.ID)" ); … … 342 355 $user_ids = array(); 343 356 344 foreach ( (array)$paged_users as $user ) 357 foreach ( (array)$paged_users as $user ) { 345 358 $user_ids[] = $user->id; 359 } 346 360 347 361 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) ); … … 372 386 373 387 $pag_sql = ''; 374 if ( $limit && $page ) 388 if ( $limit && $page ) { 375 389 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 390 } 376 391 377 392 // Multibyte compliance … … 398 413 399 414 /*** 400 * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list. 401 * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join) 415 * Lets fetch some other useful data in a separate queries, this will be 416 * faster than querying the data for every user in a list. We can't add 417 * these to the main query above since only users who have this 418 * information will be returned (since the much of the data is in 419 * usermeta and won't support any type of directional join) 402 420 */ 403 421 $user_ids = array(); … … 407 425 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) ); 408 426 409 / * Add additional data to the returned results */410 if ( $populate_extras ) 427 // Add additional data to the returned results 428 if ( $populate_extras ) { 411 429 $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids ); 430 } 412 431 413 432 return array( 'users' => $paged_users, 'total' => $total_users ); … … 417 436 * Get details of specific users from the database 418 437 * 419 * @global object $bp Global BuddyPress settings object420 438 * @global wpdb $wpdb WordPress database object 421 439 * @param array $user_ids The user IDs of the users who we wish to fetch information on. … … 427 445 */ 428 446 function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) { 429 global $ bp, $wpdb;447 global $wpdb; 430 448 431 449 $pag_sql = ''; … … 433 451 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 434 452 453 // @todo remove? $user_sql is not used here 435 454 $user_sql = " AND user_id IN ( " . $wpdb->escape( $user_ids ) . " ) "; 436 455 $status_sql = bp_core_get_status_sql(); … … 443 462 444 463 /*** 445 * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list. 446 * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join) 464 * Lets fetch some other useful data in a separate queries, this will be 465 * faster than querying the data for every user in a list. We can't add 466 * these to the main query above since only users who have this 467 * information will be returned (since the much of the data is in 468 * usermeta and won't support any type of directional join) 447 469 */ 448 470 449 / * Add additional data to the returned results */450 if ( $populate_extras )471 // Add additional data to the returned results 472 if ( !empty( $populate_extras ) ) { 451 473 $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids ); 474 } 452 475 453 476 return array( 'users' => $paged_users, 'total' => $total_users ); … … 1028 1051 1029 1052 // Wrapper ID 1030 if ( !empty( $wrapper_id ) ) 1053 if ( !empty( $wrapper_id ) ) { 1031 1054 $this->wrapper_id = ' id="' . $wrapper_id . '"'; 1055 } 1032 1056 1033 1057 // Wrapper class 1034 if ( !empty( $wrapper_class ) ) 1058 if ( !empty( $wrapper_class ) ) { 1035 1059 $this->wrapper_class = ' class="generic-button ' . $wrapper_class . '"'; 1036 else1060 } else { 1037 1061 $this->wrapper_class = ' class="generic-button"'; 1062 } 1038 1063 1039 1064 // Set before and after … … 1174 1199 foreach ( $handlers as $hid => $handler ) { 1175 1200 if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) { 1176 if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) 1201 if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) { 1177 1202 return apply_filters( 'embed_handler_html', $return, $url, $attr ); 1203 } 1178 1204 } 1179 1205 } -
trunk/bp-core/bp-core-cssjs.php
r5524 r5683 133 133 */ 134 134 function bp_core_add_ajax_url_js() { 135 global $bp;136 135 ?> 137 136 -
trunk/bp-core/bp-core-filters.php
r5670 r5683 113 113 */ 114 114 function bp_core_login_redirect( $redirect_to ) { 115 global $ bp, $wpdb;115 global $wpdb; 116 116 117 117 // Don't mess with the redirect if this is not the root blog -
trunk/bp-core/bp-core-functions.php
r5659 r5683 183 183 */ 184 184 function bp_core_get_directory_pages() { 185 global $wpdb , $bp;185 global $wpdb; 186 186 187 187 // Set pages as standard class … … 262 262 */ 263 263 function bp_core_get_root_domain() { 264 global $wpdb;265 264 266 265 $domain = get_home_url( bp_get_root_blog_id() ); … … 494 493 */ 495 494 function bp_core_record_activity() { 496 global $bp;497 495 498 496 if ( !is_user_logged_in() ) … … 543 541 * @package BuddyPress Core 544 542 * 545 * @global $bp $bp546 543 * @global object $current_site 547 544 * @return string 548 545 */ 549 546 function bp_core_get_site_path() { 550 global $ bp, $current_site;547 global $current_site; 551 548 552 549 if ( is_multisite() ) … … 624 621 * 625 622 * @package BuddyPress Core 626 * @global object $bp Global BuddyPress settings object627 623 * @param string $slug The slug to redirect to for searching. 628 624 */ 629 625 function bp_core_action_search_site( $slug = '' ) { 630 global $bp;631 626 632 627 if ( !bp_is_current_component( bp_get_search_slug() ) ) … … 1156 1151 */ 1157 1152 function bp_do_404( $redirect = 'remove_canonical_direct' ) { 1158 global $ bp, $wp_query;1153 global $wp_query; 1159 1154 1160 1155 do_action( 'bp_do_404', $redirect ); -
trunk/bp-core/bp-core-widgets.php
r5574 r5683 32 32 33 33 function widget( $args, $instance ) { 34 global $bp;35 34 36 35 extract( $args ); … … 160 159 161 160 function widget($args, $instance) { 162 global $bp;163 161 164 162 extract( $args ); … … 228 226 } 229 227 230 function widget($args, $instance) { 231 global $bp; 228 function widget( $args, $instance ) { 232 229 233 230 extract( $args ); … … 287 284 288 285 function bp_core_ajax_widget_members() { 289 global $bp;290 286 291 287 check_ajax_referer( 'bp_core_widget_members' );
Note: See TracChangeset
for help on using the changeset viewer.