Changeset 6827 for trunk/bp-forums/bp-forums-screens.php
- Timestamp:
- 03/01/2013 09:34:55 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-forums/bp-forums-screens.php
r6406 r6827 119 119 } 120 120 add_action( 'bp_screens', 'bp_forums_screen_single_topic' ); 121 122 123 /** Theme Compatability *******************************************************/ 124 125 /** 126 * The main theme compat class for legacy BuddyPress forums, as powered by bbPress 1.x 127 * 128 * This class sets up the necessary theme compatability actions to safely output 129 * old forum template parts to the_title and the_content areas of a theme. 130 * 131 * @since BuddyPress (1.7) 132 */ 133 class BP_Forum_Legacy_Theme_Compat { 134 135 /** 136 * Setup the old forums component theme compatibility 137 * 138 * @since BuddyPress (1.7) 139 */ 140 public function __construct() { 141 add_action( 'bp_setup_theme_compat', array( $this, 'is_legacy_forum' ) ); 142 } 143 144 /** 145 * Are we looking at something that needs old forum theme compatability? 146 * 147 * @since BuddyPress (1.7) 148 */ 149 public function is_legacy_forum() { 150 151 // Bail if not looking at a group 152 if ( ! bp_is_forums_component() ) 153 return; 154 155 // forum Directory 156 if ( ( ! bp_current_action() || ( 'tag' == bp_current_action() && bp_action_variables() ) ) && ! bp_current_item() ) { 157 158 if ( ! bp_forums_has_directory() ) 159 return false; 160 161 if ( ! bp_forums_is_installed_correctly() ) { 162 bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' ); 163 bp_core_redirect( bp_get_root_domain() ); 164 } 165 166 bp_update_is_directory( true, 'forums' ); 167 168 do_action( 'bp_forums_directory_forums_setup' ); 169 170 add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) ); 171 add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) ); 172 173 } 174 175 } 176 177 /** Directory *************************************************************/ 178 179 /** 180 * Update the global $post with directory data 181 * 182 * @since BuddyPress (1.7) 183 */ 184 public function directory_dummy_post() { 185 186 // Title based on ability to create groups 187 if ( is_user_logged_in() ) { 188 $title = __( 'Forums', 'buddypress' ) . ' <a class="button show-hide-new bp-title-button" href="#new-topic" id="new-topic-button">' . __( 'New Topic', 'buddypress' ) . '</a>'; 189 } else { 190 $title = __( 'Forums', 'buddypress' ); 191 } 192 193 bp_theme_compat_reset_post( array( 194 'ID' => 0, 195 'post_title' => $title, 196 'post_author' => 0, 197 'post_date' => 0, 198 'post_content' => '', 199 'post_type' => 'bp_forum', 200 'post_status' => 'publish', 201 'is_archive' => true, 202 'comment_status' => 'closed' 203 ) ); 204 } 205 206 /** 207 * Filter the_content with the old forum index template part 208 * 209 * @since BuddyPress (1.7) 210 */ 211 public function directory_content() { 212 bp_buffer_template_part( 'forums/index' ); 213 } 214 } 215 new BP_Forum_Legacy_Theme_Compat();
Note: See TracChangeset
for help on using the changeset viewer.