Changeset 4501
- Timestamp:
- 11/24/2012 07:07:31 PM (13 years ago)
- Location:
- trunk/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/common/classes.php
r4333 r4501 174 174 175 175 if ( class_exists( 'Walker' ) ) : 176 /**177 * Create HTML list of forums.178 *179 * @package bbPress180 * @subpackage Classes181 *182 * @since bbPress (r2514)183 *184 * @uses Walker185 */186 class BBP_Walker_Forum extends Walker {187 188 /**189 * @see Walker::$tree_type190 *191 * @since bbPress (r2514)192 *193 * @var string194 */195 var $tree_type;196 197 /**198 * @see Walker::$db_fields199 *200 * @since bbPress (r2514)201 *202 * @var array203 */204 var $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );205 206 /** Methods ***************************************************************/207 208 /**209 * Set the tree_type210 *211 * @since bbPress (r2514)212 */213 public function __construct() {214 $this->tree_type = bbp_get_forum_post_type();215 }216 217 /**218 * @see Walker::start_lvl()219 *220 * @since bbPress (r2514)221 *222 * @param string $output Passed by reference. Used to append additional223 * content.224 * @param int $depth Depth of page. Used for padding.225 */226 public function start_lvl( &$output, $depth ) {227 $indent = str_repeat( "\t", $depth );228 $output .= "\n$indent<ul class='children'>\n";229 }230 231 /**232 * @see Walker::end_lvl()233 *234 * @since bbPress (r2514)235 *236 * @param string $output Passed by reference. Used to append additional237 * content.238 * @param int $depth Depth of page. Used for padding.239 */240 public function end_lvl( &$output, $depth ) {241 $indent = str_repeat( "\t", $depth );242 $output .= "$indent</ul>\n";243 }244 245 /**246 * @see Walker::start_el()247 *248 * @since bbPress (r2514)249 *250 * @param string $output Passed by reference. Used to append additional251 * content.252 * @param object $forum Page data object.253 * @param int $depth Depth of page. Used for padding.254 * @param int $current_forum Page ID.255 * @param array $args256 */257 public function start_el( &$output, $forum, $depth, $args, $current_forum ) {258 259 $indent = $depth ? str_repeat( "\t", $depth ) : '';260 261 extract( $args, EXTR_SKIP );262 $css_class = array( 'bbp-forum-item', 'bbp-forum-item-' . $forum->ID );263 264 if ( !empty( $current_forum ) ) {265 $_current_page = bbp_get_forum( $current_forum );266 267 if ( isset( $_current_page->ancestors ) && in_array( $forum->ID, (array) $_current_page->ancestors ) )268 $css_class[] = 'bbp-current-forum-ancestor';269 270 if ( $forum->ID == $current_forum )271 $css_class[] = 'bbp_current_forum_item';272 elseif ( $_current_page && $forum->ID == $_current_page->post_parent )273 $css_class[] = 'bbp-current-forum-parent';274 275 } elseif ( $forum->ID == get_option( 'page_for_posts' ) ) {276 $css_class[] = 'bbp-current-forum-parent';277 }278 279 $css_class = implode( ' ', apply_filters( 'bbp_forum_css_class', $css_class, $forum ) );280 $output .= $indent . '<li class="' . $css_class . '"><a href="' . bbp_get_forum_permalink( $forum->ID ) . '" title="' . esc_attr( wp_strip_all_tags( apply_filters( 'the_title', $forum->post_title, $forum->ID ) ) ) . '">' . $link_before . apply_filters( 'the_title', $forum->post_title, $forum->ID ) . $link_after . '</a>';281 282 if ( !empty( $show_date ) ) {283 $time = ( 'modified' == $show_date ) ? $forum->post_modified : $time = $forum->post_date;284 $output .= " " . mysql2date( $date_format, $time );285 }286 }287 288 /**289 * @see Walker::end_el()290 *291 * @since bbPress (r2514)292 *293 * @param string $output Passed by reference. Used to append additional294 * content.295 * @param object $forum Page data object. Not used.296 * @param int $depth Depth of page. Not Used.297 */298 public function end_el( &$output, $forum, $depth ) {299 $output .= "</li>\n";300 }301 }302 303 176 /** 304 177 * Create HTML dropdown list of bbPress forums/topics. -
trunk/includes/forums/functions.php
r4489 r4501 664 664 } 665 665 666 /** Walk **********************************************************************/667 668 /**669 * Walk the forum tree670 *671 * @param object $forums Forums672 * @param int $depth Depth673 * @param int $current Current forum674 * @param array $r Parsed arguments, supported by the walker. If you want to675 * use your own walker, pass the 'walker' arg with the walker.676 * The walker defaults to {@link BBP_Walker_Forum}677 * @return object Walked forum tree678 */679 function bbp_walk_forum( $forums, $depth, $current, $r ) {680 $walker = empty( $r['walker'] ) ? new BBP_Walker_Forum : $r['walker'];681 $args = array( $forums, $depth, $r, $current );682 return call_user_func_array( array( &$walker, 'walk' ), $args );683 }684 685 666 /** Forum Actions *************************************************************/ 686 667
Note: See TracChangeset
for help on using the changeset viewer.