Making WordPress.org

Changeset 4196


Ignore:
Timestamp:
10/07/2016 04:35:28 AM (8 years ago)
Author:
dd32
Message:

Plugin Directory: Readme Parsing: Standardise on user_nicename rather than user_login for the Contributors header.
On WordPress.org we've got a lot of accounts for which the Login contains spaces, uppercase characters, email addresses, etc. Standardising on user_nicename simplifies the rest of the code.

See #1724

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php

    r4194 r4196  
    489489    protected function sanitize_contributors( $users ) {
    490490        foreach ( $users as $i => $name ) {
    491             if ( $user = get_user_by( 'login', $name ) ) {
    492 
    493                 // Check the case of the user login matches.
    494                 if ( $name !== $user->user_login ) {
    495                     $users[ $i ] = $user->user_login;
    496                 }
    497             } elseif ( false !== ( $user = get_user_by( 'slug', $name ) ) ) {
    498 
    499                 // Overwrite the nicename with the user_login.
    500                 $users[ $i ] = $user->user_login;
    501             } else {
    502 
    503                 // Unknown user, we'll skip these entirely to encourage correct readme files.
     491            // Contributors should be listed by their WordPress.org Login name (Example: 'Joe Bloggs')
     492            $user = get_user_by( 'login', $name );
     493
     494            // Or failing that, by their user_nicename field (Example: 'joe-bloggs')
     495            if ( ! $user ) {
     496                $user = get_user_by( 'slug', $name );
     497            }
     498
     499            // In the event that something invalid is used, we'll ignore it (Example: 'Joe Bloggs (Australian Translation)')
     500            if ( ! $user ) {
    504501                unset( $users[ $i ] );
    505             }
     502                continue;
     503            }
     504
     505            // Overwrite whatever the author has specified with the sanitized nicename.
     506            $users[ $i ] = $user->user_nicename;
    506507        }
    507508
Note: See TracChangeset for help on using the changeset viewer.