Skip to:
Content

BuddyPress.org

Ticket #6388: 6388.03.patch

File 6388.03.patch, 9.2 KB (added by r-a-y, 10 years ago)
  • src/bp-core/bp-core-template.php

     
    25342534 * @return True if the current page is a group's activity page.
    25352535 */
    25362536function bp_is_group_activity() {
    2537         return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) );
     2537        $retval = false;
     2538
     2539        if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ) {
     2540                $retval = true;
     2541        }
     2542
     2543        if ( bp_is_group_home() && bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
     2544                $retval = true;
     2545        }
     2546
     2547        return $retval;
    25382548}
    25392549
    25402550/**
     
    25672577 * @return bool True if the current page is part of a group's Members page.
    25682578 */
    25692579function bp_is_group_members() {
    2570         return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) );
     2580        $retval = false;
     2581
     2582        if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ) {
     2583                $retval = true;
     2584        }
     2585
     2586        if ( bp_is_group_home() && ! bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
     2587                $retval = true;
     2588        }
     2589
     2590        return $retval;
    25712591}
    25722592
    25732593/**
     
    26152635}
    26162636
    26172637/**
     2638 * Is the current group page a custom front?
     2639 *
     2640 * @since 2.4.0
     2641 *
     2642 * @return bool True if the current group page is a custom front.
     2643 */
     2644function bp_is_group_custom_front() {
     2645        $bp = buddypress();
     2646        return (bool) bp_is_group_home() && ! empty( $bp->groups->current_group->front_template );
     2647}
     2648
     2649/**
    26182650 * Is the current page the Create a Blog page?
    26192651 *
    26202652 * Eg http://example.com/sites/create/.
  • src/bp-groups/bp-groups-loader.php

     
    252252                                $this->current_group->user_has_access = true;
    253253                        }
    254254
     255                        // Check once if the current group has a custom front template
     256                        $this->current_group->front_template = bp_groups_get_front_template( $this->current_group );
     257
    255258                // Set current_group to 0 to prevent debug errors
    256259                } else {
    257260                        $this->current_group = 0;
     
    365368
    366369                $bp = buddypress();
    367370
     371                // If the activity component is not active and the current group has no custom front, members are displayed in the home nav
     372                if ( 'members' === $this->default_extension && ! bp_is_active( 'activity' ) && ! $this->current_group->front_template ) {
     373                        $this->default_extension = 'home';
     374                }
     375
    368376                if ( ! bp_current_action() ) {
    369377                        $bp->current_action = $this->default_extension;
    370378                }
     
    521529                                );
    522530                        }
    523531
    524                         $sub_nav[] = array(
    525                                 'name'            => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
    526                                 'slug'            => 'members',
    527                                 'parent_url'      => $group_link,
    528                                 'parent_slug'     => $this->current_group->slug,
    529                                 'screen_function' => 'groups_screen_group_members',
    530                                 'position'        => 60,
    531                                 'user_has_access' => $this->current_group->user_has_access,
    532                                 'item_css_id'     => 'members',
    533                                 'no_access_url'   => $group_link,
    534                         );
     532                        if ( $this->current_group->front_template || bp_is_active( 'activity' ) ) {
     533                                /**
     534                                 * If the theme is using a custom front, create activity subnav.
     535                                 */
     536                                if ( $this->current_group->front_template && bp_is_active( 'activity' ) ) {
     537                                        $sub_nav[] = array(
     538                                                'name'            => _x( 'Activity', 'My Group screen nav', 'buddypress' ),
     539                                                'slug'            => 'activity',
     540                                                'parent_url'      => $group_link,
     541                                                'parent_slug'     => $this->current_group->slug,
     542                                                'screen_function' => 'groups_screen_group_activity',
     543                                                'position'        => 11,
     544                                                'user_has_access' => $this->current_group->user_has_access,
     545                                                'item_css_id'     => 'activity',
     546                                                'no_access_url'   => $group_link,
     547                                        );
     548                                }
     549
     550                                /**
     551                                 * Only add the members subnav if it's not the home's nav
     552                                 */
     553                                $sub_nav[] = array(
     554                                        'name'            => sprintf( _x( 'Members <span>%s</span>', 'My Group screen nav', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
     555                                        'slug'            => 'members',
     556                                        'parent_url'      => $group_link,
     557                                        'parent_slug'     => $this->current_group->slug,
     558                                        'screen_function' => 'groups_screen_group_members',
     559                                        'position'        => 60,
     560                                        'user_has_access' => $this->current_group->user_has_access,
     561                                        'item_css_id'     => 'members',
     562                                        'no_access_url'   => $group_link,
     563                                );
     564                        }
    535565
    536566                        if ( bp_is_active( 'friends' ) && bp_groups_user_can_send_invites() ) {
    537567                                $sub_nav[] = array(
  • src/bp-groups/bp-groups-screens.php

     
    742742}
    743743
    744744/**
     745 * Handle the loading of a single group's activity.
     746 *
     747 * @since 2.4.0
     748 */
     749function groups_screen_group_activity() {
     750
     751        if ( ! bp_is_single_item() ) {
     752                return false;
     753        }
     754
     755        /**
     756         * Fires before the loading of a single group's activity page.
     757         *
     758         * @since 2.4.0
     759         */
     760        do_action( 'groups_screen_group_activity' );
     761
     762        /**
     763         * Filters the template to load for a single group's activity page.
     764         *
     765         * @since 2.4.0
     766         *
     767         * @param string $value Path to a single group's template to load.
     768         */
     769        bp_core_load_template( apply_filters( 'groups_screen_group_activity', 'groups/single/activity' ) );
     770}
     771
     772/**
    745773 * Handle the display of a single group activity item.
    746774 */
    747775function groups_screen_group_activity_permalink() {
  • src/bp-groups/bp-groups-template.php

     
    43274327        }
    43284328
    43294329/**
     4330 * Output the contents of the current group's home page.
     4331 *
     4332 * You should only use this when on a single group page.
     4333 *
     4334 * @since 2.4.0
     4335 */
     4336function bp_groups_front_template_part() {
     4337        $located = bp_groups_get_front_template();
     4338
     4339        if ( false !== $located ) {
     4340                $slug = str_replace( '.php', '', $located );
     4341
     4342                /**
     4343                 * Let plugins adding an action to bp_get_template_part get it from here
     4344                 *
     4345                 * @param string $slug Template part slug requested.
     4346                 * @param string $name Template part name requested.
     4347                 */
     4348                do_action( 'get_template_part_' . $slug, $slug, false );
     4349
     4350                load_template( $located, true );
     4351
     4352        } else if ( bp_is_active( 'activity' ) ) {
     4353                bp_get_template_part( 'groups/single/activity' );
     4354
     4355        } else if ( bp_is_active( 'members'  ) ) {
     4356                bp_groups_members_template_part();
     4357        }
     4358
     4359        return $located;
     4360}
     4361
     4362/**
     4363 * Locate a custom group front template if it exists.
     4364 *
     4365 * @since 2.4.0
     4366 *
     4367 * @param  BP_Groups_Group|null $group Optional. Falls back to current group if not passed.
     4368 * @return string|bool                 Path to front template on success; boolean false on failure.
     4369 */
     4370function bp_groups_get_front_template( $group = null ) {
     4371        if ( ! is_a( $group, 'BP_Groups_Group' ) ) {
     4372                $group = groups_get_current_group();
     4373        }
     4374
     4375        if ( ! isset( $group->id ) ) {
     4376                return false;
     4377        }
     4378
     4379        if ( isset( $group->front_template ) ) {
     4380                return $group->front_template;
     4381        }
     4382
     4383        $template_names = apply_filters( 'bp_groups_get_front_template', array(
     4384                'groups/single/front-id-'     . sanitize_file_name( $group->id )     . '.php',
     4385                'groups/single/front-slug-'   . sanitize_file_name( $group->slug )   . '.php',
     4386                'groups/single/front-status-' . sanitize_file_name( $group->status ) . '.php',
     4387                'groups/single/front.php'
     4388        ) );
     4389
     4390        return bp_locate_template( $template_names, false, true );
     4391}
     4392
     4393/**
    43304394 * Output the Group members template
    43314395 *
    43324396 * @since BuddyPress (2.0.0)
  • src/bp-templates/bp-legacy/buddypress/activity/post-form.php

     
    6767                                </div>
    6868                                <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
    6969
    70                         <?php elseif ( bp_is_group_home() ) : ?>
     70                        <?php elseif ( bp_is_group_activity() ) : ?>
    7171
    7272                                <input type="hidden" id="whats-new-post-object" name="whats-new-post-object" value="groups" />
    7373                                <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

     
    5959
    6060                                if ( bp_group_is_visible() ) {
    6161
    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();
    7364
    7465                                } else {
    7566