Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/03/2012 12:33:13 AM (13 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-activity/bp-activity-screens.php

    r6093 r6285  
    304304add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 );
    305305
    306 ?>
     306/** Theme Compatability *******************************************************/
     307
     308/**
     309 * The main theme compat class for BuddyPress Activity
     310 *
     311 * 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.
     313 *
     314 * @since BuddyPress (1.7)
     315 */
     316class BP_Activity_Theme_Compat {
     317
     318    /**
     319     * Setup the activity component theme compatibility
     320     *
     321     * @since BuddyPress (1.7)
     322     */
     323    public function __construct() {
     324        add_action( 'bp_setup_theme_compat', array( $this, 'is_activity' ) );
     325    }
     326
     327    /**
     328     * Are we looking at something that needs activity theme compatability?
     329     *
     330     * @since BuddyPress (1.7)
     331     */
     332    public function is_activity() {
     333
     334        // Bail if not looking at a group
     335        if ( ! bp_is_activity_component() )
     336            return;
     337
     338        // Activity Directory
     339        if ( ! bp_displayed_user_id() && ! bp_current_action() ) {
     340            bp_update_is_directory( true, 'activity' );
     341
     342            do_action( 'bp_activity_screen_index' );
     343
     344            add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) );
     345            add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
     346        }
     347    }
     348
     349    /** Directory *************************************************************/
     350
     351    /**
     352     * Update the global $post with directory data
     353     *
     354     * @since BuddyPress (1.7)
     355     */
     356    public function directory_dummy_post() {
     357        bp_theme_compat_reset_post( array(
     358            'ID'             => 0,
     359            'post_title'     => __( 'Sitewide Activity', 'buddypress' ),
     360            'post_author'    => 0,
     361            'post_date'      => 0,
     362            'post_content'   => '',
     363            'post_type'      => 'bp_activity',
     364            'post_status'    => 'publish',
     365            'is_archive'     => true,
     366            'comment_status' => 'closed'
     367        ) );
     368    }
     369
     370    /**
     371     * Filter the_content with the groups index template part
     372     *
     373     * @since BuddyPress (1.7)
     374     */
     375    public function directory_content() {
     376        bp_buffer_template_part( 'activity/index' );
     377    }
     378}
     379new BP_Activity_Theme_Compat();
Note: See TracChangeset for help on using the changeset viewer.