Changeset 8791
- Timestamp:
- 08/11/2014 04:56:19 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-messages/bp-messages-template.php (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-template.php
r8790 r8791 193 193 */ 194 194 function has_threads() { 195 if ( $this->thread_count ) 195 if ( $this->thread_count ) { 196 196 return true; 197 } 197 198 198 199 return false; … … 541 542 */ 542 543 function bp_get_message_thread_delete_link() { 543 global $messages_template , $bp;544 return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . $bp->messages->slug. '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) );544 global $messages_template; 545 return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) ); 545 546 } 546 547 … … 561 562 $class = false; 562 563 563 if ( $messages_template->current_thread % 2 == 1 ) 564 if ( $messages_template->current_thread % 2 == 1 ) { 564 565 $class .= 'alt'; 566 } 565 567 566 568 return apply_filters( 'bp_get_message_css_class', trim( $class ) ); … … 575 577 global $messages_template; 576 578 577 if ( $messages_template->thread->unread_count ) 578 return true; 579 580 return false; 579 $retval = ! empty( $messages_template->thread->unread_count ) 580 ? true 581 : false; 582 583 return apply_filters( 'bp_message_thread_has_unread', $retval ); 581 584 } 582 585 … … 595 598 global $messages_template; 596 599 597 if ( (int) $messages_template->thread->unread_count ) 598 return apply_filters( 'bp_get_message_thread_unread_count', $messages_template->thread->unread_count ); 599 600 return false; 600 $count = ! empty( $messages_template->thread->unread_count ) 601 ? (int) $messages_template->thread->unread_count 602 : false; 603 604 return apply_filters( 'bp_get_message_thread_unread_count', $count ); 601 605 } 602 606 … … 713 717 714 718 $start_num = intval( ( $messages_template->pag_page - 1 ) * $messages_template->pag_num ) + 1; 715 $from_num = bp_core_number_format( $start_num );716 $to_num = bp_core_number_format( ( $start_num + ( $messages_template->pag_num - 1 ) > $messages_template->total_thread_count ) ? $messages_template->total_thread_count : $start_num + ( $messages_template->pag_num - 1 ) );717 $total = bp_core_number_format( $messages_template->total_thread_count );719 $from_num = bp_core_number_format( $start_num ); 720 $to_num = bp_core_number_format( ( $start_num + ( $messages_template->pag_num - 1 ) > $messages_template->total_thread_count ) ? $messages_template->total_thread_count : $start_num + ( $messages_template->pag_num - 1 ) ); 721 $total = bp_core_number_format( $messages_template->total_thread_count ); 718 722 719 723 echo sprintf( _n( 'Viewing 1 message', 'Viewing %1$s - %2$s of %3$s messages', $total, 'buddypress' ), $from_num, $to_num, number_format_i18n( $total ) ); … … 787 791 */ 788 792 function bp_get_messages_subject_value() { 789 $subject = '';790 if ( !empty( $_POST['subject'] ) )791 $subject = $_POST['subject'];793 $subject = ! empty( $_POST['subject'] ) 794 ? $_POST['subject'] 795 : ''; 792 796 793 797 return apply_filters( 'bp_get_messages_subject_value', $subject ); … … 809 813 */ 810 814 function bp_get_messages_content_value() { 811 $content = ''; 812 if ( !empty( $_POST['content'] ) ) 813 $content = $_POST['content']; 815 816 $content = !empty( $_POST['content'] ) 817 ? $_POST['content'] 818 : ''; 814 819 815 820 return apply_filters( 'bp_get_messages_content_value', $content ); … … 851 856 global $messages_template; 852 857 853 if ( $messages_template->thread->is_active ) 854 return true; 855 856 return false; 858 $retval = ! empty( $messages_template->thread->is_active ) 859 ? true 860 : false; 861 862 return apply_filters( 'bp_messages_is_active_notice', $retval ); 857 863 } 858 864 … … 881 887 function bp_get_message_is_active_notice() { 882 888 883 $string = '';884 if ( bp_messages_is_active_notice())885 $string = __( 'Currently Active', 'buddypress' );889 $string = bp_messages_is_active_notice() 890 ? __( 'Currently Active', 'buddypress' ) 891 : ''; 886 892 887 893 return apply_filters( 'bp_get_message_is_active_notice', $string ); … … 917 923 function bp_get_message_notice_post_date() { 918 924 global $messages_template; 919 return apply_filters( 'bp_get_message_notice_post_date', bp_format_time( strtotime( $messages_template->thread->date_sent) ) );925 return apply_filters( 'bp_get_message_notice_post_date', bp_format_time( strtotime( $messages_template->thread->date_sent ) ) ); 920 926 } 921 927 … … 964 970 */ 965 971 function bp_get_message_notice_delete_link() { 966 global $messages_template , $bp;967 968 return apply_filters( 'bp_get_message_notice_delete_link', wp_nonce_url( bp_loggedin_user_domain() . $bp->messages->slug. '/notices/delete/' . $messages_template->thread->id, 'messages_delete_thread' ) );972 global $messages_template; 973 974 return apply_filters( 'bp_get_message_notice_delete_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/delete/' . $messages_template->thread->id, 'messages_delete_thread' ) ); 969 975 } 970 976 … … 981 987 */ 982 988 function bp_get_message_activate_deactivate_link() { 983 global $messages_template , $bp;984 985 if ( 1 == (int) $messages_template->thread->is_active ) {986 $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . $bp->messages->slug. '/notices/deactivate/' . $messages_template->thread->id ), 'messages_deactivate_notice' );989 global $messages_template; 990 991 if ( 1 === (int) $messages_template->thread->is_active ) { 992 $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/deactivate/' . $messages_template->thread->id ), 'messages_deactivate_notice' ); 987 993 } else { 988 $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . $bp->messages->slug. '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' );994 $link = wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices/activate/' . $messages_template->thread->id ), 'messages_activate_notice' ); 989 995 } 990 996 return apply_filters( 'bp_get_message_activate_deactivate_link', $link ); … … 1005 1011 global $messages_template; 1006 1012 1007 if ( 1 == (int) $messages_template->thread->is_active ) {1013 if ( 1 === (int) $messages_template->thread->is_active ) { 1008 1014 $text = __('Deactivate', 'buddypress'); 1009 1015 } else { … … 1031 1037 */ 1032 1038 function bp_get_messages_slug() { 1033 global $bp; 1034 return apply_filters( 'bp_get_messages_slug', $bp->messages->slug ); 1039 return apply_filters( 'bp_get_messages_slug', buddypress()->messages->slug ); 1035 1040 } 1036 1041 … … 1041 1046 $notice = BP_Messages_Notice::get_active(); 1042 1047 1043 if ( empty( $notice ) ) 1048 if ( empty( $notice ) ) { 1044 1049 return false; 1050 } 1045 1051 1046 1052 $closed_notices = bp_get_user_meta( bp_loggedin_user_id(), 'closed_notices', true ); 1047 1053 1048 if ( !$closed_notices )1054 if ( empty( $closed_notices ) ) { 1049 1055 $closed_notices = array(); 1050 1051 if ( is_array($closed_notices) ) { 1056 } 1057 1058 if ( is_array( $closed_notices ) ) { 1052 1059 if ( !in_array( $notice->id, $closed_notices ) && $notice->id ) { 1053 1060 ?> 1054 <div id="message" class="info notice" rel="n-<?php echo $notice->id?>">1061 <div id="message" class="info notice" rel="n-<?php echo esc_attr( $notice->id ); ?>"> 1055 1062 <p> 1056 1063 <strong><?php echo stripslashes( wp_filter_kses( $notice->subject ) ) ?></strong><br /> … … 1077 1084 function bp_get_send_private_message_link() { 1078 1085 1079 if ( bp_is_my_profile() || ! is_user_logged_in() )1086 if ( bp_is_my_profile() || ! is_user_logged_in() ) { 1080 1087 return false; 1088 } 1081 1089 1082 1090 return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_displayed_user_id() ) ) ); … … 1137 1145 */ 1138 1146 function bp_get_message_loading_image_src() { 1139 global $bp; 1140 return apply_filters( 'bp_get_message_loading_image_src', $bp->messages->image_base . '/ajax-loader.gif' ); 1147 return apply_filters( 'bp_get_message_loading_image_src', buddypress()->messages->image_base . '/ajax-loader.gif' ); 1141 1148 } 1142 1149 … … 1148 1155 1149 1156 foreach ( $recipients as $recipient ) { 1150 $user_id = bp_is_username_compatibility_mode() ? bp_core_get_userid( $recipient ) : bp_core_get_userid_from_nicename( $recipient ); 1151 1152 if ( $user_id ) : ?> 1157 1158 $user_id = bp_is_username_compatibility_mode() 1159 ? bp_core_get_userid( $recipient ) 1160 : bp_core_get_userid_from_nicename( $recipient ); 1161 1162 if ( ! empty( $user_id ) ) : ?> 1153 1163 1154 1164 <li id="un-<?php echo esc_attr( $recipient ); ?>" class="friend-tab"> … … 1283 1293 */ 1284 1294 function has_messages() { 1285 if ( $this->message_count ) 1295 if ( $this->message_count ) { 1286 1296 return true; 1297 } 1287 1298 1288 1299 return false; … … 1349 1360 1350 1361 // loop has just started 1351 if ( 0 == $this->current_message ) 1352 do_action('thread_loop_start'); 1362 if ( 0 == $this->current_message ) { 1363 do_action( 'thread_loop_start' ); 1364 } 1353 1365 } 1354 1366 } … … 1369 1381 global $thread_template; 1370 1382 1371 $ defaults =array(1383 $r = bp_parse_args( $args, array( 1372 1384 'thread_id' => false, 1373 1385 'order' => 'ASC' 1374 ); 1375 1376 $r = wp_parse_args( $args, $defaults ); 1377 extract( $r, EXTR_SKIP ); 1378 1379 if ( empty( $thread_id ) && bp_is_messages_component() && bp_is_current_action( 'view' ) ) 1380 $thread_id = (int) bp_action_variable( 0 ); 1381 1382 $thread_template = new BP_Messages_Thread_Template( $thread_id, $order ); 1386 ), 'thread_has_messages' ); 1387 1388 if ( empty( $r['thread_id'] ) && bp_is_messages_component() && bp_is_current_action( 'view' ) ) { 1389 $r['thread_id'] = (int) bp_action_variable( 0 ); 1390 } 1391 1392 $thread_template = new BP_Messages_Thread_Template( $r['thread_id'], $r['order'] ); 1393 1383 1394 return $thread_template->has_messages(); 1384 1395 } … … 1472 1483 $recipient_links = array(); 1473 1484 1474 if ( count( $thread_template->thread->recipients ) >= 5 ) 1475 return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count($thread_template->thread->recipients) ) ); 1485 if ( count( $thread_template->thread->recipients ) >= 5 ) { 1486 return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count( $thread_template->thread->recipients ) ) ); 1487 } 1476 1488 1477 1489 foreach( (array) $thread_template->thread->recipients as $recipient ) { … … 1508 1520 global $thread_template; 1509 1521 1510 $thread_message_id = isset( $thread_template->message->id ) ? (int) $thread_template->message->id : null; 1522 $thread_message_id = isset( $thread_template->message->id ) 1523 ? (int) $thread_template->message->id 1524 : null; 1525 1511 1526 return apply_filters( 'bp_get_the_thread_message_id', $thread_message_id ); 1512 1527 } … … 1620 1635 global $thread_template; 1621 1636 1622 $ defaults =array(1637 $r = bp_parse_args( $args, array( 1623 1638 'type' => 'thumb', 1624 1639 'width' => false, 1625 1640 'height' => false, 1626 ); 1627 1628 $r = wp_parse_args( $args, $defaults ); 1629 extract( $r, EXTR_SKIP ); 1630 1631 return apply_filters( 'bp_get_the_thread_message_sender_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $thread_template->message->sender_id, 'type' => $type, 'width' => $width, 'height' => $height, 'alt' => bp_core_get_user_displayname( $thread_template->message->sender_id ) ) ) ); 1641 ) ); 1642 1643 return apply_filters( 'bp_get_the_thread_message_sender_avatar_thumb', bp_core_fetch_avatar( array( 1644 'item_id' => $thread_template->message->sender_id, 1645 'type' => $r['type'], 1646 'width' => $r['width'], 1647 'height' => $r['height'], 1648 'alt' => bp_core_get_user_displayname( $thread_template->message->sender_id ) 1649 ) ) ); 1632 1650 } 1633 1651 … … 1665 1683 $display_name = bp_core_get_user_displayname( $thread_template->message->sender_id ); 1666 1684 1667 if ( empty( $display_name ) ) 1685 if ( empty( $display_name ) ) { 1668 1686 $display_name = __( 'Deleted User', 'buddypress' ); 1687 } 1669 1688 1670 1689 return apply_filters( 'bp_get_the_thread_message_sender_name', $display_name ); … … 1683 1702 */ 1684 1703 function bp_get_the_thread_delete_link() { 1685 global $bp; 1686 1687 return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( bp_loggedin_user_domain() . $bp->messages->slug . '/inbox/delete/' . bp_get_the_thread_id(), 'messages_delete_thread' ) ); 1704 return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox/delete/' . bp_get_the_thread_id(), 'messages_delete_thread' ) ); 1688 1705 } 1689 1706
Note: See TracChangeset
for help on using the changeset viewer.