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

    r6093 r6285  
    2121
    2222function bp_blogs_screen_create_a_blog() {
     23
    2324    if ( !is_multisite() ||  !bp_is_blogs_component() || !bp_is_current_action( 'create' ) )
    2425        return false;
     
    4445add_action( 'bp_screens', 'bp_blogs_screen_index', 2 );
    4546
    46 ?>
     47/** Theme Compatability *******************************************************/
     48
     49/**
     50 * The main theme compat class for BuddyPress Activity
     51 *
     52 * This class sets up the necessary theme compatability actions to safely output
     53 * group template parts to the_title and the_content areas of a theme.
     54 *
     55 * @since BuddyPress (1.7)
     56 */
     57class BP_Blogs_Theme_Compat {
     58
     59    /**
     60     * Setup the groups component theme compatibility
     61     *
     62     * @since BuddyPress (1.7)
     63     */
     64    public function __construct() {
     65        add_action( 'bp_setup_theme_compat', array( $this, 'is_blogs' ) );
     66    }
     67
     68    /**
     69     * Are we looking at something that needs group theme compatability?
     70     *
     71     * @since BuddyPress (1.7)
     72     */
     73    public function is_blogs() {
     74
     75        // Bail if not looking at a group
     76        if ( ! bp_is_blogs_component() )
     77            return;
     78
     79        // Blog Directory
     80        if ( is_multisite() && ! bp_current_action() ) {
     81            bp_update_is_directory( true, 'blogs' );
     82
     83            do_action( 'bp_blogs_screen_index' );
     84
     85            add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) );
     86            add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
     87
     88        // Create blog
     89        } elseif ( is_user_logged_in() && bp_blog_signup_enabled() ) {
     90            add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'create_dummy_post' ) );
     91            add_filter( 'bp_replace_the_content',                    array( $this, 'create_content'    ) );         
     92        }
     93    }
     94
     95    /** Directory *************************************************************/
     96
     97    /**
     98     * Update the global $post with directory data
     99     *
     100     * @since BuddyPress (1.7)
     101     */
     102    public function directory_dummy_post() {
     103
     104        // Title based on ability to create blogs
     105        if ( is_user_logged_in() && bp_blog_signup_enabled() ) {
     106            $title = __( 'Blogs', 'buddypress' ) . '&nbsp;<a class="button" href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create' ) . '">' . __( 'Create a Blog', 'buddypress' ) . '</a>';
     107        } else {
     108            $title = __( 'Blogs', 'buddypress' );
     109        }
     110
     111        bp_theme_compat_reset_post( array(
     112            'ID'             => 0,
     113            'post_title'     => $title,
     114            'post_author'    => 0,
     115            'post_date'      => 0,
     116            'post_content'   => '',
     117            'post_type'      => 'bp_blogs',
     118            'post_status'    => 'publish',
     119            'is_archive'     => true,
     120            'comment_status' => 'closed'
     121        ) );
     122    }
     123
     124    /**
     125     * Filter the_content with the groups index template part
     126     *
     127     * @since BuddyPress (1.7)
     128     */
     129    public function directory_content() {
     130        bp_buffer_template_part( 'blogs/index' );
     131    }
     132   
     133    /** Create ****************************************************************/
     134
     135    /**
     136     * Update the global $post with create screen data
     137     *
     138     * @since BuddyPress (1.7)
     139     */
     140    public function create_dummy_post() {
     141
     142        // Title based on ability to create blogs
     143        if ( is_user_logged_in() && bp_blog_signup_enabled() ) {
     144            $title = '<a class="button" href="' . trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) . '">' . __( 'Blogs', 'buddypress' ) . '</a>&nbsp;' . __( 'Create a Blog', 'buddypress' );
     145        } else {
     146            $title = __( 'Blogs', 'buddypress' );
     147        }
     148
     149        bp_theme_compat_reset_post( array(
     150            'ID'             => 0,
     151            'post_title'     => $title,
     152            'post_author'    => 0,
     153            'post_date'      => 0,
     154            'post_content'   => '',
     155            'post_type'      => 'bp_group',
     156            'post_status'    => 'publish',
     157            'is_archive'     => true,
     158            'comment_status' => 'closed'
     159        ) );
     160    }
     161
     162    /**
     163     * Filter the_content with the create screen template part
     164     *
     165     * @since BuddyPress (1.7)
     166     */
     167    public function create_content() {
     168        bp_buffer_template_part( 'blogs/create' );
     169    }
     170}
     171new BP_Blogs_Theme_Compat();
Note: See TracChangeset for help on using the changeset viewer.