Ticket #2566: bp_button.patch
File bp_button.patch, 42.0 KB (added by , 14 years ago) |
---|
-
bp-activity/bp-activity-templatetags.php
921 921 function bp_get_send_public_message_link() { 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 ) ) ); 925 928 } 926 929 930 function bp_send_public_message_button() { 931 bp_button( array( 932 'id' => 'public_message', 933 'component' => 'activity', 934 'must_be_logged_in' => true, 935 'block_self' => true, 936 'wrapper_id' => 'post-mention', 937 'link_href' => bp_get_send_public_message_link(), 938 'link_title' => __( 'Mention this user in a new public message, this will send the user a notification to get their attention.', 'buddypress' ), 939 'link_text' => __( 'Mention this User', 'buddypress' ) 940 ) ); 941 } 942 943 No newline at end of file 927 944 function bp_activity_post_form_action() { 928 945 echo bp_get_activity_post_form_action(); 929 946 } -
bp-blogs/bp-blogs-templatetags.php
504 504 <?php 505 505 } 506 506 507 /** 508 * bp_blogs_visit_blog_button() 509 * 510 * Button for visiting a blog in a loop 511 */ 512 function bp_blogs_visit_blog_button() { 513 bp_button( array ( 514 'id' => 'visit_blog', 515 'component' => 'blogs', 516 'must_be_logged_in' => false, 517 'block_self' => false, 518 519 'wrapper_class' => 'blog-button visit', 520 521 'link_href' => bp_get_blog_permalink(), 522 'link_class' => 'visit', 523 'link_text' => __( 'Visit Blog', 'buddypress' ), 524 'link_title' => __( 'Visit Blog', 'buddypress' ), 525 ) ); 526 } 527 507 528 ?> -
bp-core/bp-core-classes.php
495 495 } 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 { 498 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 } 651 499 652 ?> -
bp-core/bp-core-templatetags.php
417 417 return apply_filters( 'bp_member_last_active', $registered ); 418 418 } 419 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 }446 447 420 function bp_member_random_profile_data() { 448 421 global $members_template; 449 422 … … 1099 1072 } 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 /** 1100 No newline at end of file 1102 1101 * bp_create_excerpt() 1103 1102 * 1104 1103 * Fakes an excerpt on any content. Will not truncate words. -
bp-core/bp-core-widgets.php
21 21 function widget($args, $instance) { 22 22 global $bp; 23 23 24 24 extract( $args ); 25 25 26 26 echo $before_widget; 27 27 echo $before_title … … 31 31 <?php if ( bp_has_members( 'user_id=0&type=newest&max=' . $instance['max_members'] . '&populate_extras=0' ) ) : ?> 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 39 45 <ul id="members-list" class="item-list"> … … 147 153 function widget($args, $instance) { 148 154 global $bp; 149 155 150 156 extract( $args ); 151 157 152 158 echo $before_widget; 153 159 echo $before_title … … 201 207 switch ( $_POST['filter'] ) { 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 213 225 if ( bp_has_members( 'user_id=0&type=' . $type . '&per_page=' . $_POST['max-members'] . '&max=' . $_POST['max-members'] . '&populate_extras=0' ) ) : ?> … … 223 235 <div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div> 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 : ?>227 No newline at end of file 238 <?php elseif ( bp_is_active( 'friends' ) ) : ?> 239 No newline at end of file 228 240 <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count() ?></span></div> 229 241 <?php endif; ?> -
bp-friends/bp-friends-templatetags.php
</div>
104 104 ?> 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 ?> />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 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 ) ?>" />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> 114 114 <?php 115 115 } 116 116 117 function bp_member_add_friend_button() { 118 global $members_template; 119 120 if ( function_exists( 'bp_add_friend_button' ) ) { 121 if ( null === $members_template->member->is_friend ) 122 $friend_status = 'not_friends'; 123 else 124 $friend_status = ( 0 == $members_template->member->is_friend ) ? 'pending' : 'is_friend'; 125 126 echo bp_add_friend_button( $members_template->member->id, $friend_status ); 127 } 128 } 129 add_action( 'bp_directory_members_actions', 'bp_member_add_friend_button' ); 130 131 function bp_member_total_friend_count() { 132 global $members_template; 133 134 echo bp_get_member_total_friend_count(); 135 } 136 function bp_get_member_total_friend_count() { 137 global $members_template; 138 139 if ( 1 == (int) $members_template->member->total_friend_count ) 140 return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $members_template->member->total_friend_count ) ); 141 else 142 return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $members_template->member->total_friend_count ) ); 143 } 144 145 /** 146 * bp_potential_friend_id( $user_id ) 147 * 148 * Outputs the ID of the potential friend 149 * 150 * @uses bp_get_potential_friend_id() 151 * @param <type> $user_id 152 */ 153 function bp_potential_friend_id( $user_id = 0 ) { 154 echo bp_get_potential_friend_id( $user_id ); 155 } 156 /** 157 * bp_get_potential_friend_id( $user_id ) 158 * 159 * Returns the ID of the potential friend 160 * 161 * @global object $bp 162 * @global object $friends_template 163 * @param int $user_id 164 * @return int ID of potential friend 165 */ 166 function bp_get_potential_friend_id( $user_id = 0 ) { 167 global $bp, $friends_template; 168 169 if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) ) 170 $user_id = $friends_template->friendship->friend->id; 171 else if ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) ) 172 $user_id = $bp->displayed_user->id; 173 174 return apply_filters( 'bp_get_potential_friend_id', (int)$user_id ); 175 } 176 177 /** 178 * bp_is_friend( $user_id ) 179 * 180 * Returns - 'is_friend', 'not_friends', 'pending' 181 * 182 * @global object $bp 183 * @param int $potential_friend_id 184 * @return string 185 */ 186 function bp_is_friend( $user_id = 0 ) { 187 global $bp; 188 189 if ( !is_user_logged_in() ) 190 return false; 191 192 if ( empty( $user_id ) ) 193 $user_id = bp_get_potential_friend_id( $user_id ); 194 195 if ( $bp->loggedin_user->id == $user_id ) 196 return false; 197 198 return apply_filters( 'bp_is_friend', friends_check_friendship_status( $bp->loggedin_user->id, $user_id ), $user_id ); 199 } 200 117 201 function bp_add_friend_button( $potential_friend_id = false, $friend_status = false ) { 118 202 echo bp_get_add_friend_button( $potential_friend_id, $friend_status ); 119 203 } 120 204 function bp_get_add_friend_button( $potential_friend_id = false, $friend_status = false ) { 121 205 global $bp, $friends_template; 122 206 123 if ( !is_user_logged_in() )124 return false;207 if ( empty( $potential_friend_id ) ) 208 $potential_friend_id = bp_get_potential_friend_id( $potential_friend_id ); 125 209 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; 210 $is_friend = bp_is_friend( $potential_friend_id ); 130 211 131 if ( $bp->loggedin_user->id == $potential_friend_id)212 if ( empty( $is_friend ) ) 132 213 return false; 133 214 134 if ( empty( $friend_status ) ) 135 $friend_status = friends_check_friendship_status( $bp->loggedin_user->id, $potential_friend_id ); 215 switch ( $is_friend ) { 216 case 'pending' : 217 $btn = array( 218 'id' => 'pending', 219 'component' => 'friends', 220 'must_be_logged_in' => true, 221 'block_self' => true, 222 'wrapper_class' => 'friendship-button pending', 223 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 224 'link_class' => 'requested', 225 'link_href' => trailingslashit( $bp->loggedin_user->domain . $bp->friends->slug ), 226 'link_text' => __( 'Friendship Requested', 'buddypress' ), 227 'link_title' => __( 'Friendship Requested', 'buddypress' ) 228 ); 229 break; 136 230 137 $button = '<div class="generic-button friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">'; 231 case 'is_friend' : 232 $btn = array( 233 'id' => 'is_friend', 234 'component' => 'friends', 235 'must_be_logged_in' => true, 236 'block_self' => true, 237 'wrapper_class' => 'friendship-button is_friend', 238 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 239 'link_class' => '', 240 'link_href' => wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ), 241 'link_text' => __( 'Cancel Friendship', 'buddypress' ), 242 'link_title' => __( 'Cancel Friendship', 'buddypress' ), 243 'link_id' => 'friend-' . $potential_friend_id, 244 'link_rel' => 'remove', 245 'link_class' => 'remove' 246 ); 247 break; 138 248 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>'; 249 default: 250 $btn = array( 251 'id' => 'not_friends', 252 'component' => 'friends', 253 'must_be_logged_in' => true, 254 'block_self' => true, 255 'wrapper_class' => 'friendship-button not_friends', 256 'wrapper_id' => 'friendship-button-' . $potential_friend_id, 257 'link_class' => '', 258 'link_href' => wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ), 259 'link_text' => __( 'Add Friend', 'buddypress' ), 260 'link_title' => __( 'Add Friend', 'buddypress' ), 261 'link_id' => 'friend-' . $potential_friend_id, 262 'link_rel' => 'add', 263 'link_class' => 'add' 264 ); 265 break; 266 } 145 267 146 $button .= '</div>';268 $button = new BP_Button( $btn ); 147 269 148 return apply_filters( 'bp_get_add_friend_button', $button , $potential_friend_id, $friend_status );270 return apply_filters( 'bp_get_add_friend_button', $button->contents, $potential_friend_id, $friend_status ); 149 271 } 150 272 151 273 function bp_get_friend_ids( $user_id = false ) { … … 181 303 return apply_filters( 'bp_get_friend_friendship_id', $friendship_id ); 182 304 } 183 305 306 function bp_friend_request_link() { 307 echo bp_get_friend_request_link(); 308 } 309 function bp_get_friend_request_link() { 310 global $bp; 311 312 $friend_id = bp_get_potential_friend_id(); 313 $is_friend = bp_is_friend(); 314 315 if ( empty( $is_friend ) ) 316 return false; 317 318 switch ( $is_friend ) { 319 case 'pending' : 320 $link = $bp->loggedin_user->domain . $bp->friends->slug; 321 break; 322 case 'is_friend' : 323 $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $friend_id . '/', 'friends_remove_friend' ); 324 break; 325 default: 326 $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $friend_id . '/', 'friends_add_friend' ); 327 break; 328 } 329 330 return apply_filters( 'bp_get_friend_request_link', $link, $friend_id, $is_friend ); 331 } 332 333 function bp_friend_request_id() { 334 echo bp_get_friend_request_id(); 335 } 336 function bp_get_friend_request_id() { 337 338 $friend_id = bp_get_potential_friend_id(); 339 $is_friend = bp_is_friend(); 340 341 if ( empty( $is_friend ) ) 342 return false; 343 344 switch ( $is_friend ) { 345 case 'pending' : 346 $id = ''; 347 break; 348 case 'is_friend' : 349 $id = 'friend-' . $friend_id; 350 break; 351 default: 352 $id = 'friend-' . $friend_id; 353 break; 354 } 355 356 return apply_filters( 'bp_get_friend_request_id', $id, $friend_id, $is_friend ); 357 } 358 359 function bp_friend_request_rel() { 360 echo bp_get_friend_request_rel(); 361 } 362 function bp_get_friend_request_rel() { 363 364 $friend_id = bp_get_potential_friend_id(); 365 $is_friend = bp_is_friend(); 366 367 if ( empty( $is_friend ) ) 368 return false; 369 370 switch ( $is_friend ) { 371 case 'pending' : 372 $rel = ''; 373 break; 374 case 'is_friend' : 375 $rel = 'remove'; 376 break; 377 default: 378 $rel = 'add'; 379 break; 380 } 381 382 return apply_filters( 'bp_get_friend_request_rel', $rel, $friend_id, $is_friend ); 383 } 384 385 function bp_friend_request_class() { 386 echo bp_get_friend_request_class(); 387 } 388 function bp_get_friend_request_class() { 389 390 $friend_id = bp_get_potential_friend_id(); 391 $is_friend = bp_is_friend(); 392 393 if ( empty( $is_friend ) ) 394 return false; 395 396 switch ( $is_friend ) { 397 case 'pending' : 398 $class = 'pending'; 399 break; 400 case 'is_friend' : 401 $class = 'remove'; 402 break; 403 default: 404 $class = 'add'; 405 break; 406 } 407 408 return apply_filters( 'bp_get_friend_request_class', $class, $friend_id, $is_friend ); 409 } 410 411 function bp_friend_request_link_text() { 412 echo bp_get_friend_request_link_text(); 413 } 414 function bp_get_friend_request_link_text() { 415 416 $friend_id = bp_get_potential_friend_id(); 417 $is_friend = bp_is_friend(); 418 419 if ( empty( $is_friend ) ) 420 return false; 421 422 switch ( $is_friend ) { 423 case 'pending' : 424 $text = __( 'Friendship Requested', 'buddypress' ); 425 break; 426 case 'is_friend' : 427 $text = __( 'Cancel Friendship', 'buddypress' ); 428 break; 429 default: 430 $text = __( 'Add Friend', 'buddypress' ); 431 break; 432 } 433 434 return apply_filters( 'bp_get_friend_request_link_text', $text, $friend_id, $is_friend ); 435 } 436 437 No newline at end of file 184 438 function bp_friend_accept_request_link() { 185 439 echo bp_get_friend_accept_request_link(); 186 440 } -
bp-groups/bp-groups-templatetags.php
1095 1095 return true; 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; 1115 echo bp_get_group_join_button(); 1116 } 1117 function bp_get_group_join_button( $group = false ) { 1118 global $bp, $groups_template; 1100 1119 1101 if ( !$group )1102 $group =& $groups_template->group;1120 if ( !$group ) 1121 $group =& $groups_template->group; 1103 1122 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;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; 1107 1126 1108 if ( !$group->status )1109 return false;1127 if ( !$group->status ) 1128 return false; 1110 1129 1111 if ( 'hidden' == $group->status && !$group->is_member )1112 return false;1130 if ( 'hidden' == $group->status && !$group->is_member ) 1131 return false; 1113 1132 1114 echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">'; 1133 // Already a member 1134 if ( $group->is_member ) { 1135 $btn = 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 ); 1115 1147 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; 1148 // Not a member 1149 } else { 1123 1150 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>'; 1151 // Show different buttons based on group status 1152 switch ( $group->status ) { 1153 case 'public': 1154 $btn = 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 $btn = array( 1173 'id' => 'requeste_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 $btn = array( 1188 'id' => 'membership_requested', 1189 'component' => 'groups', 1190 'must_be_logged_in' => true, 1191 'block_self' => false, 1192 'wrapper_class' => 'group-button ' . $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;1203 } 1134 1204 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; 1205 $button = new BP_Button( $btn ); 1206 1207 return apply_filters( 'bp_group_join_button', $button->contents, $group ); 1139 1208 } 1140 1209 1141 echo '</div>';1142 }1143 1144 1210 function bp_group_status_message( $group = false ) { 1145 1211 global $groups_template; 1146 1212 … … 1985 2051 } 1986 2052 1987 2053 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' ) ); 2054 echo bp_get_group_request_reject_link(); 1991 2055 } 2056 function bp_get_group_request_reject_link() { 2057 global $requests_template, $groups_template; 1992 2058 2059 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' ) ); 2060 } 2061 1993 2062 function bp_group_request_accept_link() { 1994 global $requests_template, $groups_template; 2063 echo bp_get_group_request_accept_link(); 2064 } 2065 function bp_get_group_request_accept_link() { 2066 global $requests_template, $groups_template; 1995 2067 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' ) ); 2068 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' ) ); 2069 } 2070 2071 function bp_group_request_user_link() { 2072 echo bp_get_group_request_user_link(); 1997 2073 } 2074 function bp_get_group_request_user_link() { 2075 global $requests_template; 1998 2076 2077 return apply_filters( 'bp_get_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) ); 2078 } 2079 1999 2080 function bp_group_request_time_since_requested() { 2000 2081 global $requests_template; 2001 2082 … … 2008 2089 echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) ); 2009 2090 } 2010 2091 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 2018 No newline at end of file2019 2092 /************************************************************************************ 2020 2093 * Invite Friends Template Tags 2021 2094 **/ -
bp-messages/bp-messages-templatetags.php
501 501 function bp_get_send_private_message_link() { 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 ) ); 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 ) ) ); 505 508 } 506 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 } 521 507 522 function bp_send_message_button() { 508 523 echo bp_get_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>' ); 517 No newline at end of file 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 ); 539 No newline at end of file 518 540 } 519 541 -
bp-themes/bp-default/blogs/blogs-loop.php
function bp_message_loading_image_src() {
34 34 </div> 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>40 37 38 <?php do_action( 'bp_directory_blogs_actions' ) ?> 39 41 40 <div class="meta"> 42 41 <?php bp_blog_latest_post() ?> 43 42 </div> 44 43 45 <?php do_action( 'bp_directory_blogs_actions' ) ?>46 44 </div> 47 45 48 46 <div class="clear"></div> -
bp-themes/bp-default/functions.php
333 333 } 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 ?> -
bp-themes/bp-default/groups/groups-loop.php
33 33 <div class="item-desc"><?php bp_group_description_excerpt() ?></div> 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 40 41 <?php do_action( 'bp_directory_groups_actions' ) ?> 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 48 51 <div class="clear"></div> -
bp-themes/bp-default/groups/single/admin.php
116 116 </p> 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 126 126 <?php wp_nonce_field( 'bp_avatar_upload' ) ?> … … 260 260 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> 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' ) ) ); ?> 266 264 267 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' ) ) ); ?> 268 266 269 <div class="generic-button reject">270 <a href="<?php bp_group_request_reject_link() ?>"><?php _e( 'Reject', 'buddypress' ); ?></a>271 </div>272 273 267 <?php do_action( 'bp_group_membership_requests_admin_item_action' ); ?> 274 268 275 269 </div> -
bp-themes/bp-default/groups/single/group-header.php
35 35 <div id="item-meta"> 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' ); ?> 45 41 42 </div><!-- #item-buttons --> 43 44 No newline at end of file 46 45 <?php do_action( 'bp_group_header_meta' ) ?> 47 46 </div> 48 47 </div><!-- #item-header-content --> -
bp-themes/bp-default/members/members-loop.php
29 29 <div class="item"> 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 38 43 <?php do_action( 'bp_directory_members_item' ) ?> … … 41 46 /*** 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' ); 47 52 */ … … 49 54 </div> 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 57 62 <div class="clear"></div> -
bp-themes/bp-default/members/single/member-header.php
21 21 <?php endif; ?> 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 No newline at end of file40 27 </div><!-- #item-buttons --> 41 28 42 29 <?php -
bp-xprofile/bp-xprofile-templatetags.php
685 685 function bp_edit_profile_button() { 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 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 ) ); 693 698 } 694 699 695 696 700 ?>