Changeset 9471
- Timestamp:
- 02/10/2015 02:49:16 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-actions.php
r9384 r9471 36 36 * @since BuddyPress (1.2) 37 37 * 38 * @global object $bp BuddyPress global settings39 38 * @uses bp_is_activity_component() 40 39 * @uses bp_is_current_action() … … 201 200 * @since BuddyPress (1.6) 202 201 * 203 * @global object $bp BuddyPress global settings204 202 * @param int $activity_id Activity id to be deleted. Defaults to 0. 205 203 * @return bool False on failure. 206 204 */ 207 205 function bp_activity_action_spam_activity( $activity_id = 0 ) { 208 global $bp;206 $bp = buddypress(); 209 207 210 208 // Not viewing activity, or action is not spam, or Akismet isn't present … … 507 505 * @since BuddyPress (1.0) 508 506 * 509 * @global object $bp BuddyPress global settings510 507 * @uses bp_is_activity_component() 511 508 * @uses bp_is_current_action() … … 516 513 */ 517 514 function bp_activity_action_sitewide_feed() { 518 global $bp;515 $bp = buddypress(); 519 516 520 517 if ( ! bp_is_activity_component() || ! bp_is_current_action( 'feed' ) || bp_is_user() || ! empty( $bp->groups->current_group ) ) … … 715 712 * 716 713 * @since BuddyPress (1.6) 717 *718 * @global object $bp BuddyPress global settings719 714 */ 720 715 function bp_activity_setup_akismet() { 721 global $bp;716 $bp = buddypress(); 722 717 723 718 // Bail if Akismet is not active -
trunk/src/bp-activity/bp-activity-admin.php
r9351 r9471 821 821 * @since BuddyPress (1.6.0) 822 822 * 823 * @global object $bp BuddyPress global settings.824 *825 823 * @param object $item Activity item. 826 824 */ 827 825 function bp_activity_admin_edit_metabox_type( $item ) { 828 global $bp;826 $bp = buddypress(); 829 827 830 828 $actions = array(); -
trunk/src/bp-activity/bp-activity-akismet.php
r9351 r9471 655 655 * @since BuddyPress (1.6) 656 656 * 657 * @global object $bp BuddyPress global settings.658 657 * @global wpdb $wpdb WordPress database object. 659 658 */ 660 659 function bp_activity_akismet_delete_old_metadata() { 661 global $bp, $wpdb; 660 global $wpdb; 661 662 $bp = buddypress(); 662 663 663 664 /** -
trunk/src/bp-activity/bp-activity-cache.php
r9367 r9471 21 21 */ 22 22 function bp_activity_update_meta_cache( $activity_ids = false ) { 23 global $bp;23 $bp = buddypress(); 24 24 25 25 $cache_args = array( -
trunk/src/bp-activity/bp-activity-functions.php
r9456 r9471 912 912 * 913 913 * @global object $wpdb WordPress database access object. 914 * @global object $bp BuddyPress global settings.915 914 * 916 915 * @param int $activity_id ID of the activity item whose metadata is being deleted. … … 1079 1078 * 1080 1079 * @global object $wpdb WordPress database access object. 1081 * @global object $bp BuddyPress global settings.1082 1080 * 1083 1081 * @param int $user_id ID of the user whose activity is being spammed. … … 1148 1146 * 1149 1147 * @global object $wpdb WordPress database access object. 1150 * @global object $bp BuddyPress global settings.1151 1148 * 1152 1149 * @param int $user_id ID of the user whose activity is being hammed. … … 2054 2051 * @since BuddyPress (1.2.0) 2055 2052 * 2056 * @global object $bp BuddyPress global settings.2057 2053 * @uses wp_parse_args() 2058 2054 * @uses bp_activity_add() -
trunk/src/bp-activity/bp-activity-screens.php
r9351 r9471 231 231 * @since BuddyPress (1.2.0) 232 232 * 233 * @global object $bp BuddyPress global settings234 233 * @uses bp_is_activity_component() 235 234 * @uses bp_activity_get_specific() … … 253 252 */ 254 253 function bp_activity_screen_single_activity_permalink() { 255 global $bp;254 $bp = buddypress(); 256 255 257 256 // No displayed user or not viewing activity component -
trunk/src/bp-activity/bp-activity-template.php
r9411 r9471 165 165 */ 166 166 function __construct( $args ) { 167 global $bp;167 $bp = buddypress(); 168 168 169 169 // Backward compatibility with old method of passing arguments … … 427 427 * 428 428 * @global object $activities_template {@link BP_Activity_Template} 429 * @global object $bp BuddyPress global settings.430 429 * @uses groups_is_user_member() 431 430 * @uses bp_current_action() … … 1349 1348 * @see bp_core_fetch_avatar() For a description of the arguments. 1350 1349 * @global object $activities_template {@link BP_Activity_Template} 1351 * @global object $bp BuddyPress global settings1352 1350 * @uses bp_is_single_activity() 1353 1351 * @uses wp_parse_args() -
trunk/src/bp-blogs/bp-blogs-activity.php
r9369 r9471 16 16 * @since BuddyPress (1.0.0) 17 17 * 18 * @global object $bp The BuddyPress global settings object.19 *20 18 * @return bool|null Returns false if activity component is not active. 21 19 */ 22 20 function bp_blogs_register_activity_actions() { 23 global $bp;21 $bp = buddypress(); 24 22 25 23 // Bail if activity is not active … … 322 320 * 323 321 * @see bp_activity_add() for description of parameters. 324 * @global object $bp The BuddyPress global settings object.325 322 * 326 323 * @param array $args { … … 333 330 */ 334 331 function bp_blogs_record_activity( $args = '' ) { 335 global $bp;336 332 337 333 // Bail if activity is not active … … 339 335 return false; 340 336 } 337 338 $bp = buddypress(); 341 339 342 340 $defaults = array( -
trunk/src/bp-blogs/bp-blogs-classes.php
r9354 r9471 40 40 */ 41 41 public function populate() { 42 global $wpdb, $bp; 42 global $wpdb; 43 44 $bp = buddypress(); 43 45 44 46 $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) ); … … 54 56 */ 55 57 public function save() { 56 global $wpdb , $bp;58 global $wpdb; 57 59 58 60 $this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id ); … … 78 80 return false; 79 81 82 $bp = buddypress(); 83 80 84 if ( $this->id ) { 81 85 // Update … … 113 117 */ 114 118 public function exists() { 115 global $bp, $wpdb; 119 global $wpdb; 120 121 $bp = buddypress(); 116 122 117 123 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $this->user_id, $this->blog_id ) ); … … 141 147 */ 142 148 public static function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false, $update_meta_cache = true, $include_blog_ids = false ) { 143 global $bp, $wpdb; 149 global $wpdb; 150 151 $bp = buddypress(); 144 152 145 153 if ( !is_user_logged_in() || ( !bp_current_user_can( 'bp_moderate' ) && ( $user_id != bp_loggedin_user_id() ) ) ) … … 232 240 */ 233 241 public static function delete_blog_for_all( $blog_id ) { 234 global $wpdb , $bp;242 global $wpdb; 235 243 236 244 bp_blogs_delete_blogmeta( $blog_id ); 245 246 $bp = buddypress(); 247 237 248 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) ); 238 249 } … … 247 258 */ 248 259 public static function delete_blog_for_user( $blog_id, $user_id = null ) { 249 global $wpdb , $bp;260 global $wpdb; 250 261 251 262 if ( !$user_id ) 252 263 $user_id = bp_loggedin_user_id(); 264 265 $bp = buddypress(); 253 266 254 267 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) ); … … 264 277 */ 265 278 public static function delete_blogs_for_user( $user_id = null ) { 266 global $wpdb , $bp;279 global $wpdb; 267 280 268 281 if ( !$user_id ) 269 282 $user_id = bp_loggedin_user_id(); 283 284 $bp = buddypress(); 270 285 271 286 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) ); … … 290 305 */ 291 306 public static function get_blogs_for_user( $user_id = 0, $show_hidden = false ) { 292 global $bp, $wpdb; 307 global $wpdb; 308 309 $bp = buddypress(); 293 310 294 311 if ( !$user_id ) … … 325 342 */ 326 343 public static function get_blog_ids_for_user( $user_id = 0 ) { 327 global $bp, $wpdb; 344 global $wpdb; 345 346 $bp = buddypress(); 328 347 329 348 if ( !$user_id ) … … 341 360 */ 342 361 public static function is_recorded( $blog_id ) { 343 global $bp, $wpdb; 362 global $wpdb; 363 364 $bp = buddypress(); 344 365 345 366 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) ); … … 358 379 */ 359 380 public static function total_blog_count_for_user( $user_id = null ) { 360 global $bp, $wpdb; 381 global $wpdb; 382 383 $bp = buddypress(); 361 384 362 385 if ( !$user_id ) … … 387 410 */ 388 411 public static function search_blogs( $filter, $limit = null, $page = null ) { 389 global $wpdb , $bp;412 global $wpdb; 390 413 391 414 $search_terms_like = '%' . bp_esc_like( $filter ) . '%'; … … 400 423 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 401 424 } 425 426 $bp = buddypress(); 402 427 403 428 $paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" ); … … 422 447 */ 423 448 public static function get_all( $limit = null, $page = null ) { 424 global $bp, $wpdb; 449 global $wpdb; 450 451 $bp = buddypress(); 425 452 426 453 $hidden_sql = !bp_current_user_can( 'bp_moderate' ) ? "AND wb.public = 1" : ''; 427 $pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';454 $pag_sql = ( $limit && $page ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : ''; 428 455 429 456 $paged_blogs = $wpdb->get_results( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" ); … … 449 476 */ 450 477 public static function get_by_letter( $letter, $limit = null, $page = null ) { 451 global $bp, $wpdb; 478 global $wpdb; 479 480 $bp = buddypress(); 452 481 453 482 $letter_like = '%' . bp_esc_like( $letter ) . '%'; … … 483 512 */ 484 513 public static function get_blog_extras( &$paged_blogs, &$blog_ids, $type = false ) { 485 global $bp, $wpdb; 514 global $wpdb; 515 516 $bp = buddypress(); 486 517 487 518 if ( empty( $blog_ids ) ) … … 562 593 */ 563 594 public static function get_user_blog( $user_id, $blog_id ) { 564 global $bp, $wpdb; 595 global $wpdb; 596 597 $bp = buddypress(); 565 598 566 599 $user_blog = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) ); -
trunk/src/bp-blogs/bp-blogs-functions.php
r9351 r9471 15 15 * @since BuddyPress (1.5.0) 16 16 * 17 * @global BuddyPress $bp The one true BuddyPress instance.18 *19 17 * @return bool True if set, false if empty. 20 18 */ 21 19 function bp_blogs_has_directory() { 22 global $bp;20 $bp = buddypress(); 23 21 24 22 return (bool) !empty( $bp->pages->blogs->id ); … … 827 825 */ 828 826 function bp_blogs_remove_blog( $blog_id ) { 829 global $bp;830 827 831 828 $blog_id = (int) $blog_id; … … 844 841 845 842 // Delete activity stream item 846 bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->id, 'type' => 'new_blog' ) ); 843 bp_blogs_delete_activity( array( 844 'item_id' => $blog_id, 845 'component' => buddypress()->blogs->id, 846 'type' => 'new_blog' 847 ) ); 847 848 848 849 /** … … 865 866 */ 866 867 function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) { 867 global $bp;868 868 869 869 $blog_id = (int) $blog_id; … … 885 885 bp_blogs_delete_activity( array( 886 886 'item_id' => $blog_id, 887 'component' => $bp->blogs->id,887 'component' => buddypress()->blogs->id, 888 888 'type' => 'new_blog' 889 889 ) ); … … 910 910 */ 911 911 function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) { 912 global $wpdb , $bp;912 global $wpdb; 913 913 914 914 if ( empty( $wpdb->blogid ) ) … … 935 935 936 936 // Delete activity stream item 937 bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'component' => $bp->blogs->id, 'type' => 'new_blog_post' ) ); 937 bp_blogs_delete_activity( array( 938 'item_id' => $blog_id, 939 'secondary_item_id' => $post_id, 940 'component' => buddypress()->blogs->id, 941 'type' => 'new_blog_post' 942 ) ); 938 943 939 944 /** … … 1064 1069 * @since BuddyPress (1.6.0) 1065 1070 * 1066 * @global object $bp BuddyPress global settings.1067 *1068 1071 * @param string $new_status New comment status. 1069 1072 * @param string $old_status Previous comment status. … … 1071 1074 */ 1072 1075 function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) { 1073 global $bp;1074 1076 1075 1077 // Check the Activity component is active … … 1100 1102 // Get the activity 1101 1103 if ( bp_disable_blogforum_comments() ) { 1102 $activity_id = bp_activity_get_activity_id( array( 'component' => $bp->blogs->id, 'item_id' => get_current_blog_id(), 'secondary_item_id' => $comment->comment_ID, 'type' => 'new_blog_comment', ) ); 1104 $activity_id = bp_activity_get_activity_id( array( 1105 'component' => buddypress()->blogs->id, 1106 'item_id' => get_current_blog_id(), 1107 'secondary_item_id' => $comment->comment_ID, 1108 'type' => 'new_blog_comment' 1109 ) ); 1103 1110 } else { 1104 1111 $activity_id = get_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', true ); … … 1189 1196 */ 1190 1197 function bp_blogs_remove_data_for_blog( $blog_id ) { 1191 global $bp;1192 1198 1193 1199 /** … … 1205 1211 1206 1212 // Delete activity stream item 1207 bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->id, 'type' => false ) ); 1213 bp_blogs_delete_activity( array( 1214 'item_id' => $blog_id, 1215 'component' => buddypress()->blogs->id, 1216 'type' => false 1217 ) ); 1208 1218 1209 1219 /** … … 1284 1294 * 1285 1295 * @global object $wpdb WordPress database access object. 1286 * @global object $bp BuddyPress global settings.1287 1296 * 1288 1297 * @param int $blog_id ID of the blog whose metadata is being deleted. … … 1298 1307 */ 1299 1308 function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false, $delete_all = false ) { 1300 global $wpdb , $bp;1309 global $wpdb; 1301 1310 1302 1311 // Legacy - if no meta_key is passed, delete all for the blog_id … … 1326 1335 * 1327 1336 * @global object $wpdb WordPress database access object. 1328 * @global object $bp BuddyPress global settings.1329 1337 * 1330 1338 * @param int $blog_id ID of the blog whose metadata is being requested. … … 1349 1357 * 1350 1358 * @global object $wpdb WordPress database access object. 1351 * @global object $bp BuddyPress global settings.1352 1359 * 1353 1360 * @param int $blog_id ID of the blog whose metadata is being updated. -
trunk/src/bp-blogs/bp-blogs-template.php
r9468 r9471 1115 1115 */ 1116 1116 function bp_blog_signup_enabled() { 1117 global $bp; 1118 1119 $active_signup = isset( $bp->site_options['registration'] ) ? $bp->site_options['registration'] : 'all'; 1117 $bp = buddypress(); 1118 1119 $active_signup = isset( $bp->site_options['registration'] ) 1120 ? $bp->site_options['registration'] 1121 : 'all'; 1120 1122 1121 1123 /** -
trunk/src/bp-core/admin/bp-core-slugs.php
r9351 r9471 49 49 */ 50 50 function bp_core_admin_slugs_options() { 51 global $bp;51 $bp = buddypress(); 52 52 53 53 // Get the existing WP pages -
trunk/src/bp-core/admin/bp-core-tools.php
r9308 r9471 156 156 */ 157 157 function bp_admin_repair_friend_count() { 158 global $wpdb , $bp;158 global $wpdb; 159 159 160 160 if ( ! bp_is_active( 'friends' ) ) { … … 169 169 return array( 1, sprintf( $statement, $result ) ); 170 170 } 171 172 $bp = buddypress(); 171 173 172 174 // Walk through all users on the site … … 212 214 */ 213 215 function bp_admin_repair_group_count() { 214 global $wpdb , $bp;216 global $wpdb; 215 217 216 218 if ( ! bp_is_active( 'groups' ) ) { … … 225 227 return array( 1, sprintf( $statement, $result ) ); 226 228 } 229 230 $bp = buddypress(); 227 231 228 232 // Walk through all users on the site -
trunk/src/bp-core/bp-core-buddybar.php
r9351 r9471 14 14 /** 15 15 * Add an item to the main BuddyPress navigation array. 16 *17 * @global BuddyPress $bp The one true BuddyPress instance.18 16 * 19 17 * @param array $args { … … 39 37 */ 40 38 function bp_core_new_nav_item( $args = '' ) { 41 global $bp;39 $bp = buddypress(); 42 40 43 41 $defaults = array( … … 120 118 * Modify the default subnav item that loads when a top level nav item is clicked. 121 119 * 122 * @global BuddyPress $bp The one true BuddyPress instance.123 *124 120 * @param array $args { 125 121 * @type string $parent_slug The slug of the nav item whose default is … … 131 127 */ 132 128 function bp_core_new_nav_default( $args = '' ) { 133 global $bp;129 $bp = buddypress(); 134 130 135 131 $defaults = array( … … 196 192 * after all plugins have had a chance to register their navigation items. 197 193 * 198 * @global BuddyPress $bp The one true BuddyPress instance199 *200 194 * @return bool|null Returns false on failure. 201 195 */ 202 196 function bp_core_sort_nav_items() { 203 global $bp;197 $bp = buddypress(); 204 198 205 199 if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) ) … … 229 223 /** 230 224 * Add a subnav item to the BuddyPress navigation. 231 *232 * @global BuddyPress $bp The one true BuddyPress instance.233 225 * 234 226 * @param array $args { … … 261 253 */ 262 254 function bp_core_new_subnav_item( $args = '' ) { 263 global $bp;255 $bp = buddypress(); 264 256 265 257 $r = wp_parse_args( $args, array( … … 442 434 * Sort all subnavigation arrays. 443 435 * 444 * @global BuddyPress $bp The one true BuddyPress instance445 *446 436 * @return bool|null Returns false on failure. 447 437 */ 448 438 function bp_core_sort_subnav_items() { 449 global $bp;439 $bp = buddypress(); 450 440 451 441 if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) ) … … 487 477 */ 488 478 function bp_nav_item_has_subnav( $nav_item = '' ) { 489 global $bp;479 $bp = buddypress(); 490 480 491 481 if ( !$nav_item ) … … 504 494 */ 505 495 function bp_core_remove_nav_item( $parent_id ) { 506 global $bp;496 $bp = buddypress(); 507 497 508 498 // Unset subnav items for this nav item … … 533 523 */ 534 524 function bp_core_remove_subnav_item( $parent_id, $slug ) { 535 global $bp; 536 537 $screen_function = isset( $bp->bp_options_nav[$parent_id][$slug]['screen_function'] ) ? $bp->bp_options_nav[$parent_id][$slug]['screen_function'] : false; 525 $bp = buddypress(); 526 527 $screen_function = isset( $bp->bp_options_nav[$parent_id][$slug]['screen_function'] ) 528 ? $bp->bp_options_nav[$parent_id][$slug]['screen_function'] 529 : false; 538 530 539 531 if ( ! empty( $screen_function ) ) { … … 553 545 * Clear all subnav items from a specific nav item. 554 546 * 555 * @global BuddyPress $bp The one true BuddyPress instance.556 *557 547 * @param string $parent_slug The slug of the parent navigation item. 558 548 */ 559 549 function bp_core_reset_subnav_items( $parent_slug ) { 560 global $bp;550 $bp = buddypress(); 561 551 562 552 unset( $bp->bp_options_nav[$parent_slug] ); -
trunk/src/bp-core/bp-core-catchuri.php
r9467 r9471 34 34 */ 35 35 function bp_core_set_uri_globals() { 36 global $ bp, $current_blog, $wp_rewrite;36 global $current_blog, $wp_rewrite; 37 37 38 38 // Don't catch URIs on non-root blogs unless multiblog mode is on 39 39 if ( !bp_is_root_blog() && !bp_is_multiblog_mode() ) 40 40 return false; 41 42 $bp = buddypress(); 41 43 42 44 // Define local variables … … 419 421 */ 420 422 function bp_core_catch_no_access() { 421 global $bp, $wp_query; 423 global $wp_query; 424 425 $bp = buddypress(); 422 426 423 427 // If coming from bp_core_redirect() and $bp_no_status_set is true, … … 550 554 */ 551 555 function bp_redirect_canonical() { 552 global $bp;553 556 554 557 if ( !bp_is_blog_page() && apply_filters( 'bp_do_redirect_canonical', true ) ) { … … 574 577 if ( $canonical_url !== $req_url_clean ) { 575 578 579 $bp = buddypress(); 580 576 581 // Template messages have been deleted from the cookie by this point, so 577 582 // they must be readded before redirecting … … 619 624 */ 620 625 function bp_get_canonical_url( $args = array() ) { 621 global $bp;622 626 623 627 // For non-BP content, return the requested url, and let WP do the work … … 625 629 return bp_get_requested_url(); 626 630 } 631 632 $bp = buddypress(); 627 633 628 634 $defaults = array( … … 701 707 */ 702 708 function bp_get_requested_url() { 703 global $bp;709 $bp = buddypress(); 704 710 705 711 if ( empty( $bp->canonical_stack['requested_url'] ) ) { -
trunk/src/bp-core/bp-core-classes.php
r9404 r9471 222 222 */ 223 223 public function prepare_user_ids_query() { 224 global $wpdb, $bp; 224 global $wpdb; 225 226 $bp = buddypress(); 225 227 226 228 // Default query variables used here … … 953 955 */ 954 956 public static function get_users( $type, $limit = 0, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false, $meta_key = false, $meta_value = false ) { 955 global $wpdb , $bp;957 global $wpdb; 956 958 957 959 _deprecated_function( __METHOD__, '1.7', 'BP_User_Query' ); 960 961 $bp = buddypress(); 958 962 959 963 $sql = array(); … … 1129 1133 * Fetch the details for all users whose usernames start with the given letter. 1130 1134 * 1131 * @global BuddyPress $bp The one true BuddyPress instance.1132 1135 * @global wpdb $wpdb WordPress database object. 1133 1136 * … … 1143 1146 */ 1144 1147 public static function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = '' ) { 1145 global $ bp, $wpdb;1148 global $wpdb; 1146 1149 1147 1150 $pag_sql = ''; … … 1160 1163 } 1161 1164 } 1165 1166 $bp = buddypress(); 1162 1167 1163 1168 $letter_like = bp_esc_like( $letter ) . '%'; … … 1244 1249 * Find users who match on the value of an xprofile data. 1245 1250 * 1246 * @global BuddyPress $bp The one true BuddyPress instance.1247 1251 * @global wpdb $wpdb WordPress database object. 1248 1252 * … … 1255 1259 */ 1256 1260 public static function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) { 1257 global $bp, $wpdb; 1261 global $wpdb; 1262 1263 $bp = buddypress(); 1258 1264 1259 1265 $user_ids = array(); … … 1288 1294 * Accepts multiple user IDs to fetch data for. 1289 1295 * 1290 * @global BuddyPress $bp The one true BuddyPress instance.1291 1296 * @global wpdb $wpdb WordPress database object. 1292 1297 * … … 1297 1302 */ 1298 1303 public static function get_user_extras( &$paged_users, &$user_ids, $type = false ) { 1299 global $bp, $wpdb; 1304 global $wpdb; 1305 1306 $bp = buddypress(); 1300 1307 1301 1308 if ( empty( $user_ids ) ) … … 1699 1706 * Update or insert notification details into the database. 1700 1707 * 1701 * @global BuddyPress $bp The one true BuddyPress instance1702 1708 * @global wpdb $wpdb WordPress database object 1703 1709 * @return bool Success or failure 1704 1710 */ 1705 1711 public function save() { 1706 global $bp, $wpdb; 1712 global $wpdb; 1713 1714 $bp = buddypress(); 1707 1715 1708 1716 // Update … … 1728 1736 * Fetches the notification data from the database. 1729 1737 * 1730 * @global BuddyPress $bp The one true BuddyPress instance1731 1738 * @global wpdb $wpdb WordPress database object 1732 1739 */ 1733 1740 public function populate() { 1734 global $bp, $wpdb; 1741 global $wpdb; 1742 1743 $bp = buddypress(); 1735 1744 1736 1745 if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) { … … 1748 1757 1749 1758 public static function check_access( $user_id, $notification_id ) { 1750 global $wpdb, $bp; 1759 global $wpdb; 1760 1761 $bp = buddypress(); 1751 1762 1752 1763 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) ); … … 1756 1767 * Fetches all the notifications in the database for a specific user. 1757 1768 * 1758 * @global BuddyPress $bp The one true BuddyPress instance1759 1769 * @global wpdb $wpdb WordPress database object 1760 1770 * @param integer $user_id User ID … … 1764 1774 */ 1765 1775 public static function get_all_for_user( $user_id, $status = 'is_new' ) { 1766 global $bp, $wpdb; 1767 1768 $is_new = ( 'is_new' == $status ) ? ' AND is_new = 1 ' : ''; 1776 global $wpdb; 1777 1778 $bp = buddypress(); 1779 1780 $is_new = ( 'is_new' === $status ) 1781 ? ' AND is_new = 1 ' 1782 : ''; 1769 1783 1770 1784 return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d {$is_new}", $user_id ) ); … … 1774 1788 * Delete all the notifications for a user based on the component name and action. 1775 1789 * 1776 * @global BuddyPress $bp The one true BuddyPress instance1777 1790 * @global wpdb $wpdb WordPress database object 1778 1791 * @param integer $user_id … … 1782 1795 */ 1783 1796 public static function delete_for_user_by_type( $user_id, $component_name, $component_action ) { 1784 global $bp, $wpdb; 1797 global $wpdb; 1798 1799 $bp = buddypress(); 1785 1800 1786 1801 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) ); … … 1790 1805 * Delete all the notifications that have a specific item id, component name and action. 1791 1806 * 1792 * @global BuddyPress $bp The one true BuddyPress instance1793 1807 * @global wpdb $wpdb WordPress database object 1794 1808 * @param integer $user_id The ID of the user who the notifications are for. … … 1800 1814 */ 1801 1815 public static function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) { 1802 global $bp, $wpdb; 1803 1804 $secondary_item_sql = !empty( $secondary_item_id ) ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ) : ''; 1816 global $wpdb; 1817 1818 $bp = buddypress(); 1819 1820 $secondary_item_sql = !empty( $secondary_item_id ) 1821 ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ) 1822 : ''; 1805 1823 1806 1824 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) ); … … 1810 1828 * Deletes all the notifications sent by a specific user, by component and action. 1811 1829 * 1812 * @global BuddyPress $bp The one true BuddyPress instance1813 1830 * @global wpdb $wpdb WordPress database object 1814 1831 * @param integer $user_id The ID of the user whose sent notifications we wish to delete. … … 1818 1835 */ 1819 1836 public static function delete_from_user_by_type( $user_id, $component_name, $component_action ) { 1820 global $bp, $wpdb; 1837 global $wpdb; 1838 1839 $bp = buddypress(); 1821 1840 1822 1841 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) ); … … 1826 1845 * Deletes all the notifications for all users by item id, and optional secondary item id, and component name and action. 1827 1846 * 1828 * @global BuddyPress $bp The one true BuddyPress instance1829 1847 * @global wpdb $wpdb WordPress database object 1830 1848 * @param string $item_id The item id that they notifications are to be for. … … 1835 1853 */ 1836 1854 public static function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) { 1837 global $ bp, $wpdb;1855 global $wpdb; 1838 1856 1839 1857 if ( $component_action ) … … 1846 1864 else 1847 1865 $secondary_item_sql = ''; 1866 1867 $bp = buddypress(); 1848 1868 1849 1869 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}", $item_id, $component_name ) ); -
trunk/src/bp-core/bp-core-filters.php
r9399 r9471 504 504 * 505 505 * @see wp_title() 506 * @global object $bp BuddyPress global settings.507 506 * 508 507 * @param string $title Original page title. … … 512 511 */ 513 512 function bp_modify_page_title( $title, $sep = '', $seplocation = '' ) { 514 global $bp;515 513 516 514 // If this is not a BP page, just return the title produced by WP … … 529 527 } 530 528 529 $bp = buddypress(); 531 530 $title = ''; 532 531 -
trunk/src/bp-core/bp-core-options.php
r9351 r9471 297 297 */ 298 298 function bp_core_activate_site_options( $keys = array() ) { 299 global $bp;300 299 301 300 if ( !empty( $keys ) && is_array( $keys ) ) { 301 $bp = buddypress(); 302 302 303 $errors = false; 303 304 -
trunk/src/bp-core/bp-core-template.php
r9428 r9471 443 443 */ 444 444 function bp_get_search_default_text( $component = '' ) { 445 global $bp; 445 446 $bp = buddypress(); 446 447 447 448 if ( empty( $component ) ) { -
trunk/src/bp-core/deprecated/2.1.php
r9470 r9471 91 91 * @since BuddyPress (1.0.0) 92 92 * @deprecated BuddyPress (2.1.0) 93 *94 * @global object $bp The BuddyPress global settings object.95 93 * 96 94 * @return bool|null Returns false on failure. Otherwise echoes the menu item. -
trunk/src/bp-forums/bp-forums-filters.php
r9467 r9471 105 105 */ 106 106 function bp_forums_filter_tag_link( $link, $tag, $page, $context ) { 107 global $bp;108 109 107 /** 110 108 * Filters the link for a forum topic tags directory. … … 142 140 * Append forum topic to page title. 143 141 * 144 * @global object $bp Global BuddyPress settings object.145 *146 142 * @see bp_modify_page_title() 147 143 * … … 153 149 */ 154 150 function bp_forums_add_forum_topic_to_page_title( $title, $original_title, $sep, $seplocation ) { 155 global $bp;156 151 157 152 if ( bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) ) -
trunk/src/bp-forums/bp-forums-functions.php
r9383 r9471 316 316 */ 317 317 function bp_forums_new_topic( $args = '' ) { 318 global $bp;318 $bp = buddypress(); 319 319 320 320 /** This action is documented in bp-forums/bp-forums-screens */ … … 907 907 */ 908 908 function bp_forums_get_post_extras( $posts ) { 909 global $ bp, $wpdb;909 global $wpdb; 910 910 911 911 if ( empty( $posts ) ) 912 912 return $posts; 913 914 $bp = buddypress(); 913 915 914 916 // Get the user ids -
trunk/src/bp-forums/bp-forums-template.php
r9467 r9471 28 28 */ 29 29 function bp_get_forums_slug() { 30 global $bp;31 32 30 /** 33 31 * Filters the forums component slug. … … 37 35 * @param string $slug Forums component slug. 38 36 */ 39 return apply_filters( 'bp_get_forums_slug', $bp->forums->slug );37 return apply_filters( 'bp_get_forums_slug', buddypress()->forums->slug ); 40 38 } 41 39 … … 58 56 */ 59 57 function bp_get_forums_root_slug() { 60 global $bp;61 62 58 /** 63 59 * Filters the forums component root slug. … … 67 63 * @param string $root_slug Forums component root slug. 68 64 */ 69 return apply_filters( 'bp_get_forums_root_slug', $bp->forums->root_slug );65 return apply_filters( 'bp_get_forums_root_slug', buddypress()->forums->root_slug ); 70 66 } 71 67 … … 231 227 */ 232 228 function __construct( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset = false, $number = false ) { 233 global $bp;229 $bp = buddypress(); 234 230 235 231 $this->pag_page = $page; … … 333 329 * @param string $no_stickies Requested sticky format. 334 330 */ 335 $this->topic_count = apply_filters_ref_array( 'bp_forums_template_topic_count',array( $this->topic_count, &$this->topics, $type, $forum_id, $per_page, $max, $no_stickies ) );331 $this->topic_count = apply_filters_ref_array( 'bp_forums_template_topic_count', array( $this->topic_count, &$this->topics, $type, $forum_id, $per_page, $max, $no_stickies ) ); 336 332 337 333 /** … … 499 495 */ 500 496 function bp_has_forum_topics( $args = '' ) { 501 global $forum_template, $bp; 497 global $forum_template; 498 499 $bp = buddypress(); 502 500 503 501 /*** … … 1666 1664 */ 1667 1665 function bp_get_my_forum_topics_link() { 1668 global $bp;1669 1670 1666 /** 1671 1667 * Filters the permalink to the 'personal' topics tab. … … 1690 1686 */ 1691 1687 function bp_get_unreplied_forum_topics_link() { 1692 global $bp;1693 1694 1688 /** 1695 1689 * Filters the permalink to the 'unreplied' topics tab. … … 1714 1708 */ 1715 1709 function bp_get_popular_forum_topics_link() { 1716 global $bp;1717 1718 1710 /** 1719 1711 * Filters the permalink to the 'popular' topics tab. … … 1738 1730 */ 1739 1731 function bp_get_newest_forum_topics_link() { 1740 global $bp;1741 1742 1732 /** 1743 1733 * Filters the link to the forums directory. … … 1764 1754 */ 1765 1755 function bp_get_forum_topic_type() { 1766 global $bp;1767 1756 1768 1757 if ( !bp_is_directory() || !bp_current_action() ) … … 1879 1868 */ 1880 1869 function bp_get_forum_pagination_count() { 1881 global $ bp, $forum_template;1870 global $forum_template; 1882 1871 1883 1872 $start_num = intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1; … … 1909 1898 */ 1910 1899 function bp_is_edit_topic() { 1911 global $bp;1912 1900 1913 1901 if ( bp_is_action_variable( 'post' ) && bp_is_action_variable( 'edit' ) ) … … 2061 2049 */ 2062 2050 function __construct( $topic_id, $per_page, $max, $order ) { 2063 global $ bp, $current_user, $forum_template;2064 2065 2066 2067 2051 global $forum_template; 2052 2053 if ( !isset( $forum_template ) ) { 2054 $forum_template = new stdClass; 2055 } 2068 2056 2069 2057 $this->pag_page = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1; … … 2193 2181 */ 2194 2182 function the_post() { 2195 global $post;2196 2183 2197 2184 $this->in_the_loop = true; … … 2516 2503 */ 2517 2504 function bp_get_the_topic_post_is_mine() { 2518 global $ bp, $topic_template;2505 global $topic_template; 2519 2506 2520 2507 return bp_loggedin_user_id() == $topic_template->post->poster_id; … … 2629 2616 */ 2630 2617 function bp_the_topic_pagination_count() { 2631 global $ bp, $topic_template;2618 global $topic_template; 2632 2619 2633 2620 $start_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1; … … 2758 2745 */ 2759 2746 function bp_get_forum_name( $forum_id = 0 ) { 2760 global $bp;2761 2747 2762 2748 if ( empty( $forum_id ) ) { -
trunk/src/bp-friends/bp-friends-classes.php
r9351 r9471 113 113 */ 114 114 public function populate() { 115 global $wpdb, $bp; 115 global $wpdb; 116 117 $bp = buddypress(); 116 118 117 119 if ( $friendship = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) ) ) { … … 138 140 */ 139 141 public function save() { 140 global $wpdb, $bp; 142 global $wpdb; 143 144 $bp = buddypress(); 141 145 142 146 $this->initiator_user_id = apply_filters( 'friends_friendship_initiator_user_id_before_save', $this->initiator_user_id, $this->id ); … … 178 182 179 183 public function delete() { 180 global $wpdb, $bp; 184 global $wpdb; 185 186 $bp = buddypress(); 187 181 188 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) ); 182 189 } … … 195 202 */ 196 203 public static function get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) { 197 global $wpdb , $bp;204 global $wpdb; 198 205 199 206 if ( !empty( $friend_requests_only ) ) { … … 205 212 } 206 213 214 $bp = buddypress(); 207 215 $friends = $wpdb->get_results( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} {$friend_sql} {$oc_sql} ORDER BY date_created DESC" ); 208 216 $fids = array(); … … 228 236 */ 229 237 public static function get_friendship_id( $user_id, $friend_id ) { 230 global $wpdb, $bp; 238 global $wpdb; 239 240 $bp = buddypress(); 231 241 232 242 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} WHERE ( initiator_user_id = %d AND friend_user_id = %d ) OR ( initiator_user_id = %d AND friend_user_id = %d ) AND is_confirmed = 1", $user_id, $friend_id, $friend_id, $user_id ) ); … … 244 254 245 255 if ( false === $friend_requests ) { 246 global $wpdb, $bp; 256 global $wpdb; 257 258 $bp = buddypress(); 247 259 248 260 $friend_requests = $wpdb->get_col( $wpdb->prepare( "SELECT initiator_user_id FROM {$bp->friends->table_name} WHERE friend_user_id = %d AND is_confirmed = 0", $user_id ) ); … … 263 275 */ 264 276 public static function total_friend_count( $user_id = 0 ) { 265 global $wpdb , $bp;277 global $wpdb; 266 278 267 279 if ( empty( $user_id ) ) 268 280 $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id(); 281 282 $bp = buddypress(); 269 283 270 284 /* This is stored in 'total_friend_count' usermeta. … … 298 312 */ 299 313 public static function search_friends( $filter, $user_id, $limit = null, $page = null ) { 300 global $wpdb , $bp;314 global $wpdb; 301 315 302 316 // TODO: Optimize this function. … … 321 335 if ( empty( $fids ) ) 322 336 return false; 337 338 $bp = buddypress(); 323 339 324 340 // filter the user_ids based on the search criteria. … … 356 372 */ 357 373 public static function check_is_friend( $initiator_userid, $possible_friend_userid ) { 358 global $wpdb , $bp;374 global $wpdb; 359 375 360 376 if ( empty( $initiator_userid ) || empty( $possible_friend_userid ) ) { 361 377 return false; 362 378 } 379 380 $bp = buddypress(); 363 381 364 382 $result = $wpdb->get_results( $wpdb->prepare( "SELECT id, initiator_user_id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id = %d) OR (initiator_user_id = %d AND friend_user_id = %d)", $initiator_userid, $possible_friend_userid, $possible_friend_userid, $initiator_userid ) ); … … 419 437 */ 420 438 public static function accept($friendship_id) { 421 global $wpdb, $bp; 439 global $wpdb; 440 441 $bp = buddypress(); 442 422 443 return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = %s WHERE id = %d AND friend_user_id = %d", bp_core_current_time(), $friendship_id, bp_loggedin_user_id() ) ); 423 444 } … … 430 451 */ 431 452 public static function withdraw($friendship_id) { 432 global $wpdb, $bp; 453 global $wpdb; 454 455 $bp = buddypress(); 456 433 457 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND initiator_user_id = %d", $friendship_id, bp_loggedin_user_id() ) ); 434 458 } … … 441 465 */ 442 466 public static function reject($friendship_id) { 443 global $wpdb, $bp; 467 global $wpdb; 468 469 $bp = buddypress(); 470 444 471 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND friend_user_id = %d", $friendship_id, bp_loggedin_user_id() ) ); 445 472 } … … 458 485 */ 459 486 public static function search_users( $filter, $user_id, $limit = null, $page = null ) { 460 global $wpdb , $bp;487 global $wpdb; 461 488 462 489 // Only search for matching strings at the beginning of the … … 470 497 if ( !empty( $limit ) && !empty( $page ) ) 471 498 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * intval( $limit ) ), intval( $limit ) ); 499 500 $bp = buddypress(); 472 501 473 502 // filter the user_ids based on the search criteria. … … 495 524 */ 496 525 public static function search_users_count( $filter ) { 497 global $wpdb , $bp;526 global $wpdb; 498 527 499 528 // Only search for matching strings at the beginning of the … … 503 532 $usermeta_table = $wpdb->prefix . 'usermeta'; 504 533 $users_table = $wpdb->base_prefix . 'users'; 534 535 $bp = buddypress(); 505 536 506 537 // filter the user_ids based on the search criteria. … … 528 559 */ 529 560 public static function sort_by_name( $user_ids ) { 530 global $wpdb , $bp;561 global $wpdb; 531 562 532 563 if ( !bp_is_active( 'xprofile' ) ) 533 564 return false; 565 566 $bp = buddypress(); 534 567 535 568 $user_ids = implode( ',', wp_parse_id_list( $user_ids ) ); … … 548 581 */ 549 582 public static function get_random_friends( $user_id, $total_friends = 5 ) { 550 global $wpdb, $bp; 551 583 global $wpdb; 584 585 $bp = buddypress(); 552 586 $fids = array(); 553 587 $sql = $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE (friend_user_id = %d || initiator_user_id = %d) && is_confirmed = 1 ORDER BY rand() LIMIT %d", $user_id, $user_id, $total_friends ); … … 612 646 */ 613 647 public static function get_user_ids_for_friendship( $friendship_id ) { 614 global $wpdb, $bp; 648 global $wpdb; 649 650 $bp = buddypress(); 651 615 652 return $wpdb->get_row( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE id = %d", $friendship_id ) ); 616 653 } … … 622 659 */ 623 660 public static function delete_all_for_user( $user_id ) { 624 global $wpdb, $bp; 661 global $wpdb; 662 663 $bp = buddypress(); 625 664 626 665 // Get friends of $user_id -
trunk/src/bp-friends/bp-friends-filters.php
r8958 r9471 16 16 * @since BuddyPress (1.7.0) 17 17 * 18 * @global BuddyPress $bp Global BuddyPress settings.19 18 * @global WPDB $wpdb WordPress database access object. 20 19 * … … 24 23 */ 25 24 function bp_friends_filter_user_query_populate_extras( BP_User_Query $user_query, $user_ids_sql ) { 26 global $ bp, $wpdb;25 global $wpdb; 27 26 28 27 // stop if user isn't logged in … … 30 29 return; 31 30 } 31 32 $bp = buddypress(); 32 33 33 34 // Fetch whether or not the user is a friend of the current user -
trunk/src/bp-groups/bp-groups-actions.php
r9466 r9471 96 96 */ 97 97 function groups_action_create_group() { 98 global $bp;99 98 100 99 // If we're not at domain.org/groups/create/ then return false … … 109 108 bp_core_redirect( bp_get_groups_directory_permalink() ); 110 109 } 110 111 $bp = buddypress(); 111 112 112 113 // Make sure creation steps are in the right order … … 361 362 */ 362 363 function groups_action_join_group() { 363 global $bp;364 364 365 365 if ( !bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action( 'join' ) ) … … 369 369 if ( !check_admin_referer( 'groups_join_group' ) ) 370 370 return false; 371 372 $bp = buddypress(); 371 373 372 374 // Skip if banned or already a member … … 457 459 */ 458 460 function groups_action_sort_creation_steps() { 459 global $bp;460 461 461 462 if ( !bp_is_groups_component() || !bp_is_current_action( 'create' ) ) 462 463 return false; 464 465 $bp = buddypress(); 463 466 464 467 if ( !is_array( $bp->groups->group_creation_steps ) ) -
trunk/src/bp-groups/bp-groups-cache.php
r9351 r9471 29 29 */ 30 30 function bp_groups_update_meta_cache( $group_ids = false ) { 31 global $bp;31 $bp = buddypress(); 32 32 33 33 $cache_args = array( -
trunk/src/bp-groups/bp-groups-classes.php
r9365 r9471 260 260 */ 261 261 public function save() { 262 global $wpdb, $bp; 262 global $wpdb; 263 264 $bp = buddypress(); 263 265 264 266 $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id ); … … 356 358 */ 357 359 public function delete() { 358 global $wpdb , $bp;360 global $wpdb; 359 361 360 362 // Delete groupmeta for the group … … 374 376 375 377 wp_cache_delete( $this->id, 'bp_groups' ); 378 379 $bp = buddypress(); 376 380 377 381 // Finally remove the group entry from the DB … … 393 397 */ 394 398 public static function group_exists( $slug, $table_name = false ) { 395 global $wpdb , $bp;399 global $wpdb; 396 400 397 401 if ( empty( $table_name ) ) 398 $table_name = $bp->groups->table_name;402 $table_name = buddypress()->groups->table_name; 399 403 400 404 if ( empty( $slug ) ) … … 425 429 */ 426 430 public static function get_invites( $user_id, $group_id ) { 427 global $wpdb, $bp; 431 global $wpdb; 432 433 $bp = buddypress(); 434 428 435 return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d and is_confirmed = 0 AND inviter_id = %d", $group_id, $user_id ) ); 429 436 } … … 447 454 */ 448 455 public static function filter_user_groups( $filter, $user_id = 0, $order = false, $limit = null, $page = null ) { 449 global $wpdb , $bp;456 global $wpdb; 450 457 451 458 if ( empty( $user_id ) ) … … 464 471 if ( empty( $gids['groups'] ) ) 465 472 return false; 473 474 $bp = buddypress(); 466 475 467 476 $gids = esc_sql( implode( ',', wp_parse_id_list( $gids['groups'] ) ) ); … … 491 500 */ 492 501 public static function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) { 493 global $wpdb , $bp;502 global $wpdb; 494 503 495 504 $search_terms_like = '%' . bp_esc_like( $filter ) . '%'; … … 509 518 $hidden_sql = "AND status != 'hidden'"; 510 519 520 $bp = buddypress(); 521 511 522 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE %s OR description LIKE %s ) {$hidden_sql} {$order_sql} {$pag_sql}", $search_terms_like, $search_terms_like ) ); 512 523 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} WHERE ( name LIKE %s OR description LIKE %s ) {$hidden_sql}", $search_terms_like, $search_terms_like ) ); … … 522 533 */ 523 534 public static function check_slug( $slug ) { 524 global $wpdb, $bp; 535 global $wpdb; 536 537 $bp = buddypress(); 525 538 526 539 return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE slug = %s", $slug ) ); … … 534 547 */ 535 548 public static function get_slug( $group_id ) { 536 global $wpdb, $bp; 549 global $wpdb; 550 551 $bp = buddypress(); 537 552 538 553 return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE id = %d", $group_id ) ); … … 546 561 */ 547 562 public static function has_members( $group_id ) { 548 global $wpdb, $bp; 563 global $wpdb; 564 565 $bp = buddypress(); 549 566 550 567 $members = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) ); … … 564 581 */ 565 582 public static function has_membership_requests( $group_id ) { 566 global $wpdb, $bp; 583 global $wpdb; 584 585 $bp = buddypress(); 567 586 568 587 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0", $group_id ) ); … … 584 603 */ 585 604 public static function get_membership_requests( $group_id, $limit = null, $page = null ) { 586 global $wpdb , $bp;605 global $wpdb; 587 606 588 607 if ( !empty( $limit ) && !empty( $page ) ) { 589 608 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 590 609 } 610 611 $bp = buddypress(); 591 612 592 613 $paged_requests = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0{$pag_sql}", $group_id ) ); … … 648 669 */ 649 670 public static function get( $args = array() ) { 650 global $wpdb , $bp;671 global $wpdb; 651 672 652 673 // Backward compatibility with old method of passing arguments … … 687 708 688 709 $r = wp_parse_args( $args, $defaults ); 710 711 $bp = buddypress(); 689 712 690 713 $sql = array(); … … 1013 1036 */ 1014 1037 public static function get_by_most_forum_topics( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) { 1015 global $wpdb, $b p, $bbdb;1038 global $wpdb, $bbdb; 1016 1039 1017 1040 if ( empty( $bbdb ) ) … … 1034 1057 $exclude_sql = " AND g.id NOT IN ({$exclude})"; 1035 1058 } 1059 1060 $bp = buddypress(); 1036 1061 1037 1062 if ( !empty( $user_id ) ) { … … 1077 1102 */ 1078 1103 public static function get_by_most_forum_posts( $limit = null, $page = null, $search_terms = false, $populate_extras = true, $exclude = false ) { 1079 global $wpdb, $b p, $bbdb;1104 global $wpdb, $bbdb; 1080 1105 1081 1106 if ( empty( $bbdb ) ) … … 1098 1123 $exclude_sql = " AND g.id NOT IN ({$exclude})"; 1099 1124 } 1125 1126 $bp = buddypress(); 1100 1127 1101 1128 if ( !empty( $user_id ) ) { … … 1138 1165 */ 1139 1166 public static function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true, $exclude = false ) { 1140 global $wpdb , $bp;1167 global $wpdb; 1141 1168 1142 1169 $pag_sql = $hidden_sql = $exclude_sql = ''; … … 1152 1179 } 1153 1180 } 1181 1182 $bp = buddypress(); 1154 1183 1155 1184 if ( !empty( $exclude ) ) { … … 1206 1235 */ 1207 1236 public static function get_random( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) { 1208 global $wpdb , $bp;1237 global $wpdb; 1209 1238 1210 1239 $pag_sql = $hidden_sql = $search_sql = $exclude_sql = ''; … … 1226 1255 $exclude_sql = " AND g.id NOT IN ({$exclude})"; 1227 1256 } 1257 1258 $bp = buddypress(); 1228 1259 1229 1260 if ( !empty( $user_id ) ) { … … 1264 1295 */ 1265 1296 public static function get_group_extras( &$paged_groups, &$group_ids, $type = false ) { 1266 global $ bp, $wpdb;1297 global $wpdb; 1267 1298 1268 1299 if ( empty( $group_ids ) ) 1269 1300 return $paged_groups; 1301 1302 $bp = buddypress(); 1270 1303 1271 1304 // Sanitize group IDs … … 1338 1371 */ 1339 1372 public static function delete_all_invites( $group_id ) { 1340 global $wpdb, $bp; 1373 global $wpdb; 1374 1375 $bp = buddypress(); 1341 1376 1342 1377 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) ); … … 1352 1387 */ 1353 1388 public static function get_total_group_count() { 1354 global $wpdb , $bp;1389 global $wpdb; 1355 1390 1356 1391 $hidden_sql = ''; … … 1358 1393 $hidden_sql = "WHERE status != 'hidden'"; 1359 1394 1395 $bp = buddypress(); 1396 1360 1397 return $wpdb->get_var( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql}" ); 1361 1398 } … … 1369 1406 */ 1370 1407 public static function get_global_forum_topic_count( $type ) { 1371 global $bbdb, $wpdb, $bp; 1408 global $bbdb, $wpdb; 1409 1410 $bp = buddypress(); 1372 1411 1373 1412 if ( 'unreplied' == $type ) … … 1391 1430 */ 1392 1431 public static function get_total_member_count( $group_id ) { 1393 global $wpdb, $bp; 1432 global $wpdb; 1433 1434 $bp = buddypress(); 1394 1435 1395 1436 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) ); … … 1406 1447 */ 1407 1448 public static function get_global_topic_count( $status = 'public', $search_terms = false ) { 1408 global $bbdb, $wpdb , $bp;1449 global $bbdb, $wpdb; 1409 1450 1410 1451 switch ( $status ) { … … 1427 1468 } 1428 1469 1470 $bp = buddypress(); 1471 1429 1472 $sql = array(); 1430 1473 … … 1452 1495 */ 1453 1496 public static function get_group_type_ids() { 1454 global $wpdb, $bp; 1455 1497 global $wpdb; 1498 1499 $bp = buddypress(); 1456 1500 $ids = array(); 1457 1501 … … 1981 2025 */ 1982 2026 public function populate() { 1983 global $wpdb, $bp; 2027 global $wpdb; 2028 2029 $bp = buddypress(); 1984 2030 1985 2031 if ( $this->user_id && $this->group_id && !$this->id ) … … 2015 2061 */ 2016 2062 public function save() { 2017 global $wpdb, $bp; 2063 global $wpdb; 2064 2065 $bp = buddypress(); 2018 2066 2019 2067 $this->user_id = apply_filters( 'groups_member_user_id_before_save', $this->user_id, $this->id ); … … 2145 2193 */ 2146 2194 public function remove() { 2147 global $wpdb, $bp; 2148 2195 global $wpdb; 2196 2197 $bp = buddypress(); 2149 2198 $sql = $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id ); 2150 2199 … … 2195 2244 */ 2196 2245 public static function delete( $user_id, $group_id ) { 2197 global $wpdb, $bp; 2198 2246 global $wpdb; 2247 2248 $bp = buddypress(); 2199 2249 $remove = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) ); 2200 2250 … … 2222 2272 */ 2223 2273 public static function get_group_ids( $user_id, $limit = false, $page = false ) { 2224 global $wpdb , $bp;2274 global $wpdb; 2225 2275 2226 2276 $pag_sql = ''; 2227 2277 if ( !empty( $limit ) && !empty( $page ) ) 2228 2278 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 2279 2280 $bp = buddypress(); 2229 2281 2230 2282 // If the user is logged in and viewing their own groups, we can show hidden and private groups … … 2258 2310 */ 2259 2311 public static function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) { 2260 global $wpdb , $bp;2312 global $wpdb; 2261 2313 2262 2314 $user_id_sql = $pag_sql = $hidden_sql = $filter_sql = ''; … … 2274 2326 if ( $user_id != bp_loggedin_user_id() ) 2275 2327 $hidden_sql = " AND g.status != 'hidden'"; 2328 2329 $bp = buddypress(); 2276 2330 2277 2331 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY m.date_modified DESC {$pag_sql}" ); … … 2297 2351 */ 2298 2352 public static function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) { 2299 global $wpdb , $bp;2353 global $wpdb; 2300 2354 2301 2355 $user_id_sql = $pag_sql = $hidden_sql = $filter_sql = ''; … … 2313 2367 if ( $user_id != bp_loggedin_user_id() ) 2314 2368 $hidden_sql = " AND g.status != 'hidden'"; 2369 2370 $bp = buddypress(); 2315 2371 2316 2372 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY m.date_modified ASC {$pag_sql}" ); … … 2336 2392 */ 2337 2393 public static function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) { 2338 global $wpdb , $bp;2394 global $wpdb; 2339 2395 2340 2396 $user_id_sql = $pag_sql = $hidden_sql = $filter_sql = ''; … … 2353 2409 $hidden_sql = " AND g.status != 'hidden'"; 2354 2410 2411 $bp = buddypress(); 2412 2355 2413 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY m.date_modified ASC {$pag_sql}" ); 2356 2414 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND {$user_id_sql} AND m.is_confirmed = 1 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC" ); … … 2366 2424 */ 2367 2425 public static function total_group_count( $user_id = 0 ) { 2368 global $ bp, $wpdb;2426 global $wpdb; 2369 2427 2370 2428 if ( empty( $user_id ) ) 2371 2429 $user_id = bp_displayed_user_id(); 2430 2431 $bp = buddypress(); 2372 2432 2373 2433 if ( $user_id != bp_loggedin_user_id() && !bp_current_user_can( 'bp_moderate' ) ) { … … 2394 2454 */ 2395 2455 public static function get_invites( $user_id, $limit = false, $page = false, $exclude = false ) { 2396 global $wpdb , $bp;2456 global $wpdb; 2397 2457 2398 2458 $pag_sql = ( !empty( $limit ) && !empty( $page ) ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : ''; … … 2404 2464 $exclude_sql = ''; 2405 2465 } 2466 2467 $bp = buddypress(); 2406 2468 2407 2469 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND m.is_confirmed = 0 AND m.inviter_id != 0 AND m.invite_sent = 1 AND m.user_id = %d {$exclude_sql} ORDER BY m.date_modified ASC {$pag_sql}", $user_id ) ); … … 2444 2506 */ 2445 2507 public static function check_has_invite( $user_id, $group_id, $type = 'sent' ) { 2446 global $wpdb , $bp;2508 global $wpdb; 2447 2509 2448 2510 if ( empty( $user_id ) ) 2449 2511 return false; 2450 2512 2513 $bp = buddypress(); 2451 2514 $sql = "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0"; 2452 2515 … … 2465 2528 */ 2466 2529 public static function delete_invite( $user_id, $group_id ) { 2467 global $wpdb , $bp;2530 global $wpdb; 2468 2531 2469 2532 if ( empty( $user_id ) ) 2470 2533 return false; 2534 2535 $bp = buddypress(); 2471 2536 2472 2537 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) ); … … 2481 2546 */ 2482 2547 public static function delete_request( $user_id, $group_id ) { 2483 global $wpdb , $bp;2548 global $wpdb; 2484 2549 2485 2550 if ( empty( $user_id ) ) 2486 2551 return false; 2552 2553 $bp = buddypress(); 2487 2554 2488 2555 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id = 0 AND invite_sent = 0", $user_id, $group_id ) ); … … 2498 2565 */ 2499 2566 public static function check_is_admin( $user_id, $group_id ) { 2500 global $wpdb , $bp;2567 global $wpdb; 2501 2568 2502 2569 if ( empty( $user_id ) ) 2503 2570 return false; 2571 2572 $bp = buddypress(); 2504 2573 2505 2574 return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_admin = 1 AND is_banned = 0", $user_id, $group_id ) ); … … 2515 2584 */ 2516 2585 public static function check_is_mod( $user_id, $group_id ) { 2517 global $wpdb , $bp;2586 global $wpdb; 2518 2587 2519 2588 if ( empty( $user_id ) ) 2520 2589 return false; 2590 2591 $bp = buddypress(); 2521 2592 2522 2593 return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_mod = 1 AND is_banned = 0", $user_id, $group_id ) ); … … 2532 2603 */ 2533 2604 public static function check_is_member( $user_id, $group_id ) { 2534 global $wpdb , $bp;2605 global $wpdb; 2535 2606 2536 2607 if ( empty( $user_id ) ) 2537 2608 return false; 2609 2610 $bp = buddypress(); 2538 2611 2539 2612 return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 1 AND is_banned = 0", $user_id, $group_id ) ); … … 2549 2622 */ 2550 2623 public static function check_is_banned( $user_id, $group_id ) { 2551 global $wpdb , $bp;2624 global $wpdb; 2552 2625 2553 2626 if ( empty( $user_id ) ) 2554 2627 return false; 2628 2629 $bp = buddypress(); 2555 2630 2556 2631 return $wpdb->get_var( $wpdb->prepare( "SELECT is_banned FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) ); … … 2568 2643 */ 2569 2644 public static function check_is_creator( $user_id, $group_id ) { 2570 global $ bp, $wpdb;2645 global $wpdb; 2571 2646 2572 2647 if ( empty( $user_id ) ) 2573 2648 return false; 2649 2650 $bp = buddypress(); 2574 2651 2575 2652 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name} WHERE creator_id = %d AND id = %d", $user_id, $group_id ) ); … … 2584 2661 */ 2585 2662 public static function check_for_membership_request( $user_id, $group_id ) { 2586 global $wpdb , $bp;2663 global $wpdb; 2587 2664 2588 2665 if ( empty( $user_id ) ) 2589 2666 return false; 2667 2668 $bp = buddypress(); 2590 2669 2591 2670 return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND is_banned = 0 AND inviter_id = 0", $user_id, $group_id ) ); … … 2600 2679 */ 2601 2680 public static function get_random_groups( $user_id = 0, $total_groups = 5 ) { 2602 global $wpdb, $bp; 2681 global $wpdb; 2682 2683 $bp = buddypress(); 2603 2684 2604 2685 // If the user is logged in and viewing their random groups, we can show hidden and private groups … … 2617 2698 */ 2618 2699 public static function get_group_member_ids( $group_id ) { 2619 global $bp, $wpdb; 2700 global $wpdb; 2701 2702 $bp = buddypress(); 2620 2703 2621 2704 return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0", $group_id ) ); … … 2629 2712 */ 2630 2713 public static function get_group_administrator_ids( $group_id ) { 2631 global $ bp, $wpdb;2714 global $wpdb; 2632 2715 2633 2716 $group_admins = wp_cache_get( $group_id, 'bp_group_admins' ); 2634 2717 2635 2718 if ( false === $group_admins ) { 2719 $bp = buddypress(); 2636 2720 $group_admins = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_admin = 1 AND is_banned = 0", $group_id ) ); 2637 2721 … … 2649 2733 */ 2650 2734 public static function get_group_moderator_ids( $group_id ) { 2651 global $bp, $wpdb; 2735 global $wpdb; 2736 2737 $bp = buddypress(); 2652 2738 2653 2739 return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_mod = 1 AND is_banned = 0", $group_id ) ); … … 2661 2747 */ 2662 2748 public static function get_all_membership_request_user_ids( $group_id ) { 2663 global $bp, $wpdb; 2749 global $wpdb; 2750 2751 $bp = buddypress(); 2664 2752 2665 2753 return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) ); … … 2672 2760 */ 2673 2761 public static function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false ) { 2674 global $ bp, $wpdb;2762 global $wpdb; 2675 2763 2676 2764 _deprecated_function( __METHOD__, '1.8', 'BP_Group_Member_Query' ); … … 2693 2781 $exclude_sql = " AND m.user_id NOT IN ({$exclude})"; 2694 2782 } 2783 2784 $bp = buddypress(); 2695 2785 2696 2786 if ( bp_is_active( 'xprofile' ) ) { … … 2737 2827 */ 2738 2828 public static function delete_all( $group_id ) { 2739 global $wpdb, $bp; 2829 global $wpdb; 2830 2831 $bp = buddypress(); 2740 2832 2741 2833 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) ); … … 2750 2842 */ 2751 2843 public static function delete_all_for_user( $user_id ) { 2752 global $bp, $wpdb; 2844 global $wpdb; 2845 2846 $bp = buddypress(); 2753 2847 2754 2848 // Get all the group ids for the current user's groups and update counts -
trunk/src/bp-groups/bp-groups-filters.php
r9462 r9471 142 142 */ 143 143 function groups_add_forum_tables_sql( $sql = '' ) { 144 global $bp;144 $bp = buddypress(); 145 145 146 146 $sql .= 'JOIN ' . $bp->groups->table_name . ' AS g LEFT JOIN ' . $bp->groups->table_name_groupmeta . ' AS gm ON g.id = gm.group_id '; … … 156 156 */ 157 157 function groups_add_forum_where_sql( $sql = '' ) { 158 global $bp;159 158 160 159 // Define locale variable … … 190 189 // Assemble Voltron 191 190 $parts_string = implode( ' AND ', $parts ); 191 192 $bp = buddypress(); 192 193 193 194 // Set it to the global filter … … 207 208 */ 208 209 function groups_filter_bbpress_caps( $value, $cap, $args ) { 209 global $bp;210 210 211 211 if ( bp_current_user_can( 'bp_moderate' ) ) 212 212 return true; 213 213 214 if ( 'add_tag_to' == $cap ) 215 if ( $bp->groups->current_group->user_has_access ) return true; 214 if ( 'add_tag_to' === $cap ) { 215 $bp = buddypress(); 216 217 if ( $bp->groups->current_group->user_has_access ) { 218 return true; 219 } 220 } 216 221 217 222 if ( 'manage_forums' == $cap && is_user_logged_in() ) -
trunk/src/bp-groups/bp-groups-functions.php
r9351 r9471 21 21 * @since BuddyPress (1.5.0) 22 22 * 23 * @global BuddyPress $bp The one true BuddyPress instance24 23 * @return bool True if set, False if empty 25 24 */ 26 25 function bp_groups_has_directory() { 27 global $bp;26 $bp = buddypress(); 28 27 29 28 return (bool) !empty( $bp->pages->groups->id ); … … 301 300 */ 302 301 function groups_is_valid_status( $status ) { 303 global $bp;302 $bp = buddypress(); 304 303 305 304 return in_array( $status, (array) $bp->groups->valid_status ); … … 313 312 */ 314 313 function groups_check_slug( $slug ) { 315 global $bp;314 $bp = buddypress(); 316 315 317 316 if ( 'wp' == substr( $slug, 0, 2 ) ) … … 365 364 */ 366 365 function groups_leave_group( $group_id, $user_id = 0 ) { 367 global $bp;368 366 369 367 if ( empty( $user_id ) ) … … 399 397 */ 400 398 function groups_join_group( $group_id, $user_id = 0 ) { 401 global $bp;402 399 403 400 if ( empty( $user_id ) ) … … 427 424 if ( !$new_member->save() ) 428 425 return false; 426 427 $bp = buddypress(); 429 428 430 429 if ( !isset( $bp->groups->current_group ) || !$bp->groups->current_group || $group_id != $bp->groups->current_group->id ) … … 705 704 */ 706 705 function groups_get_current_group() { 707 global $bp; 708 709 $current_group = isset( $bp->groups->current_group ) ? $bp->groups->current_group : false; 706 $bp = buddypress(); 707 708 $current_group = isset( $bp->groups->current_group ) 709 ? $bp->groups->current_group 710 : false; 710 711 711 712 return apply_filters( 'groups_get_current_group', $current_group ); … … 722 723 */ 723 724 function groups_avatar_upload_dir( $group_id = 0 ) { 724 global $bp; 725 726 if ( !$group_id )727 $group_id = $bp->groups->current_group->id;725 726 if ( empty( $group_id ) ) { 727 $group_id = bp_get_current_group_id(); 728 } 728 729 729 730 $path = bp_core_avatar_upload_path() . '/group-avatars/' . $group_id; … … 810 811 */ 811 812 function groups_post_update( $args = '' ) { 812 global $bp;813 $bp = buddypress(); 813 814 814 815 $defaults = array( -
trunk/src/bp-groups/bp-groups-screens.php
r9351 r9471 510 510 */ 511 511 function groups_screen_group_request_membership() { 512 global $bp;513 512 514 513 if ( !is_user_logged_in() ) … … 912 911 */ 913 912 function groups_screen_group_admin_delete_group() { 914 global $bp;915 913 916 914 if ( 'delete-group' != bp_get_group_current_admin_tab() ) … … 919 917 if ( ! bp_is_item_admin() && !bp_current_user_can( 'bp_moderate' ) ) 920 918 return false; 919 920 $bp = buddypress(); 921 921 922 922 if ( isset( $_REQUEST['delete-group-button'] ) && isset( $_REQUEST['delete-group-understand'] ) ) { -
trunk/src/bp-groups/bp-groups-template.php
r9466 r9471 1500 1500 */ 1501 1501 function bp_group_search_form() { 1502 global $bp;1503 1502 1504 1503 $action = bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/search/'; … … 1597 1596 */ 1598 1597 function bp_groups_auto_join() { 1599 global $bp; 1600 1601 return apply_filters( 'bp_groups_auto_join', (bool)$bp->groups->auto_join ); 1598 return apply_filters( 'bp_groups_auto_join', (bool) buddypress()->groups->auto_join ); 1602 1599 } 1603 1600 … … 1861 1858 */ 1862 1859 function bp_group_get_invite_status( $group_id = false ) { 1863 global $ bp, $groups_template;1860 global $groups_template; 1864 1861 1865 1862 if ( !$group_id ) { 1863 $bp = buddypress(); 1864 1866 1865 if ( isset( $bp->groups->current_group->id ) ) { 1867 1866 // Default to the current group first … … 2558 2557 */ 2559 2558 function bp_get_group_accept_invite_link( $group = false ) { 2560 global $groups_template , $bp;2559 global $groups_template; 2561 2560 2562 2561 if ( empty( $group ) ) 2563 2562 $group =& $groups_template->group; 2563 2564 $bp = buddypress(); 2564 2565 2565 2566 return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/accept/' . $group->id ), 'groups_accept_invite' ) ); … … 2580 2581 */ 2581 2582 function bp_get_group_reject_invite_link( $group = false ) { 2582 global $groups_template , $bp;2583 global $groups_template; 2583 2584 2584 2585 if ( empty( $group ) ) 2585 2586 $group =& $groups_template->group; 2587 2588 $bp = buddypress(); 2586 2589 2587 2590 return apply_filters( 'bp_get_group_reject_invite_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/reject/' . $group->id ), 'groups_reject_invite' ) ); … … 3623 3626 3624 3627 function bp_group_creation_tabs() { 3625 global $bp;3628 $bp = buddypress(); 3626 3629 3627 3630 if ( !is_array( $bp->groups->group_creation_steps ) ) … … 3648 3651 3649 3652 function bp_group_creation_stage_title() { 3650 global $bp;3653 $bp = buddypress(); 3651 3654 3652 3655 echo apply_filters( 'bp_group_creation_stage_title', '<span>— ' . $bp->groups->group_creation_steps[bp_get_groups_current_create_step()]['name'] . '</span>' ); … … 3657 3660 } 3658 3661 function bp_get_group_creation_form_action() { 3659 global $bp;3662 $bp = buddypress(); 3660 3663 3661 3664 if ( !bp_action_variable( 1 ) ) { … … 3668 3671 3669 3672 function bp_is_group_creation_step( $step_slug ) { 3670 global $bp;3671 3673 3672 3674 /* Make sure we are in the groups component */ 3673 3675 if ( !bp_is_groups_component() || !bp_is_current_action( 'create' ) ) 3674 3676 return false; 3677 3678 $bp = buddypress(); 3675 3679 3676 3680 /* If this the first step, we can just accept and return true */ … … 3693 3697 3694 3698 function bp_is_group_creation_step_complete( $step_slugs ) { 3695 global $bp;3699 $bp = buddypress(); 3696 3700 3697 3701 if ( !isset( $bp->groups->completed_create_steps ) ) … … 3715 3719 3716 3720 function bp_are_previous_group_creation_steps_complete( $step_slug ) { 3717 global $bp;3721 $bp = buddypress(); 3718 3722 3719 3723 /* If this is the first group creation step, return true */ … … 3740 3744 } 3741 3745 function bp_get_new_group_id() { 3742 global $bp;3746 $bp = buddypress(); 3743 3747 3744 3748 if ( isset( $bp->groups->new_group_id ) ) … … 3754 3758 } 3755 3759 function bp_get_new_group_name() { 3756 global $bp;3760 $bp = buddypress(); 3757 3761 3758 3762 if ( isset( $bp->groups->current_group->name ) ) … … 3768 3772 } 3769 3773 function bp_get_new_group_description() { 3770 global $bp;3774 $bp = buddypress(); 3771 3775 3772 3776 if ( isset( $bp->groups->current_group->description ) ) … … 3782 3786 } 3783 3787 function bp_get_new_group_enable_forum() { 3784 global $bp; 3788 $bp = buddypress(); 3789 3785 3790 return (int) apply_filters( 'bp_get_new_group_enable_forum', $bp->groups->current_group->enable_forum ); 3786 3791 } … … 3790 3795 } 3791 3796 function bp_get_new_group_status() { 3792 global $bp; 3797 $bp = buddypress(); 3798 3793 3799 return apply_filters( 'bp_get_new_group_status', $bp->groups->current_group->status ); 3794 3800 } … … 3798 3804 } 3799 3805 function bp_get_new_group_avatar( $args = '' ) { 3800 global $bp;3806 $bp = buddypress(); 3801 3807 3802 3808 $defaults = array( … … 3820 3826 } 3821 3827 function bp_get_group_creation_previous_link() { 3822 global $bp;3828 $bp = buddypress(); 3823 3829 3824 3830 foreach ( (array) $bp->groups->group_creation_steps as $slug => $name ) { … … 3849 3855 */ 3850 3856 function bp_get_groups_current_create_step() { 3851 global $bp;3857 $bp = buddypress(); 3852 3858 3853 3859 if ( !empty( $bp->groups->current_create_step ) ) { … … 3861 3867 3862 3868 function bp_is_last_group_creation_step() { 3863 global $bp;3869 $bp = buddypress(); 3864 3870 3865 3871 $keys = array_keys( $bp->groups->group_creation_steps ); … … 3873 3879 3874 3880 function bp_is_first_group_creation_step() { 3875 global $bp;3881 $bp = buddypress(); 3876 3882 3877 3883 $keys = array_keys( $bp->groups->group_creation_steps ); … … 3888 3894 } 3889 3895 function bp_get_new_group_invite_friend_list( $args = '' ) { 3890 global $bp;3896 $bp = buddypress(); 3891 3897 3892 3898 if ( !bp_is_active( 'friends' ) ) … … 3945 3951 */ 3946 3952 function bp_groups_header_tabs() { 3947 global $bp;?>3953 $bp = buddypress(); ?> 3948 3954 3949 3955 <li<?php if ( !bp_action_variable( 0 ) || bp_is_action_variable( 'recently-active', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/recently-active' ) ?>"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li> … … 4095 4101 } 4096 4102 function bp_get_group_avatar_delete_link() { 4097 global $bp;4103 $bp = buddypress(); 4098 4104 4099 4105 return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/group-avatar/delete', 'bp_group_avatar_delete' ) ); -
trunk/src/bp-members/bp-members-adminbar.php
r9351 r9471 21 21 */ 22 22 function bp_members_admin_bar_my_account_menu() { 23 global $ bp, $wp_admin_bar;23 global $wp_admin_bar; 24 24 25 25 // Bail if this is an ajax request … … 29 29 // Logged in user 30 30 if ( is_user_logged_in() ) { 31 32 $bp = buddypress(); 31 33 32 34 // Stored in the global so we can add menus easily later on … … 73 75 */ 74 76 function bp_members_admin_bar_user_admin_menu() { 75 global $ bp, $wp_admin_bar;77 global $wp_admin_bar; 76 78 77 79 // Only show if viewing a user … … 82 84 if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() ) 83 85 return false; 86 87 $bp = buddypress(); 84 88 85 89 // Unique ID for the 'My Account' menu -
trunk/src/bp-members/bp-members-functions.php
r9428 r9471 21 21 */ 22 22 function bp_members_has_directory() { 23 global $bp;23 $bp = buddypress(); 24 24 25 25 return (bool) !empty( $bp->pages->members->id ); -
trunk/src/bp-members/bp-members-screens.php
r9467 r9471 65 65 */ 66 66 function bp_core_screen_signup() { 67 global $bp;67 $bp = buddypress(); 68 68 69 69 if ( ! bp_is_current_component( 'register' ) || bp_current_action() ) -
trunk/src/bp-members/bp-members-template.php
r9455 r9471 1298 1298 */ 1299 1299 function bp_get_loggedin_user_nav() { 1300 global $bp;1300 $bp = buddypress(); 1301 1301 1302 1302 // Loop through each navigation item … … 1340 1340 */ 1341 1341 function bp_get_displayed_user_nav() { 1342 global $bp;1342 $bp = buddypress(); 1343 1343 1344 1344 foreach ( (array) $bp->bp_nav as $user_nav_item ) { … … 1484 1484 */ 1485 1485 function bp_get_displayed_user_email() { 1486 global $bp;1486 $bp = buddypress(); 1487 1487 1488 1488 // If displayed user exists, return email address … … 1646 1646 */ 1647 1647 function bp_displayed_user_domain() { 1648 global $bp;1648 $bp = buddypress(); 1649 1649 1650 1650 /** … … 1664 1664 */ 1665 1665 function bp_loggedin_user_domain() { 1666 global $bp;1666 $bp = buddypress(); 1667 1667 1668 1668 /** … … 1688 1688 */ 1689 1689 function bp_get_displayed_user_fullname() { 1690 global $bp;1690 $bp = buddypress(); 1691 1691 1692 1692 /** … … 1718 1718 */ 1719 1719 function bp_get_loggedin_user_fullname() { 1720 global $bp;1720 $bp = buddypress(); 1721 1721 1722 1722 /** … … 1742 1742 */ 1743 1743 function bp_get_displayed_user_username() { 1744 global $bp;1744 $bp = buddypress(); 1745 1745 1746 1746 if ( bp_displayed_user_id() ) { … … 1772 1772 */ 1773 1773 function bp_get_loggedin_user_username() { 1774 global $bp;1774 $bp = buddypress(); 1775 1775 1776 1776 if ( bp_loggedin_user_id() ) { … … 2096 2096 */ 2097 2097 function bp_get_signup_avatar_dir_value() { 2098 global $bp;2098 $bp = buddypress(); 2099 2099 2100 2100 // Check if signup_avatar_dir is passed … … 2132 2132 */ 2133 2133 function bp_get_current_signup_step() { 2134 global $bp; 2135 2136 return $bp->signup->step; 2134 return buddypress()->signup->step; 2137 2135 } 2138 2136 … … 2303 2301 */ 2304 2302 function bp_get_members_component_link( $component, $action = '', $query_args = '', $nonce = false ) { 2305 global $bp;2306 2303 2307 2304 // Must be displayed user 2308 2305 if ( !bp_displayed_user_id() ) 2309 2306 return; 2307 2308 $bp = buddypress(); 2310 2309 2311 2310 // Append $action to $url if there is no $type -
trunk/src/bp-messages/bp-messages-classes.php
r9351 r9471 135 135 */ 136 136 public function populate( $thread_id = 0, $order = 'ASC', $args = array() ) { 137 global $wpdb , $bp;137 global $wpdb; 138 138 139 139 if( 'ASC' != $order && 'DESC' != $order ) { … … 149 149 $this->thread_id = $thread_id; 150 150 151 $bp = buddypress(); 152 151 153 if ( !$this->messages = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE thread_id = %d ORDER BY date_sent " . $order, $this->thread_id ) ) ) { 152 154 return false; … … 210 212 */ 211 213 public function get_recipients() { 212 global $wpdb, $bp; 214 global $wpdb; 215 216 $bp = buddypress(); 213 217 214 218 $recipients = array(); … … 244 248 */ 245 249 public static function delete( $thread_id ) { 246 global $wpdb , $bp;250 global $wpdb; 247 251 248 252 /** … … 254 258 */ 255 259 do_action( 'bp_messages_thread_before_mark_delete', $thread_id ); 260 261 $bp = buddypress(); 256 262 257 263 // Mark messages as deleted … … 335 341 */ 336 342 public static function get_current_threads_for_user( $args = array() ) { 337 global $wpdb , $bp;343 global $wpdb; 338 344 339 345 // Backward compatibility with old method of passing arguments … … 405 411 } 406 412 413 $bp = buddypress(); 414 407 415 // set up SQL array 408 416 $sql = array(); … … 491 499 */ 492 500 public static function mark_as_read( $thread_id ) { 493 global $wpdb, $bp; 494 501 global $wpdb; 502 503 $bp = buddypress(); 495 504 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", bp_loggedin_user_id(), $thread_id ); 496 505 $wpdb->query($sql); … … 507 516 */ 508 517 public static function mark_as_unread( $thread_id ) { 509 global $wpdb, $bp; 510 518 global $wpdb; 519 520 $bp = buddypress(); 511 521 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", bp_loggedin_user_id(), $thread_id ); 512 522 $wpdb->query($sql); … … 528 538 */ 529 539 public static function get_total_threads_for_user( $user_id, $box = 'inbox', $type = 'all' ) { 530 global $wpdb , $bp;540 global $wpdb; 531 541 532 542 $exclude_sender = ''; … … 539 549 $type_sql = " AND unread_count = 0 "; 540 550 551 $bp = buddypress(); 552 541 553 return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(thread_id) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0{$exclude_sender} {$type_sql}", $user_id ) ); 542 554 } … … 551 563 */ 552 564 public static function user_is_sender( $thread_id ) { 553 global $wpdb, $bp; 565 global $wpdb; 566 567 $bp = buddypress(); 554 568 555 569 $sender_ids = $wpdb->get_col( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) ); … … 571 585 */ 572 586 public static function get_last_sender( $thread_id ) { 573 global $wpdb, $bp; 587 global $wpdb; 588 589 $bp = buddypress(); 574 590 575 591 if ( ! $sender_id = $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d GROUP BY sender_id ORDER BY date_sent LIMIT 1", $thread_id ) ) ) { … … 589 605 */ 590 606 public static function get_inbox_count( $user_id = 0 ) { 591 global $wpdb , $bp;607 global $wpdb; 592 608 593 609 if ( empty( $user_id ) ) { … … 598 614 599 615 if ( false === $unread_count ) { 616 $bp = buddypress(); 617 600 618 $unread_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM(unread_count) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0 AND sender_only = 0", $user_id ) ); 601 619 … … 624 642 */ 625 643 public static function check_access( $thread_id, $user_id = 0 ) { 626 global $wpdb , $bp;644 global $wpdb; 627 645 628 646 if ( empty( $user_id ) ) 629 647 $user_id = bp_loggedin_user_id(); 648 649 $bp = buddypress(); 630 650 631 651 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND is_deleted = 0 AND user_id = %d", $thread_id, $user_id ) ); … … 694 714 */ 695 715 public static function update_tables() { 696 global $wpdb , $bp;716 global $wpdb; 697 717 698 718 $bp_prefix = bp_core_get_table_prefix(); … … 704 724 return true; 705 725 } 726 727 $bp = buddypress(); 706 728 707 729 foreach( (array) $threads as $thread ) { … … 798 820 */ 799 821 public function populate( $id ) { 800 global $wpdb, $bp; 822 global $wpdb; 823 824 $bp = buddypress(); 801 825 802 826 if ( $message = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $id ) ) ) { … … 817 841 */ 818 842 public function send() { 819 global $wpdb, $bp; 843 global $wpdb; 844 845 $bp = buddypress(); 820 846 821 847 $this->sender_id = apply_filters( 'messages_message_sender_id_before_save', $this->sender_id, $this->id ); … … 891 917 */ 892 918 public function get_recipients() { 893 global $bp, $wpdb; 919 global $wpdb; 920 921 $bp = buddypress(); 922 894 923 return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) ); 895 924 } … … 925 954 */ 926 955 public static function get_last_sent_for_user( $thread_id ) { 927 global $wpdb, $bp; 956 global $wpdb; 957 958 $bp = buddypress(); 959 928 960 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND thread_id = %d ORDER BY date_sent DESC LIMIT 1", bp_loggedin_user_id(), $thread_id ) ); 929 961 } … … 938 970 */ 939 971 public static function is_user_sender( $user_id, $message_id ) { 940 global $wpdb, $bp; 972 global $wpdb; 973 974 $bp = buddypress(); 975 941 976 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id = %d", $user_id, $message_id ) ); 942 977 } … … 949 984 */ 950 985 public static function get_message_sender( $message_id ) { 951 global $wpdb, $bp; 986 global $wpdb; 987 988 $bp = buddypress(); 989 952 990 return $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) ); 953 991 } … … 1018 1056 */ 1019 1057 public function populate() { 1020 global $wpdb, $bp; 1058 global $wpdb; 1059 1060 $bp = buddypress(); 1021 1061 1022 1062 $notice = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id ) ); … … 1038 1078 */ 1039 1079 public function save() { 1040 global $wpdb, $bp; 1080 global $wpdb; 1081 1082 $bp = buddypress(); 1041 1083 1042 1084 $this->subject = apply_filters( 'messages_notice_subject_before_save', $this->subject, $this->id ); … … 1117 1159 */ 1118 1160 public function delete() { 1119 global $wpdb , $bp;1161 global $wpdb; 1120 1162 1121 1163 /** … … 1128 1170 do_action( 'messages_notice_before_delete', $this ); 1129 1171 1172 $bp = buddypress(); 1130 1173 $sql = $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id ); 1131 1174 … … 1154 1197 */ 1155 1198 public static function get_notices( $args = array() ) { 1156 global $wpdb , $bp;1199 global $wpdb; 1157 1200 1158 1201 $r = wp_parse_args( $args, array( … … 1166 1209 } 1167 1210 1211 $bp = buddypress(); 1212 1168 1213 $notices = $wpdb->get_results( "SELECT * FROM {$bp->messages->table_name_notices} ORDER BY date_sent DESC {$limit_sql}" ); 1169 1214 … … 1179 1224 */ 1180 1225 public static function get_total_notice_count() { 1181 global $wpdb, $bp; 1182 1183 $notice_count = $wpdb->get_var( "SELECT COUNT(id) FROM " . $bp->messages->table_name_notices ); 1226 global $wpdb; 1227 1228 $bp = buddypress(); 1229 1230 $notice_count = $wpdb->get_var( "SELECT COUNT(id) FROM {$bp->messages->table_name_notices}" ); 1184 1231 1185 1232 return $notice_count; … … 1197 1244 1198 1245 if ( false === $notice ) { 1199 global $wpdb, $bp; 1246 global $wpdb; 1247 1248 $bp = buddypress(); 1200 1249 1201 1250 $notice_id = $wpdb->get_var( "SELECT id FROM {$bp->messages->table_name_notices} WHERE is_active = 1" ); -
trunk/src/bp-xprofile/bp-xprofile-admin.php
r9351 r9471 262 262 */ 263 263 function xprofile_admin_manage_field( $group_id, $field_id = null ) { 264 global $bp, $wpdb, $message, $groups; 264 global $wpdb, $message, $groups; 265 266 $bp = buddypress(); 265 267 266 268 $field = new BP_XProfile_Field( $field_id ); -
trunk/src/bp-xprofile/bp-xprofile-classes.php
r9351 r9471 25 25 26 26 public function populate( $id ) { 27 global $wpdb , $bp;27 global $wpdb; 28 28 29 29 $group = wp_cache_get( 'xprofile_group_' . $this->id, 'bp' ); 30 30 31 31 if ( false === $group ) { 32 $bp = buddypress(); 32 33 $group = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_groups} WHERE id = %d", $id ) ); 33 34 } … … 45 46 46 47 public function save() { 47 global $wpdb , $bp;48 global $wpdb; 48 49 49 50 $this->name = apply_filters( 'xprofile_group_name_before_save', $this->name, $this->id ); … … 60 61 */ 61 62 do_action_ref_array( 'xprofile_group_before_save', array( &$this ) ); 63 64 $bp = buddypress(); 62 65 63 66 if ( $this->id ) … … 86 89 87 90 public function delete() { 88 global $wpdb , $bp;91 global $wpdb; 89 92 90 93 if ( empty( $this->can_delete ) ) … … 99 102 */ 100 103 do_action_ref_array( 'xprofile_group_before_delete', array( &$this ) ); 104 105 $bp = buddypress(); 101 106 102 107 // Delete field group … … 163 168 */ 164 169 public static function get( $args = array() ) { 165 global $wpdb , $bp;170 global $wpdb; 166 171 167 172 $defaults = array( … … 197 202 } 198 203 204 $bp = buddypress(); 205 199 206 if ( ! empty( $hide_empty_groups ) ) { 200 207 $group_ids = $wpdb->get_col( "SELECT DISTINCT g.id FROM {$bp->profile->table_name_groups} g INNER JOIN {$bp->profile->table_name_fields} f ON g.id = f.group_id {$where_sql} ORDER BY g.group_order ASC" ); … … 416 423 417 424 public static function update_position( $field_group_id, $position ) { 418 global $wpdb , $bp;425 global $wpdb; 419 426 420 427 if ( !is_numeric( $position ) ) { … … 424 431 // purge profile field group cache 425 432 wp_cache_delete( 'xprofile_groups_inc_empty', 'bp' ); 433 434 $bp = buddypress(); 426 435 427 436 return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET group_order = %d WHERE id = %d", $position, $field_group_id ) ); … … 481 490 */ 482 491 public static function fetch_default_visibility_levels() { 483 global $wpdb , $bp;492 global $wpdb; 484 493 485 494 $default_visibility_levels = wp_cache_get( 'xprofile_default_visibility_levels', 'bp' ); 486 495 487 496 if ( false === $default_visibility_levels ) { 497 $bp = buddypress(); 498 488 499 $levels = $wpdb->get_results( "SELECT object_id, meta_key, meta_value FROM {$bp->profile->table_name_meta} WHERE object_type = 'field' AND ( meta_key = 'default_visibility' OR meta_key = 'allow_custom_visibility' )" ); 489 500 … … 658 669 659 670 public function populate( $id, $user_id, $get_data ) { 660 global $wpdb, $userdata , $bp;671 global $wpdb, $userdata; 661 672 662 673 if ( empty( $user_id ) ) { … … 664 675 } 665 676 677 $bp = buddypress(); 666 678 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_fields} WHERE id = %d", $id ); 667 679 … … 699 711 700 712 public function delete( $delete_data = false ) { 701 global $wpdb , $bp;713 global $wpdb; 702 714 703 715 // Prevent deletion if no ID is present … … 707 719 return false; 708 720 721 $bp = buddypress(); 722 709 723 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE id = %d OR parent_id = %d", $this->id, $this->id ) ) ) 710 724 return false; … … 718 732 719 733 public function save() { 720 global $wpdb, $bp; 734 global $wpdb; 735 736 $bp = buddypress(); 721 737 722 738 $this->group_id = apply_filters( 'xprofile_field_group_id_before_save', $this->group_id, $this->id ); … … 857 873 858 874 public function get_children( $for_editing = false ) { 859 global $wpdb , $bp;875 global $wpdb; 860 876 861 877 // This is done here so we don't have problems with sql injection … … 875 891 } 876 892 893 $bp = buddypress(); 877 894 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_fields} WHERE parent_id = %d AND group_id = %d $sort_sql", $parent_id, $this->group_id ); 878 895 … … 891 908 892 909 public function delete_children() { 893 global $wpdb, $bp; 894 910 global $wpdb; 911 912 $bp = buddypress(); 895 913 $sql = $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE parent_id = %d", $this->id ); 896 914 … … 901 919 902 920 public static function get_type( $field_id ) { 903 global $wpdb , $bp;921 global $wpdb; 904 922 905 923 if ( !empty( $field_id ) ) { 924 $bp = buddypress(); 906 925 $sql = $wpdb->prepare( "SELECT type FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id ); 907 926 … … 917 936 918 937 public static function delete_for_group( $group_id ) { 919 global $wpdb , $bp;938 global $wpdb; 920 939 921 940 if ( !empty( $group_id ) ) { 941 $bp = buddypress(); 922 942 $sql = $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id ); 923 943 … … 933 953 934 954 public static function get_id_from_name( $field_name ) { 935 global $wpdb, $bp; 955 global $wpdb; 956 957 $bp = buddypress(); 936 958 937 959 if ( empty( $bp->profile->table_name_fields ) || !isset( $field_name ) ) … … 942 964 943 965 public static function update_position( $field_id, $position, $field_group_id ) { 944 global $wpdb , $bp;966 global $wpdb; 945 967 946 968 if ( !is_numeric( $position ) || !is_numeric( $field_group_id ) ) 947 969 return false; 970 971 $bp = buddypress(); 948 972 949 973 // Update $field_id with new $position and $field_group_id … … 1221 1245 1222 1246 public function populate( $field_id, $user_id ) { 1223 global $wpdb , $bp;1247 global $wpdb; 1224 1248 1225 1249 $cache_key = "{$user_id}:{$field_id}"; … … 1227 1251 1228 1252 if ( false === $profiledata ) { 1253 $bp = buddypress(); 1254 1229 1255 $sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id ); 1230 1256 $profiledata = $wpdb->get_row( $sql ); … … 1257 1283 */ 1258 1284 public function exists() { 1259 global $wpdb , $bp;1285 global $wpdb; 1260 1286 1261 1287 // Check cache first … … 1266 1292 $retval = true; 1267 1293 } else { 1294 $bp = buddypress(); 1268 1295 $retval = $wpdb->get_row( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = %d", $this->user_id, $this->field_id ) ); 1269 1296 } … … 1284 1311 * 1285 1312 * @global object $wpdb 1286 * @global array $bp1287 1313 * @return bool 1288 1314 */ 1289 1315 public function is_valid_field() { 1290 global $wpdb, $bp; 1316 global $wpdb; 1317 1318 $bp = buddypress(); 1291 1319 1292 1320 $retval = $wpdb->get_row( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE id = %d", $this->field_id ) ); … … 1304 1332 1305 1333 public function save() { 1306 global $wpdb, $bp; 1334 global $wpdb; 1335 1336 $bp = buddypress(); 1307 1337 1308 1338 $this->user_id = apply_filters( 'xprofile_data_user_id_before_save', $this->user_id, $this->id ); … … 1509 1539 */ 1510 1540 public static function get_fielddataid_byid( $field_id, $user_id ) { 1511 global $wpdb , $bp;1541 global $wpdb; 1512 1542 1513 1543 if ( empty( $field_id ) || empty( $user_id ) ) { 1514 1544 $fielddata_id = 0; 1515 1545 } else { 1546 $bp = buddypress(); 1516 1547 1517 1548 // Check cache first … … 1539 1570 */ 1540 1571 public static function get_value_byid( $field_id, $user_ids = null ) { 1541 global $wpdb , $bp;1572 global $wpdb; 1542 1573 1543 1574 if ( empty( $user_ids ) ) { … … 1562 1593 // Prime caches 1563 1594 if ( ! empty( $uncached_ids ) ) { 1595 $bp = buddypress(); 1564 1596 $uncached_ids_sql = implode( ',', $uncached_ids ); 1565 1597 $queried_data = $wpdb->get_results( $wpdb->prepare( "SELECT id, user_id, field_id, value, last_updated FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id IN ({$uncached_ids_sql})", $field_id ) ); … … 1610 1642 1611 1643 public static function get_value_byfieldname( $fields, $user_id = null ) { 1612 global $ bp, $wpdb;1644 global $wpdb; 1613 1645 1614 1646 if ( empty( $fields ) ) 1615 1647 return false; 1648 1649 $bp = buddypress(); 1616 1650 1617 1651 if ( empty( $user_id ) ) … … 1659 1693 1660 1694 public static function delete_for_field( $field_id ) { 1661 global $wpdb, $bp; 1695 global $wpdb; 1696 1697 $bp = buddypress(); 1662 1698 1663 1699 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE field_id = %d", $field_id ) ) ) … … 1668 1704 1669 1705 public static function get_last_updated( $user_id ) { 1670 global $wpdb, $bp; 1706 global $wpdb; 1707 1708 $bp = buddypress(); 1671 1709 1672 1710 $last_updated = $wpdb->get_var( $wpdb->prepare( "SELECT last_updated FROM {$bp->profile->table_name_data} WHERE user_id = %d ORDER BY last_updated LIMIT 1", $user_id ) ); … … 1676 1714 1677 1715 public static function delete_data_for_user( $user_id ) { 1678 global $wpdb, $bp; 1716 global $wpdb; 1717 1718 $bp = buddypress(); 1679 1719 1680 1720 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d", $user_id ) ); … … 1682 1722 1683 1723 public static function get_random( $user_id, $exclude_fullname ) { 1684 global $wpdb , $bp;1724 global $wpdb; 1685 1725 1686 1726 $exclude_sql = ! empty( $exclude_fullname ) ? ' AND pf.id != 1' : ''; 1727 1728 $bp = buddypress(); 1687 1729 1688 1730 return $wpdb->get_results( $wpdb->prepare( "SELECT pf.type, pf.name, pd.value FROM {$bp->profile->table_name_data} pd INNER JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id AND pd.user_id = %d {$exclude_sql} ORDER BY RAND() LIMIT 1", $user_id ) ); -
trunk/src/bp-xprofile/bp-xprofile-functions.php
r9351 r9471 218 218 */ 219 219 function xprofile_insert_field( $args = '' ) { 220 global $bp;221 220 222 221 $r = wp_parse_args( $args, array( … … 240 239 241 240 // Check this is a valid field type 242 if ( ! in_array( $r['type'], (array) $bp->profile->field_types ) ) {241 if ( ! in_array( $r['type'], (array) buddypress()->profile->field_types ) ) { 243 242 return false; 244 243 } … … 1022 1021 */ 1023 1022 function bp_xprofile_get_visibility_levels() { 1024 global $bp;1025 1023 1026 1024 /** … … 1031 1029 * @param array $visibility_levels Array of visibility levels. 1032 1030 */ 1033 return apply_filters( 'bp_xprofile_get_visibility_levels', $bp->profile->visibility_levels );1031 return apply_filters( 'bp_xprofile_get_visibility_levels', buddypress()->profile->visibility_levels ); 1034 1032 } 1035 1033 -
trunk/src/bp-xprofile/bp-xprofile-template.php
r9351 r9471 370 370 } 371 371 function bp_get_the_profile_group_edit_form_action() { 372 global $bp, $group; 372 global $group; 373 374 $bp = buddypress(); 373 375 374 376 /** … … 845 847 */ 846 848 function bp_profile_group_tabs() { 847 global $bp, $group_name; 848 849 global $group_name; 850 851 $bp = buddypress(); 849 852 $groups = bp_profile_get_field_groups(); 850 853 … … 967 970 } 968 971 function bp_get_avatar_delete_link() { 969 global $bp;972 $bp = buddypress(); 970 973 971 974 /** … … 980 983 981 984 function bp_edit_profile_button() { 982 global $bp;985 $bp = buddypress(); 983 986 984 987 bp_button( array ( -
trunk/tests/phpunit/includes/testcase.php
r9282 r9471 328 328 * user during tests. BP caches the current user differently, so we 329 329 * have to do a bit more work to change it 330 *331 * @global BuddyPres $bp332 330 */ 333 331 public static function set_current_user( $user_id ) { 334 global $bp; 332 $bp = buddypress(); 333 335 334 $bp->loggedin_user->id = $user_id; 336 335 $bp->loggedin_user->fullname = bp_core_get_user_displayname( $user_id ); -
trunk/tests/phpunit/testcases/activity/template.php
r9417 r9471 22 22 */ 23 23 public function test_user_can_delete() { 24 global $bp;24 $bp = buddypress(); 25 25 26 26 $a = $this->factory->activity->create( array( … … 134 134 'action' => 'activity_update', 135 135 ) ); 136 137 global $wpdb, $bp;138 136 139 137 $ids = wp_list_pluck( $activities_template->activities, 'id' ); -
trunk/tests/phpunit/testcases/core/cache.php
r8958 r9471 14 14 15 15 // Confirm that all activitymeta is deleted 16 global $wpdb, $bp; 16 global $wpdb; 17 18 $bp = buddypress(); 19 17 20 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name_meta} WHERE activity_id = %d", $a1 ) ); 18 21 -
trunk/tests/phpunit/testcases/groups/functions.php
r9139 r9471 442 442 443 443 // Get rid of any auto-created values 444 global $wpdb, $bp; 444 global $wpdb; 445 446 $bp = buddypress(); 445 447 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_groupmeta} WHERE group_id = %d", $g ) ); 446 448 wp_cache_delete( $g, 'group_meta' ); -
trunk/tests/phpunit/testcases/members/functions.php
r9398 r9471 172 172 */ 173 173 public function test_bp_core_get_user_displayname_xprofile_does_not_exist() { 174 $bp = buddypress(); 174 175 $xprofile_is_active = bp_is_active( 'xprofile' ); 175 buddypress()->active_components['xprofile'] = '1';176 $bp->active_components['xprofile'] = '1'; 176 177 177 178 $u = $this->factory->user->create( array( … … 181 182 // Delete directly because BP won't let you delete a required 182 183 // field through the API 183 global $wpdb , $bp;184 global $wpdb; 184 185 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = 1", $u ) ); 185 186 wp_cache_delete( 'bp_user_fullname_' . $u, 'bp' ); … … 191 192 192 193 if ( ! $xprofile_is_active ) { 193 unset( buddypress()->active_components['xprofile'] );194 unset( $bp->active_components['xprofile'] ); 194 195 } 195 196 } … … 233 234 // Delete directly because BP won't let you delete a required 234 235 // field through the API 235 global $wpdb, $bp; 236 global $wpdb; 237 $bp = buddypress(); 236 238 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = 1", $u2 ) ); 237 239 wp_cache_delete( 'bp_user_fullname_' . $u2, 'bp' ); … … 378 380 379 381 // Create an existing entry in last_activity to test no dupes 380 global $wpdb, $bp; 382 global $wpdb; 383 $bp = buddypress(); 381 384 $wpdb->query( $wpdb->prepare( 382 385 "INSERT INTO {$bp->members->table_name_last_activity}
Note: See TracChangeset
for help on using the changeset viewer.