Changeset 10184
- Timestamp:
- 10/04/2015 01:47:36 PM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r10077 r10184 3105 3105 * @uses bp_is_activity_directory() to check if the current page is the activity 3106 3106 * directory. 3107 * @uses bp_is_active() to check if the group component is active.3108 3107 * @uses bp_is_group_activity() to check if on a single group, the current page 3109 3108 * is the group activities. 3110 * @uses bp_is_group_home() to check if the current page is a single group home3111 * page.3112 3109 * 3113 3110 * @return bool True if activity heartbeat is enabled, otherwise false. … … 3120 3117 } 3121 3118 3122 if ( bp_is_activity_directory() ) {3119 if ( bp_is_activity_directory() || bp_is_group_activity() ) { 3123 3120 $retval = true; 3124 3121 } 3125 3122 3126 if ( bp_is_active( 'groups') ) {3127 // If no custom front, then activities are loaded in group's home3128 $has_custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true );3129 3130 if ( bp_is_group_activity() || ( ! $has_custom_front && bp_is_group_home() ) ) {3131 $retval = true;3132 }3133 }3134 3135 3123 return $retval; 3136 3124 } -
trunk/src/bp-core/bp-core-template.php
r10152 r10184 2553 2553 */ 2554 2554 function bp_is_group_activity() { 2555 return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ); 2555 $retval = false; 2556 2557 if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ) { 2558 $retval = true; 2559 } 2560 2561 if ( bp_is_group_home() && bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) { 2562 $retval = true; 2563 } 2564 2565 return $retval; 2556 2566 } 2557 2567 … … 2586 2596 */ 2587 2597 function bp_is_group_members() { 2588 return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ); 2598 $retval = false; 2599 2600 if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ) { 2601 $retval = true; 2602 } 2603 2604 if ( bp_is_group_home() && ! bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) { 2605 $retval = true; 2606 } 2607 2608 return $retval; 2589 2609 } 2590 2610 … … 2631 2651 function bp_is_group_single() { 2632 2652 return (bool) ( bp_is_groups_component() && bp_is_single_item() ); 2653 } 2654 2655 /** 2656 * Is the current group page a custom front? 2657 * 2658 * @since 2.4.0 2659 * 2660 * @return bool True if the current group page is a custom front. 2661 */ 2662 function bp_is_group_custom_front() { 2663 $bp = buddypress(); 2664 return (bool) bp_is_group_home() && ! empty( $bp->groups->current_group->front_template ); 2633 2665 } 2634 2666 -
trunk/src/bp-groups/bp-groups-filters.php
r10148 r10184 270 270 } 271 271 272 if ( $load_mentions || ( bp_is_group_activity() || bp_is_group_home()) ) {272 if ( $load_mentions || bp_is_group_activity() ) { 273 273 return true; 274 274 } -
trunk/src/bp-groups/bp-groups-loader.php
r10158 r10184 251 251 $this->current_group->user_has_access = true; 252 252 } 253 254 // Check once if the current group has a custom front template 255 $this->current_group->front_template = bp_groups_get_front_template( $this->current_group ); 253 256 254 257 // Set current_group to 0 to prevent debug errors … … 372 375 $bp = buddypress(); 373 376 377 // If the activity component is not active and the current group has no custom front, members are displayed in the home nav 378 if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) { 379 $this->default_extension = 'home'; 380 } 381 374 382 if ( ! bp_current_action() ) { 375 383 $bp->current_action = $this->default_extension; … … 528 536 } 529 537 530 $sub_nav[] = array( 531 'name' => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ), 532 'slug' => 'members', 533 'parent_url' => $group_link, 534 'parent_slug' => $this->current_group->slug, 535 'screen_function' => 'groups_screen_group_members', 536 'position' => 60, 537 'user_has_access' => $this->current_group->user_has_access, 538 'item_css_id' => 'members', 539 'no_access_url' => $group_link, 540 ); 538 if ( $this->current_group->front_template || bp_is_active( 'activity' ) ) { 539 /** 540 * If the theme is using a custom front, create activity subnav. 541 */ 542 if ( $this->current_group->front_template && bp_is_active( 'activity' ) ) { 543 $sub_nav[] = array( 544 'name' => _x( 'Activity', 'My Group screen nav', 'buddypress' ), 545 'slug' => 'activity', 546 'parent_url' => $group_link, 547 'parent_slug' => $this->current_group->slug, 548 'screen_function' => 'groups_screen_group_activity', 549 'position' => 11, 550 'user_has_access' => $this->current_group->user_has_access, 551 'item_css_id' => 'activity', 552 'no_access_url' => $group_link, 553 ); 554 } 555 556 /** 557 * Only add the members subnav if it's not the home's nav 558 */ 559 $sub_nav[] = array( 560 'name' => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ), 561 'slug' => 'members', 562 'parent_url' => $group_link, 563 'parent_slug' => $this->current_group->slug, 564 'screen_function' => 'groups_screen_group_members', 565 'position' => 60, 566 'user_has_access' => $this->current_group->user_has_access, 567 'item_css_id' => 'members', 568 'no_access_url' => $group_link, 569 ); 570 } 541 571 542 572 if ( bp_is_active( 'friends' ) && bp_groups_user_can_send_invites() ) { -
trunk/src/bp-groups/bp-groups-screens.php
r10158 r10184 739 739 */ 740 740 bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/single/home' ) ); 741 } 742 743 /** 744 * Handle the loading of a single group's activity. 745 * 746 * @since 2.4.0 747 */ 748 function groups_screen_group_activity() { 749 750 if ( ! bp_is_single_item() ) { 751 return false; 752 } 753 754 /** 755 * Fires before the loading of a single group's activity page. 756 * 757 * @since 2.4.0 758 */ 759 do_action( 'groups_screen_group_activity' ); 760 761 /** 762 * Filters the template to load for a single group's activity page. 763 * 764 * @since 2.4.0 765 * 766 * @param string $value Path to a single group's template to load. 767 */ 768 bp_core_load_template( apply_filters( 'groups_screen_group_activity', 'groups/single/activity' ) ); 741 769 } 742 770 -
trunk/src/bp-groups/bp-groups-template.php
r10160 r10184 4344 4344 4345 4345 /** 4346 * Output the contents of the current group's home page. 4347 * 4348 * You should only use this when on a single group page. 4349 * 4350 * @since 2.4.0 4351 */ 4352 function bp_groups_front_template_part() { 4353 $located = bp_groups_get_front_template(); 4354 4355 if ( false !== $located ) { 4356 $slug = str_replace( '.php', '', $located ); 4357 4358 /** 4359 * Let plugins adding an action to bp_get_template_part get it from here 4360 * 4361 * @param string $slug Template part slug requested. 4362 * @param string $name Template part name requested. 4363 */ 4364 do_action( 'get_template_part_' . $slug, $slug, false ); 4365 4366 load_template( $located, true ); 4367 4368 } else if ( bp_is_active( 'activity' ) ) { 4369 bp_get_template_part( 'groups/single/activity' ); 4370 4371 } else if ( bp_is_active( 'members' ) ) { 4372 bp_groups_members_template_part(); 4373 } 4374 4375 return $located; 4376 } 4377 4378 /** 4379 * Locate a custom group front template if it exists. 4380 * 4381 * @since 2.4.0 4382 * 4383 * @param BP_Groups_Group|null $group Optional. Falls back to current group if not passed. 4384 * @return string|bool Path to front template on success; boolean false on failure. 4385 */ 4386 function bp_groups_get_front_template( $group = null ) { 4387 if ( ! is_a( $group, 'BP_Groups_Group' ) ) { 4388 $group = groups_get_current_group(); 4389 } 4390 4391 if ( ! isset( $group->id ) ) { 4392 return false; 4393 } 4394 4395 if ( isset( $group->front_template ) ) { 4396 return $group->front_template; 4397 } 4398 4399 $template_names = apply_filters( 'bp_groups_get_front_template', array( 4400 'groups/single/front-id-' . sanitize_file_name( $group->id ) . '.php', 4401 'groups/single/front-slug-' . sanitize_file_name( $group->slug ) . '.php', 4402 'groups/single/front-status-' . sanitize_file_name( $group->status ) . '.php', 4403 'groups/single/front.php' 4404 ) ); 4405 4406 return bp_locate_template( $template_names, false, true ); 4407 } 4408 4409 /** 4346 4410 * Output the Group members template 4347 4411 * -
trunk/src/bp-templates/bp-legacy/buddypress-functions.php
r10180 r10184 929 929 930 930 $activity_id = 0; 931 if ( empty( $_POST['object'] ) && bp_is_active( 'activity' ) ) { 931 $item_id = 0; 932 $object = ''; 933 934 935 // Try to get the item id from posted variables. 936 if ( ! empty( $_POST['item_id'] ) ) { 937 $item_id = (int) $_POST['item_id']; 938 } 939 940 // Try to get the object from posted variables. 941 if ( ! empty( $_POST['object'] ) ) { 942 $object = sanitize_key( $_POST['object'] ); 943 944 // If the object is not set and we're in a group, set the item id and the object 945 } elseif ( bp_is_group() ) { 946 $item_id = bp_get_current_group_id(); 947 $object = 'groups'; 948 } 949 950 if ( ! $object && bp_is_active( 'activity' ) ) { 932 951 $activity_id = bp_activity_post_update( array( 'content' => $_POST['content'] ) ); 933 952 934 } elseif ( $_POST['object'] == 'groups') {935 if ( ! empty( $_POST['item_id'] )&& bp_is_active( 'groups' ) )936 $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $ _POST['item_id']) );953 } elseif ( 'groups' === $object ) { 954 if ( $item_id && bp_is_active( 'groups' ) ) 955 $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $item_id ) ); 937 956 938 957 } else { 939 958 940 959 /** This filter is documented in bp-activity/bp-activity-actions.php */ 941 $activity_id = apply_filters( 'bp_activity_custom_update', false, $ _POST['object'], $_POST['item_id'], $_POST['content'] );960 $activity_id = apply_filters( 'bp_activity_custom_update', false, $object, $item_id, $_POST['content'] ); 942 961 } 943 962 -
trunk/src/bp-templates/bp-legacy/buddypress/activity/post-form.php
r10150 r10184 67 67 <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" /> 68 68 69 <?php elseif ( bp_is_group_ home() ) : ?>69 <?php elseif ( bp_is_group_activity() ) : ?> 70 70 71 71 <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" /> -
trunk/src/bp-templates/bp-legacy/buddypress/groups/single/home.php
r10181 r10184 78 78 if ( bp_group_is_visible() ) { 79 79 80 // Use custom front if one exists 81 $custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true ); 82 if ( ! empty( $custom_front ) ) : load_template( $custom_front, true ); 83 84 // Default to activity 85 elseif ( bp_is_active( 'activity' ) ) : bp_get_template_part( 'groups/single/activity' ); 86 87 // Otherwise show members 88 elseif ( bp_is_active( 'members' ) ) : bp_groups_members_template_part(); 89 90 endif; 80 // Load appropriate front template 81 bp_groups_front_template_part(); 91 82 92 83 } else {
Note: See TracChangeset
for help on using the changeset viewer.