Skip to:
Content

bbPress.org

Changeset 3505


Ignore:
Timestamp:
09/10/2011 10:27:19 PM (13 years ago)
Author:
johnjamesjacoby
Message:

API adjustments:

  • Refactor _status_ vars into callable functions.
  • Audit usage of $bbp global.
  • Perform get_class() checks on extensions to avoid errors if global $bbp is overloaded.
  • Bump DB version to 175.
Location:
branches/plugin
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-forums.php

    r3376 r3505  
    242242        // Category?
    243243        if ( !empty( $_POST['bbp_forum_type'] ) && in_array( $_POST['bbp_forum_type'], array( 'forum', 'category' ) ) ) {
    244             if ( 'category' == $_POST['bbp_forum_type'] && !bbp_is_forum_category( $forum_id ) )
     244            if ( 'category' == $_POST['bbp_forum_type'] && !bbp_is_forum_category( $forum_id ) ) {
    245245                bbp_categorize_forum( $forum_id );
    246             elseif ( 'forum' == $_POST['bbp_forum_type'] && bbp_is_forum_category( $forum_id ) )
     246            } elseif ( 'forum' == $_POST['bbp_forum_type'] && bbp_is_forum_category( $forum_id ) ) {
    247247                bbp_normalize_forum( $forum_id );
     248            }
    248249        }
    249250
    250251        // Visibility
    251         if ( !empty( $_POST['bbp_forum_visibility'] ) && in_array( $_POST['bbp_forum_visibility'], array( 'publish', 'private', 'hidden' ) ) ) {
     252        if ( !empty( $_POST['bbp_forum_visibility'] ) && in_array( $_POST['bbp_forum_visibility'], array( bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id() ) ) ) {
    252253
    253254            // Get forums current visibility
     
    261262
    262263                    // Hidden
    263                     case 'hidden'  :
     264                    case bbp_get_hidden_status_id()  :
    264265                        bbp_hide_forum( $forum_id, $visibility );
    265266                        break;
    266267
    267268                    // Private
    268                     case 'private' :
     269                    case bbp_get_private_status_id() :
    269270                        bbp_privatize_forum( $forum_id, $visibility );
    270271                        break;
    271272
    272273                    // Publish (default)
    273                     case 'publish'  :
     274                    case bbp_get_public_status_id()  :
    274275                    default        :
    275276                        bbp_publicize_forum( $forum_id, $visibility );
     
    553554    global $bbp;
    554555
     556    // Bail if bbPress is not loaded
     557    if ( 'bbPress' !== get_class( $bbp ) ) return;
     558
    555559    $bbp->admin->forums = new BBP_Forums_Admin();
    556560}
  • branches/plugin/bbp-admin/bbp-functions.php

    r3415 r3505  
    196196    $tpt = bbp_get_topic_post_type();
    197197    $rpt = bbp_get_reply_post_type();
    198     $pps = 'publish';
    199     $cps = $bbp->closed_status_id;
     198    $pps = bbp_get_public_status_id();
     199    $cps = bbp_get_closed_status_id();
    200200
    201201    $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (
     
    240240    $tpt = bbp_get_topic_post_type();
    241241    $rpt = bbp_get_reply_post_type();
    242     $pps = 'publish';
    243     $cps = $bbp->closed_status_id;
     242    $pps = bbp_get_public_status_id();
     243    $cps = bbp_get_closed_status_id();
    244244
    245245    $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (
     
    280280        return array( 1, sprintf( $statement, $result ) );
    281281
    282     $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` IN ( '" . join( "','", array( 'trash', $bbp->spam_status_id ) ) . "') GROUP BY `post_parent`);";
     282    $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` IN ( '" . join( "','", array( 'trash', bbp_get_spam_status_id() ) ) . "') GROUP BY `post_parent`);";
    283283    if ( is_wp_error( $wpdb->query( $sql ) ) )
    284284        return array( 2, sprintf( $statement, $result ) );
     
    367367 */
    368368function bbp_recount_user_topics_replied() {
    369     global $wpdb;
     369    global $wpdb, $bbp;
    370370
    371371    $statement = __( 'Counting the number of topics to which each user has replied… %s', 'bbpress' );
    372372    $result    = __( 'Failed!', 'bbpress' );
    373373
    374     $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` = 'publish' GROUP BY `post_author`;";
     374    $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author`;";
    375375    $insert_rows = $wpdb->get_results( $sql_select );
    376376
     
    706706 */
    707707function bbp_recount_clean_favorites() {
    708     global $wpdb;
     708    global $wpdb, $bbp;
    709709
    710710    $statement = __( 'Removing trashed topics from user favorites… %s', 'bbpress' );
     
    715715        return array( 1, sprintf( $statement, $result ) );
    716716
    717     $topics = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = 'publish';" );
     717    $topics = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "';" );
    718718
    719719    if ( is_wp_error( $topics ) )
     
    765765 */
    766766function bbp_recount_clean_subscriptions() {
    767     global $wpdb;
     767    global $wpdb, $bbp;
    768768
    769769    $statement = __( 'Removing trashed topics from user subscriptions… %s', 'bbpress' );
     
    774774        return array( 1, sprintf( $statement, $result ) );
    775775
    776     $topics = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = 'publish';" );
     776    $topics = $wpdb->get_col( "SELECT `ID` FROM `$wpdb->posts` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "';" );
    777777    if ( is_wp_error( $topics ) )
    778778        return array( 2, sprintf( $statement, $result ) );
     
    822822 */
    823823function bbp_recount_rewalk() {
    824     global $wpdb;
     824    global $wpdb, $bbp;
    825825
    826826    $statement = __( 'Recomputing latest post in every topic and forum… %s', 'bbpress' );
     
    835835            ( SELECT `topic`.`ID`, '_bbp_last_reply_id', MAX( `reply`.`ID` )
    836836            FROM `$wpdb->posts` AS `topic` INNER JOIN `$wpdb->posts` AS `reply` ON `topic`.`ID` = `reply`.`post_parent`
    837             WHERE `reply`.`post_status` IN ( 'publish' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
     837            WHERE `reply`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
    838838            GROUP BY `topic`.`ID` );" ) ) )
    839839        return array( 2, sprintf( $statement, $result ) );
     
    851851            ( SELECT `forum`.`ID`, '_bbp_last_topic_id', `topic`.`ID`
    852852            FROM `$wpdb->posts` AS `forum` INNER JOIN `$wpdb->posts` AS `topic` ON `forum`.`ID` = `topic`.`post_parent`
    853             WHERE `topic`.`post_status` IN ( 'publish' ) AND `forum`.`post_type` = 'forum' AND `topic`.`post_type` = 'topic'
     853            WHERE `topic`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `forum`.`post_type` = 'forum' AND `topic`.`post_type` = 'topic'
    854854            GROUP BY `forum`.`ID` );" ) ) )
    855855        return array( 4, sprintf( $statement, $result ) );
     
    867867            ( SELECT `topic`.`ID`, '_bbp_last_active_id', MAX( `reply`.`ID` )
    868868            FROM `$wpdb->posts` AS `topic` INNER JOIN `$wpdb->posts` AS `reply` ON `topic`.`ID` = `reply`.`post_parent`
    869             WHERE `reply`.`post_status` IN ( 'publish' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
     869            WHERE `reply`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
    870870            GROUP BY `topic`.`ID` );" ) ) )
    871871        return array( 6, sprintf( $statement, $result ) );
     
    883883            ( SELECT `topic`.`ID`, '_bbp_last_active_time', MAX( `reply`.`post_date` )
    884884            FROM `$wpdb->posts` AS `topic` INNER JOIN `$wpdb->posts` AS `reply` ON `topic`.`ID` = `reply`.`post_parent`
    885             WHERE `reply`.`post_status` IN ( 'publish' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
     885            WHERE `reply`.`post_status` IN ( '" . bbp_get_public_status_id() . "' ) AND `topic`.`post_type` = 'topic' AND `reply`.`post_type` = 'reply'
    886886            GROUP BY `topic`.`ID` );" ) ) )
    887887        return array( 8, sprintf( $statement, $result ) );
  • branches/plugin/bbp-admin/bbp-metaboxes.php

    r3468 r3505  
    278278
    279279    $forum['visibility']  = array(
    280         'publish' => __( 'Public',  'bbpress' ),
    281         'private' => __( 'Private', 'bbpress' ),
    282         'hidden'  => __( 'Hidden',  'bbpress' )
     280        bbp_get_public_status_id() => __( 'Public',  'bbpress' ),
     281        bbp_get_private_status_id() => __( 'Private', 'bbpress' ),
     282        bbp_get_hidden_status_id()  => __( 'Hidden',  'bbpress' )
    283283    );
    284284    $visibility_output = '<select name="bbp_forum_visibility" id="bbp_forum_visibility_select">' . "\n";
  • branches/plugin/bbp-admin/bbp-replies.php

    r3445 r3505  
    666666     */
    667667    function replies_row_actions( $actions, $reply ) {
    668         global $bbp;
    669668
    670669        if ( bbp_get_reply_post_type() == $reply->post_type ) {
     
    680679            // Only show the actions if the user is capable of viewing them
    681680            if ( current_user_can( 'moderate', $reply->ID ) ) {
    682                 if ( in_array( $reply->post_status, array( 'publish', $bbp->spam_status_id ) ) ) {
     681                if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_spam_status_id() ) ) ) {
    683682                    $spam_uri  = esc_url( wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_spam' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'spam-reply_'  . $reply->ID ) );
    684                     if ( bbp_is_reply_spam( $reply->ID ) )
     683                    if ( bbp_is_reply_spam( $reply->ID ) ) {
    685684                        $actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark the reply as not spam', 'bbpress' ) . '">' . __( 'Not spam', 'bbpress' ) . '</a>';
    686                     else
     685                    } else {
    687686                        $actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark this reply as spam',    'bbpress' ) . '">' . __( 'Spam',     'bbpress' ) . '</a>';
     687                    }
    688688                }
    689689            }
     
    691691            // Trash
    692692            if ( current_user_can( 'delete_reply', $reply->ID ) ) {
    693                 if ( $bbp->trash_status_id == $reply->post_status ) {
     693                if ( bbp_get_trash_status_id() == $reply->post_status ) {
    694694                    $post_type_object = get_post_type_object( bbp_get_reply_post_type() );
    695695                    $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash', 'bbpress' ) ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . "'>" . __( 'Restore', 'bbpress' ) . "</a>";
     
    698698                }
    699699
    700                 if ( $bbp->trash_status_id == $reply->post_status || !EMPTY_TRASH_DAYS ) {
     700                if ( bbp_get_trash_status_id() == $reply->post_status || !EMPTY_TRASH_DAYS ) {
    701701                    $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently', 'bbpress' ) ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $reply->ID, '', true ) ) . "'>" . __( 'Delete Permanently', 'bbpress' ) . "</a>";
    702                 } elseif ( $bbp->spam_status_id == $reply->post_status ) {
     702                } elseif ( bbp_get_spam_status_id() == $reply->post_status ) {
    703703                    unset( $actions['trash'] );
    704704                }
     
    873873    global $bbp;
    874874
     875    // Bail if bbPress is not loaded
     876    if ( 'bbPress' !== get_class( $bbp ) ) return;
     877
    875878    $bbp->admin->replies = new BBP_Replies_Admin();
    876879}
  • branches/plugin/bbp-admin/bbp-topics.php

    r3376 r3505  
    721721     */
    722722    function topics_row_actions( $actions, $topic ) {
    723         global $bbp;
    724723
    725724        if ( $topic->post_type == $this->post_type ) {
     
    735734                // Close
    736735                // Show the 'close' and 'open' link on published and closed posts only
    737                 if ( in_array( $topic->post_status, array( 'publish', $bbp->closed_status_id ) ) ) {
     736                if ( in_array( $topic->post_status, array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ) ) {
    738737                    $close_uri = esc_url( wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'close-topic_' . $topic->ID ) );
    739738                    if ( bbp_is_topic_open( $topic->ID ) )
     
    767766            // Do not show trash links for spam topics, or spam links for trashed topics
    768767            if ( current_user_can( 'delete_topic', $topic->ID ) ) {
    769                 if ( $bbp->trash_status_id == $topic->post_status ) {
     768                if ( bbp_get_trash_status_id() == $topic->post_status ) {
    770769                    $post_type_object   = get_post_type_object( bbp_get_topic_post_type() );
    771770                    $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash', 'bbpress' ) ) . "' href='" . wp_nonce_url( add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ) ), admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $topic->ID ) ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) . "'>" . __( 'Restore', 'bbpress' ) . "</a>";
     
    774773                }
    775774
    776                 if ( $bbp->trash_status_id == $topic->post_status || !EMPTY_TRASH_DAYS ) {
     775                if ( bbp_get_trash_status_id() == $topic->post_status || !EMPTY_TRASH_DAYS ) {
    777776                    $actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently', 'bbpress' ) ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $topic->ID, '', true ) ) . "'>" . __( 'Delete Permanently', 'bbpress' ) . "</a>";
    778                 } elseif ( $bbp->spam_status_id == $topic->post_status ) {
     777                } elseif ( bbp_get_spam_status_id() == $topic->post_status ) {
    779778                    unset( $actions['trash'] );
    780779                }
     
    949948    global $bbp;
    950949
     950    // Bail if bbPress is not loaded
     951    if ( 'bbPress' !== get_class( $bbp ) ) return;
     952
    951953    $bbp->admin->topics = new BBP_Topics_Admin();
    952954}
  • branches/plugin/bbp-admin/bbp-users.php

    r3376 r3505  
    111111    global $bbp;
    112112
     113    // Bail if bbPress is not loaded
     114    if ( 'bbPress' !== get_class( $bbp ) ) return;
     115
    113116    $bbp->admin->users = new BBP_Users_Admin();
    114117}
  • branches/plugin/bbp-admin/importers/bbpress.php

    r3376 r3505  
    880880
    881881                $forum_map     = array();
    882                 $post_statuses = array( 'publish', $bbp->trash_status_id, $bbp->spam_status_id );
     882                $post_statuses = array( bbp_get_public_status_id(), bbp_get_trash_status_id(), bbp_get_spam_status_id() );
    883883
    884884                foreach ( (array) $forums as $forum ) {
     
    891891                        'post_title'     => $forum->forum_name,
    892892                        'post_excerpt'   => '',
    893                         'post_status'    => 'publish',
     893                        'post_status'    => bbp_get_public_status_id(),
    894894                        'comment_status' => 'closed',
    895895                        'ping_status'    => 'closed',
     
    944944
    945945                        // If the topic is public, check if it's open and set the status accordingly
    946                         $topic_status       =  $topic->topic_status == 0 ? ( $topic->topic_open == 0 ? $bbp->closed_status_id : $post_statuses[$topic->topic_status] ) : $post_statuses[$topic->topic_status];
     946                        $topic_status       =  $topic->topic_status == 0 ? ( $topic->topic_open == 0 ? bbp_get_closed_status_id() : $post_statuses[$topic->topic_status] ) : $post_statuses[$topic->topic_status];
    947947
    948948                        $inserted_topic     =  wp_insert_post( array(
     
    10381038
    10391039                            // Only add favorites and subscriptions if the topic is public
    1040                             if ( in_array( $topic_status, array( 'publish', $bbp->closed_status_id ) ) ) {
     1040                            if ( in_array( $topic_status, array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ) ) {
    10411041
    10421042                                // Favorites
  • branches/plugin/bbp-includes/bbp-common-functions.php

    r3499 r3505  
    440440 */
    441441function bbp_get_statistics( $args = '' ) {
    442     global $bbp;
    443442
    444443    $defaults = array (
     
    470469    }
    471470
     471    // Post statuses
     472    $private = bbp_get_private_status_id();
     473    $spam    = bbp_get_spam_status_id();
     474    $trash   = bbp_get_trash_status_id();
     475    $closed  = bbp_get_closed_status_id();
     476
    472477    // Topics
    473478    if ( !empty( $count_topics ) ) {
     
    476481
    477482        // Published (publish + closed)
    478         $topic_count = $all_topics->publish + $all_topics->{$bbp->closed_status_id};
     483        $topic_count = $all_topics->publish + $all_topics->{$closed};
    479484
    480485        if ( current_user_can( 'read_private_topics' ) || current_user_can( 'edit_others_topics' ) || current_user_can( 'view_trash' ) ) {
    481486
    482487            // Private
    483             $topics['private'] = ( !empty( $count_private_topics ) && current_user_can( 'read_private_topics' ) ) ? (int) $all_topics->private                : 0;
     488            $topics['private'] = ( !empty( $count_private_topics ) && current_user_can( 'read_private_topics' ) ) ? (int) $all_topics->{$private} : 0;
    484489
    485490            // Spam
    486             $topics['spammed'] = ( !empty( $count_spammed_topics ) && current_user_can( 'edit_others_topics'  ) ) ? (int) $all_topics->{$bbp->spam_status_id}  : 0;
     491            $topics['spammed'] = ( !empty( $count_spammed_topics ) && current_user_can( 'edit_others_topics'  ) ) ? (int) $all_topics->{$spam}    : 0;
    487492
    488493            // Trash
    489             $topics['trashed'] = ( !empty( $count_trashed_topics ) && current_user_can( 'view_trash'          ) ) ? (int) $all_topics->{$bbp->trash_status_id} : 0;
     494            $topics['trashed'] = ( !empty( $count_trashed_topics ) && current_user_can( 'view_trash'          ) ) ? (int) $all_topics->{$trash}  : 0;
    490495
    491496            // Total hidden (private + spam + trash)
     
    513518
    514519            // Private
    515             $replies['private'] = ( !empty( $count_private_replies ) && current_user_can( 'read_private_replies' ) ) ? (int) $all_replies->private                : 0;
     520            $replies['private'] = ( !empty( $count_private_replies ) && current_user_can( 'read_private_replies' ) ) ? (int) $all_replies->{$private} : 0;
    516521
    517522            // Spam
    518             $replies['spammed'] = ( !empty( $count_spammed_replies ) && current_user_can( 'edit_others_replies'  ) ) ? (int) $all_replies->{$bbp->spam_status_id}  : 0;
     523            $replies['spammed'] = ( !empty( $count_spammed_replies ) && current_user_can( 'edit_others_replies'  ) ) ? (int) $all_replies->{$spam}    : 0;
    519524
    520525            // Trash
    521             $replies['trashed'] = ( !empty( $count_trashed_replies ) && current_user_can( 'view_trash'           ) ) ? (int) $all_replies->{$bbp->trash_status_id} : 0;
     526            $replies['trashed'] = ( !empty( $count_trashed_replies ) && current_user_can( 'view_trash'           ) ) ? (int) $all_replies->{$trash}  : 0;
    522527
    523528            // Total hidden (private + spam + trash)
     
    714719 */
    715720function bbp_filter_anonymous_post_data( $args = '', $is_edit = false ) {
    716     global $bbp;
    717721
    718722    // Assign variables
     
    769773        return true;
    770774
    771     global $bbp, $wpdb;
     775    global $wpdb;
    772776
    773777    extract( $post_data, EXTR_SKIP );
     
    792796    // Simple duplicate check
    793797    // Expected slashed ($post_type, $post_parent, $post_author, $post_content, $anonymous_data)
    794     $dupe  = "SELECT ID FROM {$wpdb->posts} {$join} WHERE post_type = '{$post_type}' AND post_status != '{$bbp->trash_status_id}' AND post_author = {$post_author} AND post_content = '{$post_content}' {$where}";
    795     $dupe .= !empty( $post_parent ) ? " AND post_parent = '{$post_parent}'" : '';
    796     $dupe .= " LIMIT 1";
    797     $dupe  = apply_filters( 'bbp_check_for_duplicate_query', $dupe, $post_data );
     798    $status = bbp_get_trash_status_id();
     799    $dupe   = "SELECT ID FROM {$wpdb->posts} {$join} WHERE post_type = '{$post_type}' AND post_status != '{$status}' AND post_author = {$post_author} AND post_content = '{$post_content}' {$where}";
     800    $dupe  .= !empty( $post_parent ) ? " AND post_parent = '{$post_parent}'" : '';
     801    $dupe  .= " LIMIT 1";
     802    $dupe   = apply_filters( 'bbp_check_for_duplicate_query', $dupe, $post_data );
    798803
    799804    if ( $wpdb->get_var( $dupe ) ) {
     
    855860 * @since bbPress (r3446)
    856861 *
    857  * @global bbPress $bbp
    858862 * @param array $anonymous_data Anonymous user data
    859863 * @param int $author_id Topic or reply author ID
     
    980984 */
    981985function bbp_notify_subscribers( $reply_id = 0 ) {
    982     global $bbp, $wpdb;
     986    global $wpdb;
    983987
    984988    // Bail if subscriptions are turned off
     
    11581162    // The ID of the cached query
    11591163    $cache_id    = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_last_id';
    1160     $post_status = array( 'publish' );
     1164    $post_status = array( bbp_get_public_status_id() );
    11611165
    11621166    // Add closed status if topic post type
    11631167    if ( $post_type == bbp_get_topic_post_type() )
    1164         $post_status[] = $bbp->closed_status_id;
     1168        $post_status[] = bbp_get_closed_status_id();
    11651169
    11661170    // Join post statuses together
     
    11921196 */
    11931197function bbp_get_public_child_count( $parent_id = 0, $post_type = 'post' ) {
    1194     global $wpdb, $bbp;
     1198    global $wpdb;
    11951199
    11961200    // Bail if nothing passed
     
    12001204    // The ID of the cached query
    12011205    $cache_id    = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_count';
    1202     $post_status = array( 'publish' );
     1206    $post_status = array( bbp_get_public_status_id() );
    12031207
    12041208    // Add closed status if topic post type
    12051209    if ( $post_type == bbp_get_topic_post_type() )
    1206         $post_status[] = $bbp->closed_status_id;
     1210        $post_status[] = bbp_get_closed_status_id();
    12071211
    12081212    // Join post statuses together
     
    12341238 */
    12351239function bbp_get_public_child_ids( $parent_id = 0, $post_type = 'post' ) {
    1236     global $wpdb, $bbp;
     1240    global $wpdb;
    12371241
    12381242    // Bail if nothing passed
     
    12421246    // The ID of the cached query
    12431247    $cache_id    = 'bbp_parent_public_' . $parent_id . '_type_' . $post_type . '_child_ids';
    1244     $post_status = array( 'publish' );
     1248    $post_status = array( bbp_get_public_status_id() );
    12451249
    12461250    // Add closed status if topic post type
    12471251    if ( $post_type == bbp_get_topic_post_type() )
    1248         $post_status[] = $bbp->closed_status_id;
     1252        $post_status[] = bbp_get_closed_status_id();
    12491253
    12501254    // Join post statuses together
     
    12751279 */
    12761280function bbp_get_all_child_ids( $parent_id = 0, $post_type = 'post' ) {
    1277     global $wpdb, $bbp;
     1281    global $wpdb;
    12781282
    12791283    // Bail if nothing passed
     
    12831287    // The ID of the cached query
    12841288    $cache_id    = 'bbp_parent_all_' . $parent_id . '_type_' . $post_type . '_child_ids';
    1285     $post_status = array( 'publish' );
     1289    $post_status = array( bbp_get_public_status_id() );
    12861290
    12871291    // Extra post statuses based on post type
     
    12901294        // Forum
    12911295        case bbp_get_forum_post_type() :
    1292             $post_status[] = 'private';
    1293             $post_status[] = $bbp->hidden_status_id;
     1296            $post_status[] = bbp_get_private_status_id();
     1297            $post_status[] = bbp_get_hidden_status_id();
    12941298            break;
    12951299
    12961300        // Topic
    12971301        case bbp_get_topic_post_type() :
    1298             $post_status[] = $bbp->closed_status_id;
    1299             $post_status[] = $bbp->trash_status_id;
    1300             $post_status[] = $bbp->spam_status_id;
     1302            $post_status[] = bbp_get_closed_status_id();
     1303            $post_status[] = bbp_get_trash_status_id();
     1304            $post_status[] = bbp_get_spam_status_id();
    13011305            break;
    13021306
    13031307        // Reply
    13041308        case bbp_get_reply_post_type() :
    1305             $post_status[] = $bbp->trash_status_id;
    1306             $post_status[] = $bbp->spam_status_id;
     1309            $post_status[] = bbp_get_trash_status_id();
     1310            $post_status[] = bbp_get_spam_status_id();
    13071311            break;
    13081312    }
     
    13311335 *
    13321336 * @global WP_Query $wp_query
    1333  * @global bbPress $bbp
    13341337 * @param array $query_vars
    13351338 * @return array
    13361339 */
    13371340function bbp_request_feed_trap( $query_vars ) {
    1338     global $wp_query, $bbp;
     1341    global $wp_query;
    13391342
    13401343    // Looking at a feed
     
    13491352                // Forum
    13501353                case bbp_get_forum_post_type() :
     1354
     1355                    // Declare local variable(s)
     1356                    $meta_query = array();
    13511357
    13521358                    // Single forum
     
    13681374                            'value'   => $forum_id,
    13691375                            'compare' => '='
    1370                         ) );
    1371                        
    1372                     // No restrictions on forum ID
    1373                     } else {
    1374                         $meta_query = array();
     1376                        ) );                       
    13751377                    }
    13761378
     
    13831385                            'post_type'      => bbp_get_reply_post_type(),
    13841386                            'post_parent'    => 'any',
    1385                             'post_status'    => join( ',', array( 'publish', $bbp->closed_status_id ) ),
     1387                            'post_status'    => join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ),
    13861388                            'posts_per_page' => get_option( '_bbp_replies_per_rss_page', 25 ),
    13871389                            'order'          => 'DESC',
     
    14001402                            'post_type'      => bbp_get_topic_post_type(),
    14011403                            'post_parent'    => 'any',
    1402                             'post_status'    => join( ',', array( 'publish', $bbp->closed_status_id ) ),
     1404                            'post_status'    => join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ),
    14031405                            'posts_per_page' => get_option( '_bbp_topics_per_rss_page', 25 ),
    14041406                            'order'          => 'DESC',
     
    14171419                            'post_type'      => array( bbp_get_reply_post_type(), bbp_get_topic_post_type() ),
    14181420                            'post_parent'    => 'any',
    1419                             'post_status'    => join( ',', array( 'publish', $bbp->closed_status_id ) ),
     1421                            'post_status'    => join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ),
    14201422                            'posts_per_page' => get_option( '_bbp_replies_per_rss_page', 25 ),
    14211423                            'order'          => 'DESC',
     
    15341536}
    15351537
     1538/** Post Statuses *************************************************************/
     1539
     1540/**
     1541 * Return the public post status ID
     1542 *
     1543 * @since bbPress (r3504)
     1544 *
     1545 * @global bbPress $bbp
     1546 * @return string
     1547 */
     1548function bbp_get_public_status_id() {
     1549    global $bbp;
     1550    return $bbp->public_status_id;
     1551}
     1552
     1553/**
     1554 * Return the private post status ID
     1555 *
     1556 * @since bbPress (r3504)
     1557 *
     1558 * @global bbPress $bbp
     1559 * @return string
     1560 */
     1561function bbp_get_private_status_id() {
     1562    global $bbp;
     1563    return $bbp->private_status_id;
     1564}
     1565
     1566/**
     1567 * Return the hidden post status ID
     1568 *
     1569 * @since bbPress (r3504)
     1570 *
     1571 * @global bbPress $bbp
     1572 * @return string
     1573 */
     1574function bbp_get_hidden_status_id() {
     1575    global $bbp;
     1576    return $bbp->hidden_status_id;
     1577}
     1578
     1579/**
     1580 * Return the closed post status ID
     1581 *
     1582 * @since bbPress (r3504)
     1583 *
     1584 * @global bbPress $bbp
     1585 * @return string
     1586 */
     1587function bbp_get_closed_status_id() {
     1588    global $bbp;
     1589    return $bbp->closed_status_id;
     1590}
     1591
     1592/**
     1593 * Return the spam post status ID
     1594 *
     1595 * @since bbPress (r3504)
     1596 *
     1597 * @global bbPress $bbp
     1598 * @return string
     1599 */
     1600function bbp_get_spam_status_id() {
     1601    global $bbp;
     1602    return $bbp->spam_status_id;
     1603}
     1604
     1605/**
     1606 * Return the trash post status ID
     1607 *
     1608 * @since bbPress (r3504)
     1609 *
     1610 * @global bbPress $bbp
     1611 * @return string
     1612 */
     1613function bbp_get_trash_status_id() {
     1614    global $bbp;
     1615    return $bbp->trash_status_id;
     1616}
     1617
     1618/**
     1619 * Return the orphan post status ID
     1620 *
     1621 * @since bbPress (r3504)
     1622 *
     1623 * @global bbPress $bbp
     1624 * @return string
     1625 */
     1626function bbp_get_orphan_status_id() {
     1627    global $bbp;
     1628    return $bbp->orphan_status_id;
     1629}
     1630
    15361631?>
  • branches/plugin/bbp-includes/bbp-common-template.php

    r3472 r3505  
    253253 */
    254254function bbp_is_topic_tag() {
    255     global $bbp;
     255    global $bbp, $wp_query;
    256256
    257257    // Return false if editing a topic tag
     
    259259        return false;
    260260
    261     if ( is_tax( bbp_get_topic_tag_tax_id() ) || !empty( $bbp->topic_query->is_tax ) )
     261    if ( is_tax( bbp_get_topic_tag_tax_id() ) || !empty( $bbp->topic_query->is_tax ) || get_query_var( 'bbp_topic_tag' ) )
    262262        return true;
    263263
     
    919919     */
    920920    function bbp_get_dropdown( $args = '' ) {
    921         global $bbp;
    922921
    923922        /** Arguments *********************************************************/
     
    962961
    963962        // Public
    964         $post_stati[] = 'publish';
     963        $post_stati[] = bbp_get_public_status_id();
    965964
    966965        // Forums
     
    969968            // Private forums
    970969            if ( current_user_can( 'read_private_forums' ) )
    971                 $post_stati[] = 'private';
     970                $post_stati[] = bbp_get_private_status_id();
    972971
    973972            // Hidden forums
    974973            if ( current_user_can( 'read_hidden_forums' ) )
    975                 $post_stati[] = $bbp->hidden_status_id;
     974                $post_stati[] = bbp_get_hidden_status_id();
    976975        }
    977976
  • branches/plugin/bbp-includes/bbp-core-caps.php

    r3504 r3505  
    165165                $post_type = get_post_type_object( $post->post_type );
    166166
    167                 if ( 'private' != $post->post_status )
     167                if ( bbp_get_public_status_id() == $post->post_status )
    168168                    $caps[] = 'read';
    169169                elseif ( (int) $user_id == (int) $post->post_author )
  • branches/plugin/bbp-includes/bbp-core-compatibility.php

    r3496 r3505  
    265265            'post_content'    => '',
    266266            'post_type'       => 'page',
    267             'post_status'     => 'publish',
     267            'post_status'     => bbp_get_public_status_id(),
    268268            'post_name'       => '',
    269269            'comment_status'  => 'closed',
     
    728728 *
    729729 * @since bbPress (r3032)
    730  *
    731  * @global bbPress $bbp
    732  * @global WP_Query $post
    733730 *
    734731 * @param string $template
     
    754751 */
    755752function bbp_template_include_theme_supports( $template = '' ) {
    756     global $bbp;
    757753
    758754    // Current theme supports bbPress
     
    826822                'post_content' => '',
    827823                'post_type'    => bbp_get_forum_post_type(),
    828                 'post_status'  => 'publish',
     824                'post_status'  => bbp_get_public_status_id(),
    829825                'is_archive'   => true
    830826            ) );
     
    843839                'post_content' => '',
    844840                'post_type'    => bbp_get_topic_post_type(),
    845                 'post_status'  => 'publish',
     841                'post_status'  => bbp_get_public_status_id(),
    846842                'is_archive'   => true
    847843            ) );
     
    875871                'post_content' => '',
    876872                'post_type'    => bbp_get_reply_post_type(),
    877                 'post_status'  => 'publish'
     873                'post_status'  => bbp_get_public_status_id()
    878874            ) );
    879875
     
    904900                'post_content' => '',
    905901                'post_type'    => '',
    906                 'post_status'  => 'publish'
     902                'post_status'  => bbp_get_public_status_id()
    907903            ) );
    908904
     
    15801576
    15811577        // All users can see published forums
    1582         $status[] = 'publish';
    1583 
    1584         // Add 'private' if user is capable
     1578        $status[] = bbp_get_public_status_id();
     1579
     1580        // Add bbp_get_private_status_id() if user is capable
    15851581        if ( current_user_can( 'read_private_forums' ) )
    1586             $status[] = 'private';
    1587 
    1588         // Add 'hidden' if user is capable
     1582            $status[] = bbp_get_private_status_id();
     1583
     1584        // Add bbp_get_hidden_status_id() if user is capable
    15891585        if ( current_user_can( 'read_hidden_forums' ) )
    1590             $status[] = $bbp->hidden_status_id;
     1586            $status[] = bbp_get_hidden_status_id();
    15911587
    15921588        // Implode and add the statuses
     
    15951591    // Topic tag page
    15961592    } elseif ( bbp_is_topic_tag() ) {
     1593        $posts_query->set( 'bbp_topic_tag',  get_query_var( 'term' )                  );
    15971594        $posts_query->set( 'post_type',      bbp_get_topic_post_type()                );
    15981595        $posts_query->set( 'posts_per_page', get_option( '_bbp_topics_per_page', 15 ) );
  • branches/plugin/bbp-includes/bbp-core-shortcodes.php

    r3395 r3505  
    757757     * @since bbPress (r3302)
    758758     *
    759      * @global bbPress $bbp
    760      *
    761759     * @return string
    762760     */
    763761    public function display_login() {
    764         global $bbp;
    765762
    766763        // Unset globals
     
    785782     * @since bbPress (r3302)
    786783     *
    787      * @global bbPress $bbp
    788      *
    789784     * @return string
    790785     */
    791786    public function display_register() {
    792         global $bbp;
    793787
    794788        // Unset globals
     
    813807     * @since bbPress (r3302)
    814808     *
    815      * @global bbPress $bbp
    816      *
    817809     * @return string
    818810     */
    819811    public function display_lost_pass() {
    820         global $bbp;
    821812
    822813        // Unset globals
     
    842833     *
    843834     * @since bbPress (r3302)
    844      *
    845      * @global bbPress $bbp
    846835     *
    847836     * @return string
     
    875864    global $bbp;
    876865
     866    // Bail if bbPress is not loaded
     867    if ( 'bbPress' !== get_class( $bbp ) ) return;
     868
    877869    $bbp->shortcodes = new BBP_Shortcodes();
    878870}
  • branches/plugin/bbp-includes/bbp-core-widgets.php

    r3491 r3505  
    530530     */
    531531    function widget( $args, $instance ) {
    532         global $bbp;
    533532
    534533        extract( $args );
     
    727726     */
    728727    function widget( $args, $instance ) {
    729         global $bbp;
    730728
    731729        extract( $args );
     
    737735        // Query defaults
    738736        $replies_query = array(
    739             'post_status'    => join( ',', array( 'publish', $bbp->closed_status_id ) ),
     737            'post_status'    => join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ),
    740738            'posts_per_page' => $max_shown,
    741739            'order'          => 'DESC'
  • branches/plugin/bbp-includes/bbp-extend-akismet.php

    r3498 r3505  
    7474     * @param string $post_data
    7575     *
    76      * @global bbPress $bbp
    77      *
    7876     * @uses get_userdata() To get the user data
    7977     * @uses bbp_filter_anonymous_user_data() To get anonymous user data
     
    8987     */
    9088    public function check_post( $post_data ) {
    91         global $bbp;
    9289
    9390        // Declare local variables
     
    9693
    9794        // Post is not published
    98         if ( 'publish' != $post_data['post_status'] )
     95        if ( bbp_get_public_status_id() != $post_data['post_status'] )
    9996            return $post_data;
    10097
     
    167164
    168165            // This is spam
    169             $post_data['post_status'] = $bbp->spam_status_id;
     166            $post_data['post_status'] = bbp_get_spam_status_id();
    170167
    171168            // We don't want your spam tags here
     
    192189     * @param int $post_id
    193190     *
    194      * @global bbPress $bbp
    195191     * @global WP_Query $wpdb
    196192     * @global string $akismet_api_host
     
    214210     */
    215211    public function submit_post( $post_id = 0 ) {
    216         global $bbp, $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
     212        global $wpdb, $akismet_api_host, $akismet_api_port, $current_user, $current_site;
    217213
    218214        // Innocent until proven guilty
     
    251247
    252248        // Bail if we're spamming, but the post_status isn't spam
    253         if ( ( 'spam' == $request_type ) && ( $bbp->spam_status_id != $post->post_status ) )
     249        if ( ( 'spam' == $request_type ) && ( bbp_get_spam_status_id() != $post->post_status ) )
    254250            return;
    255251
     
    404400     * @param object $post
    405401     *
    406      * @global bbPress $bbp
    407402     * @global object $this->last_post
    408403     *
     
    414409     */
    415410    public function update_post_meta( $post_id = 0, $post = false ) {
    416         global $bbp;
    417411
    418412        // Define local variable(s)
     
    452446
    453447                    // If post_status isn't the spam status, as expected, leave a note
    454                     if ( $post->post_status != $bbp->spam_status_id ) {
     448                    if ( $post->post_status != bbp_get_spam_status_id() ) {
    455449                        $this->update_post_history( $post_id, sprintf( __( 'Post status was changed to %s', 'bbpress' ), $post->post_status ), 'status-changed-' . $post->post_status );
    456450                    }
     
    464458
    465459                    // If post_status is the spam status, which isn't expected, leave a note
    466                     if ( $post->post_status == $bbp->spam_status_id ) {
     460                    if ( $post->post_status == bbp_get_spam_status_id() ) {
    467461
    468462                        // @todo Use wp_blacklist_check()
     
    554548     * @param int $reply_id
    555549     *
    556      * @global bbPress $bbp
    557      *
    558550     * @uses bbp_get_reply_id() To get the reply_id
    559551     * @uses bbp_get_topic_id() To get the topic_id
     
    564556     */
    565557    public function filter_post_terms( $terms = '', $topic_id = 0, $reply_id = 0 ) {
    566         global $bbp;
    567558
    568559        // Validate the reply_id and topic_id
     
    696687    if ( !defined( 'AKISMET_VERSION' ) ) return;
    697688
     689    // Bail if bbPress is not loaded
     690    if ( 'bbPress' !== get_class( $bbp ) ) return;
     691
    698692    // Instantiate Akismet for bbPress
    699693    $bbp->extend->akismet = new BBP_Akismet();
  • branches/plugin/bbp-includes/bbp-extend-buddypress.php

    r3503 r3505  
    597597    if ( !empty( $bp->maintenance_mode ) || !defined( 'BP_VERSION' ) ) return;
    598598
     599    // Bail if bbPress is not loaded
     600    if ( 'bbPress' !== get_class( $bbp ) ) return;
     601
    599602    // Instantiate BuddyPress for bbPress
    600603    $bbp->extend->buddypress = new BBP_BuddyPress();
  • branches/plugin/bbp-includes/bbp-extend-genesis.php

    r3500 r3505  
    163163    if ( basename( TEMPLATEPATH ) !== 'genesis' ) return;
    164164
     165    // Bail if bbPress is not loaded
     166    if ( 'bbPress' !== get_class( $bbp ) ) return;
     167
    165168    // Instantiate Genesis for bbPress
    166169    $bbp->extend->genesis = new BBP_Genesis();
  • branches/plugin/bbp-includes/bbp-forum-functions.php

    r3501 r3505  
    3232    $default_forum = array(
    3333        'post_parent'   => 0, // forum ID
    34         'post_status'   => 'publish',
     34        'post_status'   => bbp_get_public_status_id(),
    3535        'post_type'     => bbp_get_forum_post_type(),
    3636        'post_author'   => 0,
     
    208208
    209209    // Only run queries if visibility is changing
    210     if ( 'publish' != $current_visibility ) {
     210    if ( bbp_get_public_status_id() != $current_visibility ) {
    211211
    212212        // Remove from _bbp_private_forums site option
    213         if ( 'private' == $current_visibility ) {
     213        if ( bbp_get_private_status_id() == $current_visibility ) {
    214214
    215215            // Get private forums
     
    230230
    231231        // Remove from _bbp_hidden_forums site option
    232         if ( 'hidden' == $current_visibility ) {
     232        if ( bbp_get_hidden_status_id() == $current_visibility ) {
    233233
    234234            // Get hidden forums
     
    250250        // Update forum post_status
    251251        global $wpdb;
    252         $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $forum_id ) );
    253         wp_transition_post_status( 'publish', $current_visibility, get_post( $forum_id ) );
     252        $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_public_status_id() ), array( 'ID' => $forum_id ) );
     253        wp_transition_post_status( bbp_get_public_status_id(), $current_visibility, get_post( $forum_id ) );
    254254    }
    255255
     
    275275
    276276    // Only run queries if visibility is changing
    277     if ( 'private' != $current_visibility ) {
     277    if ( bbp_get_private_status_id() != $current_visibility ) {
    278278
    279279        // Remove from _bbp_hidden_forums site option
    280         if ( 'hidden' == $current_visibility ) {
     280        if ( bbp_get_hidden_status_id() == $current_visibility ) {
    281281
    282282            // Get hidden forums
     
    303303        // Update forums visibility setting
    304304        global $wpdb;
    305         $wpdb->update( $wpdb->posts, array( 'post_status' => 'private' ), array( 'ID' => $forum_id ) );
    306         wp_transition_post_status( 'private', $current_visibility, get_post( $forum_id ) );
     305        $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_private_status_id() ), array( 'ID' => $forum_id ) );
     306        wp_transition_post_status( bbp_get_private_status_id(), $current_visibility, get_post( $forum_id ) );
    307307    }
    308308
     
    328328
    329329    // Only run queries if visibility is changing
    330     if ( 'hidden' != $current_visibility ) {
     330    if ( bbp_get_hidden_status_id() != $current_visibility ) {
    331331
    332332        // Remove from _bbp_private_forums site option
    333         if ( 'private' == $current_visibility ) {
     333        if ( bbp_get_private_status_id() == $current_visibility ) {
    334334
    335335            // Get private forums
     
    355355
    356356        // Update forums visibility setting
    357         global $bbp, $wpdb;
    358         $wpdb->update( $wpdb->posts, array( 'post_status' => 'hidden' ), array( 'ID' => $forum_id ) );
    359         wp_transition_post_status( $bbp->hidden_status_id, $current_visibility, get_post( $forum_id ) );
     357        global $wpdb;
     358        $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_hidden_status_id() ), array( 'ID' => $forum_id ) );
     359        wp_transition_post_status( bbp_get_hidden_status_id(), $current_visibility, get_post( $forum_id ) );
    360360    }
    361361
     
    511511 */
    512512function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) {
     513
    513514    $forum_id = bbp_get_forum_id( $forum_id );
    514515
     
    544545
    545546    // Update only if published
    546     if ( 'publish' == get_post_status( $active_id ) )
     547    if ( bbp_get_public_status_id() == get_post_status( $active_id ) )
    547548        update_post_meta( $forum_id, '_bbp_last_active_id', (int) $active_id );
    548549
     
    661662 */
    662663function bbp_update_forum_topic_count_hidden( $forum_id = 0, $topic_count = 0 ) {
    663     global $wpdb, $bbp;
     664    global $wpdb;
    664665
    665666    // If topic_id was passed as $forum_id, then get its forum
     
    678679        // Get topics of forum
    679680        if ( empty( $topic_count ) )
    680             $topic_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( $bbp->trash_status_id, $bbp->spam_status_id ) ) . "') AND post_type = '%s';", $forum_id, bbp_get_topic_post_type() ) );
     681            $topic_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') AND post_type = '%s';", $forum_id, bbp_get_topic_post_type() ) );
    681682
    682683        // Update the count
     
    709710 */
    710711function bbp_update_forum_reply_count( $forum_id = 0 ) {
    711     global $wpdb, $bbp;
     712    global $wpdb;
    712713
    713714    $forum_id = bbp_get_forum_id( $forum_id );
     
    721722    // Don't count replies if the forum is a category
    722723    if ( $topic_ids = bbp_forum_query_topic_ids( $forum_id ) )
    723         $reply_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = 'publish' AND post_type = '%s';", bbp_get_reply_post_type() ) );
     724        $reply_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s';", bbp_get_public_status_id(), bbp_get_reply_post_type() ) );
    724725    else
    725726        $reply_count = 0;
     
    768769        'last_active_id'     => 0,
    769770        'last_active_time'   => 0,
    770         'last_active_status' => 'publish'
     771        'last_active_status' => bbp_get_public_status_id()
    771772    );
    772773
     
    785786        $last_active_time = get_post_field( 'post_date', $last_active_id );
    786787
    787     if ( 'publish' == $last_active_status ) {
     788    if ( bbp_get_public_status_id() == $last_active_status ) {
    788789        bbp_update_forum_last_active_time( $forum_id, $last_active_time );
    789790    }
     
    980981 */
    981982function bbp_forum_query_topic_ids( $forum_id ) {
    982     global $bbp;
    983 
    984983    $topic_ids = bbp_get_public_child_ids( $forum_id, bbp_get_topic_post_type() );
    985984
     
    10011000 */
    10021001function bbp_forum_query_subforum_ids( $forum_id ) {
    1003     global $bbp, $wpdb;
    1004 
    10051002    $subforum_ids = bbp_get_public_child_ids( $forum_id, bbp_get_forum_post_type() );
    10061003
     
    10251022 */
    10261023function bbp_forum_query_last_reply_id( $forum_id, $topic_ids = 0 ) {
    1027     global $bbp, $wpdb;
     1024    global $wpdb;
    10281025
    10291026    $cache_id = 'bbp_get_forum_' . $forum_id . '_reply_id';
     
    10341031            $topic_ids = bbp_forum_query_topic_ids( $forum_id );
    10351032
    1036         if ( !empty( $topic_ids ) && ( $reply_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = 'publish' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", bbp_get_reply_post_type() ) ) ) )
     1033        if ( !empty( $topic_ids ) && ( $reply_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent IN ( " . join( ',', $topic_ids ) . " ) AND post_status = '%s' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", bbp_get_public_status_id(), bbp_get_reply_post_type() ) ) ) )
    10371034            wp_cache_set( $cache_id, $reply_id, 'bbpress' );
    10381035        else
  • branches/plugin/bbp-includes/bbp-forum-template.php

    r3496 r3505  
    6262
    6363    // Setup possible post__not_in array
    64     $post_stati[] = 'publish';
     64    $post_stati[] = bbp_get_public_status_id();
    6565
    6666    // Super admin get whitelisted post statuses
    6767    if ( is_super_admin() ) {
    68         $post_stati = array( 'publish', 'private', 'hidden' );
     68        $post_stati = array( bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id() );
    6969
    7070    // Not a super admin, so check caps
     
    7373        // Check if user can read private forums
    7474        if ( current_user_can( 'read_private_forums' ) )
    75             $post_stati[] = 'private';
     75            $post_stati[] = bbp_get_private_status_id();
    7676
    7777        // Check if user can read hidden forums
    7878        if ( current_user_can( 'read_hidden_forums' ) )
    79             $post_stati[] = 'hidden';
     79            $post_stati[] = bbp_get_hidden_status_id();
    8080    }
    8181
     
    580580
    581581    // Setup possible post__not_in array
    582     $post_stati[] = 'publish';
     582    $post_stati[] = bbp_get_public_status_id();
    583583
    584584    // Super admin get whitelisted post statuses
    585585    if ( is_super_admin() ) {
    586         $post_stati = array( 'publish', 'private', 'hidden' );
     586        $post_stati = array( bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id() );
    587587
    588588    // Not a super admin, so check caps
     
    591591        // Check if user can read private forums
    592592        if ( current_user_can( 'read_private_forums' ) )
    593             $post_stati[] = 'private';
     593            $post_stati[] = bbp_get_private_status_id();
    594594
    595595        // Check if user can read hidden forums
    596596        if ( current_user_can( 'read_hidden_forums' ) )
    597             $post_stati[] = 'hidden';
     597            $post_stati[] = bbp_get_hidden_status_id();
    598598    }
    599599
     
    636636 */
    637637function bbp_list_forums( $args = '' ) {
    638     global $bbp;
    639638
    640639    // Define used variables
     
    10771076     */
    10781077    function bbp_get_forum_topics_link( $forum_id = 0 ) {
    1079         global $bbp;
    10801078
    10811079        $forum    = bbp_get_forum( bbp_get_forum_id( (int) $forum_id ) );
     
    13751373     */
    13761374    function bbp_is_forum_closed( $forum_id = 0, $check_ancestors = true ) {
    1377         global $bbp;
    1378 
    1379         $forum_id = bbp_get_forum_id( $forum_id );
    1380         $retval    = ( $bbp->closed_status_id == bbp_get_forum_status( $forum_id ) );
     1375
     1376        $forum_id = bbp_get_forum_id( $forum_id );
     1377        $retval    = ( bbp_get_closed_status_id() == bbp_get_forum_status( $forum_id ) );
    13811378
    13821379        if ( !empty( $check_ancestors ) ) {
     
    14081405 */
    14091406function bbp_is_forum_public( $forum_id = 0, $check_ancestors = true ) {
    1410     global $bbp;
    14111407
    14121408    $forum_id   = bbp_get_forum_id( $forum_id );
     
    14141410
    14151411    // If post status is public, return true
    1416     $retval = ( 'publish' == $visibility );
     1412    $retval = ( bbp_get_public_status_id() == $visibility );
    14171413
    14181414    // Check ancestors and inherit their privacy setting for display
     
    14451441 */
    14461442function bbp_is_forum_private( $forum_id = 0, $check_ancestors = true ) {
    1447     global $bbp;
    14481443
    14491444    $forum_id   = bbp_get_forum_id( $forum_id );
     
    14511446
    14521447    // If post status is private, return true
    1453     $retval = ( 'private' == $visibility );
     1448    $retval = ( bbp_get_private_status_id() == $visibility );
    14541449
    14551450    // Check ancestors and inherit their privacy setting for display
     
    14821477 */
    14831478function bbp_is_forum_hidden( $forum_id = 0, $check_ancestors = true ) {
    1484     global $bbp;
    14851479
    14861480    $forum_id   = bbp_get_forum_id( $forum_id );
     
    14881482
    14891483    // If post status is private, return true
    1490     $retval = ( 'hidden' == $visibility );
     1484    $retval = ( bbp_get_hidden_status_id() == $visibility );
    14911485
    14921486    // Check ancestors and inherit their privacy setting for display
  • branches/plugin/bbp-includes/bbp-reply-functions.php

    r3501 r3505  
    3232    $default_reply = array(
    3333        'post_parent'   => 0, // topic ID
    34         'post_status'   => 'publish',
     34        'post_status'   => bbp_get_public_status_id(),
    3535        'post_type'     => bbp_get_reply_post_type(),
    3636        'post_author'   => 0,
     
    116116        return;
    117117
    118     global $bbp;
    119 
    120118    // Nonce check
    121119    check_admin_referer( 'bbp-new-reply' );
     
    232230            'post_content' => $reply_content,
    233231            'post_parent'  => $topic_id,
    234             'post_status'  => 'publish',
     232            'post_status'  => bbp_get_public_status_id(),
    235233            'post_type'    => bbp_get_reply_post_type()
    236234        );
     
    264262            // If this reply starts as trash, add it to pre_trashed_replies
    265263            // for the topic, so it is properly restored.
    266             if ( bbp_is_topic_trash( $topic_id ) || ( $reply_data['post_status'] == $bbp->trash_status_id ) ) {
     264            if ( bbp_is_topic_trash( $topic_id ) || ( $reply_data['post_status'] == bbp_get_trash_status_id() ) ) {
    267265
    268266                // Trash the reply
     
    282280
    283281            // If reply or topic are spam, officially spam this reply
    284             if ( bbp_is_topic_spam( $topic_id ) || ( $reply_data['post_status'] == $bbp->spam_status_id ) )
    285                 add_post_meta( $reply_id, '_bbp_spam_meta_status', 'publish' );
     282            if ( bbp_is_topic_spam( $topic_id ) || ( $reply_data['post_status'] == bbp_get_spam_status_id() ) )
     283                add_post_meta( $reply_id, '_bbp_spam_meta_status', bbp_get_public_status_id() );
    286284
    287285            /** Update counts, etc... *****************************************/
     
    10781076 */
    10791077function bbp_spam_reply( $reply_id = 0 ) {
    1080     global $bbp;
    10811078
    10821079    // Get reply
     
    10851082
    10861083    // Bail if already spam
    1087     if ( $reply['post_status'] == $bbp->spam_status_id )
     1084    if ( bbp_get_spam_status_id() == $reply['post_status'] )
    10881085        return false;
    10891086
     
    10951092
    10961093    // Set post status to spam
    1097     $reply['post_status'] = $bbp->spam_status_id;
     1094    $reply['post_status'] = bbp_get_spam_status_id();
    10981095
    10991096    // No revisions
     
    11251122 */
    11261123function bbp_unspam_reply( $reply_id = 0 ) {
    1127     global $bbp;
    11281124
    11291125    // Get reply
     
    11321128
    11331129    // Bail if already not spam
    1134     if ( $reply['post_status'] != $bbp->spam_status_id )
     1130    if ( bbp_get_spam_status_id() != $reply['post_status'] )
    11351131        return false;
    11361132
  • branches/plugin/bbp-includes/bbp-reply-template.php

    r3501 r3505  
    7070
    7171    // Default status
    72     $default_status = join( ',', array( 'publish', $bbp->closed_status_id ) );
     72    $default_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) );
    7373
    7474    // Skip topic_id if in the replies widget query
     
    8484        // What are the default allowed statuses (based on user caps)
    8585        if ( bbp_get_view_all( 'edit_others_replies' ) ) {
    86             $default_status = join( ',', array( 'publish', $bbp->closed_status_id, $bbp->spam_status_id, 'trash' ) );
     86            $default_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), 'trash' ) );
    8787        }
    8888    }
     
    369369     */
    370370    function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) {
    371         global $bbp, $wp_rewrite;
     371        global $wp_rewrite;
    372372
    373373        // Set needed variables
     
    692692    function bbp_get_reply_status( $reply_id = 0 ) {
    693693        $reply_id = bbp_get_reply_id( $reply_id );
    694 
    695694        return apply_filters( 'bbp_get_reply_status', get_post_status( $reply_id ), $reply_id );
    696695    }
     
    707706 */
    708707function bbp_is_reply_published( $reply_id = 0 ) {
    709     global $bbp;
    710 
    711708    $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) );
    712     return apply_filters( 'bbp_is_reply_published', 'publish' == $reply_status, $reply_id );
     709    return apply_filters( 'bbp_is_reply_published', bbp_get_public_status_id() == $reply_status, $reply_id );
    713710}
    714711
     
    724721 */
    725722function bbp_is_reply_spam( $reply_id = 0 ) {
    726     global $bbp;
    727 
    728723    $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) );
    729 
    730     return apply_filters( 'bbp_is_reply_spam', $bbp->spam_status_id == $reply_status, $reply_id );
     724    return apply_filters( 'bbp_is_reply_spam', bbp_get_spam_status_id() == $reply_status, $reply_id );
    731725}
    732726
     
    742736 */
    743737function bbp_is_reply_trash( $reply_id = 0 ) {
    744     global $bbp;
    745 
    746738    $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) );
    747 
    748     return apply_filters( 'bbp_is_reply_trash', $bbp->trash_status_id == $reply_status, $reply_id );
     739    return apply_filters( 'bbp_is_reply_trash', bbp_get_trash_status_id() == $reply_status, $reply_id );
    749740}
    750741
     
    13371328     */
    13381329    function bbp_get_reply_admin_links( $args = '' ) {
    1339         global $bbp;
    13401330
    13411331        $defaults = array (
     
    13831373        // See if links need to be unset
    13841374        $reply_status = bbp_get_reply_status( $r['id'] );
    1385         if ( in_array( $reply_status, array( $bbp->spam_status_id, $bbp->trash_status_id ) ) ) {
     1375        if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) {
    13861376
    13871377            // Spam link shouldn't be visible on trashed topics
    1388             if ( $reply_status == $bbp->trash_status_id )
     1378            if ( $reply_status == bbp_get_trash_status_id() )
    13891379                unset( $r['links']['spam'] );
    13901380
    13911381            // Trash link shouldn't be visible on spam topics
    1392             elseif ( isset( $r['links']['trash'] ) && $reply_status == $bbp->spam_status_id )
     1382            elseif ( isset( $r['links']['trash'] ) && $reply_status == bbp_get_spam_status_id() )
    13931383                unset( $r['links']['trash'] );
    13941384        }
  • branches/plugin/bbp-includes/bbp-topic-functions.php

    r3501 r3505  
    3232    $default_topic = array(
    3333        'post_parent'   => 0, // forum ID
    34         'post_status'   => 'publish',
     34        'post_status'   => bbp_get_public_status_id(),
    3535        'post_type'     => bbp_get_topic_post_type(),
    3636        'post_author'   => 0,
     
    124124        return;
    125125
    126     global $bbp;
    127 
    128126    // Nonce check
    129127    check_admin_referer( 'bbp-new-topic' );
     
    268266            'post_parent'  => $forum_id,
    269267            'tax_input'    => $terms,
    270             'post_status'  => 'publish',
     268            'post_status'  => bbp_get_public_status_id(),
    271269            'post_type'    => bbp_get_topic_post_type()
    272270        );
     
    310308            // If the forum is trash, or the topic_status is switched to
    311309            // trash, trash it properly
    312             if ( ( get_post_field( 'post_status', $forum_id ) == $bbp->trash_status_id ) || ( $topic_data['post_status'] == $bbp->trash_status_id ) ) {
     310            if ( ( get_post_field( 'post_status', $forum_id ) == bbp_get_trash_status_id() ) || ( $topic_data['post_status'] == bbp_get_trash_status_id() ) ) {
    313311
    314312                // Trash the reply
     
    322320
    323321            // If reply or topic are spam, officially spam this reply
    324             if ( $topic_data['post_status'] == $bbp->spam_status_id ) {
    325                 add_post_meta( $topic_id, '_bbp_spam_meta_status', 'publish' );
     322            if ( $topic_data['post_status'] == bbp_get_spam_status_id() ) {
     323                add_post_meta( $topic_id, '_bbp_spam_meta_status', bbp_get_public_status_id() );
    326324
    327325                // Force view=all
     
    817815    if ( true == $refresh ) {
    818816        $forum_id = $topic_id = $reply_id = $active_id = $last_active_time = 0;
    819         $topic_status = 'publish';
     817        $topic_status = bbp_get_public_status_id();
    820818    }
    821819
     
    12791277        return;
    12801278
    1281     global $wpdb, $bbp;
     1279    global $wpdb;
    12821280
    12831281    // Prevent debug notices
     
    21222120 */
    21232121function bbp_update_topic_reply_count_hidden( $topic_id = 0, $reply_count = 0 ) {
    2124     global $wpdb, $bbp;
     2122    global $wpdb;
    21252123
    21262124    // If it's a reply, then get the parent (topic id)
     
    21322130    // Get replies of topic
    21332131    if ( empty( $reply_count ) )
    2134         $reply_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( $bbp->trash_status_id, $bbp->spam_status_id ) ) . "') AND post_type = '%s';", $topic_id, bbp_get_reply_post_type() ) );
     2132        $reply_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( '\',\'', array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') AND post_type = '%s';", $topic_id, bbp_get_reply_post_type() ) );
    21352133
    21362134    update_post_meta( $topic_id, '_bbp_reply_count_hidden', (int) $reply_count );
     
    21732171
    21742172    // Update only if published
    2175     if ( 'publish' == get_post_status( $active_id ) )
     2173    if ( bbp_get_public_status_id() == get_post_status( $active_id ) )
    21762174        update_post_meta( $topic_id, '_bbp_last_active_id', (int) $active_id );
    21772175
     
    22852283
    22862284    // Query the DB to get voices in this topic
    2287     $voices = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT( DISTINCT post_author ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = 'publish' AND post_type = '%s' ) OR ( ID = %d AND post_type = '%s' );", $topic_id, bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );
     2285    $voices = $wpdb->get_col( $wpdb->prepare( "SELECT COUNT( DISTINCT post_author ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' ) OR ( ID = %d AND post_type = '%s' );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );
    22882286
    22892287    // If there's an error, make sure we at least have 1 voice
     
    23262324        return;
    23272325
    2328     $anonymous_replies = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( ID ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = 'publish' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );
     2326    $anonymous_replies = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( ID ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type() ) );
    23292327
    23302328    update_post_meta( $topic_id, '_bbp_anonymous_reply_count', (int) $anonymous_replies );
     
    23912389 */
    23922390function bbp_close_topic( $topic_id = 0 ) {
    2393     global $bbp;
    23942391
    23952392    // Get topic
     
    23982395
    23992396    // Bail if already closed
    2400     if ( $topic['post_status'] == $bbp->closed_status_id )
     2397    if ( bbp_get_closed_status_id == $topic['post_status'] )
    24012398        return false;
    24022399
     
    24082405
    24092406    // Set closed status
    2410     $topic['post_status'] = $bbp->closed_status_id;
     2407    $topic['post_status'] = bbp_get_closed_status_id();
    24112408
    24122409    // No revisions
     
    24382435 */
    24392436function bbp_open_topic( $topic_id = 0 ) {
    2440     global $bbp;
    24412437
    24422438    // Get topic
     
    24452441
    24462442    // Bail if already open
    2447     if ( $topic['post_status'] != $bbp->closed_status_id )
     2443    if ( bbp_get_closed_status_id() != $topic['post_status'])
    24482444        return false;
    24492445
     
    24872483 */
    24882484function bbp_spam_topic( $topic_id = 0 ) {
    2489     global $bbp;
    24902485
    24912486    // Get the topic
     
    24942489
    24952490    // Bail if topic is spam
    2496     if ( $topic['post_status'] == $bbp->spam_status_id )
     2491    if ( bbp_get_spam_status_id() == $topic['post_status'] )
    24972492        return false;
    24982493
     
    25262521   
    25272522    // Set post status to spam
    2528     $topic['post_status'] = $bbp->spam_status_id;
     2523    $topic['post_status'] = bbp_get_spam_status_id();
    25292524
    25302525    // No revisions
     
    25562551 */
    25572552function bbp_unspam_topic( $topic_id = 0 ) {
    2558     global $bbp;
    25592553
    25602554    // Get the topic
     
    25632557
    25642558    // Bail if already not spam
    2565     if ( $topic['post_status'] != $bbp->spam_status_id )
     2559    if ( bbp_get_spam_status_id() != $topic['post_status'] )
    25662560        return false;
    25672561
     
    27132707 */
    27142708function bbp_delete_topic( $topic_id = 0 ) {
    2715     global $bbp;
    27162709
    27172710    // Validate topic ID
     
    27242717
    27252718    // Valid topic/reply statuses
    2726     $post_stati = join( ',', array( 'publish', $bbp->spam_status_id, 'trash' ) );
     2719    $post_stati = join( ',', array( bbp_get_public_status_id(), bbp_get_spam_status_id(), 'trash' ) );
    27272720
    27282721    // Topic is being permanently deleted, so its replies gotta go too
     
    27742767    if ( bbp_has_replies( array(
    27752768        'post_type'      => bbp_get_reply_post_type(),
    2776         'post_status'    => 'publish',
     2769        'post_status'    => bbp_get_public_status_id(),
    27772770        'posts_per_page' => -1,
    27782771        'meta_query'     => array( array(
  • branches/plugin/bbp-includes/bbp-topic-template.php

    r3501 r3505  
    7171    // What are the default allowed statuses (based on user caps)
    7272    if ( !bbp_is_query_name( 'bbp_widget' ) && bbp_get_view_all() )
    73         $default_status = join( ',', array( 'publish', $bbp->closed_status_id, $bbp->spam_status_id, 'trash' ) );
     73        $default_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id() ) );
    7474    else
    75         $default_status = join( ',', array( 'publish', $bbp->closed_status_id ) );
     75        $default_status = join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) );
    7676
    7777    // Default arguments
     
    121121    extract( $bbp_t );
    122122
    123     // If we're viewing a tax/term, use the existing query; if not, run our own
    124     if ( bbp_is_topic_tag() && !bbp_is_query_name( 'bbp_widget' ) )
    125         $bbp->topic_query = $wp_query;
    126     else
    127         $bbp->topic_query = new WP_Query( $bbp_t );
     123    // Call the query
     124    $bbp->topic_query = new WP_Query( $bbp_t );
    128125
    129126    // Set post_parent back to 0 if originally set to 'any'
     
    904901     */
    905902    function bbp_is_topic_closed( $topic_id = 0 ) {
    906         global $bbp;
    907 
    908         if ( $bbp->closed_status_id == bbp_get_topic_status( $topic_id ) )
     903        if ( bbp_get_closed_status_id() == bbp_get_topic_status( $topic_id ) )
    909904            return true;
    910905
     
    966961 */
    967962function bbp_is_topic_published( $topic_id = 0 ) {
    968     global $bbp;
    969 
    970963    $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) );
    971     return 'publish' == $topic_status;
     964    return bbp_get_public_status_id() == $topic_status;
    972965}
    973966
     
    983976 */
    984977function bbp_is_topic_spam( $topic_id = 0 ) {
    985     global $bbp;
    986 
    987978    $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) );
    988     return $bbp->spam_status_id == $topic_status;
     979    return bbp_get_spam_status_id() == $topic_status;
    989980}
    990981
     
    1000991 */
    1001992function bbp_is_topic_trash( $topic_id = 0 ) {
    1002     global $bbp;
    1003 
    1004993    $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) );
    1005     return $bbp->trash_status_id == $topic_status;
     994    return bbp_get_trash_status_id() == $topic_status;
    1006995}
    1007996
     
    17031692     */
    17041693    function bbp_get_topic_replies_link( $topic_id = 0 ) {
    1705         global $bbp;
    17061694
    17071695        $topic    = bbp_get_topic( bbp_get_topic_id( (int) $topic_id ) );
     
    19901978     */
    19911979    function bbp_get_topic_admin_links( $args = '' ) {
    1992         global $bbp;
    19931980
    19941981        if ( !bbp_is_single_topic() )
     
    20252012        // See if links need to be unset
    20262013        $topic_status = bbp_get_topic_status( $r['id'] );
    2027         if ( in_array( $topic_status, array( $bbp->spam_status_id, $bbp->trash_status_id ) ) ) {
     2014        if ( in_array( $topic_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) {
    20282015
    20292016            // Close link shouldn't be visible on trashed/spammed topics
     
    20312018
    20322019            // Spam link shouldn't be visible on trashed topics
    2033             if ( $topic_status == $bbp->trash_status_id )
     2020            if ( $topic_status == bbp_get_trash_status_id() )
    20342021                unset( $r['links']['spam'] );
    20352022
    20362023            // Trash link shouldn't be visible on spam topics
    2037             elseif ( $topic_status == $bbp->spam_status_id )
     2024            elseif ( $topic_status == bbp_get_spam_status_id() )
    20382025                unset( $r['links']['trash'] );
    20392026        }
     
    21872174     */
    21882175    function bbp_get_topic_trash_link( $args = '' ) {
    2189         global $bbp;
    21902176
    21912177        $defaults = array (
     
    25762562 */
    25772563function bbp_topic_notices() {
    2578     global $bbp;
    25792564
    25802565    // Bail if not viewing a topic
     
    25892574
    25902575        // Spam notice
    2591         case $bbp->spam_status_id :
     2576        case bbp_get_spam_status_id() :
    25922577            $notice_text = __( 'This topic is marked as spam.', 'bbpress' );
    25932578            break;
    25942579
    25952580        // Trashed notice
    2596         case $bbp->trash_status_id :
     2581        case bbp_get_trash_status_id() :
    25972582            $notice_text = __( 'This topic is in the trash.',   'bbpress' );
    25982583            break;
     
    30253010     */
    30263011    function bbp_get_topic_tag_description( $args = array() ) {
    3027         global $bbp;
    30283012
    30293013        $defaults = array(
     
    31453129     */
    31463130    function bbp_get_form_topic_tags() {
    3147         global $post, $bbp;
     3131        global $post;
    31483132
    31493133        // Get _POST data
  • branches/plugin/bbp-includes/bbp-user-functions.php

    r3504 r3505  
    10231023
    10241024    // Make array of post types to mark as spam
    1025     $post_types = array( bbp_get_topic_post_type(), bbp_get_reply_post_type() );
    1026     $post_types = "'" . implode( "', '", $post_types ) . "'";
     1025    $post_types  = array( bbp_get_topic_post_type(), bbp_get_reply_post_type() );
     1026    $post_types  = "'" . implode( "', '", $post_types ) . "'";
     1027    $status      = bbp_get_public_status_id();
    10271028
    10281029    // Loop through blogs and remove their posts
     
    10331034
    10341035        // Get topics and replies
    1035         $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_author = {$user_id} AND post_status = 'publish' AND post_type IN ({$post_types})" );
     1036        $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_author = {$user_id} AND post_status = '{$status}' AND post_type IN ({$post_types})" );
    10361037
    10371038        // Loop through posts and spam them
     
    10971098
    10981099    // Arm the torpedos
    1099     global $wpdb, $bbp;
     1100    global $wpdb;
    11001101
    11011102    // Get the blog IDs of the user to mark as spam
     
    11091110    $post_types = array( bbp_get_topic_post_type(), bbp_get_reply_post_type() );
    11101111    $post_types = "'" . implode( "', '", $post_types ) . "'";
     1112    $status     = bbp_get_spam_status_id();
    11111113
    11121114    // Loop through blogs and remove their posts
     
    11171119
    11181120        // Get topics and replies
    1119         $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_author = {$user_id} AND post_status = '{$bbp->spam_status_id}' AND post_type IN ({$post_types})" );
     1121        $posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_author = {$user_id} AND post_status = '{$status}' AND post_type IN ({$post_types})" );
    11201122
    11211123        // Loop through posts and spam them
  • branches/plugin/bbp-includes/bbp-user-template.php

    r3504 r3505  
    859859 */
    860860function bbp_login_notices() {
    861     global $bbp;
    862861
    863862    // loggedout was passed
     
    12511250    $defaults = array(
    12521251        'post_type'   => bbp_get_forum_post_type(),
    1253         'post_status' => 'publish',
     1252        'post_status' => bbp_get_public_status_id(),
    12541253        'numberposts' => -1,
    12551254        'exclude'     => $post__not_in
  • branches/plugin/bbpress.php

    r3496 r3505  
    3232class bbPress {
    3333
     34    /**
     35     * Note to Plugin and Theme authors:
     36     *
     37     * Do not directly reference the variables below in your code. Their names
     38     * and locations in the bbPress class are subject to change at any time.
     39     *
     40     * Most of them have reference functions located in bbp-includes. The ones
     41     * that don't can be accessed via their respective WordPress API's.
     42     */
     43
    3444    /** Version ***************************************************************/
    3545
     
    4252     * @public string bbPress DB version
    4353     */
    44     public $db_version = '165';
     54    public $db_version = '175';
    4555
    4656    /** Post types ************************************************************/
     
    347357
    348358        // Status identifiers
    349         $this->spam_status_id     = apply_filters( 'bbp_spam_post_status',   'spam'   );
    350         $this->closed_status_id   = apply_filters( 'bbp_closed_post_status', 'closed' );
    351         $this->orphan_status_id   = apply_filters( 'bbp_orphan_post_status', 'orphan' );
    352         $this->hidden_status_id   = apply_filters( 'bbp_hidden_post_status', 'hidden' );
    353         $this->trash_status_id    = 'trash';
     359        $this->spam_status_id     = apply_filters( 'bbp_spam_post_status',    'spam'    );
     360        $this->closed_status_id   = apply_filters( 'bbp_closed_post_status',  'closed'  );
     361        $this->orphan_status_id   = apply_filters( 'bbp_orphan_post_status',  'orphan'  );
     362        $this->public_status_id   = apply_filters( 'bbp_public_post_status',  'publish' );
     363        $this->private_status_id  = apply_filters( 'bbp_private_post_status', 'private' );
     364        $this->hidden_status_id   = apply_filters( 'bbp_hidden_post_status',  'hidden'  );
     365        $this->trash_status_id    = apply_filters( 'bbp_trash_post_status',   'trash'   );
    354366
    355367        // Other identifiers
Note: See TracChangeset for help on using the changeset viewer.