Making WordPress.org


Ignore:
Timestamp:
03/08/2017 12:06:02 AM (8 years ago)
Author:
obenland
Message:

Plugin Directory: Fix display of plugin contributors

  • Re-uses the contributor widget in the shortcode
  • Displays committer-, contributor-, and code-browse-lists correctly
  • Fixes the read-more link for contributor list in admin

See #2111.
Fixes #2567

File:
1 edited

Legend:

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

    r4620 r5121  
    1515     */
    1616    static function display() {
    17         $post         = get_post();
    18         $output = '';
     17        $post   = get_post();
     18        $output = '<p>' . __( 'This is open source software. The following people have contributed to this plugin.', 'wporg-plugins' ) . '</p>';
    1919
    20         $contributors = get_terms( array(
    21             'taxonomy' => 'plugin_contributors',
    22             'object_ids' => array( $post->ID ),
    23             'orderby' => 'term_order',
    24             'fields' => 'names',
     20        ob_start();
     21        the_widget( 'WordPressdotorg\Plugin_Directory\Widgets\Contributors', array(), array(
     22            'before_title'  => '<span class="screen-reader-text">',
     23            'after_title'   => '</span>',
     24            'before_widget' => '',
     25            'after_widget'  => '',
    2526        ) );
    2627
    27         if ( ! $contributors || is_wp_error( $contributors ) ) {
    28             $contributors = array();
    29             if ( $author = get_user_by( 'id', $post->post_author ) ) {
    30                 $contributors[] = $author->user_nicename;
    31             }
    32         }
    33 
    34         $output .= '<p>' . __( 'This is open source software. The following people have contributed to this plugin.', 'wporg-plugins' ) . '</p>';
    35 
    36         $output .= '<ul class="plugin-developers">';
    37         foreach ( $contributors as $contributor_slug ) {
    38             $contributor = get_user_by( 'slug', $contributor_slug );
    39             if ( ! $contributor ) {
    40                 continue;
    41             }
    42 
    43             $output .= '<li>' . get_avatar( $contributor->ID, 32 ) . '<a href="' . esc_url( 'https://profiles.wordpress.org/' . $contributor_slug ) . '">' . Template::encode( $contributor->display_name ) . '</a></li>';
    44         }
    45         $output .= '</ul>';
     28        $output .= ob_get_clean();
    4629
    4730        if ( is_user_logged_in() ) {
    4831            $subscribed = Tools::subscribed_to_plugin_commits( $post, get_current_user_id() );
    4932
    50             $subscribe_change_url = esc_url( add_query_arg(
    51                 array(
    52                     '_wpnonce' => wp_create_nonce( 'wp_rest' ),
    53                     ( $subscribed ? 'unsubscribe' : 'subscribe' ) => '1'
    54                 ),
    55                 home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/commit-subscription' )
    56             ) );
     33            $subscribe_change_url = esc_url( add_query_arg( array(
     34                '_wpnonce' => wp_create_nonce( 'wp_rest' ),
     35                ( $subscribed ? 'unsubscribe' : 'subscribe' ) => '1',
     36            ), home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/commit-subscription' ) ) );
    5737        }
    5838
Note: See TracChangeset for help on using the changeset viewer.