Making WordPress.org

Changeset 5265


Ignore:
Timestamp:
04/05/2017 10:56:02 PM (7 years ago)
Author:
coffee2code
Message:

Plugin Directory, Author Card: Modify display() to be callable for a specified user.

  • Accept first argument as post object (previous behavior) or user ID
  • Add div with class of "profile" to wrap entire author card
  • Change paragraph previously having class of "profile" to class "profile-personal"
  • Tweak CSS targeting of avatar image
Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-author-card.php

    r5208 r5265  
    1212    /**
    1313     * Displays information about the author of the current plugin.
     14     *
     15     * @param int|WP_Post $post_or_user_id The post or the ID of a specific user.
    1416     */
    15     public static function display() {
     17    public static function display( $post_or_user_id = '' ) {
    1618        global $wpdb;
    1719
     
    2123        ), 10, 6 );
    2224
    23         $post   = get_post();
    24         $author = get_user_by( 'id', $post->post_author );
     25        if ( is_int( $post_or_user_id ) ) {
     26            $post   = '';
     27            $author = get_user_by( 'id', $post_or_user_id );
     28        } else {
     29            $post   = $post_or_user_id ?: get_post();
     30            $author = get_user_by( 'id', $post->post_author );
     31        }
     32
     33        if ( ! $author ) {
     34            return;
     35        }
    2536
    2637        $author_commit  = Tools::get_users_write_access_plugins( $author );
    27         $author_plugins = get_posts( array(
     38        $author_plugins_q = array(
    2839            'author'       => $author->ID,
    2940            'post_type'    => 'plugin',
    30             'post__not_in' => array( $post->ID ),
    31         ) );
     41        );
     42        if ( $post ) {
     43            $author_plugins_q['post__not_in'] = array( $post->ID );
     44        }
     45        $author_plugins = get_posts( $author_plugins_q );
    3246        $all_plugins = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} WHERE post_name IN ('" . implode( "', '", array_merge( $author_commit, wp_list_pluck( $author_plugins, 'post_name' ) ) ) . "')" );
    3347        ?>
    34         <p class="profile">
     48        <div class="profile">
     49        <p class="profile-personal">
    3550            <?php echo get_avatar( $author->ID, 48 ); ?>
    3651            <span class="profile-details">
     
    206221         */
    207222        do_action( 'wporg_plugins_author_card', $post, $author, $all_plugins );
     223
     224        echo '</div>';
    208225    }
    209226
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/css/edit-form.css

    r4383 r5265  
    178178}
    179179
    180 .profile > img {
     180.profile .avatar {
    181181    float: left;
    182182    height: 48px;
Note: See TracChangeset for help on using the changeset viewer.