Ticket #2653: 2653.2.diff
File 2653.2.diff, 3.0 KB (added by , 11 years ago) |
---|
-
src/includes/topics/functions.php
338 338 339 339 /** No Errors *************************************************************/ 340 340 341 if ( ! empty( $topic_id ) && !is_wp_error( $topic_id ) ) {341 if ( !empty( $topic_id ) && !is_wp_error( $topic_id ) ) { 342 342 343 /** Close Check *******************************************************/ 344 345 // If the topic is closed, close it properly 346 if ( ( get_post_field( 'post_status', $topic_id ) === bbp_get_closed_status_id() ) || ( $topic_data['post_status'] === bbp_get_closed_status_id() ) ) { 347 348 // Close the topic 349 bbp_close_topic( $topic_id ); 350 } 351 343 352 /** Trash Check *******************************************************/ 344 353 345 354 // If the forum is trash, or the topic_status is switched to … … 2758 2767 * 2759 2768 * @param int $topic_id Topic id 2760 2769 * @uses bbp_get_topic() To get the topic 2770 * @uses get_post_meta() To get the topic status meta 2761 2771 * @uses do_action() Calls 'bbp_close_topic' with the topic id 2762 2772 * @uses add_post_meta() To add the previous status to a meta 2773 * @uses post_type_supports() To check if revisions are enabled 2774 * @uses bbp_get_topic_post_type() To get the topic post type 2775 * @uses remove_post_type_support() To temporarily remove topic revisions 2776 * @uses add_post_type_support() To restore topic revisions 2763 2777 * @uses wp_update_post() To update the topic with the new status 2764 2778 * @uses do_action() Calls 'bbp_opened_topic' with the topic id 2765 2779 * @return mixed False or {@link WP_Error} on failure, topic id on success … … 2772 2786 return $topic; 2773 2787 } 2774 2788 2775 // Bail if already closed 2776 if ( bbp_get_closed_status_id() === $topic->post_status ) { 2789 // Get previous topic status meta 2790 $topic_status = get_post_meta( $topic_id, '_bbp_status', true ); 2791 2792 // Bail if already closed and topic status meta exists 2793 if ( bbp_get_closed_status_id() === $topic->post_status && ! empty( $topic_status ) ) { 2777 2794 return false; 2778 2795 } 2779 2796 2797 // Set status meta public 2798 $topic_status = bbp_get_public_status_id(); 2799 2780 2800 // Execute pre close code 2781 2801 do_action( 'bbp_close_topic', $topic_id ); 2782 2802 2783 2803 // Add pre close status 2784 add_post_meta( $topic_id, '_bbp_status', $topic ->post_status );2804 add_post_meta( $topic_id, '_bbp_status', $topic_status ); 2785 2805 2786 2806 // Set closed status 2787 2807 $topic->post_status = bbp_get_closed_status_id(); 2788 2808 2789 // No revisions 2790 remove_action( 'pre_post_update', 'wp_save_post_revision' ); 2809 // Toggle revisions off as we are not altering content 2810 if ( post_type_supports( bbp_get_topic_post_type(), 'revisions' ) ) { 2811 $revisions_removed = true; 2812 remove_post_type_support( bbp_get_topic_post_type(), 'revisions' ); 2813 } 2791 2814 2792 2815 // Update topic 2793 2816 $topic_id = wp_update_post( $topic ); 2794 2817 2818 // Toggle revisions back on 2819 if ( true === $revisions_removed ) { 2820 $revisions_removed = false; 2821 add_post_type_support( bbp_get_topic_post_type(), 'revisions' ); 2822 } 2823 2795 2824 // Execute post close code 2796 2825 do_action( 'bbp_closed_topic', $topic_id ); 2797 2826