Skip to:
Content

BuddyPress.org

Changeset 6779


Ignore:
Timestamp:
02/08/2013 06:36:14 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Variable cleanup to bp-forums-functions.php.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-functions.php

    r6778 r6779  
    3535 */
    3636function bp_forums_is_installed_correctly() {
    37     global $bp;
     37    $bp = buddypress();
    3838
    3939    if ( isset( $bp->forums->bbconfig ) && is_file( $bp->forums->bbconfig ) )
     
    5252 */
    5353function bp_forums_has_directory() {
    54     global $bp;
    55 
    56     return (bool) !empty( $bp->pages->forums->id );
     54    return (bool) !empty( buddypress()->pages->forums->id );
    5755}
    5856
     
    6765    do_action( 'bbpress_init' );
    6866
    69     $defaults = array(
     67    $r = wp_parse_args( $args, array(
    7068        'forum_name'        => '',
    7169        'forum_desc'        => '',
     
    7371        'forum_order'       => false,
    7472        'forum_is_category' => 0
    75     );
    76 
    77     $r = wp_parse_args( $args, $defaults );
     73    ) );
    7874    extract( $r, EXTR_SKIP );
    7975
     
    8480    do_action( 'bbpress_init' );
    8581
    86     $defaults = array(
     82    $r = wp_parse_args( $args, array(
    8783        'forum_id'          => '',
    8884        'forum_name'        => '',
     
    9288        'forum_order'       => false,
    9389        'forum_is_category' => 0
    94     );
    95 
    96     $r = wp_parse_args( $args, $defaults );
     90    ) );
    9791    extract( $r, EXTR_SKIP );
    9892
     
    113107
    114108function bp_forums_get_forum_topics( $args = '' ) {
    115     global $bp;
    116 
    117     do_action( 'bbpress_init' );
    118 
    119     $defaults = array(
     109    do_action( 'bbpress_init' );
     110
     111    $r = wp_parse_args( $args, array(
    120112        'type'          => 'newest',
    121113        'forum_id'      => false,
     
    128120        'show_stickies' => 'all',
    129121        'filter'        => false // if $type = tag then filter is the tag name, otherwise it's terms to search on.
    130     );
    131 
    132     $r = wp_parse_args( $args, $defaults );
     122    ) );
    133123    extract( $r, EXTR_SKIP );
    134124
     
    184174    do_action( 'bbpress_init' );
    185175
    186     $defaults = array(
     176    $r = wp_parse_args( $args, array(
    187177        'topic_title'            => '',
    188178        'topic_slug'             => '',
     
    197187        'topic_tags'             => false, // accepts array or comma delim
    198188        'forum_id'               => 0      // accepts ids or slugs
    199     );
    200 
    201     $r = wp_parse_args( $args, $defaults );
     189    ) );
    202190    extract( $r, EXTR_SKIP );
    203191
     
    229217
    230218function bp_forums_update_topic( $args = '' ) {
    231     global $bp;
    232 
    233     do_action( 'bbpress_init' );
    234 
    235     $defaults = array(
     219    do_action( 'bbpress_init' );
     220
     221    $r = wp_parse_args( $args, array(
    236222        'topic_id'    => false,
    237223        'topic_title' => '',
    238224        'topic_text'  => '',
    239225        'topic_tags'  => false
    240     );
    241 
    242     $r = wp_parse_args( $args, $defaults );
     226    ) );
    243227    extract( $r, EXTR_SKIP );
    244228
     
    264248
    265249function bp_forums_sticky_topic( $args = '' ) {
    266     global $bp;
    267 
    268     do_action( 'bbpress_init' );
    269 
    270     $defaults = array(
     250    do_action( 'bbpress_init' );
     251
     252    $r = wp_parse_args( $args, array(
    271253        'topic_id' => false,
    272254        'mode'     => 'stick' // stick/unstick
    273     );
    274 
    275     $r = wp_parse_args( $args, $defaults );
     255    ) );
    276256    extract( $r, EXTR_SKIP );
    277257
     
    285265
    286266function bp_forums_openclose_topic( $args = '' ) {
    287     global $bp;
    288 
    289     do_action( 'bbpress_init' );
    290 
    291     $defaults = array(
     267    do_action( 'bbpress_init' );
     268
     269    $r = wp_parse_args( $args, array(
    292270        'topic_id' => false,
    293271        'mode'     => 'close' // stick/unstick
    294     );
    295 
    296     $r = wp_parse_args( $args, $defaults );
     272    ) );
    297273    extract( $r, EXTR_SKIP );
    298274
     
    306282
    307283function bp_forums_delete_topic( $args = '' ) {
    308     global $bp;
    309 
    310     do_action( 'bbpress_init' );
    311 
    312     $defaults = array(
     284    do_action( 'bbpress_init' );
     285
     286    $r = wp_parse_args( $args, array(
    313287        'topic_id' => false
    314     );
    315 
    316     $r = wp_parse_args( $args, $defaults );
     288    ) );
    317289    extract( $r, EXTR_SKIP );
    318290
     
    403375 */
    404376function bp_forums_total_topic_count_for_user( $user_id = 0, $type = 'active' ) {
    405     global $bp;
    406 
    407377    do_action( 'bbpress_init' );
    408378
     
    443413 */
    444414function bp_forums_total_replied_count_for_user( $user_id = 0, $type = 'active' ) {
    445     global $bp;
    446 
    447415    do_action( 'bbpress_init' );
    448416
     
    480448
    481449function bp_forums_get_topic_extras( $topics ) {
    482     global $bp, $wpdb, $bbdb;
     450    global $wpdb, $bbdb;
    483451
    484452    if ( empty( $topics ) )
    485453        return $topics;
     454
     455    $bp = buddypress();
    486456
    487457    // Get the topic ids
     
    556526
    557527function bp_forums_delete_post( $args = '' ) {
    558     global $bp;
    559 
    560     do_action( 'bbpress_init' );
    561 
    562     $defaults = array(
     528    do_action( 'bbpress_init' );
     529
     530    $r = wp_parse_args( $args, array(
    563531        'post_id' => false
    564     );
    565 
    566     $r = wp_parse_args( $args, $defaults );
     532    ) );
     533
    567534    extract( $r, EXTR_SKIP );
    568535
     
    571538
    572539function bp_forums_insert_post( $args = '' ) {
    573     global $bp;
    574 
    575540    do_action( 'bbpress_init' );
    576541
     
    666631
    667632function bp_forums_filter_caps( $allcaps ) {
    668     global $bp, $wp_roles, $bb_table_prefix;
     633    global $wp_roles, $bb_table_prefix;
    669634
    670635    if ( !bp_loggedin_user_id() )
Note: See TracChangeset for help on using the changeset viewer.