Making WordPress.org

Changeset 3179


Ignore:
Timestamp:
05/19/2016 04:45:39 AM (8 years ago)
Author:
dd32
Message:

Plugins Directory: Template tags: When no contributors exist, fall back to the post author.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-tags.php

    r3009 r3179  
    3232
    3333function wporg_plugins_download_link() {
    34     return esc_url( sprintf( "https://downloads.wordpress.org/plugin/%s.%s.zip", get_post()->post_name, wporg_plugins_the_version() ) );
     34    return esc_url( Template::download_link( get_the_id() ) );
    3535}
    3636
    3737function wporg_plugins_template_authors() {
    38     $authors = get_post_meta( get_the_id(), 'contributors', true );
     38    $contributors = get_post_meta( get_the_id(), 'contributors', true );
     39
     40    $authors = array();
     41    foreach ( $contributors as $contributor ) {
     42        $user = get_user_by( 'login', $contributor );
     43        if ( $user ) {
     44            $authors[] = $user;
     45        }
     46    }
     47
     48    if ( ! $authors ) {
     49        $authors[] = new \WP_User( get_post()->post_author );
     50    }
    3951
    4052    $author_links = array();
    4153    $and_more = false;
    42     foreach ( $authors as $author ) {
    43         $user = get_user_by( 'login', $author );
    44         if ( ! $user ) {
    45             continue;
    46         }
     54    foreach ( $authors as $user ) {
    4755        $author_links[] = sprintf( '<a href="%s">%s</a>', 'https://profiles.wordpress.org/' . $user->user_nicename . '/', $user->display_name );
    4856        if ( count( $author_links ) > 5 ) {
Note: See TracChangeset for help on using the changeset viewer.