Skip to:
Content

BuddyPress.org

Ticket #4639: 4639-ray.03.patch

File 4639-ray.03.patch, 6.9 KB (added by r-a-y, 8 years ago)
  • bp-activity/bp-activity-screens.php

    add_action( 'bp_notification_settings', 'bp_activity_screen_notification_setting 
    309309 * The main theme compat class for BuddyPress Activity
    310310 *
    311311 * This class sets up the necessary theme compatability actions to safely output
    312  * group template parts to the_title and the_content areas of a theme.
     312 * activity template parts to the_title and the_content areas of a theme.
    313313 *
    314314 * @since BuddyPress (1.7)
    315315 */
    class BP_Activity_Theme_Compat { 
    322322         */
    323323        public function __construct() {
    324324                add_action( 'bp_setup_theme_compat', array( $this, 'is_activity' ) );
     325                add_filter( 'bp_get_root_template',  array( $this, 'template_hierarchy' ), 10, 2 );
    325326        }
    326327
    327328        /**
    class BP_Activity_Theme_Compat { 
    351352                }
    352353        }
    353354
     355        /**
     356         * Add custom template hierarchy to theme compat for activity pages.
     357         *
     358         * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
     359         *
     360         * @since BuddyPress (1.7)
     361         *
     362         * @param string $template The template theme compat should look for before falling back to the default.
     363         * @param string $page_template The page template used to inject BP content into.
     364         * @return array|bool $templates Array of custom templates to look for. Boolean false if not a member page.
     365         * @uses bp_get_query_template() Retrieve paths to a template.
     366         */
     367        public function template_hierarchy( $template, $page_template ) {
     368                // We're only worried about single activity pages at the moment, so bail if
     369                // not on a single activity permalink page
     370                if ( ! bp_is_single_activity() )
     371                        return $template;
     372
     373                // Setup some variables we're going to reference in our custom templates
     374                $user_nicename = sanitize_file_name( buddypress()->displayed_user->userdata->user_nicename );
     375                $user_id       = bp_displayed_user_id();
     376
     377                // Setup our templates based on priority
     378                $templates = array(
     379                        'members/single/custom/single-activity-nicename-' . $user_nicename . '.php',
     380                        'members/single/custom/single-activity-userid-'   . $user_id  .      '.php',
     381                );
     382
     383                return bp_get_query_template( 'activity_permalink', $templates );
     384        }
     385
    354386        /** Directory *************************************************************/
    355387
    356388        /**
  • bp-groups/bp-groups-screens.php

    class BP_Groups_Theme_Compat { 
    905905         */
    906906        public function __construct() {
    907907                add_action( 'bp_setup_theme_compat', array( $this, 'is_group' ) );
     908                add_filter( 'bp_get_root_template',  array( $this, 'template_hierarchy' ), 10, 2 );
    908909        }
    909910
    910911        /**
    class BP_Groups_Theme_Compat { 
    940941                }
    941942        }
    942943
     944        /**
     945         * Add custom template hierarchy to theme compat for group pages.
     946         *
     947         * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
     948         *
     949         * @since BuddyPress (1.7)
     950         *
     951         * @param string $template The template theme compat should look for before falling back to the default.
     952         * @param string $page_template The page template used to inject BP content into.
     953         * @return array|bool $templates Array of custom templates to look for. Boolean false if not a member page.
     954         * @uses bp_get_query_template() Retrieve paths to a template.
     955         */
     956        public function template_hierarchy( $template, $page_template ) {
     957                // Bail if not on a group page
     958                if ( ! bp_is_group() )
     959                        return $template;
     960
     961                // Setup some variables we're going to reference in our custom templates
     962                $group  = buddypress()->groups->current_group;
     963                $action = bp_current_action();
     964
     965                // Setup our templates based on priority
     966                $templates = array(
     967                        'groups/single/custom/slug-'   . $group->slug   . '.php',
     968                        'groups/single/custom/id-'     . $group->id     . '.php',
     969                        'groups/single/custom/status-' . $group->status . '.php'
     970                );
     971
     972                // Add a custom template depending on the group action and if we're not on
     973                // the 'home' action
     974                if ( $action != 'home' )
     975                        $templates[] = 'groups/single/custom/action-' . $action . '.php';
     976
     977                return bp_get_query_template( 'groups', $templates );
     978        }
     979
    943980        /** Directory *************************************************************/
    944981
    945982        /**
  • bp-members/bp-members-screens.php

    add_action( 'bp_screens', 'bp_core_screen_activation' ); 
    266266 * The main theme compat class for BuddyPress Members.
    267267 *
    268268 * This class sets up the necessary theme compatability actions to safely output
    269  * group template parts to the_title and the_content areas of a theme.
     269 * member template parts to the_title and the_content areas of a theme.
    270270 *
    271271 * @since BuddyPress (1.7)
    272272 */
    class BP_Members_Theme_Compat { 
    279279         */
    280280        public function __construct() {
    281281                add_action( 'bp_setup_theme_compat', array( $this, 'is_members' ) );
     282                add_filter( 'bp_get_root_template',  array( $this, 'template_hierarchy' ), 10, 2 );
    282283        }
    283284
    284285        /**
    class BP_Members_Theme_Compat { 
    314315                }
    315316        }
    316317
     318        /**
     319         * Add custom template hierarchy to theme compat for member pages.
     320         *
     321         * This is to mirror how WordPress has {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
     322         *
     323         * @since BuddyPress (1.7)
     324         *
     325         * @param string $template The template theme compat should look for before falling back to the default.
     326         * @param string $page_template The page template used to inject BP content into.
     327         * @return array|bool $templates Array of custom templates to look for. Boolean false if not a member page.
     328         * @uses bp_get_query_template() Retrieve paths to a template.
     329         */
     330        public function template_hierarchy( $template, $page_template ) {
     331                // Bail if not on a member page
     332                if ( ! bp_is_user() )
     333                        return $template;
     334
     335                // Bail if we're on a single activity page
     336                // We handle that in BP_Activity_Theme_Compat::template_hierarchy()
     337                if ( bp_is_active( 'activity' ) && bp_is_single_activity() )
     338                        return $template;
     339
     340                // Setup some variables we're going to reference in our custom templates
     341                $user_nicename = sanitize_file_name( buddypress()->displayed_user->userdata->user_nicename );
     342                $user_id       = bp_displayed_user_id();
     343                $component     = bp_current_component();
     344
     345                // Setup our templates based on priority
     346                $templates = array(
     347                        'members/single/custom/nicename-'  . $user_nicename . '.php',
     348                        'members/single/custom/id-'        . $user_id       . '.php',
     349                        'members/single/custom/component-' . $component     . '.php'
     350                );
     351
     352                return bp_get_query_template( 'members', $templates );
     353        }
     354
    317355        /** Directory *************************************************************/
    318356
    319357        /**