Changeset 4289 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-support-compat.php
- Timestamp:
- 10/23/2016 06:12:42 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
r4234 r4289 10 10 var $loaded = false; 11 11 var $query = null; 12 var $user _login= null;12 var $user = null; 13 13 14 14 public function __construct() { … … 38 38 } 39 39 40 /** 41 * Check the request for the `wporg_user_login`, and then add filters to 42 * handle either the feed request or the custom view if a user is found. 43 * 44 * @param array $query_vars The query vars 45 * @return array The query vars 46 */ 40 47 public function request( $query_vars ) { 41 if ( isset( $query_vars['feed'] ) && isset( $query_vars['wporg_user_login'] ) ) { 42 if ( isset( $query_vars['bbp_view'] ) && in_array( $query_vars['bbp_view'], array( 'plugin-committer' ) ) ) { 43 $this->query = $query_vars; 44 add_filter( 'bbp_get_view_query_args', array( $this, 'get_view_query_args_for_feed' ), 10, 2 ); 45 46 // Override bbPress topic pubDate handling to show topic time and not last active time 47 add_filter( 'get_post_metadata', array( $this, 'topic_pubdate_correction_for_feed' ), 10, 4 ); 48 if ( isset( $query_vars['wporg_user_login'] ) && ! empty( $query_vars['wporg_user_login'] ) && ! $this->user ) { 49 $user = get_user_by( 'slug', $query_vars['wporg_user_login'] ); 50 if ( $user ) { 51 // Set the user if available for custom views. 52 $this->user = $user; 53 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' ) ) ) { 56 $this->query = $query_vars; 57 add_filter( 'bbp_get_view_query_args', array( $this, 'get_view_query_args_for_feed' ), 10, 2 ); 58 59 // Override bbPress topic pubDate handling to show topic time and not last active time. 60 add_filter( 'get_post_metadata', array( $this, 'topic_pubdate_correction_for_feed' ), 10, 4 ); 61 } 48 62 } 49 63 } … … 68 82 'taxonomy' => 'topic-plugin', 69 83 'field' => 'slug', 70 'terms' => $this->get_plugin_slugs_by_committer( $this->query['wporg_user_login']),84 'terms' => self::get_plugin_slugs_by_committer( $this->user->user_login ), 71 85 ) ), 72 86 'show_stickies' => false, … … 77 91 } 78 92 79 public function parse_query() { 80 $user_login = get_query_var( 'wporg_user_login' ); 93 /** 94 * Determine if a custom view needs to be loaded for this query and register 95 * the view if needed. 96 * 97 * @param array $query_vars The query vars 98 */ 99 public function parse_query( $query_vars ) { 81 100 $view = get_query_var( 'bbp_view' ); 82 if ( ! $ user_login || ! $view) {101 if ( ! $view || ! $this->user ) { 83 102 return; 84 103 } 85 104 86 // Basic setup.87 $this->user_login = $user_login;88 89 105 if ( $view == 'plugin-committer' ) { 90 106 91 $slugs = $this->get_plugin_slugs_by_committer( $user_login );107 $slugs = self::get_plugin_slugs_by_committer( $this->user->user_login ); 92 108 93 109 // Add plugin-committer view. 94 110 bbp_register_view( 95 111 'plugin-committer', 96 sprintf( __( 'Plugin Committer » %s', 'wporg-forums' ), esc_html( $ user_login ) ),112 sprintf( __( 'Plugin Committer » %s', 'wporg-forums' ), esc_html( $this->user->user_login ) ), 97 113 array( 98 114 'post_parent__in' => array( Plugin::PLUGINS_FORUM_ID, Plugin::REVIEWS_FORUM_ID ), … … 152 168 // Pretty permalinks. 153 169 if ( $wp_rewrite->using_permalinks() ) { 154 $url = $wp_rewrite->root . 'view/plugin-committer/' . $this->user_login;170 $url = $wp_rewrite->root . "view/{$view}/" . $this->user->user_login; 155 171 $url = home_url( user_trailingslashit( $url ) ); 156 172 … … 159 175 $url = add_query_arg( array( 160 176 bbp_get_view_rewrite_id() => $view, 161 'wporg_user_login' => $this->user _login,177 'wporg_user_login' => $this->user->user_login, 162 178 ) ); 163 179 } … … 272 288 global $wpdb; 273 289 $slugs = (array) $wpdb->get_col( $wpdb->prepare( "SELECT `path` FROM `" . PLUGINS_TABLE_PREFIX . "svn_access` WHERE `user` = %s AND `access` = 'rw'", $user_login ) ); 274 return $slugs; 290 return self::clean_slugs( $slugs ); 291 } 292 293 public static function clean_slugs( $slugs ) { 294 $cleanslugs = array(); 295 foreach ( $slugs as $slug ) { 296 $slug = trim( $slug, '/' ); 297 if ( ! empty( $slug ) ) { 298 $cleanslugs[] = $slug; 299 } 300 } 301 return $cleanslugs; 275 302 } 276 303 }
Note: See TracChangeset
for help on using the changeset viewer.