Ticket #6388: 6388.04.patch
| File 6388.04.patch, 12.6 KB (added by , 10 years ago) |
|---|
-
src/bp-core/bp-core-template.php
diff --git src/bp-core/bp-core-template.php src/bp-core/bp-core-template.php index a89a0e4..8bf0cfd 100644
function bp_is_group() { 2477 2477 * @return bool True if the current page is a single group's home page. 2478 2478 */ 2479 2479 function bp_is_group_home() { 2480 $retval = false; 2481 2480 2482 if ( bp_is_single_item() && bp_is_groups_component() && ( ! bp_current_action() || bp_is_current_action( 'home' ) ) ) { 2481 returntrue;2483 $retval = true; 2482 2484 } 2483 2485 2484 return false; 2486 // Get BuddyPress instance 2487 $bp = buddypress(); 2488 2489 /** 2490 * Since 2.4.0 The group home is not necessarly the activity page, this part 2491 * is making sure outdated templates will still be able to post activities 2492 * if the group has a custom front template. 2493 */ 2494 if ( isset( $bp->groups->is_activity ) && true === $bp->groups->is_activity ) { 2495 $retval = true; 2496 2497 // Reset the backcompat global 2498 unset( $bp->groups->is_activity ); 2499 } 2500 2501 return $retval; 2485 2502 } 2486 2503 2487 2504 /** … … function bp_is_group_forum() { 2534 2551 * @return True if the current page is a group's activity page. 2535 2552 */ 2536 2553 function bp_is_group_activity() { 2537 return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ); 2554 $retval = false; 2555 2556 if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ) { 2557 $retval = true; 2558 } 2559 2560 if ( bp_is_group_home() && bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) { 2561 $retval = true; 2562 } 2563 2564 return $retval; 2538 2565 } 2539 2566 2540 2567 /** … … function bp_is_group_forum_topic_edit() { 2567 2594 * @return bool True if the current page is part of a group's Members page. 2568 2595 */ 2569 2596 function bp_is_group_members() { 2570 return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ); 2597 $retval = false; 2598 2599 if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ) { 2600 $retval = true; 2601 } 2602 2603 if ( bp_is_group_home() && ! bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) { 2604 $retval = true; 2605 } 2606 2607 return $retval; 2571 2608 } 2572 2609 2573 2610 /** … … function bp_is_group_single() { 2615 2652 } 2616 2653 2617 2654 /** 2655 * Is the current group page a custom front? 2656 * 2657 * @since 2.4.0 2658 * 2659 * @return bool True if the current group page is a custom front. 2660 */ 2661 function bp_is_group_custom_front() { 2662 $bp = buddypress(); 2663 return (bool) bp_is_group_home() && ! empty( $bp->groups->current_group->front_template ); 2664 } 2665 2666 /** 2618 2667 * Is the current page the Create a Blog page? 2619 2668 * 2620 2669 * Eg http://example.com/sites/create/. -
src/bp-groups/bp-groups-activity.php
diff --git src/bp-groups/bp-groups-activity.php src/bp-groups/bp-groups-activity.php index 5235f76..d48d801 100644
function bp_groups_leave_group_delete_recent_activity( $group_id, $user_id ) { 577 577 add_action( 'groups_leave_group', 'bp_groups_leave_group_delete_recent_activity', 10, 2 ); 578 578 add_action( 'groups_remove_member', 'bp_groups_leave_group_delete_recent_activity', 10, 2 ); 579 579 add_action( 'groups_ban_member', 'bp_groups_leave_group_delete_recent_activity', 10, 2 ); 580 581 /** 582 * Back compatibility for outdated templates using a custom front.php template 583 * 584 * @since 2.4.0 585 * 586 * @param string $bp_version The current BuddyPress version 587 */ 588 function bp_groups_backcompat_is_group_activity( $bp_version = '' ) { 589 // The template is up to date :) 590 if ( $bp_version === '2.4.0' ) { 591 return; 592 } 593 594 /** 595 * Outdated templates are not using the bp_is_group_activity() 596 * conditional tag, but are still using bp_is_group_home(). 597 * 598 * If a custom front template is found, the activity page won't be at 599 * the home level. So we need to use a global to inform bp_is_group_home() 600 * it should be true to let group members post activities within the 601 * group's activity page. 602 */ 603 if ( bp_is_group_activity() && ! bp_is_group_home() ) { 604 buddypress()->groups->is_activity = true; 605 606 // Inform theme developers 607 _doing_it_wrong( 'activity/post-form.php', __( "The activity post form template is outdated, please make sure to use bp_is_group_activity() instead of bp_is_group_home().", 'buddypress' ), 'BP 2.4.0' ); 608 } 609 } 610 add_action( 'bp_before_activity_post_form', 'bp_groups_backcompat_is_group_activity', 10, 1 ); -
src/bp-groups/bp-groups-loader.php
diff --git src/bp-groups/bp-groups-loader.php src/bp-groups/bp-groups-loader.php index 0949b8a..f4c1d72 100644
class BP_Groups_Component extends BP_Component { 251 251 $this->current_group->user_has_access = true; 252 252 } 253 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 ); 256 254 257 // Set current_group to 0 to prevent debug errors 255 258 } else { 256 259 $this->current_group = 0; … … class BP_Groups_Component extends BP_Component { 364 367 365 368 $bp = buddypress(); 366 369 370 // If the activity component is not active and the current group has no custom front, members are displayed in the home nav 371 if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) { 372 $this->default_extension = 'home'; 373 } 374 367 375 if ( ! bp_current_action() ) { 368 376 $bp->current_action = $this->default_extension; 369 377 } … … class BP_Groups_Component extends BP_Component { 520 528 ); 521 529 } 522 530 523 $sub_nav[] = array( 524 'name' => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ), 525 'slug' => 'members', 526 'parent_url' => $group_link, 527 'parent_slug' => $this->current_group->slug, 528 'screen_function' => 'groups_screen_group_members', 529 'position' => 60, 530 'user_has_access' => $this->current_group->user_has_access, 531 'item_css_id' => 'members', 532 'no_access_url' => $group_link, 533 ); 531 if ( $this->current_group->front_template || bp_is_active( 'activity' ) ) { 532 /** 533 * If the theme is using a custom front, create activity subnav. 534 */ 535 if ( $this->current_group->front_template && bp_is_active( 'activity' ) ) { 536 $sub_nav[] = array( 537 'name' => _x( 'Activity', 'My Group screen nav', 'buddypress' ), 538 'slug' => 'activity', 539 'parent_url' => $group_link, 540 'parent_slug' => $this->current_group->slug, 541 'screen_function' => 'groups_screen_group_activity', 542 'position' => 11, 543 'user_has_access' => $this->current_group->user_has_access, 544 'item_css_id' => 'activity', 545 'no_access_url' => $group_link, 546 ); 547 } 548 549 /** 550 * Only add the members subnav if it's not the home's nav 551 */ 552 $sub_nav[] = array( 553 'name' => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ), 554 'slug' => 'members', 555 'parent_url' => $group_link, 556 'parent_slug' => $this->current_group->slug, 557 'screen_function' => 'groups_screen_group_members', 558 'position' => 60, 559 'user_has_access' => $this->current_group->user_has_access, 560 'item_css_id' => 'members', 561 'no_access_url' => $group_link, 562 ); 563 } 534 564 535 565 if ( bp_is_active( 'friends' ) && bp_groups_user_can_send_invites() ) { 536 566 $sub_nav[] = array( -
src/bp-groups/bp-groups-screens.php
diff --git src/bp-groups/bp-groups-screens.php src/bp-groups/bp-groups-screens.php index 325c4fb..452a0df 100644
function groups_screen_group_request_membership() { 741 741 } 742 742 743 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' ) ); 769 } 770 771 /** 744 772 * Handle the display of a single group activity item. 745 773 */ 746 774 function groups_screen_group_activity_permalink() { -
src/bp-groups/bp-groups-template.php
diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php index 9104ea1..e310821 100644
function bp_group_member_admin_pagination() { 4329 4329 } 4330 4330 4331 4331 /** 4332 * Output the contents of the current group's home page. 4333 * 4334 * You should only use this when on a single group page. 4335 * 4336 * @since 2.4.0 4337 */ 4338 function bp_groups_front_template_part() { 4339 $located = bp_groups_get_front_template(); 4340 4341 if ( false !== $located ) { 4342 $slug = str_replace( '.php', '', $located ); 4343 4344 /** 4345 * Let plugins adding an action to bp_get_template_part get it from here 4346 * 4347 * @param string $slug Template part slug requested. 4348 * @param string $name Template part name requested. 4349 */ 4350 do_action( 'get_template_part_' . $slug, $slug, false ); 4351 4352 load_template( $located, true ); 4353 4354 } else if ( bp_is_active( 'activity' ) ) { 4355 bp_get_template_part( 'groups/single/activity' ); 4356 4357 } else if ( bp_is_active( 'members' ) ) { 4358 bp_groups_members_template_part(); 4359 } 4360 4361 return $located; 4362 } 4363 4364 /** 4365 * Locate a custom group front template if it exists. 4366 * 4367 * @since 2.4.0 4368 * 4369 * @param BP_Groups_Group|null $group Optional. Falls back to current group if not passed. 4370 * @return string|bool Path to front template on success; boolean false on failure. 4371 */ 4372 function bp_groups_get_front_template( $group = null ) { 4373 if ( ! is_a( $group, 'BP_Groups_Group' ) ) { 4374 $group = groups_get_current_group(); 4375 } 4376 4377 if ( ! isset( $group->id ) ) { 4378 return false; 4379 } 4380 4381 if ( isset( $group->front_template ) ) { 4382 return $group->front_template; 4383 } 4384 4385 $template_names = apply_filters( 'bp_groups_get_front_template', array( 4386 'groups/single/front-id-' . sanitize_file_name( $group->id ) . '.php', 4387 'groups/single/front-slug-' . sanitize_file_name( $group->slug ) . '.php', 4388 'groups/single/front-status-' . sanitize_file_name( $group->status ) . '.php', 4389 'groups/single/front.php' 4390 ) ); 4391 4392 return bp_locate_template( $template_names, false, true ); 4393 } 4394 4395 /** 4332 4396 * Output the Group members template 4333 4397 * 4334 4398 * @since 2.0.0 -
src/bp-templates/bp-legacy/buddypress/activity/post-form.php
diff --git src/bp-templates/bp-legacy/buddypress/activity/post-form.php src/bp-templates/bp-legacy/buddypress/activity/post-form.php index fb4f175..c565331 100644
16 16 * Fires before the activity post form. 17 17 * 18 18 * @since 1.2.0 19 * @since 2.4.0 Include a new parameter to hold the BuddyPress version 20 * when the template has evolved. 21 * 22 * Please, make sure to keep the '2.4.0' argument of this hook, in your 23 * custom template 19 24 */ 20 do_action( 'bp_before_activity_post_form' ); ?>25 do_action( 'bp_before_activity_post_form', '2.4.0' ); ?> 21 26 22 27 <div id="whats-new-avatar"> 23 28 <a href="<?php echo bp_loggedin_user_domain(); ?>"> … … 66 71 </div> 67 72 <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" /> 68 73 69 <?php elseif ( bp_is_group_ home() ) : ?>74 <?php elseif ( bp_is_group_activity() ) : ?> 70 75 71 76 <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" /> 72 77 <input type="hidden" id="whats-new-post-in" name="whats-new-post-in" value="<?php bp_group_id(); ?>" /> -
src/bp-templates/bp-legacy/buddypress/groups/single/home.php
diff --git src/bp-templates/bp-legacy/buddypress/groups/single/home.php src/bp-templates/bp-legacy/buddypress/groups/single/home.php index c8e62f4..a64ac89 100644
59 59 60 60 if ( bp_group_is_visible() ) { 61 61 62 // Use custom front if one exists 63 $custom_front = bp_locate_template( array( 'groups/single/front.php' ), false, true ); 64 if ( ! empty( $custom_front ) ) : load_template( $custom_front, true ); 65 66 // Default to activity 67 elseif ( bp_is_active( 'activity' ) ) : bp_get_template_part( 'groups/single/activity' ); 68 69 // Otherwise show members 70 elseif ( bp_is_active( 'members' ) ) : bp_groups_members_template_part(); 71 72 endif; 62 // Load appropriate front template 63 bp_groups_front_template_part(); 73 64 74 65 } else { 75 66