Skip to:
Content

bbPress.org


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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.