Created
July 29, 2013 19:40
-
-
Save rogercoathup/6107122 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BuddyDrive_Theme_Compat { | |
/** | |
* Setup the BuddyDrive component theme compatibility | |
* | |
* @since BuddyDrive (1.0) | |
*/ | |
public function __construct() { | |
add_action( 'bp_setup_theme_compat', array( $this, 'is_buddydrive' ) ); | |
} | |
/** | |
* Are we looking at something that needs BuddyDrive theme compatability? | |
* | |
* @since BuddyDrive (1.0) | |
* | |
* @uses bp_displayed_user_id() to check we're not on a user's page | |
* @uses bp_is_current_component() to check we're on BuddyDrive component | |
*/ | |
public function is_buddydrive() { | |
if ( !bp_displayed_user_id() && bp_is_current_component( 'buddydrive' ) ) { | |
add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) ); | |
add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) ); | |
} | |
} | |
/** Directory *************************************************************/ | |
/** | |
* Update the global $post with directory data | |
* | |
* @since BuddyDrive (1.0) | |
* | |
* @uses bp_theme_compat_reset_post() to reset the post data | |
*/ | |
public function directory_dummy_post() { | |
bp_theme_compat_reset_post( array( | |
'ID' => 0, | |
'post_title' => buddydrive_get_name(), | |
'post_author' => 0, | |
'post_date' => 0, | |
'post_content' => '', | |
'post_type' => 'buddydrive_dir', | |
'post_status' => 'publish', | |
'is_archive' => true, | |
'comment_status' => 'closed' | |
) ); | |
} | |
/** | |
* Filter the_content with the groups index template part | |
* | |
* @since BuddyDrive (1.0) | |
* | |
* @uses bp_buffer_template_part() | |
*/ | |
public function directory_content() { | |
bp_buffer_template_part( 'buddydrive' ); | |
} | |
} | |
new BuddyDrive_Theme_Compat(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment