Changeset 4493
- Timestamp:
- 06/12/2011 01:06:21 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-template.php
r4478 r4493 537 537 538 538 $defaults = array( 539 'type' => 'thumb', 540 'width' => 20, 541 'height' => 20, 542 'class' => 'avatar', 543 'alt' => __( 'Profile picture of %s', 'buddypress' ), 544 'email' => false 539 'type' => 'thumb', 540 'width' => 20, 541 'height' => 20, 542 'class' => 'avatar', 543 'alt' => __( 'Profile picture of %s', 'buddypress' ), 544 'email' => false, 545 'user_id' => false 545 546 ); 546 547 … … 553 554 554 555 // If this is a user object pass the users' email address for Gravatar so we don't have to refetch it. 555 if ( 'user' == $object && empty( $ email ) && isset( $activities_template->activity->user_email ) )556 if ( 'user' == $object && empty( $user_id ) && empty( $email ) && isset( $activities_template->activity->user_email ) ) 556 557 $email = $activities_template->activity->user_email; 557 558 … … 776 777 } 777 778 779 /** 780 * Echoes the comment markup for an activity item 781 * 782 * @package BuddyPress 783 * @subpackage Activity Template 784 * 785 * @param str $args Unused 786 */ 778 787 function bp_activity_comments( $args = '' ) { 779 788 echo bp_activity_get_comments( $args ); 780 789 } 790 /** 791 * Gets the comment markup for an activity item 792 * 793 * @package BuddyPress 794 * @subpackage Activity Template 795 * 796 * @param str $args Unused. Appears to be left over from an earlier implementation. 797 * @todo Given that checks for children already happen in bp_activity_recurse_comments(), 798 * this function can probably be streamlined or removed. 799 */ 781 800 function bp_activity_get_comments( $args = '' ) { 782 801 global $activities_template, $bp; … … 785 804 return false; 786 805 787 $comments_html = bp_activity_recurse_comments( $activities_template->activity ); 788 789 return apply_filters( 'bp_activity_get_comments', $comments_html ); 790 } 791 // TODO: The HTML in this function is temporary and will be moved 792 // to the template in a future version 806 bp_activity_recurse_comments( $activities_template->activity ); 807 } 808 809 /** 810 * Loops through a level of activity comments and loads the template for each 811 * 812 * Note: The recursion itself used to happen entirely in this function. Now it is 813 * split between here and the comment.php template. 814 * 815 * @package BuddyPress 816 * @subpackage Activity Template 817 * 818 * @param obj $comment The activity object currently being recursed 819 */ 793 820 function bp_activity_recurse_comments( $comment ) { 794 global $activities_template, $bp; 795 821 global $activities_template, $bp, $counter; 822 823 if ( !$comment ) 824 return false; 825 796 826 if ( !$comment->children ) 797 827 return false; 798 828 799 $content ='<ul>';829 echo '<ul>'; 800 830 foreach ( (array)$comment->children as $comment_child ) { 801 831 // Put the comment into the global so it's available to filters 802 832 $activities_template->activity->current_comment = $comment_child; 803 833 804 if ( empty( $comment_child->user_fullname ) ) 805 $comment_child->user_fullname = $comment_child->display_name; 806 807 if ( empty( $comment_child->user_nicename ) ) 808 $comment_child->user_nicename = ''; 809 810 if ( empty( $comment_child->user_login ) ) 811 $comment_child->user_login = ''; 812 813 if ( empty( $comment_child->user_email ) ) 814 $comment_child->user_email = ''; 815 816 $content .= '<li id="acomment-' . $comment_child->id . '">'; 817 $content .= '<div class="acomment-avatar"><a href="' . 818 bp_core_get_user_domain( 819 $comment_child->user_id, 820 $comment_child->user_nicename, 821 $comment_child->user_login ) . '">' . 822 bp_core_fetch_avatar( array( 823 'alt' => __( 'Profile picture of %s', 'buddypress' ), 824 'item_id' => $comment_child->user_id, 825 'width' => 30, 826 'height' => 30, 827 'email' => $comment_child->user_email 828 ) ) . 829 '</a></div>'; 830 831 $content .= '<div class="acomment-meta"><a href="' . 832 bp_core_get_user_domain( 833 $comment_child->user_id, 834 $comment_child->user_nicename, 835 $comment_child->user_login ) . '">' . 836 apply_filters( 'bp_acomment_name', $comment_child->user_fullname, $comment_child ) . 837 '</a> · ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $comment_child->date_recorded ) ); 838 839 // Reply link - the span is so that threaded reply links can be 840 // hidden when JS is off. 841 if ( is_user_logged_in() && bp_activity_can_comment_reply( $comment ) ) 842 $content .= apply_filters( 'bp_activity_comment_reply_link', '<span class="acomment-replylink"> · <a href="#acomment-' . $comment_child->id . '" class="acomment-reply" id="acomment-reply-' . $activities_template->activity->id . '">' . __( 'Reply', 'buddypress' ) . '</a></span>', $comment_child ); 843 844 // Delete link 845 if ( $bp->loggedin_user->is_super_admin || $bp->loggedin_user->id == $comment->user_id ) { 846 $delete_url = wp_nonce_url( bp_get_root_domain() . '/' . $bp->activity->slug . '/delete/?cid=' . $comment_child->id, 'bp_activity_delete_link' ); 847 $content .= apply_filters( 'bp_activity_comment_delete_link', ' · <a href="' . $delete_url . '" class="delete acomment-delete confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>', $comment_child, $delete_url ); 834 $template = locate_template( 'activity/comment.php', false, false ); 835 836 // Backward compatibility. In older versions of BP, the markup was 837 // generated in the PHP instead of a template. This ensures that 838 // older themes (which are not children of bp-default and won't 839 // have the new template) will still work. 840 if ( !$template ) { 841 $template = BP_PLUGIN_DIR . '/bp-themes/bp-default/activity/comment.php'; 848 842 } 849 850 $content .= '</div>'; 851 $content .= '<div class="acomment-content">' . apply_filters( 'bp_get_activity_content', $comment_child->content ) . '</div>'; 852 853 $content .= bp_activity_recurse_comments( $comment_child ); 854 $content .= '</li>'; 855 856 // Unset in the global in case of the last iteration 843 844 load_template( $template, false ); 845 857 846 unset( $activities_template->activity->current_comment ); 858 847 } 859 $content .= '</ul>'; 860 861 return apply_filters( 'bp_activity_recurse_comments', $content ); 848 echo '</ul>'; 862 849 } 850 851 /** 852 * Utility function that returns the comment currently being recursed 853 * 854 * @package BuddyPress 855 * @subpackage Activity Template 856 * @since 1.3 857 * 858 * @return obj $current_comment The activity comment currently being displayed 859 */ 860 function bp_activity_current_comment() { 861 global $activities_template; 862 863 $current_comment = !empty( $activities_template->activity->current_comment ) ? $activities_template->activity->current_comment : false; 864 865 return apply_filters( 'bp_activity_current_comment', $current_comment ); 866 } 867 868 869 /** 870 * Echoes the id of the activity comment currently being displayed 871 * 872 * @package BuddyPress 873 * @subpackage Activity Template 874 * @since 1.3 875 */ 876 function bp_activity_comment_id() { 877 echo bp_get_activity_comment_id(); 878 } 879 /** 880 * Gets the id of the activity comment currently being displayed 881 * 882 * @package BuddyPress 883 * @subpackage Activity Template 884 * @since 1.3 885 * 886 * @return int $comment_id The id of the activity comment currently being displayed 887 */ 888 function bp_get_activity_comment_id() { 889 global $activities_template; 890 891 $comment_id = isset( $activities_template->activity->current_comment->id ) ? $activities_template->activity->current_comment->id : false; 892 893 return apply_filters( 'bp_activity_comment_id', $comment_id ); 894 } 895 896 /** 897 * Echoes the user_id of the author of the activity comment currently being displayed 898 * 899 * @package BuddyPress 900 * @subpackage Activity Template 901 * @since 1.3 902 */ 903 function bp_activity_comment_user_id() { 904 echo bp_get_activity_comment_user_id(); 905 } 906 /** 907 * Gets the user_id of the author of the activity comment currently being displayed 908 * 909 * @package BuddyPress 910 * @subpackage Activity Template 911 * @since 1.3 912 * 913 * @return int $user_id The user_id of the author of the displayed activity comment 914 */ 915 function bp_get_activity_comment_user_id() { 916 global $activities_template; 917 918 $user_id = isset( $activities_template->activity->current_comment->user_id ) ? $activities_template->activity->current_comment->user_id : false; 919 920 return apply_filters( 'bp_activity_comment_user_id', $user_id ); 921 } 922 923 /** 924 * Echoes the author link for the activity comment currently being displayed 925 * 926 * @package BuddyPress 927 * @subpackage Activity Template 928 * @since 1.3 929 */ 930 function bp_activity_comment_user_link() { 931 echo bp_get_activity_comment_user_link(); 932 } 933 /** 934 * Gets the author link for the activity comment currently being displayed 935 * 936 * @package BuddyPress 937 * @subpackage Activity Template 938 * @since 1.3 939 * 940 * @return str $user_link The URL of the activity comment author's profile 941 */ 942 function bp_get_activity_comment_user_link() { 943 $user_link = bp_core_get_user_domain( bp_get_activity_comment_user_id() ); 944 945 return apply_filters( 'bp_activity_comment_user_link', $user_link ); 946 } 947 948 /** 949 * Echoes the author name for the activity comment currently being displayed 950 * 951 * @package BuddyPress 952 * @subpackage Activity Template 953 * @since 1.3 954 */ 955 function bp_activity_comment_name() { 956 echo bp_get_activity_comment_name(); 957 } 958 /** 959 * Gets the author name for the activity comment currently being displayed 960 * 961 * The use of the bp_acomment_name filter is deprecated. Please use bp_activity_comment_name 962 * 963 * @package BuddyPress 964 * @subpackage Activity Template 965 * @since 1.3 966 * 967 * @return str $name The full name of the activity comment author 968 */ 969 function bp_get_activity_comment_name() { 970 global $activities_template; 971 972 $name = apply_filters( 'bp_acomment_name', $activities_template->activity->current_comment->user_fullname, $activities_template->activity->current_comment ); // backward compatibility 973 974 return apply_filters( 'bp_activity_comment_name', $name ); 975 } 976 977 /** 978 * Echoes the date_recorded of the activity comment currently being displayed 979 * 980 * @package BuddyPress 981 * @subpackage Activity Template 982 * @since 1.3 983 */ 984 function bp_activity_comment_date_recorded() { 985 echo bp_get_activity_comment_date_recorded(); 986 } 987 /** 988 * Gets the date_recorded for the activity comment currently being displayed 989 * 990 * @package BuddyPress 991 * @subpackage Activity Template 992 * @since 1.3 993 * 994 * @return str $date_recorded Time since the activity was recorded, of the form "%s ago" 995 */ 996 function bp_get_activity_comment_date_recorded() { 997 global $activities_template; 998 999 if ( empty( $activities_template->activity->current_comment->date_recorded ) ) 1000 return false; 1001 1002 $date_recorded = sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $activities_template->activity->current_comment->date_recorded ) ); 1003 1004 return apply_filters( 'bp_activity_comment_date_recorded', $date_recorded ); 1005 } 1006 1007 /** 1008 * Echoes the 'delete' URL for the activity comment currently being displayed 1009 * 1010 * @package BuddyPress 1011 * @subpackage Activity Template 1012 * @since 1.3 1013 */ 1014 function bp_activity_comment_delete_link() { 1015 echo bp_get_activity_comment_delete_link(); 1016 } 1017 /** 1018 * Gets the 'delete' URL for the activity comment currently being displayed 1019 * 1020 * @package BuddyPress 1021 * @subpackage Activity Template 1022 * @since 1.3 1023 * 1024 * @return str $link The nonced URL for deleting the current activity comment 1025 */ 1026 function bp_get_activity_comment_delete_link() { 1027 global $bp; 1028 1029 $link = wp_nonce_url( bp_get_root_domain() . '/' . $bp->activity->slug . '/delete/?cid=' . bp_get_activity_comment_id(), 'bp_activity_delete_link' ); 1030 1031 return apply_filters( 'bp_activity_comment_delete_link', $link ); 1032 } 1033 1034 /** 1035 * Echoes the content of the activity comment currently being displayed 1036 * 1037 * @package BuddyPress 1038 * @subpackage Activity Template 1039 * @since 1.3 1040 */ 1041 function bp_activity_comment_content() { 1042 echo bp_get_activity_comment_content(); 1043 } 1044 /** 1045 * Gets the content of the activity comment currently being displayed 1046 * 1047 * The content is run through two filters. bp_get_activity_content will apply all filters 1048 * applied to activity items in general. Use bp_activity_comment_content to modify the 1049 * content of activity comments only. 1050 * 1051 * @package BuddyPress 1052 * @subpackage Activity Template 1053 * @since 1.3 1054 * 1055 * @return str $content The content of the current activity comment 1056 */ 1057 function bp_get_activity_comment_content() { 1058 global $activities_template; 1059 1060 $content = apply_filters( 'bp_get_activity_content', $activities_template->activity->current_comment->content ); 1061 1062 return apply_filters( 'bp_activity_comment_content', $content ); 1063 } 863 1064 864 1065 function bp_activity_comment_count() { -
trunk/bp-themes/bp-default/activity/entry.php
r4043 r4493 81 81 <?php if ( bp_activity_can_comment() ) : ?> 82 82 <div class="activity-comments"> 83 83 84 84 <?php bp_activity_comments(); ?> 85 85
Note: See TracChangeset
for help on using the changeset viewer.