Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/01/2011 02:01:58 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Don't create post revisions when changing a topic/reply status (open/close/spam/unspam).

Update phpdoc in forum open/close.

File:
1 edited

Legend:

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

    r3275 r3287  
    21902190    global $bbp;
    21912191
     2192    // Get topic
    21922193    if ( !$topic = wp_get_single_post( $topic_id, ARRAY_A ) )
    21932194        return $topic;
    21942195
     2196    // Bail if already closed
    21952197    if ( $topic['post_status'] == $bbp->closed_status_id )
    21962198        return false;
    21972199
     2200    // Execute pre close code
    21982201    do_action( 'bbp_close_topic', $topic_id );
    21992202
     2203    // Add pre close status
    22002204    add_post_meta( $topic_id, '_bbp_status', $topic['post_status'] );
    22012205
     2206    // Set closed status
    22022207    $topic['post_status'] = $bbp->closed_status_id;
    22032208
     2209    // No revisions
     2210    remove_action( 'pre_post_update', 'wp_save_post_revision' );
     2211
     2212    // Update topic
    22042213    $topic_id = wp_insert_post( $topic );
    22052214
     2215    // Execute post close code
    22062216    do_action( 'bbp_closed_topic', $topic_id );
    22072217
     2218    // Return topic_id
    22082219    return $topic_id;
    22092220}
     
    22262237    global $bbp;
    22272238
     2239    // Get topic
    22282240    if ( !$topic = wp_get_single_post( $topic_id, ARRAY_A ) )
    22292241        return $topic;
    22302242
     2243    // Bail if already open
    22312244    if ( $topic['post_status'] != $bbp->closed_status_id )
    22322245        return false;
    22332246
     2247    // Execute pre open code
    22342248    do_action( 'bbp_open_topic', $topic_id );
    22352249
     2250    // Get previous status
    22362251    $topic_status         = get_post_meta( $topic_id, '_bbp_status', true );
     2252   
     2253    // Set previous status
    22372254    $topic['post_status'] = $topic_status;
    22382255
     2256    // Remove old status meta
    22392257    delete_post_meta( $topic_id, '_bbp_status' );
    22402258
     2259    // No revisions
     2260    remove_action( 'pre_post_update', 'wp_save_post_revision' );
     2261
     2262    // Update topic
    22412263    $topic_id = wp_insert_post( $topic );
    22422264
     2265    // Execute post open code
    22432266    do_action( 'bbp_opened_topic', $topic_id );
    22442267
     2268    // Return topic_id
    22452269    return $topic_id;
    22462270}
     
    22622286    global $bbp;
    22632287
     2288    // Get the topic
    22642289    if ( !$topic = wp_get_single_post( $topic_id, ARRAY_A ) )
    22652290        return $topic;
    22662291
     2292    // Bail if topic is spam
    22672293    if ( $topic['post_status'] == $bbp->spam_status_id )
    22682294        return false;
    22692295
     2296    // Execute pre spam code
    22702297    do_action( 'bbp_spam_topic', $topic_id );
    22712298
     2299    // Add the original post status as post meta for future restoration
    22722300    add_post_meta( $topic_id, '_bbp_spam_meta_status', $topic['post_status'] );
    22732301
     2302    // Set post status to spam
    22742303    $topic['post_status'] = $bbp->spam_status_id;
    22752304
     2305    // No revisions
     2306    remove_action( 'pre_post_update', 'wp_save_post_revision' );
     2307   
     2308    // Update the topic
    22762309    $topic_id = wp_insert_post( $topic );
    22772310
     2311    // Execute post spam code
    22782312    do_action( 'bbp_spammed_topic', $topic_id );
    22792313
     2314    // Return topic_id
    22802315    return $topic_id;
    22812316}
     
    22982333    global $bbp;
    22992334
     2335    // Get the topic
    23002336    if ( !$topic = wp_get_single_post( $topic_id, ARRAY_A ) )
    23012337        return $topic;
    23022338
     2339    // Bail if already not spam
    23032340    if ( $topic['post_status'] != $bbp->spam_status_id )
    23042341        return false;
    23052342
     2343    // Execute pre unspam code
    23062344    do_action( 'bbp_unspam_topic', $topic_id );
    23072345
     2346    // Get pre spam status
    23082347    $topic_status         = get_post_meta( $topic_id, '_bbp_spam_meta_status', true );
     2348   
     2349    // Set post status to pre spam
    23092350    $topic['post_status'] = $topic_status;
    23102351
     2352    // Delete pre spam meta
    23112353    delete_post_meta( $topic_id, '_bbp_spam_meta_status' );
    23122354
     2355    // No revisions
     2356    remove_action( 'pre_post_update', 'wp_save_post_revision' );
     2357
     2358    // Update the topic
    23132359    $topic_id = wp_insert_post( $topic );
    23142360
     2361    // Execute post unspam code
    23152362    do_action( 'bbp_unspammed_topic', $topic_id );
    23162363
     2364    // Return topic_id
    23172365    return $topic_id;
    23182366}
Note: See TracChangeset for help on using the changeset viewer.