Skip to:
Content

bbPress.org

Changeset 4782


Ignore:
Timestamp:
02/28/2013 02:59:33 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Move new topic sticky-check after 'bbp_new_topic' action, to ensure forum ID meta is saved via bbp_update_topic(). Also move sticky-check in edit-topic handler, so correct forum ID is used when moving a sticky topic. Props imath. Fixes #2230.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/topics/functions.php

    r4778 r4782  
    297297    if ( !empty( $topic_id ) && !is_wp_error( $topic_id ) ) {
    298298
     299        /** Trash Check *******************************************************/
     300
     301        // If the forum is trash, or the topic_status is switched to
     302        // trash, trash it properly
     303        if ( ( get_post_field( 'post_status', $forum_id ) == bbp_get_trash_status_id() ) || ( $topic_data['post_status'] == bbp_get_trash_status_id() ) ) {
     304
     305            // Trash the reply
     306            wp_trash_post( $topic_id );
     307
     308            // Force view=all
     309            $view_all = true;
     310        }
     311
     312        /** Spam Check ********************************************************/
     313
     314        // If reply or topic are spam, officially spam this reply
     315        if ( $topic_data['post_status'] == bbp_get_spam_status_id() ) {
     316            add_post_meta( $topic_id, '_bbp_spam_meta_status', bbp_get_public_status_id() );
     317
     318            // Force view=all
     319            $view_all = true;
     320        }
     321
     322        /** Update counts, etc... *********************************************/
     323
     324        do_action( 'bbp_new_topic', $topic_id, $forum_id, $anonymous_data, $topic_author );
     325
    299326        /** Stickies **********************************************************/
    300327
     328        // Sticky check after 'bbp_new_topic' action so forum ID meta is set
    301329        if ( !empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array( 'stick', 'super', 'unstick' ) ) ) {
    302330
     
    320348            }
    321349        }
    322 
    323         /** Trash Check *******************************************************/
    324 
    325         // If the forum is trash, or the topic_status is switched to
    326         // trash, trash it properly
    327         if ( ( get_post_field( 'post_status', $forum_id ) == bbp_get_trash_status_id() ) || ( $topic_data['post_status'] == bbp_get_trash_status_id() ) ) {
    328 
    329             // Trash the reply
    330             wp_trash_post( $topic_id );
    331 
    332             // Force view=all
    333             $view_all = true;
    334         }
    335 
    336         /** Spam Check ********************************************************/
    337 
    338         // If reply or topic are spam, officially spam this reply
    339         if ( $topic_data['post_status'] == bbp_get_spam_status_id() ) {
    340             add_post_meta( $topic_id, '_bbp_spam_meta_status', bbp_get_public_status_id() );
    341 
    342             // Force view=all
    343             $view_all = true;
    344         }
    345 
    346         /** Update counts, etc... *********************************************/
    347 
    348         do_action( 'bbp_new_topic', $topic_id, $forum_id, $anonymous_data, $topic_author );
    349350
    350351        /** Additional Actions (After Save) ***********************************/
     
    639640    }
    640641
    641     /** Stickies **************************************************************/
    642 
    643     if ( !empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array( 'stick', 'super', 'unstick' ) ) ) {
    644 
    645         // What's the dilly?
    646         switch ( $_POST['bbp_stick_topic'] ) {
    647 
    648             // Sticky in forum
    649             case 'stick'   :
    650                 bbp_stick_topic( $topic_id );
    651                 break;
    652 
    653             // Sticky in all forums
    654             case 'super'   :
    655                 bbp_stick_topic( $topic_id, true );
    656                 break;
    657 
    658             // Normal
    659             case 'unstick' :
    660             default        :
    661                 bbp_unstick_topic( $topic_id );
    662                 break;
    663         }
    664     }
    665 
    666     /** Revisions *************************************************************/
    667 
    668     // Revision Reason
    669     if ( !empty( $_POST['bbp_topic_edit_reason'] ) )
    670         $topic_edit_reason = esc_attr( strip_tags( $_POST['bbp_topic_edit_reason'] ) );
    671 
    672     // Update revision log
    673     if ( !empty( $_POST['bbp_log_topic_edit'] ) && ( 1 == $_POST['bbp_log_topic_edit'] ) )  {
    674         $revision_id = wp_save_post_revision( $topic_id );
    675         if ( ! empty( $revision_id ) ) {
    676             bbp_update_topic_revision_log( array(
    677                 'topic_id'    => $topic_id,
    678                 'revision_id' => $revision_id,
    679                 'author_id'   => bbp_get_current_user_id(),
    680                 'reason'      => $topic_edit_reason
    681             ) );
    682         }
    683     }
    684 
    685642    /** No Errors *************************************************************/
    686643
     
    689646        // Update counts, etc...
    690647        do_action( 'bbp_edit_topic', $topic_id, $forum_id, $anonymous_data, $topic_author , true /* Is edit */ );
     648
     649        /** Revisions *********************************************************/
     650
     651        // Revision Reason
     652        if ( !empty( $_POST['bbp_topic_edit_reason'] ) ) {
     653            $topic_edit_reason = esc_attr( strip_tags( $_POST['bbp_topic_edit_reason'] ) );
     654        }
     655
     656        // Update revision log
     657        if ( !empty( $_POST['bbp_log_topic_edit'] ) && ( 1 == $_POST['bbp_log_topic_edit'] ) )  {
     658            $revision_id = wp_save_post_revision( $topic_id );
     659            if ( ! empty( $revision_id ) ) {
     660                bbp_update_topic_revision_log( array(
     661                    'topic_id'    => $topic_id,
     662                    'revision_id' => $revision_id,
     663                    'author_id'   => bbp_get_current_user_id(),
     664                    'reason'      => $topic_edit_reason
     665                ) );
     666            }
     667        }
     668
     669        /** Move Topic ********************************************************/
    691670
    692671        // If the new forum id is not equal to the old forum id, run the
    693672        // bbp_move_topic action and pass the topic's forum id as the
    694673        // first arg and topic id as the second to update counts.
    695         if ( $forum_id != $topic->post_parent )
     674        if ( $forum_id != $topic->post_parent ) {
    696675            bbp_move_topic_handler( $topic_id, $topic->post_parent, $forum_id );
     676        }
     677
     678        /** Stickies **********************************************************/
     679
     680        if ( !empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array( 'stick', 'super', 'unstick' ) ) ) {
     681
     682            // What's the dilly?
     683            switch ( $_POST['bbp_stick_topic'] ) {
     684
     685                // Sticky in forum
     686                case 'stick'   :
     687                    bbp_stick_topic( $topic_id );
     688                    break;
     689
     690                // Sticky in all forums
     691                case 'super'   :
     692                    bbp_stick_topic( $topic_id, true );
     693                    break;
     694
     695                // Normal
     696                case 'unstick' :
     697                default        :
     698                    bbp_unstick_topic( $topic_id );
     699                    break;
     700            }
     701        }
    697702
    698703        /** Additional Actions (After Save) ***********************************/
Note: See TracChangeset for help on using the changeset viewer.