Skip to:
Content

BuddyPress.org

Changeset 6395


Ignore:
Timestamp:
10/08/2012 09:16:00 AM (12 years ago)
Author:
r-a-y
Message:

Theme Compat:

  • Merge BP_XProfile_Theme_Compat class into the BP_Members_Theme_Compat class.
  • This was done because if the Extended Profiles module was disabled, theme compat would fail on a displayed user's page.
  • Fix PHPDoc in the BP_Members_Theme_Compat class.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-members/bp-members-screens.php

    r6285 r6395  
    264264
    265265/**
    266  * The main theme compat class for BuddyPress Groups
     266 * The main theme compat class for BuddyPress Members.
    267267 *
    268268 * This class sets up the necessary theme compatability actions to safely output
     
    274274
    275275    /**
    276      * Setup the groups component theme compatibility
     276     * Setup the members component theme compatibility
    277277     *
    278278     * @since BuddyPress (1.7)
     
    283283
    284284    /**
    285      * Are we looking at something that needs group theme compatability?
     285     * Are we looking at something that needs members theme compatability?
    286286     *
    287287     * @since BuddyPress (1.7)
     
    289289    public function is_members() {
    290290
    291         // Bail if not looking at a group
    292         if ( ! bp_is_members_component() )
     291        // Bail if not looking at the members component or a user's page
     292        if ( ! bp_is_members_component() && ! bp_displayed_user_id() )
    293293            return;
    294294
    295         // Group Directory
     295        // Members Directory
    296296        if ( ! bp_current_action() && ! bp_current_item() ) {
    297297            bp_update_is_directory( true, 'members' );
    298298
    299             do_action( 'members_directory_groups_setup' );
     299            do_action( 'bp_members_screen_index' );
    300300
    301301            add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) );
    302302            add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
     303
     304        // User page
     305        } elseif ( bp_displayed_user_id() ) {
     306            add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'single_dummy_post'    ) );
     307            add_filter( 'bp_replace_the_content',                    array( $this, 'single_dummy_content' ) );
     308
    303309        }
    304310    }
     
    326332
    327333    /**
    328      * Filter the_content with the groups index template part
     334     * Filter the_content with the members index template part
    329335     *
    330336     * @since BuddyPress (1.7)
     
    333339        bp_buffer_template_part( 'members/index' );
    334340    }
     341
     342    /** Single ****************************************************************/
     343
     344    /**
     345     * Update the global $post with the displayed user's data
     346     *
     347     * @since BuddyPress (1.7)
     348     */
     349    public function single_dummy_post() {
     350        bp_theme_compat_reset_post( array(
     351            'ID'             => 0,
     352            'post_title'     => bp_get_displayed_user_fullname(),
     353            'post_author'    => 0,
     354            'post_date'      => 0,
     355            'post_content'   => '',
     356            'post_type'      => 'bp_members',
     357            'post_status'    => 'publish',
     358            'is_archive'     => true,
     359            'comment_status' => 'closed'
     360        ) );
     361    }
     362
     363    /**
     364     * Filter the_content with the members' single home template part
     365     *
     366     * @since BuddyPress (1.7)
     367     */
     368    public function single_dummy_content() {
     369        bp_buffer_template_part( 'members/single/home' );
     370    }
    335371}
    336372new BP_Members_Theme_Compat();
  • trunk/bp-xprofile/bp-xprofile-screens.php

    r6332 r6395  
    192192    bp_core_load_template( apply_filters( 'xprofile_template_change_avatar', 'members/single/home' ) );
    193193}
    194 
    195 /** Theme Compatability *******************************************************/
    196 
    197 /**
    198  * The main theme compat class for BuddyPress Profiles
    199  *
    200  * This class sets up the necessary theme compatability actions to safely output
    201  * group template parts to the_title and the_content areas of a theme.
    202  *
    203  * @since BuddyPress (1.7)
    204  */
    205 class BP_XProfile_Theme_Compat {
    206 
    207     /**
    208      * Setup the xprofile component theme compatibility
    209      *
    210      * @since BuddyPress (1.7)
    211      *
    212      * @todo is 'bp_screens' correct here?
    213      */
    214     public function __construct() {
    215         add_action( 'bp_setup_theme_compat', array( $this, 'is_xprofile' ) );
    216     }
    217 
    218     /**
    219      * Are we looking at something that needs group theme compatability?
    220      *
    221      * @since BuddyPress (1.7)
    222      */
    223     public function is_xprofile() {
    224 
    225         // Bail if not looking at a profile
    226         if ( ! bp_displayed_user_id() )
    227             return;
    228 
    229         // Creating a group
    230         add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'dummy_post'    ) );
    231         add_filter( 'bp_replace_the_content',                    array( $this, 'dummy_content' ) );
    232     }
    233 
    234     /** Directory *************************************************************/
    235 
    236     /**
    237      * Update the global $post with directory data
    238      *
    239      * @since BuddyPress (1.7)
    240      */
    241     public function dummy_post() {
    242         bp_theme_compat_reset_post( array(
    243             'ID'             => 0,
    244             'post_title'     => bp_get_displayed_user_fullname(),
    245             'post_author'    => 0,
    246             'post_date'      => 0,
    247             'post_content'   => '',
    248             'post_type'      => 'bp_xprofile',
    249             'post_status'    => 'publish',
    250             'is_archive'     => true,
    251             'comment_status' => 'closed'
    252         ) );
    253     }
    254 
    255     /**
    256      * Filter the_content with the groups index template part
    257      *
    258      * @since BuddyPress (1.7)
    259      */
    260     public function dummy_content() {
    261         bp_buffer_template_part( 'members/single/home' );
    262     }
    263 }
    264 new BP_XProfile_Theme_Compat();
Note: See TracChangeset for help on using the changeset viewer.