Ticket #1393: anon-user-link.2.diff
File anon-user-link.2.diff, 17.9 KB (added by , 12 years ago) |
---|
-
bbp-includes/bbp-reply-template.php
20 20 21 21 $default = array( 22 22 // Narrow query down to bbPress topics 23 'post_type' 23 'post_type' => $bbp->reply_id, 24 24 25 25 // Forum ID 26 'post_parent' 26 'post_parent' => isset( $_REQUEST['topic_id'] ) ? $_REQUEST['topic_id'] : bbp_get_topic_id(), 27 27 28 28 //'author', 'date', 'title', 'modified', 'parent', rand', 29 'orderby' => isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby']: 'date',29 'orderby' => isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : 'date', 30 30 31 31 // 'ASC', 'DESC' 32 'order' => isset( $_REQUEST['order'] ) ? $_REQUEST['order']: 'ASC',32 'order' => isset( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'ASC', 33 33 34 34 // @todo replace 15 with setting 35 'posts_per_page' => isset( $_REQUEST['posts'] ) ? $_REQUEST['posts']: 15,35 'posts_per_page' => isset( $_REQUEST['posts'] ) ? $_REQUEST['posts'] : 15, 36 36 37 37 // Page Number 38 'paged' 38 'paged' => bbp_get_paged(), 39 39 40 40 // Reply Search 41 's' => empty( $_REQUEST['rs'] ) ? '': $_REQUEST['rs'],41 's' => empty( $_REQUEST['rs'] ) ? '' : $_REQUEST['rs'], 42 42 ); 43 43 44 44 // Set up topic variables … … 50 50 51 51 // Add pagination values to query object 52 52 $bbp->reply_query->posts_per_page = $posts_per_page; 53 $bbp->reply_query->paged = $paged;53 $bbp->reply_query->paged = $paged; 54 54 55 55 // Only add pagination if query returned results 56 if ( (int)$bbp->reply_query->found_posts && (int) $bbp->reply_query->posts_per_page ) {56 if ( (int)$bbp->reply_query->found_posts && (int) $bbp->reply_query->posts_per_page ) { 57 57 58 58 // If pretty permalinks are enabled, make our pagination pretty 59 59 if ( $wp_rewrite->using_permalinks() ) … … 65 65 $bbp_replies_pagination = apply_filters( 'bbp_replies_pagination', array( 66 66 'base' => $base, 67 67 'format' => '', 68 'total' => ceil( (int)$bbp->reply_query->found_posts / (int) $posts_per_page ),68 'total' => ceil( (int)$bbp->reply_query->found_posts / (int) $posts_per_page ), 69 69 'current' => (int)$bbp->reply_query->paged, 70 70 'prev_text' => '←', 71 71 'next_text' => '→', … … 395 395 if ( get_post_field( 'post_author', $reply_id ) ) 396 396 $author = get_the_author(); 397 397 else 398 $author = get_post_meta( $ topic_id, '_bbp_anonymous_name', true );398 $author = get_post_meta( $reply_id, '_bbp_anonymous_name', true ); 399 399 400 400 return apply_filters( 'bbp_get_reply_author', $author ); 401 401 } … … 473 473 else 474 474 $author_name = get_post_meta( $reply_id, '_bbp_anonymous_name', true ); 475 475 476 return apply_filters( 'bbp_get_reply_author_ id', esc_attr( $author_name ) );476 return apply_filters( 'bbp_get_reply_author_display_name', esc_attr( $author_name ) ); 477 477 } 478 478 479 479 /** … … 486 486 * @since bbPress (r2667) 487 487 * @param int $reply_id optional 488 488 * 489 * @uses bbp_get_reply_author ()489 * @uses bbp_get_reply_author_avatar() 490 490 */ 491 491 function bbp_reply_author_avatar ( $reply_id = 0, $size = 40 ) { 492 492 echo bbp_get_reply_author_avatar( $reply_id, $size ); … … 503 503 * @uses apply_filters 504 504 * @param int $reply_id optional 505 505 * 506 * @return string A uthor ofreply506 * @return string Avatar of author of the reply 507 507 */ 508 508 function bbp_get_reply_author_avatar ( $reply_id = 0, $size = 40 ) { 509 509 $reply_id = bbp_get_reply_id( $reply_id ); 510 510 511 return apply_filters( 'bbp_get_reply_author_avatar', get_avatar( get_post_field( 'post_author', $reply_id ), $size ) ); 511 // Check for anonymous user 512 if ( $author_id = get_post_field( 'post_author', $reply_id ) ) 513 $author_avatar = get_avatar( $author_id ); 514 else 515 $author_avatar = get_avatar( get_post_meta( $reply_id, '_bbp_anonymous_email', true ) ); 516 517 return apply_filters( 'bbp_get_reply_author_avatar', $author_avatar, $reply_id, $size ); 512 518 } 513 519 514 520 /** 515 * bbp_reply_author_ url()521 * bbp_reply_author_link () 516 522 * 517 * Output the author urlof the reply in the loop523 * Output the author link of the reply in the loop 518 524 * 519 525 * @package bbPress 520 526 * @subpackage Template Tags 521 * @since bbPress (r2667) 522 * @param int $reply_id optional 527 * @since bbPress (r2717) 523 528 * 524 * @uses bbp_get_reply_author_url() 529 * @param mixed|int $args If it is an integer, it is used as reply_id. Optional. 530 * @uses bbp_get_reply_author_link() 525 531 */ 526 function bbp_reply_author_ url ( $reply_id = 0) {527 echo bbp_get_reply_author_ url( $reply_id);532 function bbp_reply_author_link ( $args = '' ) { 533 echo bbp_get_reply_author_link( $args ); 528 534 } 529 535 /** 530 * bbp_get_reply_author_ url()536 * bbp_get_reply_author_link () 531 537 * 532 * Return the author urlof the reply in the loop538 * Return the author link of the reply in the loop 533 539 * 534 540 * @package bbPress 535 541 * @subpackage Template Tags 536 * @since bbPress (r2 667)542 * @since bbPress (r2717) 537 543 * 538 * @uses apply_filters539 * @ param int $reply_id optional544 * @uses bbp_get_reply_author_url() 545 * @uses bbp_get_reply_author() 540 546 * 541 * @return string Author URL of reply 547 * @param mixed|int $args If it is an integer, it is used as reply_id. Optional. 548 * @return string Author link of reply 542 549 */ 543 function bbp_get_reply_author_url ( $reply_id = 0 ) { 544 $reply_id = bbp_get_reply_id( $reply_id ); 550 function bbp_get_reply_author_link ( $args = '' ) { 551 if ( is_int( $args ) ) { // Used as reply_id 552 $reply_id = bbp_get_reply_id( $args ); 553 } else { 554 $defaults = array ( 555 'reply_id' => 0, 556 'link_title' => '', 557 'link_text' => '' 558 ); 545 559 560 $r = wp_parse_args( $args, $defaults ); 561 extract( $r ); 562 } 563 564 if ( empty( $reply_id ) ) 565 $reply_id = bbp_get_reply_id( $reply_id ); 566 567 if ( empty( $link_title ) && ( bbp_is_topic() || bbp_is_reply() ) ) 568 $link_title = sprintf( get_the_author_meta( 'ID' ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), bbp_get_reply_author( $reply_id ) ); 569 570 if ( empty( $link_text ) && ( bbp_is_topic() || bbp_is_reply() ) ) 571 $link_text = bbp_get_reply_author_avatar( $reply_id, 80 ); 572 else 573 $link_text = bbp_get_reply_author( $reply_id ); 574 575 $link_title = !empty( $link_title ) ? ' title="' . $link_title . '"' : ''; 576 546 577 // Check for anonymous user 547 if ( $author_ id = get_post_field( 'post_author',$reply_id ) )548 $author_ url = bbp_get_user_profile_url( $author_id);578 if ( $author_url = bbp_get_reply_author_url( $reply_id ) ) 579 $author_link = sprintf( '<a href="%1$s"%2$s>%3$s</a>', $author_url, $link_title, $link_text ); 549 580 else 550 $author_ url = get_post_meta( $reply_id, '_bbp_anonymous_website', true );581 $author_link = $link_text; // Still return $link_text 551 582 552 return apply_filters( 'bbp_get_reply_author_ url', $author_url);583 return apply_filters( 'bbp_get_reply_author_link', $author_link, $args ); 553 584 } 554 585 586 /** 587 * bbp_reply_author_url () 588 * 589 * Output the author url of the reply in the loop 590 * 591 * @package bbPress 592 * @subpackage Template Tags 593 * @since bbPress (r2667) 594 * @param int $reply_id optional 595 * 596 * @uses bbp_get_reply_author_url() 597 */ 598 function bbp_reply_author_url ( $reply_id = 0 ) { 599 echo bbp_get_reply_author_url( $reply_id ); 600 } 601 /** 602 * bbp_get_reply_author_url () 603 * 604 * Return the author url of the reply in the loop 605 * 606 * @package bbPress 607 * @subpackage Template Tags 608 * @since bbPress (r22667) 609 * 610 * @uses bbp_get_user_profile_url() 611 * @uses get_post_meta() 612 * 613 * @param int $reply_id optional 614 * @return string Author URL of reply 615 */ 616 function bbp_get_reply_author_url ( $reply_id = 0 ) { 617 $reply_id = bbp_get_reply_id( $reply_id ); 618 619 // Check for anonymous user 620 if ( $author_id = get_post_field( 'post_author', $reply_id ) ) 621 $author_url = bbp_get_user_profile_url( $author_id ); 622 else 623 if ( !$author_url = get_post_meta( $reply_id, '_bbp_anonymous_website', true ) ) 624 $author_url = ''; 625 626 return apply_filters( 'bbp_get_reply_author_url', $author_url, $reply_id ); 627 } 628 555 629 /** 556 630 * bbp_reply_topic_title () 557 631 * -
bbp-includes/bbp-topic-template.php
20 20 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 39 40 40 // Page Number 41 'paged' 41 'paged' => bbp_get_paged(), 42 42 43 43 // Topic Search 44 's' => empty( $_REQUEST['ts'] ) ? '': $_REQUEST['ts'],44 's' => empty( $_REQUEST['ts'] ) ? '' : $_REQUEST['ts'], 45 45 ); 46 46 47 47 // Don't pass post_parent if forum_id is empty or 0 … … 427 427 * @since bbPress (r2590) 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 ) { 433 433 echo bbp_get_topic_author_avatar( $topic_id, $size ); … … 441 441 * @subpackage Template Tags 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 451 $topic_id = bbp_get_topic_id( $topic_id ); 451 452 452 return apply_filters( 'bbp_get_topic_author_avatar', get_avatar( get_post_field( 'post_author', $topic_id ), $size ) ); 453 // Check for anonymous user 454 if ( $author_id = get_post_field( 'post_author', $topic_id ) ) 455 $author_avatar = get_avatar( $author_id ); 456 else 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 ); 453 460 } 454 461 455 462 /** 456 * bbp_topic_author_ avatar()463 * bbp_topic_author_link () 457 464 * 458 * Output the author avatarof the topic in the loop465 * Output the author link of the topic in the loop 459 466 * 460 467 * @package bbPress 461 468 * @subpackage Template Tags 462 * @since bbPress (r2590) 463 * @param int $topic_id optional 469 * @since bbPress (r2717) 464 470 * 465 * @uses bbp_get_topic_author() 471 * @param mixed|int $args If it is an integer, it is used as topic_id. Optional. 472 * @uses bbp_get_topic_author_link() 466 473 */ 467 function bbp_topic_author_ url ( $topic_id = 0) {468 echo bbp_get_topic_author_ url( $topic_id);474 function bbp_topic_author_link ( $args = '' ) { 475 echo bbp_get_topic_author_link( $args ); 469 476 } 470 477 /** 471 * bbp_get_topic_author_ url()478 * bbp_get_topic_author_link () 472 479 * 473 * Return the author urlof the topic in the loop480 * Return the author link of the topic in the loop 474 481 * 475 482 * @package bbPress 476 483 * @subpackage Template Tags 477 * @since bbPress (r2 590)484 * @since bbPress (r2717) 478 485 * 479 * @uses apply_filters480 * @ param int $topic_id optional486 * @uses bbp_get_topic_author_url() 487 * @uses bbp_get_topic_author() 481 488 * 482 * @return string Author URL of topic 489 * @param mixed|int $args If it is an integer, it is used as topic_id. Optional. 490 * @return string Author link of topic 483 491 */ 484 function bbp_get_topic_author_url ( $topic_id = 0 ) { 485 $topic_id = bbp_get_topic_id( $topic_id ); 492 function bbp_get_topic_author_link ( $args = '' ) { 493 if ( is_int( $args ) ) { // Used as topic_id 494 $topic_id = bbp_get_topic_id( $args ); 495 } else { 496 $defaults = array ( 497 'topic_id' => 0, 498 'link_title' => '', 499 'link_text' => '' 500 ); 486 501 502 $r = wp_parse_args( $args, $defaults ); 503 extract( $r ); 504 } 505 506 if ( empty( $topic_id ) ) 507 $topic_id = bbp_get_topic_id( $topic_id ); 508 509 if ( empty( $link_title ) && ( bbp_is_topic() || bbp_is_topic() ) ) 510 $link_title = sprintf( get_the_author_meta( 'ID' ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' ), bbp_get_topic_author( $topic_id ) ); 511 512 if ( empty( $link_text ) && ( bbp_is_topic() || bbp_is_topic() ) ) 513 $link_text = bbp_get_topic_author_avatar( $topic_id, 80 ); 514 else 515 $link_text = bbp_get_topic_author( $topic_id ); 516 517 $link_title = !empty( $link_title ) ? ' title="' . $link_title . '"' : ''; 518 487 519 // Check for anonymous user 488 if ( $author_ id = get_post_field( 'post_author',$topic_id ) )489 $author_ url = bbp_get_user_profile_url( $author_id);520 if ( $author_url = bbp_get_topic_author_url( $topic_id ) ) 521 $author_link = sprintf( '<a href="%1$s"%2$s>%3$s</a>', $author_url, $link_title, $link_text ); 490 522 else 491 $author_ url = get_post_meta( $topic_id, '_bbp_anonymous_website', true );523 $author_link = $link_text; 492 524 493 return apply_filters( 'bbp_get_topic_author_ url', $author_url);525 return apply_filters( 'bbp_get_topic_author_link', $author_link, $topic_id ); 494 526 } 495 527 528 /** 529 * bbp_topic_author_url () 530 * 531 * Output the author url of the topic in the loop 532 * 533 * @package bbPress 534 * @subpackage Template Tags 535 * @since bbPress (r2590) 536 * @param int $topic_id optional 537 * 538 * @uses bbp_get_topic_author_url() 539 */ 540 function bbp_topic_author_url ( $topic_id = 0 ) { 541 echo bbp_get_topic_author_url( $topic_id ); 542 } 543 /** 544 * bbp_get_topic_author_url () 545 * 546 * Return the author url of the topic in the loop 547 * 548 * @package bbPress 549 * @subpackage Template Tags 550 * @since bbPress (r2590) 551 * 552 * @uses bbp_get_user_profile_url() 553 * @uses get_post_meta() 554 * 555 * @param int $topic_id optional 556 * @return string Author URL of topic 557 */ 558 function bbp_get_topic_author_url ( $topic_id = 0 ) { 559 $topic_id = bbp_get_topic_id( $topic_id ); 560 561 // Check for anonymous user 562 if ( $author_id = get_post_field( 'post_author', $topic_id ) ) 563 $author_url = bbp_get_user_profile_url( $author_id ); 564 else 565 if ( !$author_url = get_post_meta( $topic_id, '_bbp_anonymous_website', true ) ) 566 $author_url = ''; 567 568 return apply_filters( 'bbp_get_topic_author_url', $author_url, $topic_id ); 569 } 570 496 571 /** 497 572 * bbp_topic_forum_title () 498 573 * … … 858 933 $topic_id = bbp_get_topic_id( $topic_id ); 859 934 860 935 // Look for existing count, and populate if does not exist 861 if ( !$voices = get_post_meta( $topic_id, '_bbp_topic_voice_count', true ) )936 if ( !$voices = get_post_meta( $topic_id, '_bbp_topic_voice_count', true ) ) 862 937 $voices = bbp_update_topic_voice_count( $topic_id ); 863 938 864 939 return apply_filters( 'bbp_get_topic_voice_count', (int)$voices, $topic_id ); -
bbp-themes/bbp-twentyten/loop-bbp_replies.php
58 58 <td class="bbp-reply-author"> 59 59 <?php 60 60 // @todo - abstract 61 printf ( 62 '<a href="%1$s" title="%2$s">%3$s</a>', 63 bbp_get_reply_author_url(), 64 sprintf( get_the_author_meta( 'ID' ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s Website' ), bbp_get_reply_author_display_name() ), 65 bbp_get_reply_author_avatar( 0, 80 ) 66 ); 61 bbp_reply_author_link(); 67 62 ?> 68 63 </td> 69 64 -
bbp-themes/bbp-twentyten/loop-bbp_topics.php
36 36 37 37 <p class="bbp-topic-meta"> 38 38 39 <?php printf( 'Started by: <a href="%1$s">%2$s</a>', bbp_get_topic_author_url(), bbp_get_topic_author() ); ?>39 <?php printf( __( 'Started by: %1$s', 'bbpress' ), bbp_get_topic_author_link() ); ?> 40 40 41 <?php if ( !bbp_is_forum() ) printf( 'in: <a href="%1$s">%2$s</a>', bbp_get_forum_permalink( bbp_get_topic_forum_id() ), bbp_get_forum_title( bbp_get_topic_forum_id() ) ); ?>41 <?php if ( !bbp_is_forum() ) printf( __( 'in: <a href="%1$s">%2$s</a>', 'bbpress' ), bbp_get_forum_permalink( bbp_get_topic_forum_id() ), bbp_get_forum_title( bbp_get_topic_forum_id() ) ); ?> 42 42 43 43 </p> 44 44 -
bbp-themes/bbp-twentyten/single-bbp_topic.php
69 69 70 70 <?php 71 71 // @todo - abstract 72 printf ( 73 '<a href="%1$s" title="%2$s">%3$s</a>', 74 bbp_get_topic_author_url(), 75 sprintf( get_the_author_meta( 'ID' ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s Website' ), bbp_get_topic_author_display_name() ), 76 bbp_get_topic_author_avatar( 0, 100 ) 77 ); 72 bbp_topic_author_link(); 78 73 ?> 79 74 80 75 </td>