Skip to:
Content

bbPress.org


Ignore:
Timestamp:
02/18/2011 10:16:22 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Decouple bbp_is_ functionality from bbp_get_{post_type}_id functionality, and use correctly through-out. Add ability to show all forums regardless of post_parent, and fix forums widget to use this functionality correctly.

File:
1 edited

Legend:

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

    r2905 r2914  
    4747    global $wp_query, $bbp;
    4848
    49     if ( is_singular( bbp_get_forum_post_type() ) )
    50         return true;
    51 
    52     if ( isset( $wp_query->query_vars['post_type'] ) && bbp_get_forum_post_type() === $wp_query->query_vars['post_type'] )
    53         return true;
    54 
    55     if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && bbp_get_forum_post_type() === $_GET['post_type'] )
    56         return true;
    57 
    58     if ( !empty( $post_id ) && ( bbp_get_forum_post_type() == get_post_field( 'post_type', $post_id ) ) )
     49    if ( empty( $post_id ) ) {
     50
     51        if ( is_singular( bbp_get_forum_post_type() ) )
     52            return true;
     53
     54        if ( isset( $wp_query->query_vars['post_type'] ) && ( bbp_get_forum_post_type() === $wp_query->query_vars['post_type'] ) )
     55            return true;
     56
     57        if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && ( bbp_get_forum_post_type() === $_GET['post_type'] ) )
     58            return true;
     59
     60    } elseif ( !empty( $post_id ) && ( bbp_get_forum_post_type() == get_post_field( 'post_type', $post_id ) ) )
    5961        return true;
    6062
     
    8082        return false;
    8183
    82     if ( is_singular( bbp_get_topic_post_type() ) )
    83         return true;
    84 
    85     if ( isset( $wp_query->query_vars['post_type'] ) && bbp_get_topic_post_type() === $wp_query->query_vars['post_type'] )
    86         return true;
    87 
    88     if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && bbp_get_topic_post_type() === $_GET['post_type'] )
    89         return true;
    90 
    91     if ( !empty( $post_id ) && ( bbp_get_topic_post_type() == get_post_field( 'post_type', $post_id ) ) )
     84    if ( empty( $post_id ) ) {
     85
     86        if ( is_singular( bbp_get_topic_post_type() ) )
     87            return true;
     88
     89        if ( isset( $wp_query->query_vars['post_type'] ) && ( bbp_get_topic_post_type() === $wp_query->query_vars['post_type'] ) )
     90            return true;
     91
     92        if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && ( bbp_get_topic_post_type() === $_GET['post_type'] ) )
     93            return true;
     94
     95    } elseif ( !empty( $post_id ) && ( bbp_get_topic_post_type() == get_post_field( 'post_type', $post_id ) ) )
    9296        return true;
    9397
     
    122126function bbp_is_topic_merge() {
    123127
    124     if ( bbp_is_topic_edit() && !empty( $_GET['action'] ) && 'merge' == $_GET['action'] )
     128    if ( bbp_is_topic_edit() && !empty( $_GET['action'] ) && ( 'merge' == $_GET['action'] ) )
    125129        return true;
    126130
     
    138142function bbp_is_topic_split() {
    139143
    140     if ( bbp_is_topic_edit() && !empty( $_GET['action'] ) && 'split' == $_GET['action'] )
     144    if ( bbp_is_topic_edit() && !empty( $_GET['action'] ) && ( 'split' == $_GET['action'] ) )
    141145        return true;
    142146
     
    162166        return false;
    163167
    164     if ( is_singular( bbp_get_reply_post_type() ) )
    165         return true;
    166 
    167     if ( isset( $wp_query->query_vars['post_type'] ) && bbp_get_reply_post_type() === $wp_query->query_vars['post_type'] )
    168         return true;
    169 
    170     if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && bbp_get_reply_post_type() === $_GET['post_type'] )
    171         return true;
    172 
    173     if ( !empty( $post_id ) && ( bbp_get_reply_post_type() == get_post_field( 'post_type', $post_id ) ) )
     168    if ( empty( $post_id ) ) {
     169
     170        if ( is_singular( bbp_get_reply_post_type() ) )
     171            return true;
     172
     173        if ( isset( $wp_query->query_vars['post_type'] ) && ( bbp_get_reply_post_type() === $wp_query->query_vars['post_type'] ) )
     174            return true;
     175
     176        if ( isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) && ( bbp_get_reply_post_type() === $_GET['post_type'] ) )
     177            return true;
     178
     179    } elseif ( !empty( $post_id ) && ( bbp_get_reply_post_type() == get_post_field( 'post_type', $post_id ) ) )
    174180        return true;
    175181
     
    188194    global $wp_query;
    189195
    190     if ( !empty( $wp_query->bbp_is_reply_edit ) && $wp_query->bbp_is_reply_edit == true )
     196    if ( !empty( $wp_query->bbp_is_reply_edit ) && ( true == $wp_query->bbp_is_reply_edit ) )
    191197        return true;
    192198
     
    211217        return false;
    212218
    213     if ( !empty( $query_name_check ) && 'bbp_user_profile_favorites' != bbp_get_query_name() )
     219    if ( !empty( $query_name_check ) && ( 'bbp_user_profile_favorites' != bbp_get_query_name() ) )
    214220        return false;
    215221
     
    234240        return false;
    235241
    236     if ( !empty( $query_name_check ) && 'bbp_user_profile_subscriptions' != bbp_get_query_name() )
     242    if ( !empty( $query_name_check ) && ( 'bbp_user_profile_subscriptions' != bbp_get_query_name() ) )
    237243        return false;
    238244
     
    258264        return false;
    259265
    260     if ( !empty( $query_name_check ) && 'bbp_user_profile_topics_created' != bbp_get_query_name() )
     266    if ( !empty( $query_name_check ) && ( 'bbp_user_profile_topics_created' != bbp_get_query_name() ) )
    261267        return false;
    262268
     
    292298    global $wp_query;
    293299
    294     if ( !empty( $wp_query->bbp_is_user_profile_page ) && $wp_query->bbp_is_user_profile_page == true )
     300    if ( !empty( $wp_query->bbp_is_user_profile_page ) && ( true == $wp_query->bbp_is_user_profile_page ) )
    295301        return true;
    296302
     
    309315    global $wp_query;
    310316
    311     if ( !empty( $wp_query->bbp_is_user_profile_edit ) && $wp_query->bbp_is_user_profile_edit == true )
     317    if ( !empty( $wp_query->bbp_is_user_profile_edit ) && ( true == $wp_query->bbp_is_user_profile_edit ) )
    312318        return true;
    313319
     
    326332    global $wp_query;
    327333
    328     if ( !empty( $wp_query->bbp_is_view ) && $wp_query->bbp_is_view == true )
     334    if ( !empty( $wp_query->bbp_is_view ) && ( true == $wp_query->bbp_is_view ) )
    329335        return true;
    330336
Note: See TracChangeset for help on using the changeset viewer.