Making WordPress.org

Changeset 5309


Ignore:
Timestamp:
04/10/2017 08:44:33 PM (8 years ago)
Author:
ocean90
Message:

Plugin Directory: Avoid a PHP warning if a plugin contributor doesn't exist as a user.

File:
1 edited

Legend:

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

    r5121 r5309  
    2828    public function widget( $args, $instance ) {
    2929        $post = get_post();
     30        $contributors = get_the_terms( 2, 'plugin_contributors' );
    3031
    31         if ( $contributors = get_the_terms( $post, 'plugin_contributors' ) ) {
     32        if ( $contributors ) {
    3233            $contributors = (array) wp_list_pluck( $contributors, 'name' );
    3334            $contributors = array_map( function( $user_nicename ) {
    3435                return get_user_by( 'slug', $user_nicename );
    3536            }, $contributors );
    36         } else {
     37            $contributors = array_filter( $contributors );
     38        }
     39
     40        if ( ! $contributors ) {
    3741            return;
    3842        }
Note: See TracChangeset for help on using the changeset viewer.