Changeset 5055 for trunk/includes/topics/functions.php
- Timestamp:
- 07/29/2013 01:41:36 AM (13 years ago)
- File:
-
- 1 edited
-
trunk/includes/topics/functions.php (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/topics/functions.php
r5036 r5055 215 215 216 216 // Forum does not exist 217 } elseif ( ! get_post( $posted_forum_id ) ) {217 } elseif ( ! bbp_get_forum( $posted_forum_id ) ) { 218 218 bbp_add_error( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum does not exist.', 'bbpress' ) ); 219 219 … … 2662 2662 * 2663 2663 * @param int $topic_id Topic id 2664 * @uses get_post() To get the topic2664 * @uses bbp_get_topic() To get the topic 2665 2665 * @uses do_action() Calls 'bbp_close_topic' with the topic id 2666 2666 * @uses add_post_meta() To add the previous status to a meta 2667 * @uses wp_ insert_post() To update the topic with the new status2667 * @uses wp_update_post() To update the topic with the new status 2668 2668 * @uses do_action() Calls 'bbp_opened_topic' with the topic id 2669 2669 * @return mixed False or {@link WP_Error} on failure, topic id on success … … 2672 2672 2673 2673 // Get topic 2674 if ( !$topic = get_post( $topic_id, ARRAY_A ) ) 2674 $topic = bbp_get_topic( $topic_id ); 2675 if ( empty( $topic ) ) 2675 2676 return $topic; 2676 2677 2677 2678 // Bail if already closed 2678 if ( bbp_get_closed_status_id() === $topic ['post_status'])2679 if ( bbp_get_closed_status_id() === $topic->post_status ) 2679 2680 return false; 2680 2681 … … 2683 2684 2684 2685 // Add pre close status 2685 add_post_meta( $topic_id, '_bbp_status', $topic ['post_status']);2686 add_post_meta( $topic_id, '_bbp_status', $topic->post_status ); 2686 2687 2687 2688 // Set closed status 2688 $topic ['post_status']= bbp_get_closed_status_id();2689 $topic->post_status = bbp_get_closed_status_id(); 2689 2690 2690 2691 // No revisions … … 2692 2693 2693 2694 // Update topic 2694 $topic_id = wp_ insert_post( $topic );2695 $topic_id = wp_update_post( $topic ); 2695 2696 2696 2697 // Execute post close code … … 2707 2708 * 2708 2709 * @param int $topic_id Topic id 2709 * @uses get_post() To get the topic2710 * @uses bbp_get_topic() To get the topic 2710 2711 * @uses do_action() Calls 'bbp_open_topic' with the topic id 2711 2712 * @uses get_post_meta() To get the previous status 2712 2713 * @uses delete_post_meta() To delete the previous status meta 2713 * @uses wp_ insert_post() To update the topic with the new status2714 * @uses wp_update_post() To update the topic with the new status 2714 2715 * @uses do_action() Calls 'bbp_opened_topic' with the topic id 2715 2716 * @return mixed False or {@link WP_Error} on failure, topic id on success … … 2718 2719 2719 2720 // Get topic 2720 if ( !$topic = get_post( $topic_id, ARRAY_A ) ) 2721 $topic = bbp_get_topic( $topic_id ); 2722 if ( empty( $topic ) ) 2721 2723 return $topic; 2722 2724 2723 2725 // Bail if already open 2724 if ( bbp_get_closed_status_id() !== $topic ['post_status'])2726 if ( bbp_get_closed_status_id() !== $topic->post_status ) 2725 2727 return false; 2726 2728 … … 2729 2731 2730 2732 // Get previous status 2731 $topic_status = get_post_meta( $topic_id, '_bbp_status', true );2733 $topic_status = get_post_meta( $topic_id, '_bbp_status', true ); 2732 2734 2733 2735 // Set previous status 2734 $topic ['post_status']= $topic_status;2736 $topic->post_status = $topic_status; 2735 2737 2736 2738 // Remove old status meta … … 2741 2743 2742 2744 // Update topic 2743 $topic_id = wp_ insert_post( $topic );2745 $topic_id = wp_update_post( $topic ); 2744 2746 2745 2747 // Execute post open code … … 2756 2758 * 2757 2759 * @param int $topic_id Topic id 2758 * @uses get_post() To get the topic2760 * @uses bbp_get_topic() To get the topic 2759 2761 * @uses do_action() Calls 'bbp_spam_topic' with the topic id 2760 2762 * @uses add_post_meta() To add the previous status to a meta 2761 * @uses wp_ insert_post() To update the topic with the new status2763 * @uses wp_update_post() To update the topic with the new status 2762 2764 * @uses do_action() Calls 'bbp_spammed_topic' with the topic id 2763 2765 * @return mixed False or {@link WP_Error} on failure, topic id on success … … 2766 2768 2767 2769 // Get the topic 2768 if ( !$topic = get_post( $topic_id, ARRAY_A ) ) 2770 $topic = bbp_get_topic( $topic_id ); 2771 if ( empty( $topic ) ) 2769 2772 return $topic; 2770 2773 2771 2774 // Bail if topic is spam 2772 if ( bbp_get_spam_status_id() === $topic ['post_status'])2775 if ( bbp_get_spam_status_id() === $topic->post_status ) 2773 2776 return false; 2774 2777 … … 2815 2818 2816 2819 // Add the original post status as post meta for future restoration 2817 add_post_meta( $topic_id, '_bbp_spam_meta_status', $topic ['post_status']);2820 add_post_meta( $topic_id, '_bbp_spam_meta_status', $topic->post_status ); 2818 2821 2819 2822 // Get topic tags … … 2838 2841 2839 2842 // Empty the topic of its tags 2840 $topic ['tax_input']= array( bbp_get_topic_tag_tax_id() => '' );2843 $topic->tax_input = array( bbp_get_topic_tag_tax_id() => '' ); 2841 2844 } 2842 2845 } 2843 2846 2844 2847 // Set post status to spam 2845 $topic ['post_status']= bbp_get_spam_status_id();2848 $topic->post_status = bbp_get_spam_status_id(); 2846 2849 2847 2850 // No revisions … … 2849 2852 2850 2853 // Update the topic 2851 $topic_id = wp_ insert_post( $topic );2854 $topic_id = wp_update_post( $topic ); 2852 2855 2853 2856 // Execute post spam code … … 2864 2867 * 2865 2868 * @param int $topic_id Topic id 2866 * @uses get_post() To get the topic2869 * @uses bbp_get_topic() To get the topic 2867 2870 * @uses do_action() Calls 'bbp_unspam_topic' with the topic id 2868 2871 * @uses get_post_meta() To get the previous status 2869 2872 * @uses delete_post_meta() To delete the previous status meta 2870 * @uses wp_ insert_post() To update the topic with the new status2873 * @uses wp_update_post() To update the topic with the new status 2871 2874 * @uses do_action() Calls 'bbp_unspammed_topic' with the topic id 2872 2875 * @return mixed False or {@link WP_Error} on failure, topic id on success … … 2875 2878 2876 2879 // Get the topic 2877 if ( !$topic = get_post( $topic_id, ARRAY_A ) ) 2880 $topic = bbp_get_topic( $topic_id ); 2881 if ( empty( $topic ) ) 2878 2882 return $topic; 2879 2883 2880 2884 // Bail if already not spam 2881 if ( bbp_get_spam_status_id() !== $topic ['post_status'])2885 if ( bbp_get_spam_status_id() !== $topic->post_status ) 2882 2886 return false; 2883 2887 … … 2912 2916 2913 2917 // Set the tax_input of the topic 2914 $topic ['tax_input']= array( bbp_get_topic_tag_tax_id() => $terms );2918 $topic->tax_input = array( bbp_get_topic_tag_tax_id() => $terms ); 2915 2919 2916 2920 // Delete pre-spam topic tag meta … … 2929 2933 2930 2934 // Set post status to pre spam 2931 $topic ['post_status']= $topic_status;2935 $topic->post_status = $topic_status; 2932 2936 2933 2937 // Delete pre spam meta … … 2938 2942 2939 2943 // Update the topic 2940 $topic_id = wp_ insert_post( $topic );2944 $topic_id = wp_update_post( $topic ); 2941 2945 2942 2946 // Execute post unspam code
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)