Making WordPress.org

Ticket #2966: 2966.patch

File 2966.patch, 1.9 KB (added by SergeyBiryukov, 8 years ago)
  • wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-moderation/inc/class-plugin.php

     
    6262                        add_filter( 'bbp_edit_topic_pre_insert', array( $this, 'pre_insert' ) );
    6363                        add_filter( 'bbp_new_reply_pre_insert',  array( $this, 'pre_insert' ) );
    6464                        add_filter( 'bbp_edit_reply_pre_insert', array( $this, 'pre_insert' ) );
    65 
    66                         // Alter queries for moderated users.
    67                         add_filter( 'posts_where', array( $this, 'posts_where' ) );
    6865                }
    6966
     67                // Alter queries for the current user.
     68                add_filter( 'posts_where', array( $this, 'posts_where' ) );
     69
    7070                // Add views and actions for moderators.
    7171                if ( user_can( $user_id, 'moderate' ) ) {
    7272                        // Provide user moderation actions.
     
    9494        }
    9595
    9696        /**
    97          * Adjust the query for moderated users.
     97         * Adjust the query for the current user.
    9898         */
    9999        public function posts_where( $where ) {
    100100                global $wpdb;
     
    105105                                strpos( $where, $wpdb->prepare( "$wpdb->posts.post_type = %s", bbp_get_reply_post_type() ) ) !== false
    106106                        ) {
    107107                                $original = $wpdb->prepare( "$wpdb->posts.post_status = %s OR ", bbp_get_public_status_id() );
    108                                 $replacement = $wpdb->prepare( " ( $wpdb->posts.post_status = '%s' AND $wpdb->posts.post_author = '%d' ) OR ", bbp_get_pending_status_id(), get_current_user_id() );
     108                                $replacement = $wpdb->prepare( " ( $wpdb->posts.post_status IN ( %s, %s ) AND $wpdb->posts.post_author = '%d' ) OR ",
     109                                        bbp_get_pending_status_id(),
     110                                        bbp_get_spam_status_id(),
     111                                        get_current_user_id()
     112                                );
    109113                                $where = str_replace( $original, $original . $replacement, $where );
    110114                        }
    111115                }