Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/15/2010 04:08:11 AM (16 years ago)
Author:
johnjamesjacoby
Message:

Replace constants with $bbp global. Rename 'post type' references to 'content type.' Various human readability fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-templatetags.php

    r2594 r2596  
    4949 */
    5050function bbp_has_forums ( $args = '' ) {
    51         global $bbp_forums_template, $wp_query;
     51        global $wp_query, $bbp_forums_template, $bbp;
    5252
    5353        if ( bbp_is_forum() )
     
    5757
    5858        $default = array (
    59                 'post_type'     => BBP_FORUM_POST_TYPE_ID,
     59                'post_type'     => $bbp->forum_id,
    6060                'post_parent'   => $post_parent,
    6161                'orderby'       => 'menu_order',
     
    293293         */
    294294        function bbp_get_forum_topic_count ( $forum_id = 0 ) {
     295                global $bbp;
     296
    295297                if ( empty( $forum_id ) )
    296298                        $forum_id = bbp_get_forum_id();
    297299
    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 ) );
    299301
    300302                return apply_filters( 'bbp_get_forum_topic_count', $forum_topics );
     
    358360         */
    359361        function bbp_get_forum_topic_reply_count ( $forum_id = 0 ) {
     362                global $bbp;
     363
    360364                if ( empty( $forum_id ) )
    361365                        $forum_id = bbp_get_forum_id();
    362366
    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 ) );
    364368
    365369                return apply_filters( 'bbp_get_forum_topic_reply_count', $forum_topic_replies );
     
    412416 */
    413417function bbp_has_topics ( $args = '' ) {
    414         global $bbp_topics_template;
     418        global $bbp_topics_template, $bbp;
    415419
    416420        $default = array (
    417421                // Narrow query down to bbPress topics
    418                 'post_type'        => BBP_TOPIC_POST_TYPE_ID,
     422                'post_type'        => $bbp->topic_id,
    419423
    420424                // Forum ID
     
    985989         */
    986990        function bbp_get_topic_reply_count ( $topic_id = 0 ) {
     991                global $bbp;
     992
    987993                if ( empty( $topic_id ) )
    988994                        $topic_id = bbp_get_topic_id();
    989995
    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 ) );
    991997
    992998                return apply_filters( 'bbp_get_topic_reply_count', $topic_replies );
     
    10851091 */
    10861092function bbp_update_topic_voice_count ( $topic_id = 0 ) {
    1087         global $wpdb;
     1093        global $wpdb, $bbp;
    10881094
    10891095        if ( empty( $topic_id ) )
     
    10911097
    10921098        // 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 ) ) )
    10941100                return false;
    10951101
    10961102        // 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 ) )
    10981104                $topic_id = get_post_field( 'post_parent', $topic_id );
    10991105
    11001106        // 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 ) ) ) )
    11021108                $voices = 1;
    11031109
     
    11291135         */
    11301136        function bbp_get_topic_tag_list ( $topic_id = 0, $args = '' ) {
     1137                global $bbp;
     1138
    11311139                $defaults = array(
    11321140                        'before' => '<p>' . __( 'Tagged:', 'bbpress' ) . '&nbsp;',
     
    11411149                        $topic_id = bbp_get_topic_id();
    11421150
    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 );
    11441152        }
    11451153
     
    12821290 */
    12831291function bbp_has_replies ( $args = '' ) {
    1284         global $bbp_replies_template;
     1292        global $bbp_replies_template, $bbp;
    12851293
    12861294        $default = array(
    12871295                // Narrow query down to bbPress topics
    1288                 'post_type'        => BBP_REPLY_POST_TYPE_ID,
     1296                'post_type'        => $bbp->reply_id,
    12891297
    12901298                // Forum ID
     
    16981706 */
    16991707function 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'] )
    17031711                return true;
    17041712
    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'] )
    17061714                return true;
    17071715
     
    17201728 */
    17211729function 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'] )
    17251733                return true;
    17261734
    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'] )
    17281736                return true;
    17291737
     
    17421750 */
    17431751function 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'] )
    17471755                return true;
    17481756
    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'] )
    17501758                return true;
    17511759
     
    19141922         */
    19151923        function bbp_get_breadcrumb( $sep = '&larr;' ) {
    1916                 global $post;
     1924                global $post, $bbp;
    19171925
    19181926                $trail       = '';
     
    19281936                        switch ( $parent->post_type ) {
    19291937                                // Forum
    1930                                 case BBP_FORUM_POST_TYPE_ID :
     1938                                case $bbp->forum_id :
    19311939                                        $breadcrumbs[] = '<a href="' . bbp_get_forum_permalink( $parent->ID ) . '">' . bbp_get_forum_title( $parent->ID ) . '</a>';
    19321940                                        break;
    19331941
    19341942                                // Topic
    1935                                 case BBP_TOPIC_POST_TYPE_ID :
     1943                                case $bbp->topic_id :
    19361944                                        $breadcrumbs[] = '<a href="' . bbp_get_topic_permalink( $parent->ID ) . '">' . bbp_get_topic_title( $parent->ID ) . '</a>';
    19371945                                        break;
    19381946
    19391947                                // Reply (Note: not in most themes)
    1940                                 case BBP_REPLY_POST_TYPE_ID :
     1948                                case $bbp->reply_id :
    19411949                                        $breadcrumbs[] = '<a href="' . bbp_get_reply_permalink( $parent->ID ) . '">' . bbp_get_reply_title( $parent->ID ) . '</a>';
    19421950                                        break;
Note: See TracChangeset for help on using the changeset viewer.