Changeset 13096 for trunk/src/bp-messages/bp-messages-template.php
- Timestamp:
- 08/26/2021 12:53:27 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-template.php
r12990 r13096 94 94 * Check whether there are more threads to iterate over. 95 95 * 96 * @global BP_Messages_Box_Template $messages_template 97 * 96 98 * @return bool 97 99 */ … … 104 106 * Set up the current thread inside the loop. 105 107 * 106 * @return object 108 * @global BP_Messages_Box_Template $messages_template 109 * 110 * @return BP_Messages_Thread 107 111 */ 108 112 function bp_message_thread() { … … 120 124 * Get the ID of the current thread in the loop. 121 125 * 126 * @global BP_Messages_Box_Template $messages_template 127 * 122 128 * @return int 123 129 */ … … 132 138 * @param int $thread_id ID of the current thread in the loop. 133 139 */ 134 return apply_filters( 'bp_get_message_thread_id', $messages_template->thread->thread_id );140 return apply_filters( 'bp_get_message_thread_id', (int) $messages_template->thread->thread_id ); 135 141 } 136 142 … … 144 150 * Get the subject of the current thread in the loop. 145 151 * 152 * @global BP_Messages_Box_Template $messages_template 153 * 146 154 * @return string 147 155 */ … … 168 176 * Generate an excerpt from the current message in the loop. 169 177 * 178 * @global BP_Messages_Box_Template $messages_template 179 * 170 180 * @return string 171 181 */ … … 208 218 * @since 2.0.0 209 219 * 220 * @global BP_Messages_Box_Template $messages_template 221 * 210 222 * @return string The raw content of the last message in the thread. 211 223 */ … … 232 244 * Get a link to the page of the current thread's last author. 233 245 * 246 * @global BP_Messages_Box_Template $messages_template 247 * 234 248 * @return string 235 249 */ … … 256 270 * Generate HTML links to the pages of the current thread's recipients. 257 271 * 272 * @global BP_Messages_Box_Template $messages_template 273 * 258 274 * @return string 259 275 */ … … 268 284 * @param string $value HTML links to the pages of the current thread's recipients. 269 285 */ 270 return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links( $messages_template->thread->recipients ) );286 return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links( $messages_template->thread->recipients ) ); 271 287 } 272 288 … … 288 304 * 289 305 * @since 2.9.0 Introduced `$user_id` parameter. 306 * 307 * @global BP_Messages_Box_Template $messages_template 290 308 * 291 309 * @param int $thread_id Optional. ID of the thread. Default: current … … 304 322 } 305 323 306 if ( null === $user_id) {324 if ( empty( $user_id ) ) { 307 325 $user_id = bp_loggedin_user_id(); 308 326 } … … 329 347 * @since 2.9.0 Introduced `$user_id` parameter. 330 348 * 331 * @param int $user_id Optional. ID of the user relative to whom the link332 * should be generated. Default: ID of logged-in user.349 * @param int|null $user_id Optional. ID of the user relative to whom the link 350 * should be generated. Default: ID of logged-in user. 333 351 */ 334 352 function bp_message_thread_delete_link( $user_id = null ) { … … 340 358 * @since 2.9.0 Introduced `$user_id` parameter. 341 359 * 342 * @param int $user_id Optional. ID of the user relative to whom the link 343 * should be generated. Default: ID of logged-in user. 360 * @global BP_Messages_Box_Template $messages_template 361 * 362 * @param int|null $user_id Optional. ID of the user relative to whom the link 363 * should be generated. Default: ID of logged-in user. 344 364 * @return string 345 365 */ … … 347 367 global $messages_template; 348 368 349 if ( null === $user_id) {369 if ( empty( $user_id ) ) { 350 370 $user_id = bp_loggedin_user_id(); 351 371 } … … 372 392 * @since 2.9.0 Introduced `$user_id` parameter. 373 393 * 374 * @param int $user_id Optional. ID of the user relative to whom the link375 * should be generated. Default: ID of logged-in user.394 * @param int|null $user_id Optional. ID of the user relative to whom the link 395 * should be generated. Default: ID of logged-in user. 376 396 */ 377 397 function bp_the_message_thread_mark_unread_url( $user_id = null ) { … … 384 404 * @since 2.9.0 Introduced `$user_id` parameter. 385 405 * 386 * @param int $user_id Optional. ID of the user relative to whom the link387 * should be generated. Default: ID of logged-in user.406 * @param int|null $user_id Optional. ID of the user relative to whom the link 407 * should be generated. Default: ID of logged-in user. 388 408 * @return string 389 409 */ … … 396 416 $args = array( 397 417 'action' => 'unread', 398 'message_id' => $id 418 'message_id' => $id, 399 419 ); 400 420 401 if ( null === $user_id) {421 if ( empty( $user_id ) ) { 402 422 $user_id = bp_loggedin_user_id(); 403 423 } … … 434 454 * @since 2.9.0 Introduced `$user_id` parameter. 435 455 * 436 * @param int $user_id Optional. ID of the user relative to whom the link437 * should be generated. Default: ID of logged-in user.456 * @param int|null $user_id Optional. ID of the user relative to whom the link 457 * should be generated. Default: ID of logged-in user. 438 458 */ 439 459 function bp_the_message_thread_mark_read_url( $user_id = null ) { … … 446 466 * @since 2.9.0 Introduced `$user_id` parameter. 447 467 * 448 * @param int $user_id Optional. ID of the user relative to whom the link449 * should be generated. Default: ID of logged-in user.468 * @param int|null $user_id Optional. ID of the user relative to whom the link 469 * should be generated. Default: ID of logged-in user. 450 470 * @return string 451 471 */ … … 458 478 $args = array( 459 479 'action' => 'read', 460 'message_id' => $id 480 'message_id' => $id, 461 481 ); 462 482 463 if ( null === $user_id) {483 if ( empty( $user_id ) ) { 464 484 $user_id = bp_loggedin_user_id(); 465 485 } … … 484 504 * @param int $user_id ID of the user relative to whom the link should be generated. 485 505 */ 486 return apply_filters( 'bp_get_the_message_thread_mark_read_url', $url );506 return apply_filters( 'bp_get_the_message_thread_mark_read_url', $url, $user_id ); 487 507 } 488 508 … … 496 516 * Generate the CSS class for the current thread. 497 517 * 518 * @global BP_Messages_Box_Template $messages_template 519 * 498 520 * @return string 499 521 */ … … 503 525 $class = false; 504 526 505 if ( $messages_template->current_thread % 2 == 1 ) {527 if ( $messages_template->current_thread % 2 === 1 ) { 506 528 $class .= 'alt'; 507 529 } … … 520 542 * Check whether the current thread has unread items. 521 543 * 544 * @global BP_Messages_Box_Template $messages_template 545 * 522 546 * @return bool True if there are unread items, otherwise false. 523 547 */ … … 525 549 global $messages_template; 526 550 527 $retval = ! empty( $messages_template->thread->unread_count ) 528 ? true 529 : false; 551 $retval = ! empty( $messages_template->thread->unread_count ); 530 552 531 553 /** … … 547 569 /** 548 570 * Get the current thread's unread count. 571 * 572 * @global BP_Messages_Box_Template $messages_template 549 573 * 550 574 * @return int … … 564 588 * @param int $count Current thread unread count. 565 589 */ 566 return apply_filters( 'bp_get_message_thread_unread_count', $count );590 return apply_filters( 'bp_get_message_thread_unread_count', (int) $count ); 567 591 } 568 592 … … 654 678 * Get the unformatted date of the last post in the current thread. 655 679 * 680 * @global BP_Messages_Box_Template $messages_template 681 * 656 682 * @return string 657 683 */ … … 707 733 * @see bp_core_fetch_avatar() For a description of arguments and 708 734 * return values. 735 * 736 * @global BP_Messages_Box_Template $messages_template 709 737 * 710 738 * @param array|string $args { … … 759 787 * Output the unread messages count for the current inbox. 760 788 * 761 * @since 2.6.x Added $user_id argument.789 * @since 2.6.x Added the `$user_id` paremeter. 762 790 * 763 791 * @param int $user_id The user ID. 764 *765 * @return int $unread_count Total inbox unread count for user.766 792 */ 767 793 function bp_total_unread_messages_count( $user_id = 0 ) { … … 771 797 * Get the unread messages count for the current inbox. 772 798 * 773 * @since 2.6.x Added $user_id argument.799 * @since 2.6.x Added the `$user_id` paremeter. 774 800 * 775 801 * @param int $user_id The user ID. … … 784 810 * @since 1.0.0 785 811 * 786 * @param int $value Unread messages count for the current inbox. 787 */ 788 return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count( $user_id ) ); 812 * @param int $value Unread messages count for the current inbox. 813 * @param int $user_id ID of the user the messages are from. 814 */ 815 return apply_filters( 'bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count( $user_id ), $user_id ); 789 816 } 790 817 … … 798 825 * Get the pagination HTML for the current thread loop. 799 826 * 827 * @global BP_Messages_Box_Template $messages_template 828 * 800 829 * @return string 801 830 */ … … 815 844 /** 816 845 * Generate the "Viewing message x to y (of z messages)" string for a loop. 846 * 847 * @global BP_Messages_Box_Template $messages_template 817 848 */ 818 849 function bp_messages_pagination_count() { … … 1058 1089 * @since 1.6.0 1059 1090 * 1091 * @global BP_Messages_Box_Template $messages_template 1092 * 1060 1093 * @return bool 1061 1094 */ … … 1084 1117 * @since 1.0.0 1085 1118 * @deprecated 1.6.0 1086 * @return bool1087 1119 */ 1088 1120 function bp_message_is_active_notice() { … … 1112 1144 */ 1113 1145 function bp_message_notice_id() { 1114 echo (int)bp_get_message_notice_id();1146 echo bp_get_message_notice_id(); 1115 1147 } 1116 1148 /** 1117 1149 * Get the ID of the current notice in the loop. 1150 * 1151 * @global BP_Messages_Box_Template $messages_template 1118 1152 * 1119 1153 * @return int … … 1129 1163 * @param int $id ID of the current notice in the loop. 1130 1164 */ 1131 return apply_filters( 'bp_get_message_notice_id', $messages_template->thread->id );1165 return apply_filters( 'bp_get_message_notice_id', (int) $messages_template->thread->id ); 1132 1166 } 1133 1167 … … 1141 1175 * Get the post date of the current notice in the loop. 1142 1176 * 1177 * @global BP_Messages_Box_Template $messages_template 1178 * 1143 1179 * @return string 1144 1180 */ … … 1171 1207 * @since 5.0.0 The $notice parameter has been added. 1172 1208 * 1173 * @param BP_Messages_Notice $notice The notice object. 1209 * @global BP_Messages_Box_Template $messages_template 1210 * 1211 * @param BP_Messages_Notice|null $notice The notice object. 1174 1212 * @return string 1175 1213 */ … … 1206 1244 * @since 5.0.0 The $notice parameter has been added. 1207 1245 * 1208 * @param BP_Messages_Notice $notice The notice object. 1246 * @global BP_Messages_Box_Template $messages_template 1247 * 1248 * @param BP_Messages_Notice|null $notice The notice object. 1209 1249 * @return string 1210 1250 */ … … 1235 1275 * Get the URL for deleting the current notice. 1236 1276 * 1277 * @global BP_Messages_Box_Template $messages_template 1278 * 1237 1279 * @return string Delete URL. 1238 1280 */ … … 1259 1301 /** 1260 1302 * Get the URL for deactivating the current notice. 1303 * 1304 * @global BP_Messages_Box_Template $messages_template 1261 1305 * 1262 1306 * @return string … … 1290 1334 * Generate the text ('Deactivate' or 'Activate') for the notice action link. 1291 1335 * 1336 * @global BP_Messages_Box_Template $messages_template 1337 * 1292 1338 * @return string 1293 1339 */ … … 1315 1361 * 1316 1362 * @since 9.0.0 1317 * @return string URL for dismissing the current notice for the current user.1318 1363 */ 1319 1364 function bp_message_notice_dismiss_link() { … … 1385 1430 1386 1431 if ( is_array( $closed_notices ) ) { 1387 if ( ! in_array( $notice->id, $closed_notices) && $notice->id ) {1432 if ( ! in_array( $notice->id, $closed_notices, true ) && $notice->id ) { 1388 1433 ?> 1389 1434 <div id="message" class="info notice" rel="n-<?php echo esc_attr( $notice->id ); ?>"> … … 1577 1622 * Initialize the messages template loop for a specific thread. 1578 1623 * 1624 * @global BP_Messages_Thread_Template $thread_template 1625 * 1579 1626 * @param array|string $args { 1580 1627 * Array of arguments. All are optional. … … 1619 1666 * Get the 'ASC' or 'DESC' messages order string for this loop. 1620 1667 * 1668 * @global BP_Messages_Thread_Template $thread_template 1669 * 1621 1670 * @return string 1622 1671 */ 1623 1672 function bp_get_thread_messages_order() { 1624 1673 global $thread_template; 1674 1625 1675 return $thread_template->thread->messages_order; 1626 1676 } … … 1628 1678 /** 1629 1679 * Check whether there are more messages to iterate over. 1680 * 1681 * @global BP_Messages_Thread_Template $thread_template 1630 1682 * 1631 1683 * @return bool … … 1640 1692 * Set up the current thread inside the loop. 1641 1693 * 1642 * @return object 1694 * @global BP_Messages_Thread_Template $thread_template 1695 * 1696 * @return BP_Messages_Message 1643 1697 */ 1644 1698 function bp_thread_the_message() { … … 1657 1711 * Get the ID of the thread that the current loop belongs to. 1658 1712 * 1713 * @global BP_Messages_Thread_Template $thread_template 1714 * 1659 1715 * @return int 1660 1716 */ … … 1680 1736 /** 1681 1737 * Get the subject of the thread currently being iterated over. 1738 * 1739 * @global BP_Messages_Thread_Template $thread_template 1682 1740 * 1683 1741 * @return string … … 1713 1771 } 1714 1772 1773 /** 1774 * Filters the thread recipients. 1775 * 1776 * @since 10.0.0 1777 * 1778 * @param string $recipients List of thread recipients. 1779 */ 1715 1780 return apply_filters( 'bp_get_the_thread_recipients', $recipients ); 1716 1781 } … … 1720 1785 * 1721 1786 * @since 2.2.0 1787 * 1788 * @global BP_Messages_Thread_Template $thread_template 1722 1789 * 1723 1790 * @return int … … 1725 1792 function bp_get_thread_recipients_count() { 1726 1793 global $thread_template; 1794 1727 1795 /** 1728 1796 * Filters the total number of recipients in a thread. … … 1765 1833 * 1766 1834 * @since 2.2.0 1835 * 1836 * @global BP_Messages_Thread_Template $thread_template 1767 1837 * 1768 1838 * @return string … … 1806 1876 */ 1807 1877 function bp_the_thread_message_id() { 1808 echo (int)bp_get_the_thread_message_id();1878 echo bp_get_the_thread_message_id(); 1809 1879 } 1810 1880 /** … … 1812 1882 * 1813 1883 * @since 1.9.0 1884 * 1885 * @global BP_Messages_Thread_Template $thread_template 1814 1886 * 1815 1887 * @return int … … 1820 1892 $thread_message_id = isset( $thread_template->message->id ) 1821 1893 ? (int) $thread_template->message->id 1822 : null;1894 : 0; 1823 1895 1824 1896 /** … … 1829 1901 * @param int $thread_message_id ID of the current message in the thread. 1830 1902 */ 1831 return apply_filters( 'bp_get_the_thread_message_id',$thread_message_id );1903 return (int) apply_filters( 'bp_get_the_thread_message_id', (int) $thread_message_id ); 1832 1904 } 1833 1905 … … 1845 1917 * @since 2.1.0 1846 1918 * 1919 * @global BP_Messages_Thread_Template $thread_template 1920 * 1847 1921 * @return string 1848 1922 */ … … 1859 1933 1860 1934 // Whether the sender is the same as the logged-in user. 1861 if ( bp_loggedin_user_id() == $thread_template->message->sender_id ) {1935 if ( bp_loggedin_user_id() === $thread_template->message->sender_id ) { 1862 1936 $classes[] = 'sent-by-me'; 1863 1937 } … … 1884 1958 * Get the CSS class used for message zebra striping. 1885 1959 * 1960 * @global BP_Messages_Thread_Template $thread_template 1961 * 1886 1962 * @return string 1887 1963 */ … … 1889 1965 global $thread_template; 1890 1966 1891 if ( $thread_template->current_message % 2 == 1 ) { 1967 $class = 'odd'; 1968 if ( 1 === $thread_template->current_message % 2 ) { 1892 1969 $class = 'even alt'; 1893 } else {1894 $class = 'odd';1895 1970 } 1896 1971 … … 1911 1986 */ 1912 1987 function bp_the_thread_message_sender_id() { 1913 echo (int)bp_get_the_thread_message_sender_id();1988 echo bp_get_the_thread_message_sender_id(); 1914 1989 } 1915 1990 /** … … 1917 1992 * 1918 1993 * @since 2.1.0 1994 * 1995 * @global BP_Messages_Thread_Template $thread_template 1919 1996 * 1920 1997 * @return int … … 1948 2025 /** 1949 2026 * Get the avatar for the current message sender. 2027 * 2028 * @global BP_Messages_Thread_Template $thread_template 1950 2029 * 1951 2030 * @param array|string $args { … … 1998 2077 * @since 1.1.0 1999 2078 * 2079 * @global BP_Messages_Thread_Template $thread_template 2080 * 2000 2081 * @return string 2001 2082 */ … … 2025 2106 * 2026 2107 * @since 1.1.0 2108 * 2109 * @global BP_Messages_Thread_Template $thread_template 2027 2110 * 2028 2111 * @return string … … 2122 2205 * @since 2.1.0 2123 2206 * 2207 * @global BP_Messages_Thread_Template $thread_template 2124 2208 * 2125 2209 * @return int … … 2150 2234 * 2151 2235 * @since 1.1.0 2236 * 2237 * @global BP_Messages_Thread_Template $thread_template 2152 2238 * 2153 2239 * @return string … … 2183 2269 */ 2184 2270 function bp_messages_embed() { 2185 add_filter( 'embed_post_id', 2186 add_filter( 'bp_embed_get_cache', 'bp_embed_message_cache',10, 3 );2271 add_filter( 'embed_post_id', 'bp_get_the_thread_message_id' ); 2272 add_filter( 'bp_embed_get_cache', 'bp_embed_message_cache', 10, 3 ); 2187 2273 add_action( 'bp_embed_update_cache', 'bp_embed_message_save_cache', 10, 3 ); 2188 2274 }
Note: See TracChangeset
for help on using the changeset viewer.