Changeset 2720 for branches/plugin/bbp-includes/bbp-topic-template.php
- Timestamp:
- 12/13/2010 03:31:07 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-topic-template.php
r2715 r2720 21 21 $default = array ( 22 22 // Narrow query down to bbPress topics 23 'post_type' 23 'post_type' => $bbp->topic_id, 24 24 25 25 // Forum ID 26 'post_parent' 26 'post_parent' => isset( $_REQUEST['forum_id'] ) ? $_REQUEST['forum_id'] : bbp_get_forum_id(), 27 27 28 28 // Make sure topic has some last activity time 29 'meta_key' 29 'meta_key' => '_bbp_topic_last_active', 30 30 31 31 //'author', 'date', 'title', 'modified', 'parent', rand', 32 'orderby' => isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby']: 'meta_value',32 'orderby' => isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : 'meta_value', 33 33 34 34 // 'ASC', 'DESC' 35 'order' => isset( $_REQUEST['order'] ) ? $_REQUEST['order']: 'DESC',35 'order' => isset( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'DESC', 36 36 37 37 // @todo replace 15 with setting 38 'posts_per_page' => isset( $_REQUEST['posts'] ) ? $_REQUEST['posts'] : 15, 38 'posts_per_page' => isset( $_REQUEST['posts'] ) ? $_REQUEST['posts'] : 15, 39 40 // Topic Search 41 's' => !empty( $_REQUEST['ts'] ) ? $_REQUEST['ts'] : '', 39 42 40 43 // Page Number 41 'paged' => bbp_get_paged(), 42 43 // Topic Search 44 's' => empty( $_REQUEST['ts'] ) ? '' : $_REQUEST['ts'], 44 'paged' => bbp_get_paged(), 45 45 ); 46 46 … … 428 428 * @param int $topic_id optional 429 429 * 430 * @uses bbp_get_topic_author ()430 * @uses bbp_get_topic_author_avatar() 431 431 */ 432 432 function bbp_topic_author_avatar ( $topic_id = 0, $size = 40 ) { … … 442 442 * @since bbPress (r2590) 443 443 * 444 * @uses apply_filters 444 * @uses get_avatar() 445 * @uses get_post_meta() 446 * 445 447 * @param int $topic_id optional 446 * 447 * @return string Author of topic 448 * @return string Avatar of the author of the topic 448 449 */ 449 450 function bbp_get_topic_author_avatar ( $topic_id = 0, $size = 40 ) { 450 $topic_id = bbp_get_topic_id( $topic_id );451 452 return apply_filters( 'bbp_get_topic_author_avatar', get_avatar( get_post_field( 'post_author', $topic_id ), $size ) );453 }454 455 /**456 * bbp_topic_author_avatar ()457 *458 * Output the author avatar of the topic in the loop459 *460 * @package bbPress461 * @subpackage Template Tags462 * @since bbPress (r2590)463 * @param int $topic_id optional464 *465 * @uses bbp_get_topic_author()466 */467 function bbp_topic_author_url ( $topic_id = 0 ) {468 echo bbp_get_topic_author_url( $topic_id );469 }470 /**471 * bbp_get_topic_author_url ()472 *473 * Return the author url of the topic in the loop474 *475 * @package bbPress476 * @subpackage Template Tags477 * @since bbPress (r2590)478 *479 * @uses apply_filters480 * @param int $topic_id optional481 *482 * @return string Author URL of topic483 */484 function bbp_get_topic_author_url ( $topic_id = 0 ) {485 451 $topic_id = bbp_get_topic_id( $topic_id ); 486 452 487 453 // Check for anonymous user 488 454 if ( $author_id = get_post_field( 'post_author', $topic_id ) ) 489 $author_ url = bbp_get_user_profile_url( $author_id );455 $author_avatar = get_avatar( $author_id ); 490 456 else 491 $author_url = get_post_meta( $topic_id, '_bbp_anonymous_website', true ); 492 493 return apply_filters( 'bbp_get_topic_author_url', $author_url ); 494 } 457 $author_avatar = get_avatar( get_post_meta( $topic_id, '_bbp_anonymous_email', true ) ); 458 459 return apply_filters( 'bbp_get_topic_author_avatar', $author_avatar, $topic_id, $size ); 460 } 461 462 /** 463 * bbp_topic_author_link () 464 * 465 * Output the author link of the topic in the loop 466 * 467 * @package bbPress 468 * @subpackage Template Tags 469 * @since bbPress (r2717) 470 * 471 * @param mixed|int $args If it is an integer, it is used as topic_id. Optional. 472 * @uses bbp_get_topic_author_link() 473 */ 474 function bbp_topic_author_link ( $args = '' ) { 475 echo bbp_get_topic_author_link( $args ); 476 } 477 /** 478 * bbp_get_topic_author_link () 479 * 480 * Return the author link of the topic in the loop 481 * 482 * @package bbPress 483 * @subpackage Template Tags 484 * @since bbPress (r2717) 485 * 486 * @uses bbp_get_topic_author_url() 487 * @uses bbp_get_topic_author() 488 * 489 * @param mixed|int $args If it is an integer, it is used as topic_id. Optional. 490 * @return string Author link of topic 491 */ 492 function bbp_get_topic_author_link ( $args = '' ) { 493 // Used as topic_id 494 if ( is_int( $args ) ) { 495 $topic_id = bbp_get_topic_id( $args ); 496 } else { 497 $defaults = array ( 498 'topic_id' => 0, 499 'link_title' => '', 500 'link_text' => '' 501 ); 502 503 $r = wp_parse_args( $args, $defaults ); 504 extract( $r ); 505 } 506 507 if ( empty( $topic_id ) ) 508 $topic_id = bbp_get_topic_id( $topic_id ); 509 510 if ( empty( $link_title ) && ( bbp_is_topic() || bbp_is_topic() ) ) 511 $link_title = sprintf( get_the_author_meta( 'ID' ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), bbp_get_topic_author( $topic_id ) ); 512 513 if ( empty( $link_text ) && ( bbp_is_topic() || bbp_is_topic() ) ) 514 $link_text = bbp_get_topic_author_avatar( $topic_id, 80 ); 515 else 516 $link_text = bbp_get_topic_author( $topic_id ); 517 518 $link_title = !empty( $link_title ) ? ' title="' . $link_title . '"' : ''; 519 520 // Check for anonymous user 521 if ( $author_url = bbp_get_topic_author_url( $topic_id ) ) 522 $author_link = sprintf( '<a href="%1$s"%2$s>%3$s</a>', $author_url, $link_title, $link_text ); 523 else 524 $author_link = $link_text; 525 526 return apply_filters( 'bbp_get_topic_author_link', $author_link, $topic_id ); 527 } 528 529 /** 530 * bbp_topic_author_url () 531 * 532 * Output the author url of the topic in the loop 533 * 534 * @package bbPress 535 * @subpackage Template Tags 536 * @since bbPress (r2590) 537 * @param int $topic_id optional 538 * 539 * @uses bbp_get_topic_author_url() 540 */ 541 function bbp_topic_author_url ( $topic_id = 0 ) { 542 echo bbp_get_topic_author_url( $topic_id ); 543 } 544 /** 545 * bbp_get_topic_author_url () 546 * 547 * Return the author url of the topic in the loop 548 * 549 * @package bbPress 550 * @subpackage Template Tags 551 * @since bbPress (r2590) 552 * 553 * @uses bbp_get_user_profile_url() 554 * @uses get_post_meta() 555 * 556 * @param int $topic_id optional 557 * @return string Author URL of topic 558 */ 559 function bbp_get_topic_author_url ( $topic_id = 0 ) { 560 $topic_id = bbp_get_topic_id( $topic_id ); 561 562 // Check for anonymous user 563 if ( $author_id = get_post_field( 'post_author', $topic_id ) ) 564 $author_url = bbp_get_user_profile_url( $author_id ); 565 else 566 if ( !$author_url = get_post_meta( $topic_id, '_bbp_anonymous_website', true ) ) 567 $author_url = ''; 568 569 return apply_filters( 'bbp_get_topic_author_url', $author_url, $topic_id ); 570 } 495 571 496 572 /** … … 859 935 860 936 // Look for existing count, and populate if does not exist 861 if ( !$voices = get_post_meta( $topic_id, '_bbp_topic_voice_count', true ) )937 if ( !$voices = get_post_meta( $topic_id, '_bbp_topic_voice_count', true ) ) 862 938 $voices = bbp_update_topic_voice_count( $topic_id ); 863 939
Note: See TracChangeset
for help on using the changeset viewer.