Changeset 4543 for trunk/includes/users/template-tags.php
- Timestamp:
- 12/05/2012 09:02:01 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/users/template-tags.php
r4542 r4543 640 640 * @param int $user_id Optional. User id 641 641 * @param int $topic_id Optional. Topic id 642 * @param bool $wrap Optional. If you want to wrap the link in <span id="favorite-toggle">. See ajax_favorite() 642 643 * @uses bbp_get_user_id() To get the user id 643 644 * @uses current_user_can() If the current user can edit the user … … 651 652 * @return string User favorites link 652 653 */ 653 function bbp_get_user_favorites_link( $add = array(), $rem = array(), $user_id = 0, $topic_id = 0 ) {654 function bbp_get_user_favorites_link( $add = array(), $rem = array(), $user_id = 0, $topic_id = 0, $wrap = true ) { 654 655 if ( !bbp_is_favorites_active() ) 655 656 return false; … … 704 705 } elseif ( is_singular( bbp_get_reply_post_type() ) ) { 705 706 $permalink = bbp_get_topic_permalink( $topic_id ); 706 } else if ( bbp_is_query_name( 'bbp_single_topic' ) ){707 } else { 707 708 $permalink = get_permalink(); 708 709 } 709 710 710 $url = esc_url( wp_nonce_url( add_query_arg( $favs, $permalink ), 'toggle-favorite_' . $topic_id ) ); 711 $is_fav = $is_fav ? 'is-favorite' : ''; 712 $html = '<span id="favorite-toggle"><span id="favorite-' . $topic_id . '" class="' . $is_fav . '">' . $pre . '<a href="' . $url . '" class="dim:favorite-toggle:favorite-' . $topic_id . ':is-favorite">' . $mid . '</a>' . $_post . '</span></span>'; 711 $url = esc_url( wp_nonce_url( add_query_arg( $favs, $permalink ), 'toggle-favorite_' . $topic_id ) ); 712 $fav = $is_fav ? 'is-favorite' : ''; 713 $html = sprintf( '<span id="favorite-%d" class="%s">%s<a href="%s" class="favorite-toggle" data-topic="%d" >%s</a>%s</span>', $topic_id, $fav, $pre, $url, $topic_id, $mid, $_post ); 714 715 // Initial output is wrapped in a span, ajax output is hooked to this 716 if ( !empty( $wrap ) ) { 717 $html = '<span id="favorite-toggle">' . $html . '</span>'; 718 } 713 719 714 720 // Return the link … … 801 807 * - after: After the link 802 808 * @param int $user_id Optional. User id 809 * @param bool $wrap Optional. If you want to wrap the link in <span id="favorite-toggle">. 803 810 * @uses bbp_get_user_id() To get the user id 804 811 * @uses current_user_can() To check if the current user can edit user … … 812 819 * @return string Permanent link to topic 813 820 */ 814 function bbp_get_user_subscribe_link( $args = '', $user_id = 0 ) {821 function bbp_get_user_subscribe_link( $args = '', $user_id = 0, $wrap = true ) { 815 822 if ( !bbp_is_subscriptions_active() ) 816 823 return; … … 856 863 } elseif ( is_singular( bbp_get_reply_post_type() ) ) { 857 864 $permalink = bbp_get_topic_permalink( $topic_id ); 858 } else if ( bbp_is_query_name( 'bbp_single_topic' ) ){865 } else { 859 866 $permalink = get_permalink(); 860 867 } 861 868 862 $url = esc_url( wp_nonce_url( add_query_arg( $query_args, $permalink ), 'toggle-subscription_' . $topic_id ) ); 863 $subscribed = $is_subscribed ? ' class="is_subscribed"' : ''; 864 $html = '<span id="subscription-toggle">' . $r['before'] . '<span id="subscribe-' . $topic_id . '"' . $subscribed . '><a href="' . $url . '" class="dim:subscription-toggle:subscribe-' . $topic_id . ':is-subscribed">' . $text . '</a></span>' . $r['after'] . '</span>'; 869 $url = esc_url( wp_nonce_url( add_query_arg( $query_args, $permalink ), 'toggle-subscription_' . $topic_id ) ); 870 $sub = $is_subscribed ? ' class="is_subscribed"' : ''; 871 $html = sprintf( '%s <span id="subscribe-%d" %s><a href="%s" class="subscription-toggle" data-topic="%d">%s</a></span>' . $r['after'] . '</span>', $r['before'], $topic_id, $sub, $url, $topic_id, $text ); 872 873 // Initial output is wrapped in a span, ajax output is hooked to this 874 if ( !empty( $wrap ) ) { 875 $html = '<span id="subscription-toggle">' . $html . '</span>'; 876 } 865 877 866 878 // Return the link
Note: See TracChangeset
for help on using the changeset viewer.