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-xprofile/bp-xprofile-screens.php

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