Changeset 5288
- Timestamp:
- 04/07/2017 09:25:27 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-badges/inc/class-plugin.php
r5287 r5288 74 74 * @param int $item_id The ID of the item getting badge assigned. 75 75 * @return array|false Associative array with keys 'type', 'slug', and 76 * 'user_ login' if author merits a badge, else false.76 * 'user_nicename' if author merits a badge, else false. 77 77 */ 78 78 protected function get_author_badge_info( $item_type, $item_id ) { … … 107 107 $slugs = $types = array(); 108 108 109 $user_ login = get_user_by( 'id', $user_id )->user_login;109 $user_nicename = get_user_by( 'id', $user_id )->user_nicename; 110 110 111 111 // Check if the thread is associated with a plugin. … … 141 141 'type' => $type, 142 142 'slug' => $slugs[0], 143 'user_ login' => $user_login,143 'user_nicename' => $user_nicename, 144 144 ); 145 145 } … … 195 195 // Class related to plugin and theme authors/contributors. 196 196 if ( $info = $this->get_author_badge_info( $item_type, $item_id ) ) { 197 if ( $this->is_user_author( $info['user_ login'], $info['type'], $info['slug'] ) ) {197 if ( $this->is_user_author( $info['user_nicename'], $info['type'], $info['slug'] ) ) { 198 198 $contrib_type = 'author'; 199 } elseif ( $this->is_user_contributor( $info['user_ login'], $info['type'], $info['slug'] ) ) {199 } elseif ( $this->is_user_contributor( $info['user_nicename'], $info['type'], $info['slug'] ) ) { 200 200 $contrib_type = 'contributor'; 201 201 } else { … … 285 285 * @param int $item_id The ID of the item getting badge assigned. 286 286 * @return array|false Associative array with keys 'type', 'slug', and 287 * 'user_ login' if author merits a badge, else null.287 * 'user_nicename' if author merits a badge, else null. 288 288 */ 289 289 protected function get_author_badge( $item_type, $item_id ) { … … 295 295 296 296 // Determine strings to use based on user being an author or contributor. 297 if ( $this->is_user_author( $info['user_ login'], $info['type'], $info['slug'] ) ) {297 if ( $this->is_user_author( $info['user_nicename'], $info['type'], $info['slug'] ) ) { 298 298 if ( 'plugin' == $info['type'] ) { 299 299 $label = __( 'Plugin Author', 'wporg-forums' ); … … 304 304 } 305 305 } 306 elseif ( $this->is_user_contributor( $info['user_ login'], $info['type'], $info['slug'] ) ) {306 elseif ( $this->is_user_contributor( $info['user_nicename'], $info['type'], $info['slug'] ) ) { 307 307 if ( 'plugin' == $info['type'] ) { 308 308 $label = __( 'Plugin Contributor', 'wporg-forums' ); … … 342 342 * the designated author for a theme. 343 343 * 344 * @param string $user_ login User login.344 * @param string $user_nicename User slug. 345 345 * @param string $type Either 'plugin' or 'theme'. 346 346 * @param string $slug Slug for the plugin or theme. 347 347 * @return bool True if user is an author, false otherwise. 348 348 */ 349 public function is_user_author( $user_ login, $type, $slug ) {349 public function is_user_author( $user_nicename, $type, $slug ) { 350 350 if ( 'plugin' === $type ) { 351 351 $compat = class_exists( '\WordPressdotorg\Forums\Plugin' ) ? \WordPressdotorg\Forums\Plugin::get_instance()->plugins : ''; … … 355 355 $authors = $compat ? $compat->get_authors( $slug ) : array(); 356 356 357 return $authors && in_array( $user_ login, $authors );357 return $authors && in_array( $user_nicename, $authors ); 358 358 } 359 359 … … 364 364 * Currently, themes do not support having contirbutors. 365 365 * 366 * @param string $user_ login User login.366 * @param string $user_nicename User slug. 367 367 * @param string $type Either 'plugin' or 'theme'. 368 368 * @param string $slug Slug for the plugin or theme. 369 369 * @return bool True if user is a contributor, false otherwise. 370 370 */ 371 public function is_user_contributor( $user_ login, $type, $slug ) {371 public function is_user_contributor( $user_nicename, $type, $slug ) { 372 372 if ( 'plugin' === $type ) { 373 373 $compat = class_exists( '\WordPressdotorg\Forums\Plugin' ) ? \WordPressdotorg\Forums\Plugin::get_instance()->plugins : ''; … … 377 377 $contributors = $compat ? $compat->get_contributors( $slug ) : array(); 378 378 379 return $contributors && in_array( $user_ login, $contributors );379 return $contributors && in_array( $user_nicename, $contributors ); 380 380 } 381 381
Note: See TracChangeset
for help on using the changeset viewer.