Making WordPress.org

Changeset 14396


Ignore:
Timestamp:
02/25/2025 03:45:29 AM (11 months ago)
Author:
dd32
Message:

Plugin Directory: Consistency show the plugin owner in the Contributor list for a plugin.

See https://make.wordpress.org/plugins/2025/02/20/plugin-author-now-linked-wp-profiles/

File:
1 edited

Legend:

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

    r11804 r14396  
    3838
    3939        if ( is_wp_error( $contributors ) ) {
    40             return;
     40            $contributors = [];
    4141        }
    4242
    43         if ( $contributors ) {
    44             $contributors = array_map( function( $user_nicename ) {
    45                 return get_user_by( 'slug', $user_nicename );
    46             }, $contributors );
    47             $contributors = array_filter( $contributors );
     43        // The owner of the plugin is always a contributor, and shown first.
     44        $plugin_owner = get_the_author_meta( 'user_nicename', $post->post_author );
     45        if ( $plugin_owner && 0 !== array_search( $plugin_owner, $contributors, true ) ) {
     46            $contributors = array_unique(
     47                array_merge(
     48                    [ $plugin_owner ],
     49                    $contributors
     50                )
     51            );
    4852        }
    4953
    50         // If no contributors were explicitly or properly listed, default to associated author.
    51         if ( ! $contributors && ( $author = get_user_by( 'ID', $post->post_author ) ) ) {
    52             $contributors = [ $author ];
    53         }
     54        // Convert the user_nicenames to user objects.
     55        $contributors = array_map(
     56            function( $user_nicename ) {
     57                return get_user_by( 'slug', $user_nicename );
     58            },
     59            $contributors
     60        );
     61
     62        // Remove any users that didn't exist.
     63        $contributors = array_filter( $contributors );
    5464
    5565        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Contributors', 'wporg-plugins' ) : $instance['title'], $instance, $this->id_base );
Note: See TracChangeset for help on using the changeset viewer.