Changeset 5389
- Timestamp:
- 06/12/2014 02:15:20 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/common/classes.php
r5135 r5389 192 192 * @var string 193 193 */ 194 var $tree_type;194 public $tree_type = 'forum'; 195 195 196 196 /** … … 201 201 * @var array 202 202 */ 203 var $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); 203 public $db_fields = array( 204 'parent' => 'post_parent', 205 'id' => 'ID' 206 ); 204 207 205 208 /** Methods ***************************************************************/ … … 220 223 * 221 224 * @param string $output Passed by reference. Used to append additional 222 * content. 223 * @param object $_post Post data object. 224 * @param int $depth Depth of post in reference to parent posts. Used 225 * for padding. 226 * @param array $args Uses 'selected' argument for selected post to set 227 * selected HTML attribute for option element. 228 * @param int $current_object_id 225 * content. 226 * @param object $object Post data object. 227 * @param int $depth Depth of post in reference to parent posts. Used 228 * for padding. 229 * @param array $args Uses 'selected' argument for selected post to set 230 * selected HTML attribute for option element. 231 * @param int $current_object_id 232 * 229 233 * @uses bbp_is_forum_category() To check if the forum is a category 230 234 * @uses current_user_can() To check if the current user can post in … … 278 282 * @var string 279 283 */ 280 var$tree_type = 'reply';284 public $tree_type = 'reply'; 281 285 282 286 /** … … 287 291 * @var array 288 292 */ 289 var$db_fields = array(293 public $db_fields = array( 290 294 'parent' => 'reply_to', 291 295 'id' => 'ID' … … 293 297 294 298 /** 299 * Confirm the tree_type 300 * 301 * @since bbPress (r5389) 302 */ 303 public function __construct() { 304 $this->tree_type = bbp_get_reply_post_type(); 305 } 306 307 /** 295 308 * @see Walker::start_lvl() 296 309 * … … 302 315 */ 303 316 public function start_lvl( &$output = '', $depth = 0, $args = array() ) { 304 bbpress()->reply_query->reply_depth = $depth + 1;317 bbpress()->reply_query->reply_depth = (int) $depth + 1; 305 318 306 319 switch ( $args['style'] ) { … … 376 389 // Set up reply 377 390 $depth++; 378 bbpress()->reply_query->reply_depth = $depth;391 bbpress()->reply_query->reply_depth = (int) $depth; 379 392 bbpress()->reply_query->post = $object; 380 393 bbpress()->current_reply_id = $object->ID; … … 415 428 } 416 429 } 430 431 /** 432 * Create HTML dropdown list of bbPress replies. 433 * 434 * @package bbPress 435 * @subpackage Classes 436 * 437 * @since bbPress (r5389) 438 * @uses Walker 439 */ 440 class BBP_Walker_Reply_Dropdown extends Walker { 441 442 /** 443 * @see Walker::$tree_type 444 * 445 * @since bbPress (r5389) 446 * 447 * @var string 448 */ 449 public $tree_type = 'reply'; 450 451 /** 452 * @see Walker::$db_fields 453 * 454 * @since bbPress (r5389) 455 * 456 * @var array 457 */ 458 public $db_fields = array( 459 'parent' => 'reply_to', 460 'id' => 'ID' 461 ); 462 463 /** Methods ***************************************************************/ 464 465 /** 466 * Confirm the tree_type 467 * 468 * @since bbPress (r5389) 469 */ 470 public function __construct() { 471 $this->tree_type = bbp_get_reply_post_type(); 472 } 473 474 /** 475 * @see Walker::start_el() 476 * 477 * @since bbPress (r5389) 478 * 479 * @param string $output Passed by reference. Used to append additional 480 * content. 481 * 482 * @param object $object Post data object. 483 * 484 * @param int $depth Depth of post in reference to parent posts. Used 485 * for padding. 486 * 487 * @param array $args Uses 'selected' argument for selected post to set 488 * selected HTML attribute for option element. 489 * 490 * @param int $current_object_id Not Used 491 * 492 * @uses bbp_is_forum_category() To check if the forum is a category 493 * @uses current_user_can() To check if the current user can post in 494 * closed forums 495 * @uses bbp_is_forum_closed() To check if the forum is closed 496 * @uses apply_filters() Calls 'bbp_walker_dropdown_post_title' with the 497 * title, output, post, depth and args 498 */ 499 public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) { 500 501 // Set up reply 502 $depth++; 503 bbpress()->reply_query->reply_depth = (int) $depth; 504 bbpress()->reply_query->post = $object; 505 bbpress()->current_reply_id = $object->ID; 506 507 // Get reply ancestors 508 $to_check = bbp_get_reply_ancestors( $object->ID ); 509 510 // Array of ancestors to check for disabling 511 if ( $args['selected'] !== $object->ID ) { 512 array_unshift( $to_check, $object->ID ); 513 } 514 515 // Determine the indentation 516 $pad = str_repeat( ' ', (int) $depth * 3 ); 517 518 // Determine reply title (either post_title, or excerpt of post_content) 519 $title = ! empty( $object->post_title ) ? $object->post_title : wp_html_excerpt( $object->post_content, 10 ); 520 $title = sprintf( esc_html__( '%1$s - %2$s', 'bbpress' ), (int) $object->ID, $title ); 521 $title = apply_filters( 'bbp_walker_dropdown_post_title', $title, $output, $object, $depth, $args ); 522 523 // Attributes 524 $class = 'level-' . (int) $depth; 525 $value = (int) $object->ID; 526 527 // Start an output buffer to make late escaping easier 528 ob_start(); ?> 529 530 <option class="<?php echo esc_attr( $class ); ?>" value="<?php echo esc_attr( $value ); ?>"<?php selected( $args['selected'], $object->ID ); ?> <?php disabled( in_array( $args['selected'], $to_check ), true ); ?>><?php echo $pad . esc_html( $title ); ?></option> 531 532 <?php 533 534 // Append the output buffer to the $output variable 535 $output .= ob_get_clean(); 536 } 537 } 417 538 endif; // class_exists check
Note: See TracChangeset
for help on using the changeset viewer.