Changeset 4290
- Timestamp:
- 10/23/2016 06:39:39 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-support-compat.php
r4289 r4290 53 53 54 54 // If this is a feed, add filters to handle the custom view. 55 if ( isset( $query_vars['feed'] ) && isset( $query_vars['bbp_view'] ) && in_array( $query_vars['bbp_view'], array( 'plugin-committer' ) ) ) {55 if ( isset( $query_vars['feed'] ) && isset( $query_vars['bbp_view'] ) && in_array( $query_vars['bbp_view'], array( 'plugin-committer', 'plugin-contributor' ) ) ) { 56 56 $this->query = $query_vars; 57 57 add_filter( 'bbp_get_view_query_args', array( $this, 'get_view_query_args_for_feed' ), 10, 2 ); … … 83 83 'field' => 'slug', 84 84 'terms' => self::get_plugin_slugs_by_committer( $this->user->user_login ), 85 ) ), 86 'show_stickies' => false, 87 ); 88 break; 89 case 'plugin-contributor' : 90 return array( 91 'post_parent__in' => array( Plugin::PLUGINS_FORUM_ID, Plugin::REVIEWS_FORUM_ID ), 92 'post_status' => 'publish', 93 'tax_query' => array( array( 94 'taxonomy' => 'topic-plugin', 95 'field' => 'slug', 96 'terms' => $this->get_plugin_slugs_by_contributor( $this->user ), 85 97 ) ), 86 98 'show_stickies' => false, … … 125 137 // Add output filters and actions. 126 138 add_filter( 'bbp_get_view_link', array( $this, 'get_view_link' ), 10, 2 ); 139 140 } elseif ( $view == 'plugin-contributor' ) { 141 142 $slugs = self::get_plugin_slugs_by_contributor( $this->user ); 143 144 // Add plugin-contributor view. 145 bbp_register_view( 146 'plugin-contributor', 147 sprintf( __( 'Plugin Contributor » %s', 'wporg-forums' ), esc_html( $this->user->user_login ) ), 148 array( 149 'post_parent__in' => array( Plugin::PLUGINS_FORUM_ID, Plugin::REVIEWS_FORUM_ID ), 150 'post_status' => 'publish', 151 'tax_query' => array( array( 152 'taxonomy' => 'topic-plugin', 153 'field' => 'slug', 154 'terms' => $slugs, 155 ) ), 156 'show_stickies' => false, 157 ) 158 ); 159 160 // Add output filters and actions. 161 add_filter( 'bbp_get_view_link', array( $this, 'get_view_link' ), 10, 2 ); 127 162 } 128 163 } … … 136 171 $priority = 'top'; 137 172 138 $plugin_committer_rule = bbp_get_view_slug() . '/plugin-committer/([^/]+)/'; 173 $plugin_committer_rule = bbp_get_view_slug() . '/plugin-committer/([^/]+)/'; 174 $plugin_contributor_rule = bbp_get_view_slug() . '/plugin-contributor/([^/]+)/'; 139 175 140 176 $feed_id = 'feed'; … … 153 189 add_rewrite_rule( $plugin_committer_rule . $paged_rule, 'index.php?' . $view_id . '=plugin-committer&wporg_user_login=$matches[1]&' . $paged_id . '=$matches[2]', $priority ); 154 190 add_rewrite_rule( $plugin_committer_rule . $feed_rule, 'index.php?' . $view_id . '=plugin-committer&wporg_user_login=$matches[1]&' . $feed_id . '=$matches[2]', $priority ); 191 192 // Add plugin contributor rewrite rules. 193 add_rewrite_rule( $plugin_contributor_rule . $base_rule, 'index.php?' . $view_id . '=plugin-contributor&wporg_user_login=$matches[1]', $priority ); 194 add_rewrite_rule( $plugin_contributor_rule . $paged_rule, 'index.php?' . $view_id . '=plugin-contributor&wporg_user_login=$matches[1]&' . $paged_id . '=$matches[2]', $priority ); 195 add_rewrite_rule( $plugin_contributor_rule . $feed_rule, 'index.php?' . $view_id . '=plugin-contributor&wporg_user_login=$matches[1]&' . $feed_id . '=$matches[2]', $priority ); 155 196 } 156 197 … … 162 203 163 204 $view = bbp_get_view_id( $view ); 164 if ( ! in_array( $view, array( 'plugin-committer' ) ) ) {205 if ( ! in_array( $view, array( 'plugin-committer', 'plugin-contributor' ) ) ) { 165 206 return $url; 166 207 } … … 291 332 } 292 333 334 public static function get_plugin_slugs_by_contributor( $user ) { 335 global $wpdb; 336 $slugs = (array) $wpdb->get_col( $wpdb->prepare( "SELECT `topic_slug` FROM `" . PLUGINS_TABLE_PREFIX . "topics` WHERE `topic_poster` = %d AND topic_open = 1 AND topic_status = 0", $user->ID ) ); 337 $slugs = self::clean_slugs( $slugs ); 338 if ( $contributor = $wpdb->get_col( $wpdb->prepare( "SELECT `object_id` FROM `" . PLUGINS_TABLE_PREFIX . "meta` WHERE `object_type` = 'bb_topic' AND `meta_key` = 'contributors' AND `meta_value` LIKE %s", '%"' . str_replace( array( '%', '_' ), array( '\\%', '\\_' ), $user->user_login ) . '"%' ) ) ) { 339 if ( $contributor_slugs = $wpdb->get_col( "SELECT `topic_slug` FROM `" . PLUGINS_TABLE_PREFIX . "topics` WHERE `topic_id` IN (" . join( ',', $contributor ) . ") AND topic_open = 1 AND topic_status = 0" ) ) { 340 $slugs = array_unique( array_merge( $slugs, $contributor_slugs ) ); 341 } 342 } 343 return $slugs; 344 } 345 293 346 public static function clean_slugs( $slugs ) { 294 347 $cleanslugs = array();
Note: See TracChangeset
for help on using the changeset viewer.