/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { echo $args['before_widget']; $blogusers = get_users('blog_id=1&orderby=nicename&role=editor'); // Array of WP_User objects. if ($blogusers) { echo '<ul class="author">'; foreach ($blogusers as $user) { ?> <li> <a href="<?php echo esc_url(get_author_posts_url($user->ID)); ?> " class="tooltip" title="<?php echo get_the_author_meta('user_description', $user->ID); ?> "> <?php include_once ABSPATH . 'wp-admin/includes/plugin.php'; if (is_plugin_active('metronet-profile-picture/metronet-profile-picture.php')) { mt_profile_img($user->ID); } else { echo get_avatar(get_the_author_meta('user_email', $user->ID)); } ?> <?php echo $user->data->display_name; ?> </a> </li> <?php } echo '</ul>'; } echo $args['after_widget']; }
if (have_posts()) { ?> <div class="authorTitle pure-u-1" > <p class="profile"> <?php $paths = explode('/', $_SERVER['REQUEST_URI']); $author_slug = end($paths); if (is_numeric($author_slug)) { prev($paths); prev($paths); $author_slug = current($paths); } $author = get_user_by('slug', $author_slug); include_once ABSPATH . 'wp-admin/includes/plugin.php'; if (is_plugin_active('metronet-profile-picture/metronet-profile-picture.php')) { mt_profile_img($author->ID); } else { echo get_avatar(get_the_author_meta('user_email', $author->ID)); } ?> <br> <?php echo $author_slug; ?> </p> <?php if ('' != get_the_author_meta('user_description')) { $user_description = get_the_author_meta('user_description', $author->ID); echo apply_filters('archive_meta', '<span class="archive-meta"><small>' . $user_description . '</small></span>'); } ?>
/** * Display an user info. * * * @since Product Express 1.0 */ function product_express_another_author_bio($writer){ ?> <div class="author <?php echo $writer['nickname']; ?>"> <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( $writer['ID'] ) ) ); ?>"> <?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if ( is_plugin_active( 'metronet-profile-picture/metronet-profile-picture.php' ) ) { mt_profile_img( $writer['ID'] ); }else{ echo get_avatar( get_the_author_meta( 'user_email', $writer['ID'] ) ); } ?> <span><?php echo $writer['display_name']; ?></span> </a> </div> <?php }
/** * avatar_override() * * Overrides an avatar with a profile image * * @param string $avatar SRC to the avatar * @param mixed $id_or_email * @param int $size Size of the image * @param string $default URL to the default image * @param string $alt Alternative text **/ public function avatar_override($avatar, $id_or_email, $size, $default, $alt) { //Get user data if (is_numeric($id_or_email)) { $user = get_user_by('id', (int) $id_or_email); } elseif (is_object($id_or_email)) { $comment = $id_or_email; if (empty($comment->user_id)) { $user = get_user_by('id', $comment->user_id); } else { $user = get_user_by('email', $comment->comment_author_email); } if (!$user) { return $avatar; } } elseif (is_string($id_or_email)) { $user = get_user_by('email', $id_or_email); } else { return $avatar; } if (!$user) { return $avatar; } $user_id = $user->ID; //Determine if user has an avatar override $avatar_override = get_user_option('metronet_avatar_override', $user_id); if (!$avatar_override || $avatar_override != 'on') { return $avatar; } //Determine if the user has a profile image $custom_avatar = mt_profile_img($user_id, array('size' => array($size, $size), 'attr' => array('alt' => $alt, 'class' => "avatar avatar-{$size} photo"), 'echo' => false)); if (!$custom_avatar) { return $avatar; } return $custom_avatar; }
/** * avatar_override() * * Overrides an avatar with a profile image * * @param string $avatar SRC to the avatar * @param mixed $id_or_email * @param int $size Size of the image * @param string $default URL to the default image * @param string $alt Alternative text **/ public function avatar_override($avatar, $id_or_email, $size, $default, $alt, $args = array()) { global $pagenow; if ('options-discussion.php' == $pagenow) { return $avatar; } //Stop overriding gravatars on options-discussion page //Get user data if (is_numeric($id_or_email)) { $user = get_user_by('id', (int) $id_or_email); } elseif (is_object($id_or_email)) { $comment = $id_or_email; if (empty($comment->user_id)) { $user = get_user_by('id', $comment->user_id); } else { $user = get_user_by('email', $comment->comment_author_email); } if (!$user) { return $avatar; } } elseif (is_string($id_or_email)) { $user = get_user_by('email', $id_or_email); } else { return $avatar; } if (!$user) { return $avatar; } $user_id = $user->ID; //Determine if user has an avatar override $avatar_override = get_user_option('metronet_avatar_override', $user_id); if (!$avatar_override || $avatar_override != 'on') { return $avatar; } //Build classes array based on passed in args, else set defaults - see get_avatar in /wp-includes/pluggable.php $classes = array('avatar', sprintf('avatar-%s', esc_attr($size)), 'photo'); if (isset($args['class'])) { if (is_array($args['class'])) { $classes = array_merge($classes, $args['class']); } else { $args['class'] = explode(' ', $args['class']); $classes = array_merge($classes, $args['class']); } } //Get custom filter classes $classes = (array) apply_filters('mpp_avatar_classes', $classes); //Determine if the user has a profile image $custom_avatar = mt_profile_img($user_id, array('size' => array($size, $size), 'attr' => array('alt' => $alt, 'class' => implode(' ', $classes)), 'echo' => false)); if (!$custom_avatar) { return $avatar; } return $custom_avatar; }