Changeset 4258 for trunk/bbp-includes/topics/template-tags.php
- Timestamp:
- 10/19/2012 07:42:49 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bbp-includes/topics/template-tags.php
r4255 r4258 737 737 738 738 // Get total and add 1 if topic is included in the reply loop 739 $total = bbp_get_topic_reply_count( $topic_id );739 $total = bbp_get_topic_reply_count( $topic_id, true ); 740 740 741 741 // Bump if topic is in loop … … 918 918 * @return string Topic revision count 919 919 */ 920 function bbp_get_topic_revision_count( $topic_id = 0 ) { 921 return apply_filters( 'bbp_get_topic_revisions', count( bbp_get_topic_revisions( $topic_id ) ), $topic_id ); 920 function bbp_get_topic_revision_count( $topic_id = 0, $integer = false ) { 921 $count = absint( count( bbp_get_topic_revisions( $topic_id ) ) ); 922 $filter = ( true === $integer ) ? 'bbp_get_topic_revision_count_int' : 'bbp_get_topic_revision_count'; 923 924 return apply_filters( $filter, $count, $topic_id ); 922 925 } 923 926 … … 1855 1858 $topic = bbp_get_topic( bbp_get_topic_id( (int) $topic_id ) ); 1856 1859 $topic_id = $topic->ID; 1857 $replies = bbp_get_topic_reply_count( $topic_id ); 1858 $replies = sprintf( _n( '%s reply', '%s replies', $replies, 'bbpress' ), $replies ); 1860 $replies = sprintf( _n( '%s reply', '%s replies', bbp_get_topic_reply_count( $topic_id, true ), 'bbpress' ), bbp_get_topic_reply_count( $topic_id ) ); 1859 1861 $retval = ''; 1860 1862 … … 1893 1895 * 1894 1896 * @param int $topic_id Optional. Topic id 1897 * @param boolean $integer Optional. Whether or not to format the result 1895 1898 * @uses bbp_get_topic_reply_count() To get the topic reply count 1896 1899 */ 1897 function bbp_topic_reply_count( $topic_id = 0 ) {1898 echo bbp_get_topic_reply_count( $topic_id );1900 function bbp_topic_reply_count( $topic_id = 0, $integer = false ) { 1901 echo bbp_get_topic_reply_count( $topic_id, $integer ); 1899 1902 } 1900 1903 /** … … 1904 1907 * 1905 1908 * @param int $topic_id Optional. Topic id 1909 * @param boolean $integer Optional. Whether or not to format the result 1906 1910 * @uses bbp_get_topic_id() To get the topic id 1907 1911 * @uses get_post_meta() To get the topic reply count meta … … 1910 1914 * @return int Reply count 1911 1915 */ 1912 function bbp_get_topic_reply_count( $topic_id = 0 ) {1916 function bbp_get_topic_reply_count( $topic_id = 0, $integer = false ) { 1913 1917 $topic_id = bbp_get_topic_id( $topic_id ); 1914 $replies = get_post_meta( $topic_id, '_bbp_reply_count', true ); 1915 1916 return apply_filters( 'bbp_get_topic_reply_count', (int) $replies, $topic_id ); 1918 $replies = absint( get_post_meta( $topic_id, '_bbp_reply_count', true ) ); 1919 $filter = ( true === $integer ) ? 'bbp_get_topic_reply_count_int' : 'bbp_get_topic_reply_count'; 1920 1921 return apply_filters( $filter, $replies, $topic_id ); 1917 1922 } 1918 1923 … … 1923 1928 * 1924 1929 * @param int $topic_id Optional. Topic id 1930 * @param boolean $integer Optional. Whether or not to format the result 1925 1931 * @uses bbp_get_topic_post_count() To get the topic post count 1926 1932 */ 1927 function bbp_topic_post_count( $topic_id = 0 ) {1928 echo bbp_get_topic_post_count( $topic_id );1933 function bbp_topic_post_count( $topic_id = 0, $integer = false ) { 1934 echo bbp_get_topic_post_count( $topic_id, $integer ); 1929 1935 } 1930 1936 /** … … 1934 1940 * 1935 1941 * @param int $topic_id Optional. Topic id 1942 * @param boolean $integer Optional. Whether or not to format the result 1936 1943 * @uses bbp_get_topic_id() To get the topic id 1937 1944 * @uses get_post_meta() To get the topic post count meta … … 1940 1947 * @return int Post count 1941 1948 */ 1942 function bbp_get_topic_post_count( $topic_id = 0 ) {1949 function bbp_get_topic_post_count( $topic_id = 0, $integer = false ) { 1943 1950 $topic_id = bbp_get_topic_id( $topic_id ); 1944 $replies = get_post_meta( $topic_id, '_bbp_reply_count', true ); 1945 1946 return apply_filters( 'bbp_get_topic_post_count', (int) $replies + 1, $topic_id ); 1951 $replies = absint( get_post_meta( $topic_id, '_bbp_reply_count', true ) ) + 1; 1952 $filter = ( true === $integer ) ? 'bbp_get_topic_post_count_int' : 'bbp_get_topic_post_count'; 1953 1954 return apply_filters( $filter, $replies, $topic_id ); 1947 1955 } 1948 1956 … … 1954 1962 * 1955 1963 * @param int $topic_id Optional. Topic id 1964 * @param boolean $integer Optional. Whether or not to format the result 1956 1965 * @uses bbp_get_topic_reply_count_hidden() To get the topic hidden reply count 1957 1966 */ 1958 function bbp_topic_reply_count_hidden( $topic_id = 0 ) {1959 echo bbp_get_topic_reply_count_hidden( $topic_id );1967 function bbp_topic_reply_count_hidden( $topic_id = 0, $integer = false ) { 1968 echo bbp_get_topic_reply_count_hidden( $topic_id, $integer ); 1960 1969 } 1961 1970 /** … … 1966 1975 * 1967 1976 * @param int $topic_id Optional. Topic id 1977 * @param boolean $integer Optional. Whether or not to format the result 1968 1978 * @uses bbp_get_topic_id() To get the topic id 1969 1979 * @uses get_post_meta() To get the hidden reply count … … 1972 1982 * @return int Topic hidden reply count 1973 1983 */ 1974 function bbp_get_topic_reply_count_hidden( $topic_id = 0 ) {1984 function bbp_get_topic_reply_count_hidden( $topic_id = 0, $integer = false ) { 1975 1985 $topic_id = bbp_get_topic_id( $topic_id ); 1976 $replies = get_post_meta( $topic_id, '_bbp_reply_count_hidden', true ); 1977 1978 return (int) apply_filters( 'bbp_get_topic_reply_count_hidden', (int) $replies, $topic_id ); 1986 $replies = absint( get_post_meta( $topic_id, '_bbp_reply_count_hidden', true ) ); 1987 $filter = ( true === $integer ) ? 'bbp_get_topic_reply_count_hidden_int' : 'bbp_get_topic_reply_count_hidden'; 1988 1989 return apply_filters( $filter, $replies, $topic_id ); 1979 1990 } 1980 1991 … … 1987 1998 * @uses bbp_get_topic_voice_count() To get the topic voice count 1988 1999 */ 1989 function bbp_topic_voice_count( $topic_id = 0 ) {1990 echo bbp_get_topic_voice_count( $topic_id );2000 function bbp_topic_voice_count( $topic_id = 0, $integer = false ) { 2001 echo bbp_get_topic_voice_count( $topic_id, $integer ); 1991 2002 } 1992 2003 /** … … 2002 2013 * @return int Voice count of the topic 2003 2014 */ 2004 function bbp_get_topic_voice_count( $topic_id = 0 ) {2015 function bbp_get_topic_voice_count( $topic_id = 0, $integer = false ) { 2005 2016 $topic_id = bbp_get_topic_id( $topic_id ); 2006 $voices = get_post_meta( $topic_id, '_bbp_voice_count', true ); 2007 2008 return apply_filters( 'bbp_get_topic_voice_count', (int) $voices, $topic_id ); 2017 $voices = absint( get_post_meta( $topic_id, '_bbp_voice_count', true ) ); 2018 $filter = ( true === $integer ) ? 'bbp_get_topic_voice_count_int' : 'bbp_get_topic_voice_count'; 2019 2020 return apply_filters( $filter, $voices, $topic_id ); 2009 2021 } 2010 2022
Note: See TracChangeset
for help on using the changeset viewer.