Changeset 10373 for trunk/src/bp-groups/bp-groups-loader.php
- Timestamp:
- 11/22/2015 04:58:34 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-loader.php
r10262 r10373 14 14 defined( 'ABSPATH' ) || exit; 15 15 16 /** 17 * Creates our Groups component. 18 */ 16 19 class BP_Groups_Component extends BP_Component { 17 20 … … 37 40 * @since 1.6.0 38 41 * @todo Is this used anywhere? Is this a duplicate of $default_extension? 42 * @var string 39 43 */ 40 44 var $default_component; … … 136 140 $bp = buddypress(); 137 141 138 // Define a slug, if necessary 142 // Define a slug, if necessary. 139 143 if ( ! defined( 'BP_GROUPS_SLUG' ) ) { 140 144 define( 'BP_GROUPS_SLUG', $this->id ); 141 145 } 142 146 143 // Global tables for groups component 147 // Global tables for groups component. 144 148 $global_tables = array( 145 149 'table_name' => $bp->table_prefix . 'bp_groups', … … 148 152 ); 149 153 150 // Metadata tables for groups component 154 // Metadata tables for groups component. 151 155 $meta_tables = array( 152 156 'group' => $bp->table_prefix . 'bp_groups_groupmeta', … … 168 172 parent::setup_globals( $args ); 169 173 170 /* *Single Group Globals **********************************************/174 /* Single Group Globals **********************************************/ 171 175 172 176 // Are we viewing a single group? … … 215 219 } 216 220 217 // If the user is not an admin, check if they are a moderator 221 // If the user is not an admin, check if they are a moderator. 218 222 if ( ! bp_is_item_admin() ) { 219 223 bp_update_is_item_mod ( groups_is_user_mod ( bp_loggedin_user_id(), $this->current_group->id ), 'groups' ); … … 245 249 } 246 250 247 // Check once if the current group has a custom front template 251 // Check once if the current group has a custom front template. 248 252 $this->current_group->front_template = bp_groups_get_front_template( $this->current_group ); 249 253 250 // Set current_group to 0 to prevent debug errors 254 // Set current_group to 0 to prevent debug errors. 251 255 } else { 252 256 $this->current_group = 0; … … 277 281 ) ); 278 282 279 // If the user was attempting to access a group, but no group by that name was found, 404 283 // If the user was attempting to access a group, but no group by that name was found, 404. 280 284 if ( bp_is_groups_component() && empty( $this->current_group ) && bp_current_action() && !in_array( bp_current_action(), $this->forbidden_names ) ) { 281 285 bp_do_404(); … … 301 305 ) ); 302 306 303 // If avatar uploads are not disabled, add avatar option 307 // If avatar uploads are not disabled, add avatar option. 304 308 $disabled_avatar_uploads = (int) bp_disable_group_avatar_uploads(); 305 309 if ( ! $disabled_avatar_uploads && $bp->avatar->show_avatars ) { … … 317 321 } 318 322 319 // If friends component is active, add invitations 323 // If friends component is active, add invitations. 320 324 if ( bp_is_active( 'friends' ) ) { 321 325 $this->group_creation_steps['group-invites'] = array( … … 338 342 ) ); 339 343 340 // Auto join group when non group member performs group activity 344 // Auto join group when non group member performs group activity. 341 345 $this->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) && BP_DISABLE_AUTO_GROUP_JOIN ? false : true; 342 346 } … … 368 372 $bp = buddypress(); 369 373 370 // If the activity component is not active and the current group has no custom front, members are displayed in the home nav 374 // If the activity component is not active and the current group has no custom front, members are displayed in the home nav. 371 375 if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) { 372 376 $this->default_extension = 'home'; … … 377 381 } 378 382 379 // Prepare for a redirect to the canonical URL 383 // Prepare for a redirect to the canonical URL. 380 384 $bp->canonical_stack['base_url'] = bp_get_group_permalink( $this->current_group ); 381 385 … … 401 405 // When viewing the default extension, the canonical URL should not have 402 406 // that extension's slug, unless more has been tacked onto the URL via 403 // action variables 407 // action variables. 404 408 if ( bp_is_current_action( $this->default_extension ) && empty( $bp->action_variables ) ) { 405 409 unset( $bp->canonical_stack['action'] ); … … 419 423 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 420 424 421 // Determine user to use 425 // Determine user to use. 422 426 if ( bp_displayed_user_domain() ) { 423 427 $user_domain = bp_displayed_user_domain(); … … 428 432 } 429 433 430 // Only grab count if we're on a user page 434 // Only grab count if we're on a user page. 431 435 if ( bp_is_user() ) { 432 436 $count = bp_get_total_group_count_for_user(); … … 439 443 $slug = bp_get_groups_slug(); 440 444 441 // Add 'Groups' to the main navigation 445 // Add 'Groups' to the main navigation. 442 446 $main_nav = array( 443 447 'name' => $nav_name, … … 453 457 $groups_link = trailingslashit( $user_domain . $slug ); 454 458 455 // Add the My Groups nav item 459 // Add the My Groups nav item. 456 460 $sub_nav[] = array( 457 461 'name' => __( 'Memberships', 'buddypress' ), … … 464 468 ); 465 469 466 // Add the Group Invites nav item 470 // Add the Group Invites nav item. 467 471 $sub_nav[] = array( 468 472 'name' => __( 'Invitations', 'buddypress' ), … … 480 484 if ( bp_is_groups_component() && bp_is_single_item() ) { 481 485 482 // Reset sub nav 486 // Reset sub nav. 483 487 $sub_nav = array(); 484 488 485 // Add 'Groups' to the main navigation 489 // Add 'Groups' to the main navigation. 486 490 $main_nav = array( 487 491 'name' => __( 'Memberships', 'buddypress' ), 488 492 'slug' => $this->current_group->slug, 489 'position' => -1, // Do not show in BuddyBar 493 'position' => -1, // Do not show in BuddyBar. 490 494 'screen_function' => 'groups_screen_group_home', 491 495 'default_subnav_slug' => $this->default_extension, … … 495 499 $group_link = bp_get_group_permalink( $this->current_group ); 496 500 497 // Add the "Home" subnav item, as this will always be present 501 // Add the "Home" subnav item, as this will always be present. 498 502 $sub_nav[] = array( 499 503 'name' => _x( 'Home', 'Group screen navigation title', 'buddypress' ), … … 526 530 } 527 531 528 // Forums are enabled and turned on 532 // Forums are enabled and turned on. 529 533 if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) { 530 534 $sub_nav[] = array( … … 559 563 560 564 /** 561 * Only add the members subnav if it's not the home's nav 565 * Only add the members subnav if it's not the home's nav. 562 566 */ 563 567 $sub_nav[] = array( … … 588 592 } 589 593 590 // If the user is a group admin, then show the group admin nav item 594 // If the user is a group admin, then show the group admin nav item. 591 595 if ( bp_is_item_admin() ) { 592 596 $sub_nav[] = array( … … 604 608 $admin_link = trailingslashit( $group_link . 'admin' ); 605 609 606 // Common params to all nav items 610 // Common params to all nav items. 607 611 $default_params = array( 608 612 'parent_url' => $admin_link, … … 692 696 public function setup_admin_bar( $wp_admin_nav = array() ) { 693 697 694 // Menus for logged in user 698 // Menus for logged in user. 695 699 if ( is_user_logged_in() ) { 696 700 697 // Setup the logged in user variables 701 // Setup the logged in user variables. 698 702 $groups_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ); 699 703 700 // Pending group invites 704 // Pending group invites. 701 705 $count = groups_get_invite_count_for_user(); 702 706 $title = _x( 'Groups', 'My Account Groups', 'buddypress' ); … … 708 712 } 709 713 710 // Add the "My Account" sub menus 714 // Add the "My Account" sub menus. 711 715 $wp_admin_nav[] = array( 712 716 'parent' => buddypress()->my_account_menu_id, … … 716 720 ); 717 721 718 // My Groups 722 // My Groups. 719 723 $wp_admin_nav[] = array( 720 724 'parent' => 'my-account-' . $this->id, … … 724 728 ); 725 729 726 // Invitations 730 // Invitations. 727 731 $wp_admin_nav[] = array( 728 732 'parent' => 'my-account-' . $this->id, … … 732 736 ); 733 737 734 // Create a Group 738 // Create a Group. 735 739 if ( bp_user_can_create_groups() ) { 736 740 $wp_admin_nav[] = array( … … 793 797 public function setup_cache_groups() { 794 798 795 // Global groups 799 // Global groups. 796 800 wp_cache_add_global_groups( array( 797 801 'bp_groups',
Note: See TracChangeset
for help on using the changeset viewer.