| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Output the unique id of the custom post type for topics |
| 17 | 17 | * |
| 18 | - * @since 2.0.0 bbPress (r2857) | |
| 18 | + * @since 2.0.0 bbPress (r2858) | |
| 19 | 19 | */ |
| 20 | 20 | function bbp_topic_post_type() { |
| 21 | 21 | echo bbp_get_topic_post_type(); |
| 22 | 22 | } |
| @@ -22,9 +22,9 @@ | ||
| 22 | 22 | } |
| 23 | 23 | /** |
| 24 | 24 | * Return the unique id of the custom post type for topics |
| 25 | 25 | * |
| 26 | - * @since 2.0.0 bbPress (r2857) | |
| 26 | + * @since 2.0.0 bbPress (r2858) | |
| 27 | 27 | * |
| 28 | 28 | * @return string The unique topic post type id |
| 29 | 29 | */ |
| 30 | 30 | function bbp_get_topic_post_type() { |
| @@ -35,9 +35,9 @@ | ||
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Return array of labels used by the topic post type |
| 38 | 38 | * |
| 39 | - * @since 2.5.0 bbPress (r5129) | |
| 39 | + * @since 2.5.0 bbPress (r5130) | |
| 40 | 40 | * |
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | 43 | function bbp_get_topic_post_type_labels() { |
| @@ -84,9 +84,9 @@ | ||
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Return array of topic post type rewrite settings |
| 87 | 87 | * |
| 88 | - * @since 2.5.0 bbPress (r5129) | |
| 88 | + * @since 2.5.0 bbPress (r5130) | |
| 89 | 89 | * |
| 90 | 90 | * @return array |
| 91 | 91 | */ |
| 92 | 92 | function bbp_get_topic_post_type_rewrite() { |
| @@ -103,9 +103,9 @@ | ||
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * Return array of features the topic post type supports |
| 106 | 106 | * |
| 107 | - * @since 2.5.0 bbPress (r5129) | |
| 107 | + * @since 2.5.0 bbPress (r5130) | |
| 108 | 108 | * |
| 109 | 109 | * @return array |
| 110 | 110 | */ |
| 111 | 111 | function bbp_get_topic_post_type_supports() { |
| @@ -625,9 +625,9 @@ | ||
| 625 | 625 | |
| 626 | 626 | /** |
| 627 | 627 | * Output the topic archive title |
| 628 | 628 | * |
| 629 | - * @since 2.0.0 bbPress (r3249) | |
| 629 | + * @since 2.0.0 bbPress (r3250) | |
| 630 | 630 | * |
| 631 | 631 | * @param string $title Default text to use as title |
| 632 | 632 | */ |
| 633 | 633 | function bbp_topic_archive_title( $title = '' ) { |
| @@ -635,9 +635,9 @@ | ||
| 635 | 635 | } |
| 636 | 636 | /** |
| 637 | 637 | * Return the topic archive title |
| 638 | 638 | * |
| 639 | - * @since 2.0.0 bbPress (r3249) | |
| 639 | + * @since 2.0.0 bbPress (r3250) | |
| 640 | 640 | * |
| 641 | 641 | * @param string $title Default text to use as title |
| 642 | 642 | * |
| 643 | 643 | * @return string The topic archive title |
| @@ -683,11 +683,12 @@ | ||
| 683 | 683 | */ |
| 684 | 684 | function bbp_get_topic_content( $topic_id = 0 ) { |
| 685 | 685 | $topic_id = bbp_get_topic_id( $topic_id ); |
| 686 | 686 | |
| 687 | - // Check if password is required | |
| 688 | - if ( post_password_required( $topic_id ) ) { | |
| 689 | - return get_the_password_form(); | |
| 687 | + // Check the topic and its forum ancestors. | |
| 688 | + $password_id = bbp_get_password_required_id( $topic_id ); | |
| 689 | + if ( ! empty( $password_id ) ) { | |
| 690 | + return get_the_password_form( $password_id ); | |
| 690 | 691 | } |
| 691 | 692 | |
| 692 | 693 | $content = get_post_field( 'post_content', $topic_id ); |
| 693 | 694 | |
| @@ -716,11 +717,14 @@ | ||
| 716 | 717 | * letters |
| 717 | 718 | * @return string topic Excerpt |
| 718 | 719 | */ |
| 719 | 720 | function bbp_get_topic_excerpt( $topic_id = 0, $length = 100 ) { |
| 720 | - $topic_id = bbp_get_topic_id( $topic_id ); | |
| 721 | - $length = (int) $length; | |
| 722 | - $excerpt = get_post_field( 'post_excerpt', $topic_id ); | |
| 721 | + $topic_id = bbp_get_topic_id( $topic_id ); | |
| 722 | + $length = (int) $length; | |
| 723 | + $password_id = bbp_get_password_required_id( $topic_id ); | |
| 724 | + $excerpt = ! empty( $password_id ) | |
| 725 | + ? get_the_password_form( $password_id ) | |
| 726 | + : get_post_field( 'post_excerpt', $topic_id ); | |
| 723 | 727 | |
| 724 | 728 | if ( empty( $excerpt ) ) { |
| 725 | 729 | $excerpt = bbp_get_topic_content( $topic_id ); |
| 726 | 730 | } |
| @@ -745,9 +749,9 @@ | ||
| 745 | 749 | |
| 746 | 750 | /** |
| 747 | 751 | * Output the post date and time of a topic |
| 748 | 752 | * |
| 749 | - * @since 2.2.0 bbPress (r4155) | |
| 753 | + * @since 2.2.0 bbPress (r4156) | |
| 750 | 754 | * |
| 751 | 755 | * @param int $topic_id Optional. Topic id. |
| 752 | 756 | * @param bool $humanize Optional. Humanize output using time_since |
| 753 | 757 | * @param bool $gmt Optional. Use GMT |
| @@ -757,9 +761,9 @@ | ||
| 757 | 761 | } |
| 758 | 762 | /** |
| 759 | 763 | * Return the post date and time of a topic |
| 760 | 764 | * |
| 761 | - * @since 2.2.0 bbPress (r4155) | |
| 765 | + * @since 2.2.0 bbPress (r4156) | |
| 762 | 766 | * |
| 763 | 767 | * @param int $topic_id Optional. Topic id. |
| 764 | 768 | * @param bool $humanize Optional. Humanize output using time_since |
| 765 | 769 | * @param bool $gmt Optional. Use GMT |
| @@ -789,9 +793,9 @@ | ||
| 789 | 793 | |
| 790 | 794 | /** |
| 791 | 795 | * Output pagination links of a topic within the topic loop |
| 792 | 796 | * |
| 793 | - * @since 2.0.0 bbPress (r2966) | |
| 797 | + * @since 2.0.0 bbPress (r2967) | |
| 794 | 798 | * |
| 795 | 799 | * @param array $args See {@link bbp_get_topic_pagination()} |
| 796 | 800 | */ |
| 797 | 801 | function bbp_topic_pagination( $args = array() ) { |
| @@ -799,9 +803,9 @@ | ||
| 799 | 803 | } |
| 800 | 804 | /** |
| 801 | 805 | * Returns pagination links of a topic within the topic loop |
| 802 | 806 | * |
| 803 | - * @since 2.0.0 bbPress (r2966) | |
| 807 | + * @since 2.0.0 bbPress (r2967) | |
| 804 | 808 | * |
| 805 | 809 | * @param array $args This function supports these arguments: |
| 806 | 810 | * - topic_id: Topic id |
| 807 | 811 | * - before: Before the links |
| @@ -1127,9 +1131,9 @@ | ||
| 1127 | 1131 | * Is the topic publicly viewable? |
| 1128 | 1132 | * |
| 1129 | 1133 | * See bbp_get_public_topic_statuses() for public statuses. |
| 1130 | 1134 | * |
| 1131 | - * @since 2.6.0 bbPress (r6383) | |
| 1135 | + * @since 2.6.0 bbPress (r6384) | |
| 1132 | 1136 | * |
| 1133 | 1137 | * @param int $topic_id Optional. Topic id |
| 1134 | 1138 | * @return bool True if public, false if not. |
| 1135 | 1139 | */ |
| @@ -1145,9 +1149,9 @@ | ||
| 1145 | 1149 | |
| 1146 | 1150 | /** |
| 1147 | 1151 | * Does the topic have a published status? |
| 1148 | 1152 | * |
| 1149 | - * @since 2.0.0 bbPress (r3496) | |
| 1153 | + * @since 2.0.0 bbPress (r3501) | |
| 1150 | 1154 | * |
| 1151 | 1155 | * @param int $topic_id Optional. Topic id |
| 1152 | 1156 | * @return bool True if published, false if not. |
| 1153 | 1157 | */ |
| @@ -1179,9 +1183,9 @@ | ||
| 1179 | 1183 | |
| 1180 | 1184 | /** |
| 1181 | 1185 | * Is the topic trashed? |
| 1182 | 1186 | * |
| 1183 | - * @since 2.0.0 bbPress (r2888) | |
| 1187 | + * @since 2.0.0 bbPress (r2893) | |
| 1184 | 1188 | * |
| 1185 | 1189 | * @param int $topic_id Optional. Topic id |
| 1186 | 1190 | * @return bool True if trashed, false if not. |
| 1187 | 1191 | */ |
| @@ -1331,9 +1335,9 @@ | ||
| 1331 | 1335 | } |
| 1332 | 1336 | /** |
| 1333 | 1337 | * Return the author display_name of the topic |
| 1334 | 1338 | * |
| 1335 | - * @since 2.0.0 bbPress (r2485) | |
| 1339 | + * @since 2.0.0 bbPress (r2590) | |
| 1336 | 1340 | * |
| 1337 | 1341 | * @param int $topic_id Optional. Topic id |
| 1338 | 1342 | * @return string Topic's author's display name |
| 1339 | 1343 | */ |
| @@ -1406,9 +1410,9 @@ | ||
| 1406 | 1410 | |
| 1407 | 1411 | /** |
| 1408 | 1412 | * Output the author link of the topic |
| 1409 | 1413 | * |
| 1410 | - * @since 2.0.0 bbPress (r2717) | |
| 1414 | + * @since 2.0.0 bbPress (r2720) | |
| 1411 | 1415 | * |
| 1412 | 1416 | * @param mixed|int $args If it is an integer, it is used as topic_id. Optional. |
| 1413 | 1417 | */ |
| 1414 | 1418 | function bbp_topic_author_link( $args = array() ) { |
| @@ -1416,9 +1420,9 @@ | ||
| 1416 | 1420 | } |
| 1417 | 1421 | /** |
| 1418 | 1422 | * Return the author link of the topic |
| 1419 | 1423 | * |
| 1420 | - * @since 2.0.0 bbPress (r2717) | |
| 1424 | + * @since 2.0.0 bbPress (r2720) | |
| 1421 | 1425 | * |
| 1422 | 1426 | * @param mixed|int $args If it is an integer, it is used as topic id. |
| 1423 | 1427 | * Optional. |
| 1424 | 1428 | * @return string Author link of topic |
| @@ -1561,9 +1565,9 @@ | ||
| 1561 | 1565 | |
| 1562 | 1566 | /** |
| 1563 | 1567 | * Output the topic author email address |
| 1564 | 1568 | * |
| 1565 | - * @since 2.0.0 bbPress (r3445) | |
| 1569 | + * @since 2.0.0 bbPress (r3446) | |
| 1566 | 1570 | * |
| 1567 | 1571 | * @param int $topic_id Optional. Reply id |
| 1568 | 1572 | */ |
| 1569 | 1573 | function bbp_topic_author_email( $topic_id = 0 ) { |
| @@ -1571,9 +1575,9 @@ | ||
| 1571 | 1575 | } |
| 1572 | 1576 | /** |
| 1573 | 1577 | * Return the topic author email address |
| 1574 | 1578 | * |
| 1575 | - * @since 2.0.0 bbPress (r3445) | |
| 1579 | + * @since 2.0.0 bbPress (r3446) | |
| 1576 | 1580 | * |
| 1577 | 1581 | * @param int $topic_id Optional. Reply id |
| 1578 | 1582 | * @return string Topic author email address |
| 1579 | 1583 | */ |
| @@ -1656,9 +1660,9 @@ | ||
| 1656 | 1660 | |
| 1657 | 1661 | /** |
| 1658 | 1662 | * Output the title of the forum a topic belongs to |
| 1659 | 1663 | * |
| 1660 | - * @since 2.0.0 bbPress (r2485) | |
| 1664 | + * @since 2.0.0 bbPress (r2572) | |
| 1661 | 1665 | * |
| 1662 | 1666 | * @param int $topic_id Optional. Topic id |
| 1663 | 1667 | */ |
| 1664 | 1668 | function bbp_topic_forum_title( $topic_id = 0 ) { |
| @@ -1666,9 +1670,9 @@ | ||
| 1666 | 1670 | } |
| 1667 | 1671 | /** |
| 1668 | 1672 | * Return the title of the forum a topic belongs to |
| 1669 | 1673 | * |
| 1670 | - * @since 2.0.0 bbPress (r2485) | |
| 1674 | + * @since 2.0.0 bbPress (r2572) | |
| 1671 | 1675 | * |
| 1672 | 1676 | * @param int $topic_id Optional. Topic id |
| 1673 | 1677 | * @return string Topic forum title |
| 1674 | 1678 | */ |
| @@ -1682,9 +1686,9 @@ | ||
| 1682 | 1686 | |
| 1683 | 1687 | /** |
| 1684 | 1688 | * Output the forum id a topic belongs to |
| 1685 | 1689 | * |
| 1686 | - * @since 2.0.0 bbPress (r2491) | |
| 1690 | + * @since 2.0.0 bbPress (r2494) | |
| 1687 | 1691 | * |
| 1688 | 1692 | * @param int $topic_id Optional. Topic id |
| 1689 | 1693 | */ |
| 1690 | 1694 | function bbp_topic_forum_id( $topic_id = 0 ) { |
| @@ -1692,9 +1696,9 @@ | ||
| 1692 | 1696 | } |
| 1693 | 1697 | /** |
| 1694 | 1698 | * Return the forum id a topic belongs to |
| 1695 | 1699 | * |
| 1696 | - * @since 2.0.0 bbPress (r2491) | |
| 1700 | + * @since 2.0.0 bbPress (r2494) | |
| 1697 | 1701 | * |
| 1698 | 1702 | * @param int $topic_id Optional. Topic id |
| 1699 | 1703 | * @return int Topic forum id |
| 1700 | 1704 | */ |
| @@ -1718,9 +1722,9 @@ | ||
| 1718 | 1722 | |
| 1719 | 1723 | /** |
| 1720 | 1724 | * Output the topics last active ID |
| 1721 | 1725 | * |
| 1722 | - * @since 2.0.0 bbPress (r2860) | |
| 1726 | + * @since 2.0.0 bbPress (r2872) | |
| 1723 | 1727 | * |
| 1724 | 1728 | * @param int $topic_id Optional. Forum id |
| 1725 | 1729 | */ |
| 1726 | 1730 | function bbp_topic_last_active_id( $topic_id = 0 ) { |
| @@ -1728,9 +1732,9 @@ | ||
| 1728 | 1732 | } |
| 1729 | 1733 | /** |
| 1730 | 1734 | * Return the topics last active ID |
| 1731 | 1735 | * |
| 1732 | - * @since 2.0.0 bbPress (r2860) | |
| 1736 | + * @since 2.0.0 bbPress (r2872) | |
| 1733 | 1737 | * |
| 1734 | 1738 | * @param int $topic_id Optional. Forum id |
| 1735 | 1739 | * @return int Forum's last active id |
| 1736 | 1740 | */ |
| @@ -1744,9 +1748,9 @@ | ||
| 1744 | 1748 | |
| 1745 | 1749 | /** |
| 1746 | 1750 | * Output the topics last update date/time (aka freshness) |
| 1747 | 1751 | * |
| 1748 | - * @since 2.0.0 bbPress (r2625) | |
| 1752 | + * @since 2.0.0 bbPress (r2872) | |
| 1749 | 1753 | * |
| 1750 | 1754 | * @param int $topic_id Optional. Topic id |
| 1751 | 1755 | */ |
| 1752 | 1756 | function bbp_topic_last_active_time( $topic_id = 0 ) { |
| @@ -1754,9 +1758,9 @@ | ||
| 1754 | 1758 | } |
| 1755 | 1759 | /** |
| 1756 | 1760 | * Return the topics last update date/time (aka freshness) |
| 1757 | 1761 | * |
| 1758 | - * @since 2.0.0 bbPress (r2625) | |
| 1762 | + * @since 2.0.0 bbPress (r2872) | |
| 1759 | 1763 | * |
| 1760 | 1764 | * @param int $topic_id Optional. Topic id |
| 1761 | 1765 | * @return string Topic freshness |
| 1762 | 1766 | */ |
| @@ -1785,9 +1789,9 @@ | ||
| 1785 | 1789 | /** |
| 1786 | 1790 | * Output the topic subscription link |
| 1787 | 1791 | * |
| 1788 | 1792 | * @since 2.5.0 bbPress (r5156) |
| 1789 | - * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support | |
| 1793 | + * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support | |
| 1790 | 1794 | */ |
| 1791 | 1795 | function bbp_topic_subscription_link( $args = array() ) { |
| 1792 | 1796 | echo bbp_get_topic_subscription_link( $args ); |
| 1793 | 1797 | } |
| @@ -1797,9 +1801,9 @@ | ||
| 1797 | 1801 | * |
| 1798 | 1802 | * A custom wrapper for bbp_get_user_subscribe_link() |
| 1799 | 1803 | * |
| 1800 | 1804 | * @since 2.5.0 bbPress (r5156) |
| 1801 | - * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support | |
| 1805 | + * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support | |
| 1802 | 1806 | */ |
| 1803 | 1807 | function bbp_get_topic_subscription_link( $args = array() ) { |
| 1804 | 1808 | |
| 1805 | 1809 | // Defaults |
| @@ -1837,9 +1841,9 @@ | ||
| 1837 | 1841 | /** |
| 1838 | 1842 | * Output the topic favorite link |
| 1839 | 1843 | * |
| 1840 | 1844 | * @since 2.5.0 bbPress (r5156) |
| 1841 | - * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support | |
| 1845 | + * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support | |
| 1842 | 1846 | */ |
| 1843 | 1847 | function bbp_topic_favorite_link( $args = array() ) { |
| 1844 | 1848 | echo bbp_get_topic_favorite_link( $args ); |
| 1845 | 1849 | } |
| @@ -1849,9 +1853,9 @@ | ||
| 1849 | 1853 | * |
| 1850 | 1854 | * A custom wrapper for bbp_get_user_favorites_link() |
| 1851 | 1855 | * |
| 1852 | 1856 | * @since 2.5.0 bbPress (r5156) |
| 1853 | - * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support | |
| 1857 | + * @since 2.6.0 bbPress (r6307) Add 'redirect_to' support | |
| 1854 | 1858 | */ |
| 1855 | 1859 | function bbp_get_topic_favorite_link( $args = array() ) { |
| 1856 | 1860 | |
| 1857 | 1861 | // No link |
| @@ -1888,9 +1892,9 @@ | ||
| 1888 | 1892 | |
| 1889 | 1893 | /** |
| 1890 | 1894 | * Output the id of the topics last reply |
| 1891 | 1895 | * |
| 1892 | - * @since 2.0.0 bbPress (r2625) | |
| 1896 | + * @since 2.0.0 bbPress (r2627) | |
| 1893 | 1897 | * |
| 1894 | 1898 | * @param int $topic_id Optional. Topic id |
| 1895 | 1899 | */ |
| 1896 | 1900 | function bbp_topic_last_reply_id( $topic_id = 0 ) { |
| @@ -1898,9 +1902,9 @@ | ||
| 1898 | 1902 | } |
| 1899 | 1903 | /** |
| 1900 | 1904 | * Return the id of the topics last reply |
| 1901 | 1905 | * |
| 1902 | - * @since 2.0.0 bbPress (r2625) | |
| 1906 | + * @since 2.0.0 bbPress (r2627) | |
| 1903 | 1907 | * |
| 1904 | 1908 | * @param int $topic_id Optional. Topic id |
| 1905 | 1909 | * @return int Topic last reply id |
| 1906 | 1910 | */ |
| @@ -1914,9 +1918,9 @@ | ||
| 1914 | 1918 | |
| 1915 | 1919 | /** |
| 1916 | 1920 | * Output the title of the last reply inside a topic |
| 1917 | 1921 | * |
| 1918 | - * @since 2.0.0 bbPress (r2753) | |
| 1922 | + * @since 2.0.0 bbPress (r2627) | |
| 1919 | 1923 | * |
| 1920 | 1924 | * @param int $topic_id Optional. Topic id |
| 1921 | 1925 | */ |
| 1922 | 1926 | function bbp_topic_last_reply_title( $topic_id = 0 ) { |
| @@ -1924,10 +1928,10 @@ | ||
| 1924 | 1928 | } |
| 1925 | 1929 | /** |
| 1926 | 1930 | * Return the title of the last reply inside a topic |
| 1927 | 1931 | * |
| 1928 | - * @since 2.0.0 bbPress (r2753) | |
| 1929 | - * @since 2.6.0 bbPress https://bbpress.trac.wordpress.org/ticket/3039 | |
| 1932 | + * @since 2.0.0 bbPress (r2627) | |
| 1933 | + * @since 2.6.0 bbPress (r6244) https://bbpress.trac.wordpress.org/ticket/3039 | |
| 1930 | 1934 | * |
| 1931 | 1935 | * @param int $topic_id Optional. Topic id |
| 1932 | 1936 | * @return string Topic last reply title |
| 1933 | 1937 | */ |
| @@ -1945,9 +1949,9 @@ | ||
| 1945 | 1949 | |
| 1946 | 1950 | /** |
| 1947 | 1951 | * Output the link to the last reply in a topic |
| 1948 | 1952 | * |
| 1949 | - * @since 2.0.0 bbPress (r2464) | |
| 1953 | + * @since 2.0.0 bbPress (r2627) | |
| 1950 | 1954 | * |
| 1951 | 1955 | * @param int $topic_id Optional. Topic id |
| 1952 | 1956 | */ |
| 1953 | 1957 | function bbp_topic_last_reply_permalink( $topic_id = 0 ) { |
| @@ -1955,9 +1959,9 @@ | ||
| 1955 | 1959 | } |
| 1956 | 1960 | /** |
| 1957 | 1961 | * Return the link to the last reply in a topic |
| 1958 | 1962 | * |
| 1959 | - * @since 2.0.0 bbPress (r2464) | |
| 1963 | + * @since 2.0.0 bbPress (r2627) | |
| 1960 | 1964 | * |
| 1961 | 1965 | * @param int $topic_id Optional. Topic id |
| 1962 | 1966 | * @return string Permanent link to the reply |
| 1963 | 1967 | */ |
| @@ -1972,9 +1976,9 @@ | ||
| 1972 | 1976 | |
| 1973 | 1977 | /** |
| 1974 | 1978 | * Output the link to the last reply in a topic |
| 1975 | 1979 | * |
| 1976 | - * @since 2.0.0 bbPress (r2683) | |
| 1980 | + * @since 2.0.0 bbPress (r2684) | |
| 1977 | 1981 | * |
| 1978 | 1982 | * @param int $topic_id Optional. Topic id |
| 1979 | 1983 | */ |
| 1980 | 1984 | function bbp_topic_last_reply_url( $topic_id = 0 ) { |
| @@ -1982,9 +1986,9 @@ | ||
| 1982 | 1986 | } |
| 1983 | 1987 | /** |
| 1984 | 1988 | * Return the link to the last reply in a topic |
| 1985 | 1989 | * |
| 1986 | - * @since 2.0.0 bbPress (r2683) | |
| 1990 | + * @since 2.0.0 bbPress (r2684) | |
| 1987 | 1991 | * |
| 1988 | 1992 | * @param int $topic_id Optional. Topic id |
| 1989 | 1993 | * @return string Topic last reply url |
| 1990 | 1994 | */ |
| @@ -2005,9 +2009,9 @@ | ||
| 2005 | 2009 | /** |
| 2006 | 2010 | * Output link to the most recent activity inside a topic, complete with link |
| 2007 | 2011 | * attributes and content. |
| 2008 | 2012 | * |
| 2009 | - * @since 2.0.0 bbPress (r2625) | |
| 2013 | + * @since 2.0.0 bbPress (r2627) | |
| 2010 | 2014 | * |
| 2011 | 2015 | * @param int $topic_id Optional. Topic id |
| 2012 | 2016 | */ |
| 2013 | 2017 | function bbp_topic_freshness_link( $topic_id = 0 ) { |
| @@ -2016,9 +2020,9 @@ | ||
| 2016 | 2020 | /** |
| 2017 | 2021 | * Returns link to the most recent activity inside a topic, complete |
| 2018 | 2022 | * with link attributes and content. |
| 2019 | 2023 | * |
| 2020 | - * @since 2.0.0 bbPress (r2625) | |
| 2024 | + * @since 2.0.0 bbPress (r2627) | |
| 2021 | 2025 | * |
| 2022 | 2026 | * @param int $topic_id Optional. Topic id |
| 2023 | 2027 | * @return string Topic freshness link |
| 2024 | 2028 | */ |
| @@ -2120,9 +2124,9 @@ | ||
| 2120 | 2124 | |
| 2121 | 2125 | /** |
| 2122 | 2126 | * Output total post count of a topic |
| 2123 | 2127 | * |
| 2124 | - * @since 2.0.0 bbPress (r2954) | |
| 2128 | + * @since 2.0.0 bbPress (r2955) | |
| 2125 | 2129 | * |
| 2126 | 2130 | * @param int $topic_id Optional. Topic id |
| 2127 | 2131 | * @param boolean $integer Optional. Whether or not to format the result |
| 2128 | 2132 | */ |
| @@ -2131,9 +2135,9 @@ | ||
| 2131 | 2135 | } |
| 2132 | 2136 | /** |
| 2133 | 2137 | * Return total post count of a topic |
| 2134 | 2138 | * |
| 2135 | - * @since 2.0.0 bbPress (r2954) | |
| 2139 | + * @since 2.0.0 bbPress (r2955) | |
| 2136 | 2140 | * |
| 2137 | 2141 | * @param int $topic_id Optional. Topic id |
| 2138 | 2142 | * @param boolean $integer Optional. Whether or not to format the result |
| 2139 | 2143 | * @return int Post count |
| @@ -2151,9 +2155,9 @@ | ||
| 2151 | 2155 | /** |
| 2152 | 2156 | * Output total hidden reply count of a topic (hidden includes trashed and |
| 2153 | 2157 | * spammed replies) |
| 2154 | 2158 | * |
| 2155 | - * @since 2.0.0 bbPress (r2740) | |
| 2159 | + * @since 2.0.0 bbPress (r3349) | |
| 2156 | 2160 | * |
| 2157 | 2161 | * @param int $topic_id Optional. Topic id |
| 2158 | 2162 | * @param boolean $integer Optional. Whether or not to format the result |
| 2159 | 2163 | */ |
| @@ -2163,9 +2167,9 @@ | ||
| 2163 | 2167 | /** |
| 2164 | 2168 | * Return total hidden reply count of a topic (hidden includes trashed |
| 2165 | 2169 | * and spammed replies) |
| 2166 | 2170 | * |
| 2167 | - * @since 2.0.0 bbPress (r2740) | |
| 2171 | + * @since 2.0.0 bbPress (r3349) | |
| 2168 | 2172 | * |
| 2169 | 2173 | * @param int $topic_id Optional. Topic id |
| 2170 | 2174 | * @param boolean $integer Optional. Whether or not to format the result |
| 2171 | 2175 | * @return int Topic hidden reply count |
| @@ -2210,9 +2214,9 @@ | ||
| 2210 | 2214 | |
| 2211 | 2215 | /** |
| 2212 | 2216 | * Output a the tags of a topic |
| 2213 | 2217 | * |
| 2214 | - * @since 2.0.0 bbPress (r2688) | |
| 2218 | + * @since 2.0.0 bbPress (r2583) | |
| 2215 | 2219 | * |
| 2216 | 2220 | * @param int $topic_id Optional. Topic id |
| 2217 | 2221 | * @param array $args See {@link bbp_get_topic_tag_list()} |
| 2218 | 2222 | */ |
| @@ -2221,9 +2225,9 @@ | ||
| 2221 | 2225 | } |
| 2222 | 2226 | /** |
| 2223 | 2227 | * Return the tags of a topic |
| 2224 | 2228 | * |
| 2225 | - * @since 2.0.0 bbPress (r2688) | |
| 2229 | + * @since 2.0.0 bbPress (r2583) | |
| 2226 | 2230 | * |
| 2227 | 2231 | * @param int $topic_id Optional. Topic id |
| 2228 | 2232 | * @param array $args This function supports these arguments: |
| 2229 | 2233 | * - before: Before the tag list |
| @@ -2280,9 +2284,9 @@ | ||
| 2280 | 2284 | |
| 2281 | 2285 | /** |
| 2282 | 2286 | * Output the row class of a topic |
| 2283 | 2287 | * |
| 2284 | - * @since 2.0.0 bbPress (r2667) | |
| 2288 | + * @since 2.0.0 bbPress (r2678) | |
| 2285 | 2289 | * |
| 2286 | 2290 | * @param int $topic_id Optional. Topic id |
| 2287 | 2291 | * @param array Extra classes you can pass when calling this function |
| 2288 | 2292 | */ |
| @@ -2291,9 +2295,9 @@ | ||
| 2291 | 2295 | } |
| 2292 | 2296 | /** |
| 2293 | 2297 | * Return the row class of a topic |
| 2294 | 2298 | * |
| 2295 | - * @since 2.0.0 bbPress (r2667) | |
| 2299 | + * @since 2.0.0 bbPress (r2678) | |
| 2296 | 2300 | * |
| 2297 | 2301 | * @param int $topic_id Optional. Topic id |
| 2298 | 2302 | * @param array Extra classes you can pass when calling this function |
| 2299 | 2303 | * @return string Row class of a topic |
| @@ -2820,8 +2824,13 @@ | ||
| 2820 | 2824 | if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) { |
| 2821 | 2825 | return; |
| 2822 | 2826 | } |
| 2823 | 2827 | |
| 2828 | + // Per-forum moderators cannot unstick a topic from every forum | |
| 2829 | + if ( bbp_is_topic_super_sticky( $topic->ID ) && ! current_user_can( 'moderate' ) ) { | |
| 2830 | + return; | |
| 2831 | + } | |
| 2832 | + | |
| 2824 | 2833 | $is_sticky = bbp_is_topic_sticky( $topic->ID ); |
| 2825 | 2834 | |
| 2826 | 2835 | $stick_uri = add_query_arg( |
| 2827 | 2836 | array( |
| @@ -2835,9 +2844,9 @@ | ||
| 2835 | 2844 | ? $r['unstick_text'] |
| 2836 | 2845 | : $r['stick_text']; |
| 2837 | 2846 | $stick_display = '<a href="' . esc_url( $stick_uri ) . '" class="bbp-topic-sticky-link">' . $stick_display . '</a>'; |
| 2838 | 2847 | |
| 2839 | - if ( empty( $is_sticky ) ) { | |
| 2848 | + if ( empty( $is_sticky ) && current_user_can( 'moderate' ) ) { | |
| 2840 | 2849 | $super_uri = add_query_arg( |
| 2841 | 2850 | array( |
| 2842 | 2851 | 'action' => 'bbp_toggle_topic_stick', |
| 2843 | 2852 | 'topic_id' => $topic->ID, |
| @@ -2898,10 +2907,10 @@ | ||
| 2898 | 2907 | |
| 2899 | 2908 | // Get topic |
| 2900 | 2909 | $topic = bbp_get_topic( $r['id'] ); |
| 2901 | 2910 | |
| 2902 | - // Bail if no topic or current user cannot moderate | |
| 2903 | - if ( empty( $topic ) || ! current_user_can( 'moderate', $topic->ID ) ) { | |
| 2911 | + // Bail if no topic or current user cannot moderate and edit it | |
| 2912 | + if ( empty( $topic ) || ! bbp_current_user_can_access_topic_moderation( $topic->ID ) ) { | |
| 2904 | 2913 | return; |
| 2905 | 2914 | } |
| 2906 | 2915 | |
| 2907 | 2916 | $uri = add_query_arg( array( 'action' => 'merge' ), bbp_get_topic_edit_url( $topic->ID ) ); |
| @@ -3110,9 +3119,9 @@ | ||
| 3110 | 3119 | * |
| 3111 | 3120 | * The results are unescaped by design, to allow them to be filtered freely via |
| 3112 | 3121 | * the 'bbp_get_forum_pagination_count' filter. |
| 3113 | 3122 | * |
| 3114 | - * @since 2.0.0 bbPress (r2519) | |
| 3123 | + * @since 2.0.0 bbPress (r2574) | |
| 3115 | 3124 | */ |
| 3116 | 3125 | function bbp_forum_pagination_count() { |
| 3117 | 3126 | echo bbp_get_forum_pagination_count(); |
| 3118 | 3127 | } |
| @@ -3118,9 +3127,9 @@ | ||
| 3118 | 3127 | } |
| 3119 | 3128 | /** |
| 3120 | 3129 | * Return the pagination count |
| 3121 | 3130 | * |
| 3122 | - * @since 2.0.0 bbPress (r2519) | |
| 3131 | + * @since 2.0.0 bbPress (r2574) | |
| 3123 | 3132 | * |
| 3124 | 3133 | * @return string Forum Pagination count |
| 3125 | 3134 | */ |
| 3126 | 3135 | function bbp_get_forum_pagination_count() { |
| @@ -3168,9 +3177,9 @@ | ||
| 3168 | 3177 | |
| 3169 | 3178 | /** |
| 3170 | 3179 | * Output pagination links |
| 3171 | 3180 | * |
| 3172 | - * @since 2.0.0 bbPress (r2519) | |
| 3181 | + * @since 2.0.0 bbPress (r2574) | |
| 3173 | 3182 | */ |
| 3174 | 3183 | function bbp_forum_pagination_links() { |
| 3175 | 3184 | echo bbp_get_forum_pagination_links(); |
| 3176 | 3185 | } |
| @@ -3176,9 +3185,9 @@ | ||
| 3176 | 3185 | } |
| 3177 | 3186 | /** |
| 3178 | 3187 | * Return pagination links |
| 3179 | 3188 | * |
| 3180 | - * @since 2.0.0 bbPress (r2519) | |
| 3189 | + * @since 2.0.0 bbPress (r2574) | |
| 3181 | 3190 | * |
| 3182 | 3191 | * @return string Pagination links |
| 3183 | 3192 | */ |
| 3184 | 3193 | function bbp_get_forum_pagination_links() { |
| @@ -3259,9 +3268,9 @@ | ||
| 3259 | 3268 | |
| 3260 | 3269 | /** |
| 3261 | 3270 | * Displays topic type select box (normal/sticky/super sticky) |
| 3262 | 3271 | * |
| 3263 | - * @since 2.4.0 bbPress (r5059) | |
| 3272 | + * @since 2.4.0 bbPress (r5060) | |
| 3264 | 3273 | * |
| 3265 | 3274 | * @param $args This function supports these arguments: |
| 3266 | 3275 | * - select_id: Select id. Defaults to bbp_stick_topic |
| 3267 | 3276 | * - tab: Deprecated. Tabindex |
| @@ -3273,9 +3282,9 @@ | ||
| 3273 | 3282 | } |
| 3274 | 3283 | /** |
| 3275 | 3284 | * Returns topic type select box (normal/sticky/super sticky) |
| 3276 | 3285 | * |
| 3277 | - * @since 2.4.0 bbPress (r5059) | |
| 3286 | + * @since 2.4.0 bbPress (r5060) | |
| 3278 | 3287 | * |
| 3279 | 3288 | * @param $args This function supports these arguments: |
| 3280 | 3289 | * - select_id: Select id. Defaults to bbp_stick_topic |
| 3281 | 3290 | * - tab: Deprecated. Tabindex |
| @@ -3322,14 +3331,23 @@ | ||
| 3322 | 3331 | } |
| 3323 | 3332 | } |
| 3324 | 3333 | } |
| 3325 | 3334 | |
| 3335 | + // Per-forum moderators cannot change a super sticky or make one | |
| 3336 | + $topic_types = bbp_get_topic_types( $r['topic_id'] ); | |
| 3337 | + if ( ! current_user_can( 'moderate' ) ) { | |
| 3338 | + if ( ! empty( $r['topic_id'] ) && bbp_is_topic_super_sticky( $r['topic_id'] ) ) { | |
| 3339 | + return apply_filters( 'bbp_get_form_topic_type_dropdown', '', $r, $args ); | |
| 3340 | + } | |
| 3341 | + unset( $topic_types['super'] ); | |
| 3342 | + } | |
| 3343 | + | |
| 3326 | 3344 | // Start an output buffer, we'll finish it after the select loop |
| 3327 | 3345 | ob_start(); ?> |
| 3328 | 3346 | |
| 3329 | 3347 | <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>> |
| 3330 | 3348 | |
| 3331 | - <?php foreach ( bbp_get_topic_types( $r['topic_id'] ) as $key => $label ) : ?> | |
| 3349 | + <?php foreach ( $topic_types as $key => $label ) : ?> | |
| 3332 | 3350 | |
| 3333 | 3351 | <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option> |
| 3334 | 3352 | |
| 3335 | 3353 | <?php endforeach; ?> |
| @@ -3344,9 +3362,9 @@ | ||
| 3344 | 3362 | |
| 3345 | 3363 | /** |
| 3346 | 3364 | * Output value topic status dropdown |
| 3347 | 3365 | * |
| 3348 | - * @since 2.4.0 bbPress (r5059) | |
| 3366 | + * @since 2.4.0 bbPress (r5060) | |
| 3349 | 3367 | * |
| 3350 | 3368 | * @param $args This function supports these arguments: |
| 3351 | 3369 | * - select_id: Select id. Defaults to bbp_topic_status |
| 3352 | 3370 | * - tab: Deprecated. Tabindex |
| @@ -3362,9 +3380,9 @@ | ||
| 3362 | 3380 | * This dropdown is only intended to be seen by users with the 'moderate' |
| 3363 | 3381 | * capability. Because of this, no additional capability checks are performed |
| 3364 | 3382 | * within this function to check available topic statuses. |
| 3365 | 3383 | * |
| 3366 | - * @since 2.4.0 bbPress (r5059) | |
| 3384 | + * @since 2.4.0 bbPress (r5060) | |
| 3367 | 3385 | * |
| 3368 | 3386 | * @param $args This function supports these arguments: |
| 3369 | 3387 | * - select_id: Select id. Defaults to bbp_topic_status |
| 3370 | 3388 | * - tab: Deprecated. Tabindex |
| @@ -3428,9 +3446,9 @@ | ||
| 3428 | 3446 | /** |
| 3429 | 3447 | * Output a fancy description of the current topic, including total topics, |
| 3430 | 3448 | * total replies, and last activity. |
| 3431 | 3449 | * |
| 3432 | - * @since 2.0.0 bbPress (r2860) | |
| 3450 | + * @since 2.0.0 bbPress (r2872) | |
| 3433 | 3451 | * |
| 3434 | 3452 | * @param array $args See {@link bbp_get_single_topic_description()} |
| 3435 | 3453 | */ |
| 3436 | 3454 | function bbp_single_topic_description( $args = array() ) { |
| @@ -3439,9 +3457,9 @@ | ||
| 3439 | 3457 | /** |
| 3440 | 3458 | * Return a fancy description of the current topic, including total topics, |
| 3441 | 3459 | * total replies, and last activity. |
| 3442 | 3460 | * |
| 3443 | - * @since 2.0.0 bbPress (r2860) | |
| 3461 | + * @since 2.0.0 bbPress (r2872) | |
| 3444 | 3462 | * |
| 3445 | 3463 | * @param array $args This function supports these arguments: |
| 3446 | 3464 | * - topic_id: Topic id |
| 3447 | 3465 | * - before: Before the text |
| @@ -3544,9 +3562,9 @@ | ||
| 3544 | 3562 | |
| 3545 | 3563 | /** |
| 3546 | 3564 | * Return array of labels used by the topic-tag taxonomy |
| 3547 | 3565 | * |
| 3548 | - * @since 2.5.0 bbPress (r5129) | |
| 3566 | + * @since 2.5.0 bbPress (r5130) | |
| 3549 | 3567 | * |
| 3550 | 3568 | * @return array |
| 3551 | 3569 | */ |
| 3552 | 3570 | function bbp_get_topic_tag_tax_labels() { |
| @@ -3583,9 +3601,9 @@ | ||
| 3583 | 3601 | |
| 3584 | 3602 | /** |
| 3585 | 3603 | * Return an array of topic-tag taxonomy rewrite settings |
| 3586 | 3604 | * |
| 3587 | - * @since 2.5.0 bbPress (r5129) | |
| 3605 | + * @since 2.5.0 bbPress (r5130) | |
| 3588 | 3606 | * |
| 3589 | 3607 | * @return array |
| 3590 | 3608 | */ |
| 3591 | 3609 | function bbp_get_topic_tag_tax_rewrite() { |
| @@ -3898,9 +3916,9 @@ | ||
| 3898 | 3916 | |
| 3899 | 3917 | /** |
| 3900 | 3918 | * Allow topic rows to have administrative actions |
| 3901 | 3919 | * |
| 3902 | - * @since 2.1.0 bbPress (r3653) | |
| 3920 | + * @since 2.1.0 bbPress (r3654) | |
| 3903 | 3921 | * |
| 3904 | 3922 | * @todo Links and filter |
| 3905 | 3923 | */ |
| 3906 | 3924 | function bbp_topic_row_actions() { |
| @@ -4143,9 +4161,9 @@ | ||
| 4143 | 4161 | |
| 4144 | 4162 | /** |
| 4145 | 4163 | * Should the topic-lock alert appear? |
| 4146 | 4164 | * |
| 4147 | - * @since 2.6.0 bbPress (r6342) | |
| 4165 | + * @since 2.6.0 bbPress (r6344) | |
| 4148 | 4166 | * |
| 4149 | 4167 | * @return bool |
| 4150 | 4168 | */ |
| 4151 | 4169 | function bbp_show_topic_lock_alert() { |
| @@ -4178,9 +4196,9 @@ | ||
| 4178 | 4196 | |
| 4179 | 4197 | /** |
| 4180 | 4198 | * Output the topic lock description |
| 4181 | 4199 | * |
| 4182 | - * @since 2.6.0 bbPress (r6343) | |
| 4200 | + * @since 2.6.0 bbPress (r6344) | |
| 4183 | 4201 | * |
| 4184 | 4202 | * @param int $topic_id Optional. Topic id |
| 4185 | 4203 | */ |
| 4186 | 4204 | function bbp_topic_lock_description( $topic_id = 0 ) { |
| @@ -4188,9 +4206,9 @@ | ||
| 4188 | 4206 | } |
| 4189 | 4207 | /** |
| 4190 | 4208 | * Return the topic lock description |
| 4191 | 4209 | * |
| 4192 | - * @since 2.6.0 bbPress (r6343) | |
| 4210 | + * @since 2.6.0 bbPress (r6344) | |
| 4193 | 4211 | * |
| 4194 | 4212 | * @param int $topic_id Optional. Topic id |
| 4195 | 4213 | */ |
| 4196 | 4214 | function bbp_get_topic_lock_description( $topic_id = 0 ) { |