Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/03/2012 12:33:13 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Theme Compatibility:

  • First pass at including theme compatibility into BuddyPress.
  • Introduce dependency, theme-compatibility, template-loader files into Core component.
  • Add theme compatibility classes for components with direct template access.
  • Move actions and filters around for improved plugin dependency.
  • Remove old $bbp references.
  • Turn $bp global into byref singleton, and include methods for setting up theme compatibility. (Fixes #4470.)
  • Add is_buddypress() function to bp-core-template.php.
  • Rename incorrectly named bp_after_theme_setup sub-action.
  • See: #3741.
File:
1 edited

Legend:

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

    r6236 r6285  
    261261add_action( 'bp_screens', 'bp_core_screen_activation' );
    262262
    263 ?>
     263/** Theme Compatability *******************************************************/
     264
     265/**
     266 * The main theme compat class for BuddyPress Groups
     267 *
     268 * 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.
     270 *
     271 * @since BuddyPress (1.7)
     272 */
     273class BP_Members_Theme_Compat {
     274
     275    /**
     276     * Setup the groups component theme compatibility
     277     *
     278     * @since BuddyPress (1.7)
     279     */
     280    public function __construct() {
     281        add_action( 'bp_setup_theme_compat', array( $this, 'is_members' ) );
     282    }
     283
     284    /**
     285     * Are we looking at something that needs group theme compatability?
     286     *
     287     * @since BuddyPress (1.7)
     288     */
     289    public function is_members() {
     290
     291        // Bail if not looking at a group
     292        if ( ! bp_is_members_component() )
     293            return;
     294
     295        // Group Directory
     296        if ( ! bp_current_action() && ! bp_current_item() ) {
     297            bp_update_is_directory( true, 'members' );
     298
     299            do_action( 'members_directory_groups_setup' );
     300
     301            add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) );
     302            add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
     303        }
     304    }
     305
     306    /** Directory *************************************************************/
     307
     308    /**
     309     * Update the global $post with directory data
     310     *
     311     * @since BuddyPress (1.7)
     312     */
     313    public function directory_dummy_post() {
     314        bp_theme_compat_reset_post( array(
     315            'ID'             => 0,
     316            'post_title'     => __( 'Members', 'buddypress' ),
     317            'post_author'    => 0,
     318            'post_date'      => 0,
     319            'post_content'   => '',
     320            'post_type'      => 'bp_members',
     321            'post_status'    => 'publish',
     322            'is_archive'     => true,
     323            'comment_status' => 'closed'
     324        ) );
     325    }
     326
     327    /**
     328     * Filter the_content with the groups index template part
     329     *
     330     * @since BuddyPress (1.7)
     331     */
     332    public function directory_content() {
     333        bp_buffer_template_part( 'members/index' );
     334    }
     335}
     336new BP_Members_Theme_Compat();
Note: See TracChangeset for help on using the changeset viewer.