Changeset 2596 for branches/plugin/bbp-includes/bbp-templatetags.php
- Timestamp:
- 11/15/2010 04:08:11 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-templatetags.php
r2594 r2596 49 49 */ 50 50 function bbp_has_forums ( $args = '' ) { 51 global $ bbp_forums_template, $wp_query;51 global $wp_query, $bbp_forums_template, $bbp; 52 52 53 53 if ( bbp_is_forum() ) … … 57 57 58 58 $default = array ( 59 'post_type' => BBP_FORUM_POST_TYPE_ID,59 'post_type' => $bbp->forum_id, 60 60 'post_parent' => $post_parent, 61 61 'orderby' => 'menu_order', … … 293 293 */ 294 294 function bbp_get_forum_topic_count ( $forum_id = 0 ) { 295 global $bbp; 296 295 297 if ( empty( $forum_id ) ) 296 298 $forum_id = bbp_get_forum_id(); 297 299 298 $forum_topics = 0; //get_pages( array( 'post_parent' => $forum_id, 'post_type' => BBP_TOPIC_POST_TYPE_ID) );300 $forum_topics = 0; //get_pages( array( 'post_parent' => $forum_id, 'post_type' => $bbp->topic_id ) ); 299 301 300 302 return apply_filters( 'bbp_get_forum_topic_count', $forum_topics ); … … 358 360 */ 359 361 function bbp_get_forum_topic_reply_count ( $forum_id = 0 ) { 362 global $bbp; 363 360 364 if ( empty( $forum_id ) ) 361 365 $forum_id = bbp_get_forum_id(); 362 366 363 $forum_topic_replies = 0; //get_pages( array( 'post_parent' => $forum_id, 'post_type' => BBP_REPLY_POST_TYPE_ID) );367 $forum_topic_replies = 0; //get_pages( array( 'post_parent' => $forum_id, 'post_type' => $bbp->reply_id ) ); 364 368 365 369 return apply_filters( 'bbp_get_forum_topic_reply_count', $forum_topic_replies ); … … 412 416 */ 413 417 function bbp_has_topics ( $args = '' ) { 414 global $bbp_topics_template ;418 global $bbp_topics_template, $bbp; 415 419 416 420 $default = array ( 417 421 // Narrow query down to bbPress topics 418 'post_type' => BBP_TOPIC_POST_TYPE_ID,422 'post_type' => $bbp->topic_id, 419 423 420 424 // Forum ID … … 985 989 */ 986 990 function bbp_get_topic_reply_count ( $topic_id = 0 ) { 991 global $bbp; 992 987 993 if ( empty( $topic_id ) ) 988 994 $topic_id = bbp_get_topic_id(); 989 995 990 $topic_replies = 0; //get_pages( array( 'post_parent' => $topic_id, 'post_type' => BBP_REPLY_POST_TYPE_ID) );996 $topic_replies = 0; //get_pages( array( 'post_parent' => $topic_id, 'post_type' => $bbp->reply_id ) ); 991 997 992 998 return apply_filters( 'bbp_get_topic_reply_count', $topic_replies ); … … 1085 1091 */ 1086 1092 function bbp_update_topic_voice_count ( $topic_id = 0 ) { 1087 global $wpdb ;1093 global $wpdb, $bbp; 1088 1094 1089 1095 if ( empty( $topic_id ) ) … … 1091 1097 1092 1098 // If it is not a topic or reply, then we don't need it 1093 if ( !in_array( get_post_field( 'post_type', $topic_id ), array( BBP_TOPIC_POST_TYPE_ID, BBP_REPLY_POST_TYPE_ID) ) )1099 if ( !in_array( get_post_field( 'post_type', $topic_id ), array( $bbp->topic_id, $bbp->reply_id ) ) ) 1094 1100 return false; 1095 1101 1096 1102 // If it's a reply, then get the parent (topic id) 1097 if ( BBP_REPLY_POST_TYPE_ID== get_post_field( 'post_type', $topic_id ) )1103 if ( $bbp->reply_id == get_post_field( 'post_type', $topic_id ) ) 1098 1104 $topic_id = get_post_field( 'post_parent', $topic_id ); 1099 1105 1100 1106 // There should always be at least 1 voice 1101 if ( !$voices = count( $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE ( post_parent = %d AND post_status = 'publish' AND post_type = '" . BBP_REPLY_POST_TYPE_ID . "' ) OR ( ID = %d AND post_type = '" . BBP_TOPIC_POST_TYPE_ID. "' );", $topic_id, $topic_id ) ) ) )1107 if ( !$voices = count( $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE ( post_parent = %d AND post_status = 'publish' AND post_type = '" . $bbp->reply_id . "' ) OR ( ID = %d AND post_type = '" . $bbp->topic_id . "' );", $topic_id, $topic_id ) ) ) ) 1102 1108 $voices = 1; 1103 1109 … … 1129 1135 */ 1130 1136 function bbp_get_topic_tag_list ( $topic_id = 0, $args = '' ) { 1137 global $bbp; 1138 1131 1139 $defaults = array( 1132 1140 'before' => '<p>' . __( 'Tagged:', 'bbpress' ) . ' ', … … 1141 1149 $topic_id = bbp_get_topic_id(); 1142 1150 1143 return get_the_term_list( $topic_id, BBP_TOPIC_TAG_ID, $before, $sep, $after );1151 return get_the_term_list( $topic_id, $bbp->topic_tag_id, $before, $sep, $after ); 1144 1152 } 1145 1153 … … 1282 1290 */ 1283 1291 function bbp_has_replies ( $args = '' ) { 1284 global $bbp_replies_template ;1292 global $bbp_replies_template, $bbp; 1285 1293 1286 1294 $default = array( 1287 1295 // Narrow query down to bbPress topics 1288 'post_type' => BBP_REPLY_POST_TYPE_ID,1296 'post_type' => $bbp->reply_id, 1289 1297 1290 1298 // Forum ID … … 1698 1706 */ 1699 1707 function bbp_is_forum () { 1700 global $wp_query ;1701 1702 if ( isset( $wp_query->query_vars['post_type'] ) && BBP_FORUM_POST_TYPE_ID=== $wp_query->query_vars['post_type'] )1708 global $wp_query, $bbp; 1709 1710 if ( isset( $wp_query->query_vars['post_type'] ) && $bbp->forum_id === $wp_query->query_vars['post_type'] ) 1703 1711 return true; 1704 1712 1705 if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && BBP_FORUM_POST_TYPE_ID=== $_GET['post_type'] )1713 if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && $bbp->forum_id === $_GET['post_type'] ) 1706 1714 return true; 1707 1715 … … 1720 1728 */ 1721 1729 function bbp_is_topic () { 1722 global $wp_query ;1723 1724 if ( isset( $wp_query->query_vars['post_type'] ) && BBP_TOPIC_POST_TYPE_ID=== $wp_query->query_vars['post_type'] )1730 global $wp_query, $bbp; 1731 1732 if ( isset( $wp_query->query_vars['post_type'] ) && $bbp->topic_id === $wp_query->query_vars['post_type'] ) 1725 1733 return true; 1726 1734 1727 if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && BBP_TOPIC_POST_TYPE_ID=== $_GET['post_type'] )1735 if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && $bbp->topic_id === $_GET['post_type'] ) 1728 1736 return true; 1729 1737 … … 1742 1750 */ 1743 1751 function bbp_is_reply () { 1744 global $wp_query ;1745 1746 if ( isset( $wp_query->query_vars['post_type'] ) && BBP_REPLY_POST_TYPE_ID=== $wp_query->query_vars['post_type'] )1752 global $wp_query, $bbp; 1753 1754 if ( isset( $wp_query->query_vars['post_type'] ) && $bbp->reply_id === $wp_query->query_vars['post_type'] ) 1747 1755 return true; 1748 1756 1749 if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && BBP_REPLY_POST_TYPE_ID=== $_GET['post_type'] )1757 if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && $bbp->reply_id === $_GET['post_type'] ) 1750 1758 return true; 1751 1759 … … 1914 1922 */ 1915 1923 function bbp_get_breadcrumb( $sep = '←' ) { 1916 global $post ;1924 global $post, $bbp; 1917 1925 1918 1926 $trail = ''; … … 1928 1936 switch ( $parent->post_type ) { 1929 1937 // Forum 1930 case BBP_FORUM_POST_TYPE_ID:1938 case $bbp->forum_id : 1931 1939 $breadcrumbs[] = '<a href="' . bbp_get_forum_permalink( $parent->ID ) . '">' . bbp_get_forum_title( $parent->ID ) . '</a>'; 1932 1940 break; 1933 1941 1934 1942 // Topic 1935 case BBP_TOPIC_POST_TYPE_ID:1943 case $bbp->topic_id : 1936 1944 $breadcrumbs[] = '<a href="' . bbp_get_topic_permalink( $parent->ID ) . '">' . bbp_get_topic_title( $parent->ID ) . '</a>'; 1937 1945 break; 1938 1946 1939 1947 // Reply (Note: not in most themes) 1940 case BBP_REPLY_POST_TYPE_ID:1948 case $bbp->reply_id : 1941 1949 $breadcrumbs[] = '<a href="' . bbp_get_reply_permalink( $parent->ID ) . '">' . bbp_get_reply_title( $parent->ID ) . '</a>'; 1942 1950 break;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)