Changeset 3260
- Timestamp:
- 09/13/2010 01:08:31 AM (14 years ago)
- Location:
- branches/1.2
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.2/bp-activity/bp-activity-templatetags.php
r3245 r3260 922 922 global $bp; 923 923 924 return apply_filters( 'bp_get_send_public_message_link', $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ); 924 if ( bp_is_my_profile() || !is_user_logged_in() ) 925 return false; 926 927 return apply_filters( 'bp_get_send_public_message_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ); 928 } 929 930 /** 931 * bp_send_public_message_button( $args ) 932 * 933 * Output button for sending a public message 934 * 935 * @param array $args 936 */ 937 function bp_send_public_message_button( $args = '' ) { 938 echo bp_get_send_public_message_button( $args ); 939 } 940 /** 941 * bp_get_send_public_message_button( $args ) 942 * 943 * Return button for sending a public message 944 * 945 * @param array $args 946 * @return string 947 */ 948 function bp_get_send_public_message_button( $args = '' ) { 949 $defaults = array( 950 'id' => 'public_message', 951 'component' => 'activity', 952 'must_be_logged_in' => true, 953 'block_self' => true, 954 'wrapper_id' => 'post-mention', 955 'link_href' => bp_get_send_public_message_link(), 956 'link_title' => __( 'Mention this user in a new public message, this will send the user a notification to get their attention.', 'buddypress' ), 957 'link_text' => __( 'Mention this User', 'buddypress' ) 958 ); 959 960 $button = wp_parse_args( $args, $defaults ); 961 962 // Filter and return the HTML button 963 return bp_get_button( apply_filters( 'bp_get_send_public_message_button', $button ) ); 925 964 } 926 965 -
branches/1.2/bp-blogs/bp-blogs-templatetags.php
r3245 r3260 505 505 } 506 506 507 /** 508 * bp_blogs_visit_blog_button() 509 * 510 * Output button for visiting a blog in a loop 511 * 512 * @param array $args Custom button properties 513 */ 514 function bp_blogs_visit_blog_button( $args = '' ) { 515 echo bp_get_blogs_visit_blog_button( $args ); 516 } 517 /** 518 * bp_get_blogs_visit_blog_button() 519 * 520 * Return button for visiting a blog in a loop 521 * 522 * @param array $args Custom button properties 523 * @return string 524 */ 525 function bp_get_blogs_visit_blog_button( $args = '' ) { 526 $defaults = array( 527 'id' => 'visit_blog', 528 'component' => 'blogs', 529 'must_be_logged_in' => false, 530 'block_self' => false, 531 'wrapper_class' => 'blog-button visit', 532 'link_href' => bp_get_blog_permalink(), 533 'link_class' => 'visit', 534 'link_text' => __( 'Visit Blog', 'buddypress' ), 535 'link_title' => __( 'Visit Blog', 'buddypress' ), 536 ); 537 538 $button = wp_parse_args( $args, $defaults ); 539 540 // Filter and return the HTML button 541 return bp_get_button( apply_filters( 'bp_get_blogs_visit_blog_button', $button ) ); 542 } 543 507 544 ?> -
branches/1.2/bp-core/bp-core-classes.php
r3224 r3260 496 496 } 497 497 498 /** 499 * BP_Button 500 * 501 * API to create BuddyPress buttons 502 * 503 * @package BuddyPress Core 504 * @since 1.2.6 505 */ 506 class BP_Button { 507 508 // Button properties 509 var $id; 510 var $component; 511 var $must_be_logged_in; 512 var $block_self; 513 514 // Wrapper div 515 var $wrapper_class; 516 var $wrapper_id; 517 518 // Button 519 var $link_href; 520 var $link_class; 521 var $link_id; 522 var $link_rel; 523 var $link_title; 524 var $link_text; 525 526 // HTML result 527 var $contents; 528 529 /** 530 * bp_button() 531 * 532 * Builds the button based on passed parameters: 533 * 534 * component: Which component this button is for 535 * must_be_logged_in: Button only appears for logged in users 536 * block_self: Button will not appear when viewing your own profile. 537 * wrapper_id: The DOM ID of the button wrapper 538 * wrapper_class: The DOM class of the button wrapper 539 * link_href: The destination link of the button 540 * link_title: Title of the button 541 * link_id: The DOM ID of the button 542 * link_class: The DOM class of the button 543 * link_rel: The DOM rel of the button 544 * link_text: The contents of the button 545 * 546 * @param array $args 547 * @return bool False if not allowed 548 */ 549 function bp_button( $args = '' ) { 550 551 $defaults = array( 552 'id' => '', 553 'component' => 'core', 554 'must_be_logged_in' => true, 555 'block_self' => true, 556 557 'wrapper_id' => '', 558 'wrapper_class' => '', 559 560 'link_href' => '', 561 'link_title' => '', 562 'link_id' => '', 563 'link_class' => '', 564 'link_rel' => '', 565 'link_text' => '', 566 ); 567 568 $r = wp_parse_args( $args, $defaults ); 569 extract( $r, EXTR_SKIP ); 570 571 // Required button properties 572 $this->id = $id; 573 $this->component = $component; 574 $this->must_be_logged_in = (bool)$must_be_logged_in; 575 $this->block_self = (bool)$block_self; 576 577 // $id and $component are required 578 if ( empty( $id ) || empty( $component ) ) 579 return false; 580 581 // No button if component is not active 582 if ( !bp_is_active( $this->component ) ) 583 return false; 584 585 // No button for guests if must be logged in 586 if ( true == $this->must_be_logged_in && !is_user_logged_in ) 587 return false; 588 589 // No button if viewing your own profile 590 if ( true == $this->block_self && bp_is_my_profile() ) 591 return false; 592 593 // Wrapper properties 594 if ( !empty( $wrapper_id ) ) 595 $this->wrapper_id = ' id="' . $wrapper_id . '"'; 596 597 if ( !empty( $wrapper_class ) ) 598 $this->wrapper_class = ' class="generic-button ' . $wrapper_class . '"'; 599 else 600 $this->wrapper_class = ' class="generic-button"'; 601 602 // Link properties 603 if ( !empty( $link_id ) ) 604 $this->link_id = ' id="' . $link_id . '"'; 605 606 if ( !empty( $link_href ) ) 607 $this->link_href = ' href="' . $link_href . '"'; 608 609 if ( !empty( $link_title ) ) 610 $this->link_title = ' title="' . $link_title . '"'; 611 612 if ( !empty( $link_rel ) ) 613 $this->link_rel = ' rel="' . $link_rel . '"'; 614 615 if ( !empty( $link_class ) ) 616 $this->link_class = ' class="' . $link_class . '"'; 617 618 if ( !empty( $link_text ) ) 619 $this->link_text = $link_text; 620 621 // Build the button 622 $this->contents = '<div' . $this->wrapper_class . $this->wrapper_id . '>'; 623 $this->contents .= '<a'. $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->link_class . '>' . $this->link_text . '</a>'; 624 $this->contents .= '</div>'; 625 626 // Allow button to be manipulated externally 627 $this->contents = apply_filters( 'bp_button_' . $component . '_' . $id, $this->contents, $this ); 628 } 629 630 /** 631 * contents() 632 * 633 * Return contents of button 634 * 635 * @return string 636 */ 637 function contents() { 638 return $this->contents; 639 } 640 641 /** 642 * display() 643 * 644 * Output contents of button 645 */ 646 function display() { 647 if ( !empty( $this->contents ) ) 648 echo $this->contents; 649 } 650 } 498 651 499 652 ?> -
branches/1.2/bp-core/bp-core-templatetags.php
r3245 r3260 416 416 417 417 return apply_filters( 'bp_member_last_active', $registered ); 418 }419 420 function bp_member_add_friend_button() {421 global $members_template;422 423 if ( function_exists( 'bp_add_friend_button' ) ) {424 if ( null === $members_template->member->is_friend )425 $friend_status = 'not_friends';426 else427 $friend_status = ( 0 == $members_template->member->is_friend ) ? 'pending' : 'is_friend';428 429 echo bp_add_friend_button( $members_template->member->id, $friend_status );430 }431 }432 433 function bp_member_total_friend_count() {434 global $members_template;435 436 echo bp_get_member_total_friend_count();437 }438 function bp_get_member_total_friend_count() {439 global $members_template;440 441 if ( 1 == (int) $members_template->member->total_friend_count )442 return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $members_template->member->total_friend_count ) );443 else444 return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $members_template->member->total_friend_count ) );445 418 } 446 419 … … 1100 1073 1101 1074 /** 1075 * bp_button( $button ) 1076 * 1077 * Creates and outputs a button. 1078 * Args: div_id | div_class | a_href | a_title | a_id | a_class | a_rel | a_text 1079 * 1080 * @param array $button 1081 */ 1082 function bp_button( $button = '' ) { 1083 echo bp_get_button( $button ); 1084 } 1085 /** 1086 * bp_get_button( $button ) 1087 * 1088 * Creates and returns a button. 1089 * Args: div_id | div_class | a_href | a_title | a_id | a_class | a_rel | a_text 1090 * 1091 * @param array $button 1092 * @return string 1093 */ 1094 function bp_get_button( $button = '' ) { 1095 $btn = new BP_Button( $button ); 1096 return apply_filters( 'bp_get_button', $btn->contents, $button ); 1097 } 1098 1099 /** 1102 1100 * bp_create_excerpt() 1103 1101 * -
branches/1.2/bp-core/bp-core-widgets.php
r3143 r3260 22 22 global $bp; 23 23 24 24 extract( $args ); 25 25 26 26 echo $before_widget; … … 32 32 <div class="item-options" id="members-list-options"> 33 33 <span class="ajax-loader" id="ajax-loader-members"></span> 34 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> | 35 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> | 36 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a> 34 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> 35 | <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> 36 37 <?php if ( bp_is_active( 'friends' ) ) : ?> 38 39 | <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a> 40 41 <?php endif; ?> 42 37 43 </div> 38 44 … … 148 154 global $bp; 149 155 150 156 extract( $args ); 151 157 152 158 echo $before_widget; … … 202 208 case 'newest-members': 203 209 $type = 'newest'; 204 break; 210 break; 211 205 212 case 'recently-active-members': 206 213 $type = 'active'; 207 break; 214 break; 215 208 216 case 'popular-members': 209 $type = 'popular'; 210 break; 217 if ( bp_is_active( 'friends' ) ) 218 $type = 'popular'; 219 else 220 $type = 'active'; 221 222 break; 211 223 } 212 224 … … 224 236 <?php if ( 'active' == $type || 'newest' == $type ) : ?> 225 237 <div class="item-meta"><span class="activity"><?php bp_member_last_active() ?></span></div> 226 <?php else : ?>238 <?php elseif ( bp_is_active( 'friends' ) ) : ?> 227 239 <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count() ?></span></div> 228 240 <?php endif; ?> -
branches/1.2/bp-friends/bp-friends-templatetags.php
r3162 r3260 105 105 <form action="<?php echo $action ?>" id="friend-search-form" method="post"> 106 106 107 <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label>108 <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> />109 110 <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>111 <input type="hidden" name="initiator" id="initiator" value="<?php echo esc_attr( $bp->displayed_user->id ) ?>" />107 <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label> 108 <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> /> 109 110 <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?> 111 <input type="hidden" name="initiator" id="initiator" value="<?php echo esc_attr( $bp->displayed_user->id ) ?>" /> 112 112 113 113 </form> … … 115 115 } 116 116 117 function bp_add_friend_button( $potential_friend_id = false, $friend_status = false ) { 117 function bp_member_add_friend_button() { 118 global $members_template; 119 120 if ( null === $members_template->member->is_friend ) 121 $friend_status = 'not_friends'; 122 else 123 $friend_status = ( 0 == $members_template->member->is_friend ) ? 'pending' : 'is_friend'; 124 125 echo bp_get_add_friend_button( $members_template->member->id, $friend_status ); 126 } 127 add_action( 'bp_directory_members_actions', 'bp_member_add_friend_button' ); 128 129 function bp_member_total_friend_count() { 130 global $members_template; 131 132 echo bp_get_member_total_friend_count(); 133 } 134 function bp_get_member_total_friend_count() { 135 global $members_template; 136 137 if ( 1 == (int) $members_template->member->total_friend_count ) 138 return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $members_template->member->total_friend_count ) ); 139 else 140 return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $members_template->member->total_friend_count ) ); 141 } 142 143 /** 144 * bp_potential_friend_id( $user_id ) 145 * 146 * Outputs the ID of the potential friend 147 * 148 * @uses bp_get_potential_friend_id() 149 * @param <type> $user_id 150 */ 151 function bp_potential_friend_id( $user_id = 0 ) { 152 echo bp_get_potential_friend_id( $user_id ); 153 } 154 /** 155 * bp_get_potential_friend_id( $user_id ) 156 * 157 * Returns the ID of the potential friend 158 * 159 * @global object $bp 160 * @global object $friends_template 161 * @param int $user_id 162 * @return int ID of potential friend 163 */ 164 function bp_get_potential_friend_id( $user_id = 0 ) { 165 global $bp, $friends_template; 166 167 if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) ) 168 $user_id = $friends_template->friendship->friend->id; 169 else if ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) ) 170 $user_id = $bp->displayed_user->id; 171 172 return apply_filters( 'bp_get_potential_friend_id', (int)$user_id ); 173 } 174 175 /** 176 * bp_is_friend( $user_id ) 177 * 178 * Returns - 'is_friend', 'not_friends', 'pending' 179 * 180 * @global object $bp 181 * @param int $potential_friend_id 182 * @return string 183 */ 184 function bp_is_friend( $user_id = 0 ) { 185 global $bp; 186 187 if ( !is_user_logged_in() ) 188 return false; 189 190 if ( empty( $user_id ) ) 191 $user_id = bp_get_potential_friend_id( $user_id ); 192 193 if ( $bp->loggedin_user->id == $user_id ) 194 return false; 195 196 return apply_filters( 'bp_is_friend', friends_check_friendship_status( $bp->loggedin_user->id, $user_id ), $user_id ); 197 } 198 199 function bp_add_friend_button( $potential_friend_id = 0, $friend_status = false ) { 118 200 echo bp_get_add_friend_button( $potential_friend_id, $friend_status ); 119 201 } 120 function bp_get_add_friend_button( $potential_friend_id = false, $friend_status = false ) {202 function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) { 121 203 global $bp, $friends_template; 122 204 123 if ( !is_user_logged_in() ) 205 if ( empty( $potential_friend_id ) ) 206 $potential_friend_id = bp_get_potential_friend_id( $potential_friend_id ); 207 208 $is_friend = bp_is_friend( $potential_friend_id ); 209 210 if ( empty( $is_friend ) ) 124 211 return false; 125 212 126 if ( !$potential_friend_id && $friends_template->friendship->friend ) 127 $potential_friend_id = $friends_template->friendship->friend->id; 128 else if ( !$potential_friend_id && !$friends_template->friendship->friend ) 129 $potential_friend_id = $bp->displayed_user->id; 130 131 if ( $bp->loggedin_user->id == $potential_friend_id ) 132 return false; 133 134 if ( empty( $friend_status ) ) 135 $friend_status = friends_check_friendship_status( $bp->loggedin_user->id, $potential_friend_id ); 136 137 $button = '<div class="generic-button friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">'; 138 139 if ( 'pending' == $friend_status ) 140 $button .= '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/">' . __( 'Friendship Requested', 'buddypress' ) . '</a>'; 141 else if ( 'is_friend' == $friend_status ) 142 $button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ) . '" title="' . __('Cancel Friendship', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="remove" class="remove">' . __('Cancel Friendship', 'buddypress') . '</a>'; 143 else 144 $button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ) . '" title="' . __('Add Friend', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="add" class="add">' . __('Add Friend', 'buddypress') . '</a>'; 145 146 $button .= '</div>'; 147 148 return apply_filters( 'bp_get_add_friend_button', $button, $potential_friend_id, $friend_status ); 213 switch ( $is_friend ) { 214 case 'pending' : 215 $button = array( 216 'id' => 'pending', 217 'component' => 'friends', 218 'must_be_logged_in' => true, 219 'block_self' => true, 220 'wrapper_class' => 'friendship-button pending', 221 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 222 'link_class' => 'requested', 223 'link_href' => trailingslashit( $bp->loggedin_user->domain . $bp->friends->slug ), 224 'link_text' => __( 'Friendship Requested', 'buddypress' ), 225 'link_title' => __( 'Friendship Requested', 'buddypress' ) 226 ); 227 break; 228 229 case 'is_friend' : 230 $button = array( 231 'id' => 'is_friend', 232 'component' => 'friends', 233 'must_be_logged_in' => true, 234 'block_self' => true, 235 'wrapper_class' => 'friendship-button is_friend', 236 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 237 'link_class' => '', 238 'link_href' => wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ), 239 'link_text' => __( 'Cancel Friendship', 'buddypress' ), 240 'link_title' => __( 'Cancel Friendship', 'buddypress' ), 241 'link_id' => 'friend-' . $potential_friend_id, 242 'link_rel' => 'remove', 243 'link_class' => 'remove' 244 ); 245 break; 246 247 default: 248 $button = array( 249 'id' => 'not_friends', 250 'component' => 'friends', 251 'must_be_logged_in' => true, 252 'block_self' => true, 253 'wrapper_class' => 'friendship-button not_friends', 254 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 255 'link_class' => '', 256 'link_href' => wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ), 257 'link_text' => __( 'Add Friend', 'buddypress' ), 258 'link_title' => __( 'Add Friend', 'buddypress' ), 259 'link_id' => 'friend-' . $potential_friend_id, 260 'link_rel' => 'add', 261 'link_class' => 'add' 262 ); 263 break; 264 } 265 266 // Filter and return the HTML button 267 return bp_get_button( apply_filters( 'bp_get_add_friend_button', $button ) ); 149 268 } 150 269 … … 210 329 } 211 330 212 function bp_total_friend_count( $user_id = false) {331 function bp_total_friend_count( $user_id = 0 ) { 213 332 echo bp_get_total_friend_count( $user_id ); 214 333 } 215 function bp_get_total_friend_count( $user_id = false) {334 function bp_get_total_friend_count( $user_id = 0 ) { 216 335 return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) ); 217 336 } 218 337 add_filter( 'bp_get_total_friend_count', 'bp_core_number_format' ); 219 338 220 function bp_friend_total_requests_count( $user_id = false) {339 function bp_friend_total_requests_count( $user_id = 0 ) { 221 340 echo bp_friend_get_total_requests_count( $user_id ); 222 341 } 223 function bp_friend_get_total_requests_count( $user_id = false) {342 function bp_friend_get_total_requests_count( $user_id = 0 ) { 224 343 global $bp; 225 344 226 if ( !$user_id)345 if ( empty( $user_id ) ) 227 346 $user_id = $bp->loggedin_user->id; 228 347 -
branches/1.2/bp-groups/bp-groups-templatetags.php
r3245 r3260 1096 1096 } 1097 1097 1098 function bp_group_new_topic_button() { 1099 if ( bp_is_group_forum() && is_user_logged_in() && !bp_is_group_forum_topic() ) { 1100 bp_button( array ( 1101 'id' => 'new_topic', 1102 'component' => 'groups', 1103 'must_be_logged_in' => true, 1104 'block_self' => true, 1105 'wrapper_class' => 'group-button', 1106 'link_href' => '#post-new', 1107 'link_class' => '', 1108 'link_text' => __( 'New Topic', 'buddypress' ), 1109 'link_title' => __( 'New Topic', 'buddypress' ), 1110 ) ); 1111 } 1112 } 1113 1098 1114 function bp_group_join_button( $group = false ) { 1099 global $bp, $groups_template; 1100 1101 if ( !$group ) 1102 $group =& $groups_template->group; 1103 1104 // If they're not logged in or are banned from the group, no join button. 1105 if ( !is_user_logged_in() || $group->is_banned ) 1106 return false; 1107 1108 if ( !$group->status ) 1109 return false; 1110 1111 if ( 'hidden' == $group->status && !$group->is_member ) 1112 return false; 1113 1114 echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">'; 1115 1116 switch ( $group->status ) { 1117 case 'public': 1118 if ( $group->is_member ) 1119 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1120 else 1121 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1122 break; 1123 1124 case 'private': 1125 if ( $group->is_member ) { 1126 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1127 } else { 1128 if ( !bp_group_has_requested_membership( $group ) ) 1129 echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1130 else 1131 echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1115 echo bp_get_group_join_button(); 1116 } 1117 function bp_get_group_join_button( $group = false ) { 1118 global $bp, $groups_template; 1119 1120 if ( !$group ) 1121 $group =& $groups_template->group; 1122 1123 // If they're not logged in or are banned from the group, no join button. 1124 if ( !is_user_logged_in() || $group->is_banned ) 1125 return false; 1126 1127 if ( !$group->status ) 1128 return false; 1129 1130 if ( 'hidden' == $group->status && !$group->is_member ) 1131 return false; 1132 1133 // Already a member 1134 if ( $group->is_member ) { 1135 $button = array( 1136 'id' => 'leave_group', 1137 'component' => 'groups', 1138 'must_be_logged_in' => true, 1139 'block_self' => false, 1140 'wrapper_class' => 'group-button ' . $group->status, 1141 'wrapper_id' => 'groupbutton-' . $group->id, 1142 'link_class' => 'leave-group', 1143 'link_href' => wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ), 1144 'link_text' => __( 'Leave Group', 'buddypress' ), 1145 'link_title' => __( 'Leave Group', 'buddypress' ) 1146 ); 1147 1148 // Not a member 1149 } else { 1150 1151 // Show different buttons based on group status 1152 switch ( $group->status ) { 1153 case 'public': 1154 $button = array( 1155 'id' => 'join_group', 1156 'component' => 'groups', 1157 'must_be_logged_in' => true, 1158 'block_self' => false, 1159 'wrapper_class' => 'group-button ' . $group->status, 1160 'wrapper_id' => 'groupbutton-' . $group->id, 1161 'link_class' => 'join-group', 1162 'link_href' => wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ), 1163 'link_text' => __( 'Join Group', 'buddypress' ), 1164 'link_title' => __( 'Join Group', 'buddypress' ) 1165 ); 1166 break; 1167 1168 case 'private' : 1169 1170 // Member has not requested membership yet 1171 if ( !bp_group_has_requested_membership( $group ) ) { 1172 $button = array( 1173 'id' => 'request_membership', 1174 'component' => 'groups', 1175 'must_be_logged_in' => true, 1176 'block_self' => false, 1177 'wrapper_class' => 'group-button ' . $group->status, 1178 'wrapper_id' => 'groupbutton-' . $group->id, 1179 'link_class' => 'request-membership', 1180 'link_href' => wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ), 1181 'link_text' => __( 'Request Membership', 'buddypress' ), 1182 'link_title' => __( 'Request Membership', 'buddypress' ), 1183 ); 1184 1185 // Member has requested membership already 1186 } else { 1187 $button = array( 1188 'id' => 'membership_requested', 1189 'component' => 'groups', 1190 'must_be_logged_in' => true, 1191 'block_self' => false, 1192 'wrapper_class' => 'group-button pending ' . $group->status, 1193 'wrapper_id' => 'groupbutton-' . $group->id, 1194 'link_class' => 'membership-requested', 1195 'link_href' => bp_get_group_permalink( $group ), 1196 'link_text' => __( 'Request Sent', 'buddypress' ), 1197 'link_title' => __( 'Request Sent', 'buddypress' ), 1198 ); 1199 } 1200 1201 break; 1132 1202 } 1133 break; 1134 1135 case 'hidden': 1136 if ( $group->is_member ) 1137 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1138 break; 1139 } 1140 1141 echo '</div>'; 1142 } 1203 } 1204 1205 // Filter and return the HTML button 1206 return bp_get_button( apply_filters( 'bp_get_group_join_button', $button ) ); 1207 } 1143 1208 1144 1209 function bp_group_status_message( $group = false ) { … … 1986 2051 1987 2052 function bp_group_request_reject_link() { 1988 global $requests_template, $groups_template; 1989 1990 echo apply_filters( 'bp_group_request_reject_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/reject/' . $requests_template->request->id, 'groups_reject_membership_request' ) ); 1991 } 2053 echo bp_get_group_request_reject_link(); 2054 } 2055 function bp_get_group_request_reject_link() { 2056 global $requests_template, $groups_template; 2057 2058 return apply_filters( 'bp_get_group_request_reject_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/reject/' . $requests_template->request->id, 'groups_reject_membership_request' ) ); 2059 } 1992 2060 1993 2061 function bp_group_request_accept_link() { 1994 global $requests_template, $groups_template; 1995 1996 echo apply_filters( 'bp_group_request_accept_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/accept/' . $requests_template->request->id, 'groups_accept_membership_request' ) ); 1997 } 2062 echo bp_get_group_request_accept_link(); 2063 } 2064 function bp_get_group_request_accept_link() { 2065 global $requests_template, $groups_template; 2066 2067 return apply_filters( 'bp_get_group_request_accept_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/accept/' . $requests_template->request->id, 'groups_accept_membership_request' ) ); 2068 } 2069 2070 function bp_group_request_user_link() { 2071 echo bp_get_group_request_user_link(); 2072 } 2073 function bp_get_group_request_user_link() { 2074 global $requests_template; 2075 2076 return apply_filters( 'bp_get_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) ); 2077 } 1998 2078 1999 2079 function bp_group_request_time_since_requested() { … … 2008 2088 echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) ); 2009 2089 } 2010 2011 function bp_group_request_user_link() {2012 global $requests_template;2013 2014 echo apply_filters( 'bp_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) );2015 }2016 2017 2090 2018 2091 /************************************************************************************ -
branches/1.2/bp-messages/bp-messages-templatetags.php
r3246 r3260 502 502 global $bp; 503 503 504 return apply_filters( 'bp_get_send_private_message_link', $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ); 505 } 504 if ( bp_is_my_profile() || !is_user_logged_in() ) 505 return false; 506 507 return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ); 508 } 509 510 /** 511 * bp_send_private_message_button() 512 * 513 * Explicitly named function to avoid confusion with public messages. 514 * 515 * @uses bp_get_send_message_button() 516 * @since 1.2.6 517 */ 518 function bp_send_private_message_button() { 519 echo bp_get_send_message_button(); 520 } 506 521 507 522 function bp_send_message_button() { … … 509 524 } 510 525 function bp_get_send_message_button() { 511 global $bp; 512 513 if ( bp_is_my_profile() || !is_user_logged_in() ) 514 return false; 515 516 return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' ); 526 return apply_filters( 'bp_get_send_message_button', 527 bp_get_button( array( 528 'id' => 'private_message', 529 'component' => 'messages', 530 'must_be_logged_in' => true, 531 'block_self' => true, 532 'wrapper_id' => 'send-private-message', 533 'link_href' => bp_get_send_private_message_link(), 534 'link_class' => 'send-message', 535 'link_title' => __( 'Send a private message to this user.', 'buddypress' ), 536 'link_text' => __( 'Send Private Message', 'buddypress' ) 537 ) ) 538 ); 517 539 } 518 540 -
branches/1.2/bp-themes/bp-default/blogs/blogs-loop.php
r3222 r3260 35 35 36 36 <div class="action"> 37 <div class="generic-button blog-button visit"> 38 <a href="<?php bp_blog_permalink() ?>" class="visit" title="<?php _e( 'Visit Blog', 'buddypress' ) ?>"><?php _e( 'Visit Blog', 'buddypress' ) ?></a> 39 </div> 37 38 <?php do_action( 'bp_directory_blogs_actions' ) ?> 40 39 41 40 <div class="meta"> … … 43 42 </div> 44 43 45 <?php do_action( 'bp_directory_blogs_actions' ) ?>46 44 </div> 47 45 -
branches/1.2/bp-themes/bp-default/functions.php
r3227 r3260 334 334 if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) 335 335 add_action( 'admin_notices', 'bp_dtheme_show_notice' ); 336 337 338 // Member Buttons 339 add_action( 'bp_member_header_actions', 'bp_add_friend_button' ); 340 add_action( 'bp_member_header_actions', 'bp_send_public_message_button' ); 341 add_action( 'bp_member_header_actions', 'bp_send_private_message_button' ); 342 343 // Group Buttons 344 add_action( 'bp_group_header_actions', 'bp_group_join_button' ); 345 add_action( 'bp_group_header_actions', 'bp_group_new_topic_button' ); 346 add_action( 'bp_directory_groups_actions', 'bp_group_join_button' ); 347 348 // Blog Buttons 349 add_action( 'bp_directory_blogs_actions', 'bp_blogs_visit_blog_button' ); 350 336 351 ?> -
branches/1.2/bp-themes/bp-default/groups/groups-loop.php
r3222 r3260 34 34 35 35 <?php do_action( 'bp_directory_groups_item' ) ?> 36 36 37 </div> 37 38 38 39 <div class="action"> 39 <?php bp_group_join_button() ?> 40 41 <?php do_action( 'bp_directory_groups_actions' ) ?> 40 42 41 43 <div class="meta"> 44 42 45 <?php bp_group_type() ?> / <?php bp_group_member_count() ?> 46 43 47 </div> 44 48 45 <?php do_action( 'bp_directory_groups_actions' ) ?>46 49 </div> 47 50 -
branches/1.2/bp-themes/bp-default/groups/single/admin.php
r3203 r3260 117 117 118 118 <?php if ( bp_get_group_has_avatar() ) : ?> 119 119 120 <p><?php _e( "If you'd like to remove the existing avatar but not upload a new one, please use the delete avatar button.", 'buddypress' ) ?></p> 120 121 121 <div class="generic-button" id="delete-group-avatar-button"> 122 <a class="edit" href="<?php bp_group_avatar_delete_link() ?>" title="<?php _e( 'Delete Avatar', 'buddypress' ) ?>"><?php _e( 'Delete Avatar', 'buddypress' ) ?></a> 123 </div> 122 <?php bp_button( array( 'id' => 'delete_group_avatar', 'component' => 'groups', 'wrapper_id' => 'delete-group-avatar-button', 'link_class' => 'edit', 'link_href' => bp_get_group_avatar_delete_link(), 'link_title' => __( 'Delete Avatar', 'buddypress' ), 'link_text' => __( 'Delete Avatar', 'buddypress' ) ) ); ?> 123 124 124 <?php endif; ?> 125 125 … … 261 261 <div class="action"> 262 262 263 <div class="generic-button accept"> 264 <a href="<?php bp_group_request_accept_link() ?>"><?php _e( 'Accept', 'buddypress' ); ?></a> 265 </div> 266 267 268 269 <div class="generic-button reject"> 270 <a href="<?php bp_group_request_reject_link() ?>"><?php _e( 'Reject', 'buddypress' ); ?></a> 271 </div> 263 <?php bp_button( array( 'id' => 'group_membership_accept', 'component' => 'groups', 'wrapper_class' => 'accept', 'link_href' => bp_get_group_request_accept_link(), 'link_title' => __( 'Accept', 'buddypress' ), 'link_text' => __( 'Accept', 'buddypress' ) ) ); ?> 264 265 <?php bp_button( array( 'id' => 'group_membership_reject', 'component' => 'groups', 'wrapper_class' => 'reject', 'link_href' => bp_get_group_request_reject_link(), 'link_title' => __( 'Reject', 'buddypress' ), 'link_text' => __( 'Reject', 'buddypress' ) ) ); ?> 272 266 273 267 <?php do_action( 'bp_group_membership_requests_admin_item_action' ); ?> -
branches/1.2/bp-themes/bp-default/groups/single/group-header.php
r3109 r3260 36 36 <?php bp_group_description() ?> 37 37 38 <?php if ( bp_is_group_forum() && is_user_logged_in() && !bp_is_group_forum_topic() ) : ?> 39 <div class="generic-button group-button"> 40 <a href="#post-new" class=""><?php _e( 'New Topic', 'buddypress' ) ?></a> 41 </div> 42 <?php endif; ?> 38 <div id="item-buttons"> 43 39 44 <?php bp_group_join_button() ?> 40 <?php do_action( 'bp_group_header_actions' ); ?> 41 42 </div><!-- #item-buttons --> 45 43 46 44 <?php do_action( 'bp_group_header_meta' ) ?> -
branches/1.2/bp-themes/bp-default/members/members-loop.php
r3222 r3260 30 30 <div class="item-title"> 31 31 <a href="<?php bp_member_permalink() ?>"><?php bp_member_name() ?></a> 32 32 33 <?php if ( bp_get_member_latest_update() ) : ?> 34 33 35 <span class="update"> - <?php bp_member_latest_update( 'length=10' ) ?></span> 36 34 37 <?php endif; ?> 38 35 39 </div> 40 36 41 <div class="item-meta"><span class="activity"><?php bp_member_last_active() ?></span></div> 37 42 … … 42 47 * If you want to show specific profile fields here you can, 43 48 * but it'll add an extra query for each member in the loop 44 * (only one rega dless of the number of fields you show):49 * (only one regardless of the number of fields you show): 45 50 * 46 51 * bp_member_profile_data( 'field=the field name' ); … … 50 55 51 56 <div class="action"> 52 <?php bp_member_add_friend_button() ?>53 57 54 <?php do_action( 'bp_directory_members_actions' ) ?> 58 <?php do_action( 'bp_directory_members_actions' ); ?> 59 55 60 </div> 56 61 -
branches/1.2/bp-themes/bp-default/members/single/member-header.php
r3006 r3260 22 22 23 23 <div id="item-buttons"> 24 <?php if ( function_exists( 'bp_add_friend_button' ) ) : ?>25 <?php bp_add_friend_button() ?>26 <?php endif; ?>27 24 28 <?php if ( is_user_logged_in() && !bp_is_my_profile() && function_exists( 'bp_send_public_message_link' ) ) : ?> 29 <div class="generic-button" id="post-mention"> 30 <a href="<?php bp_send_public_message_link() ?>" title="<?php _e( 'Mention this user in a new public message, this will send the user a notification to get their attention.', 'buddypress' ) ?>"><?php _e( 'Mention this User', 'buddypress' ) ?></a> 31 </div> 32 <?php endif; ?> 25 <?php do_action( 'bp_member_header_actions' ); ?> 33 26 34 <?php if ( is_user_logged_in() && !bp_is_my_profile() && function_exists( 'bp_send_private_message_link' ) ) : ?>35 <div class="generic-button" id="send-private-message">36 <a href="<?php bp_send_private_message_link() ?>" title="<?php _e( 'Send a private message to this user.', 'buddypress' ) ?>"><?php _e( 'Send Private Message', 'buddypress' ) ?></a>37 </div>38 <?php endif; ?>39 27 </div><!-- #item-buttons --> 40 28 -
branches/1.2/bp-xprofile/bp-xprofile-templatetags.php
r3145 r3260 686 686 global $bp; 687 687 688 ?> 689 <div class="generic-button"> 690 <a class="edit" title="<?php _e( 'Edit Profile', 'buddypress' ) ?>" href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit"><?php _e( 'Edit Profile', 'buddypress' ) ?></a> 691 </div> 692 <?php 693 } 694 688 bp_button( array ( 689 'id' => 'edit_profile', 690 'component' => 'xprofile', 691 'must_be_logged_in' => true, 692 'block_self' => true, 693 'link_href' => trailingslashit( $bp->displayed_user->domain . $bp->profile->slug . '/edit' ), 694 'link_class' => 'edit', 695 'link_text' => __( 'Edit Profile', 'buddypress' ), 696 'link_title' => __( 'Edit Profile', 'buddypress' ), 697 ) ); 698 } 695 699 696 700 ?>
Note: See TracChangeset
for help on using the changeset viewer.