• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_avatar_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_avatar_url函数的典型用法代码示例。如果您正苦于以下问题:PHP get_avatar_url函数的具体用法?PHP get_avatar_url怎么用?PHP get_avatar_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_avatar_url函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: get_avatar

 /**
  * Retrieve the avatar `<img>` tag for a user, email address, MD5 hash, comment, or post.
  *
  * @since 2.5.0
  * @since 4.2.0 Optional `$args` parameter added.
  *
  * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
  *                           user email, WP_User object, WP_Post object, or comment object.
  * @param int    $size       Optional. Height and width of the avatar image file in pixels. Default 96.
  * @param string $default    Optional. URL for the default image or a default type. Accepts '404'
  *                           (return a 404 instead of a default image), 'retro' (8bit), 'monsterid'
  *                           (monster), 'wavatar' (cartoon face), 'indenticon' (the "quilt"),
  *                           'mystery', 'mm', or 'mysterman' (The Oyster Man), 'blank' (transparent GIF),
  *                           or 'gravatar_default' (the Gravatar logo). Default is the value of the
  *                           'avatar_default' option, with a fallback of 'mystery'.
  * @param string $alt        Optional. Alternative text to use in &lt;img&gt; tag. Default empty.
  * @param array  $args       {
  *     Optional. Extra arguments to retrieve the avatar.
  *
  *     @type int          $height        Display height of the avatar in pixels. Defaults to $size.
  *     @type int          $width         Display width of the avatar in pixels. Defaults to $size.
  *     @type bool         $force_default Whether to always show the default image, never the Gravatar. Default false.
  *     @type string       $rating        What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
  *                                       judged in that order. Default is the value of the 'avatar_rating' option.
  *     @type string       $scheme        URL scheme to use. See set_url_scheme() for accepted values.
  *                                       Default null.
  *     @type array|string $class         Array or string of additional classes to add to the &lt;img&gt; element.
  *                                       Default null.
  *     @type bool         $force_display Whether to always show the avatar - ignores the show_avatars option.
  *                                       Default false.
  *     @type string       $extra_attr    HTML attributes to insert in the IMG element. Is not sanitized. Default empty.
  * }
  * @return false|string `<img>` tag for the user's avatar. False on failure.
  */
 function get_avatar($id_or_email, $size = 96, $default = '', $alt = '', $args = null)
 {
     $defaults = array('size' => 96, 'height' => null, 'width' => null, 'default' => get_option('avatar_default', 'mystery'), 'force_default' => false, 'rating' => get_option('avatar_rating'), 'scheme' => null, 'alt' => '', 'class' => null, 'force_display' => false, 'extra_attr' => '');
     if (empty($args)) {
         $args = array();
     }
     $args['size'] = (int) $size;
     $args['default'] = $default;
     $args['alt'] = $alt;
     $args = wp_parse_args($args, $defaults);
     if (empty($args['height'])) {
         $args['height'] = $args['size'];
     }
     if (empty($args['width'])) {
         $args['width'] = $args['size'];
     }
     /**
      * Filter whether to retrieve the avatar URL early.
      *
      * Passing a non-null value will effectively short-circuit get_avatar(), passing
      * the value through the {@see 'pre_get_avatar'} filter and returning early.
      *
      * @since 4.2.0
      *
      * @param string            $avatar      HTML for the user's avatar. Default null.
      * @param int|object|string $id_or_email A user ID, email address, or comment object.
      * @param array             $args        Arguments passed to get_avatar_url(), after processing.
      */
     $avatar = apply_filters('pre_get_avatar', null, $id_or_email, $args);
     if (!is_null($avatar)) {
         /** This filter is documented in wp-includes/pluggable.php */
         return apply_filters('get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args);
     }
     if (!$args['force_display'] && !get_option('show_avatars')) {
         return false;
     }
     $url2x = get_avatar_url($id_or_email, array_merge($args, array('size' => $args['size'] * 2)));
     $args = get_avatar_data($id_or_email, $args);
     $url = $args['url'];
     if (!$url || is_wp_error($url)) {
         return false;
     }
     $class = array('avatar', 'avatar-' . (int) $args['size'], 'photo');
     if (!$args['found_avatar'] || $args['force_default']) {
         $class[] = 'avatar-default';
     }
     if ($args['class']) {
         if (is_array($args['class'])) {
             $class = array_merge($class, $args['class']);
         } else {
             $class[] = $args['class'];
         }
     }
     $avatar = sprintf("<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>", esc_attr($args['alt']), esc_url($url), esc_attr("{$url2x} 2x"), esc_attr(join(' ', $class)), (int) $args['height'], (int) $args['width'], $args['extra_attr']);
     /**
      * Filter the avatar to retrieve.
      *
      * @since 2.5.0
      * @since 4.2.0 The `$args` parameter was added.
      *
      * @param string            $avatar      &lt;img&gt; tag for the user's avatar.
      * @param int|object|string $id_or_email A user ID, email address, or comment object.
      * @param int               $size        Square avatar width and height in pixels to retrieve.
      * @param string            $alt         Alternative text to use in the avatar image tag.
      *                                       Default empty.
      * @param array             $args        Arguments passed to get_avatar_data(), after processing.
//.........这里部分代码省略.........
开发者ID:cybKIRA,项目名称:roverlink-updated,代码行数:101,代码来源:pluggable.php


示例2: fa_cache_avatar

function fa_cache_avatar($avatar, $id_or_email, $size, $default, $alt)
{
    $avatar = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com"), "cn.gravatar.com", $avatar);
    $tmp = strpos($avatar, 'http');
    $url = get_avatar_url($id_or_email, $size);
    $url = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com"), "cn.gravatar.com", $url);
    $avatar2x = get_avatar_url($id_or_email, $size * 2);
    $avatar2x = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com"), "cn.gravatar.com", $avatar2x);
    $g = substr($avatar, $tmp, strpos($avatar, "'", $tmp) - $tmp);
    $tmp = strpos($g, 'avatar/') + 7;
    $f = substr($g, $tmp, strpos($g, "?", $tmp) - $tmp);
    $w = home_url();
    $e = ABSPATH . 'avatar/' . $size . '*' . $f . '.jpg';
    $e2x = ABSPATH . 'avatar/' . $size * 2 . '*' . $f . '.jpg';
    $t = 1209600;
    if ((!is_file($e) || time() - filemtime($e) > $t) && (!is_file($e2x) || time() - filemtime($e2x) > $t)) {
        copy(htmlspecialchars_decode($g), $e);
        copy(htmlspecialchars_decode($avatar2x), $e2x);
    } else {
        $avatar = $w . '/avatar/' . $size . '*' . $f . '.jpg';
        $avatar2x = $w . '/avatar/' . $size * 2 . '*' . $f . '.jpg';
        if (filesize($e) < 1000) {
            copy($w . '/avatar/default.jpg', $e);
        }
        if (filesize($e2x) < 1000) {
            copy($w . '/avatar/default.jpg', $e2x);
        }
        $avatar = "<img alt='{$alt}' src='{$avatar}' srcset='{$avatar2x}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
    }
    return $avatar;
}
开发者ID:wangshijun101,项目名称:morketing.cn,代码行数:31,代码来源:avatar.php


示例3: hwseo_jsonld_person

function hwseo_jsonld_person()
{
    $payload = array('@type' => 'Person');
    if (is_author()) {
        global $wp_query;
        $author_data = $wp_query->get_queried_object();
    } elseif (is_single()) {
        global $post;
        $author_data = get_userdata($post->post_author);
    } else {
        $author_data = get_userdata(1);
    }
    //refer to admin
    // fetch twitter from author meta and concatenate with full twitter URL
    $twitter_url = " https://twitter.com/";
    $twitterHandle = get_the_author_meta('twitter', $author_data->ID);
    $twitterHandleURL = $twitter_url . $twitterHandle;
    $websiteHandle = get_the_author_meta('url', $author_data->ID);
    $facebookHandle = get_the_author_meta('facebook', $author_data->ID);
    $gplusHandle = get_the_author_meta('googleplus', $author_data->ID);
    $linkedinHandle = get_the_author_meta('linkedin', $author_data->ID);
    $slideshareHandle = get_the_author_meta('slideshare', $author_data->ID);
    //user custom fields
    $phone = get_the_author_meta('phone', $author_data->ID);
    $jobtitle = get_the_author_meta('jobtitle', $author_data->ID);
    $payload['name'] = $author_data->display_name;
    $payload['email'] = $author_data->user_email;
    $payload['telephone'] = $phone;
    $payload['image'] = get_avatar_url(get_avatar($author_data->ID, 150));
    $payload['jobTitle'] = $jobtitle;
    $payload["sameAs"] = array($twitterHandleURL, $websiteHandle, $facebookHandle, $gplusHandle, $linkedinHandle, $slideshareHandle);
    return $payload;
}
开发者ID:hoangsoft90,项目名称:wordpress-hw-seo,代码行数:33,代码来源:json-ld.php


示例4: getUser

 public function getUser($name, $meta = array())
 {
     global $wpdb;
     $meta_fields = '';
     if (sizeof($meta) > 0) {
         foreach ($meta as $meta_item) {
             $meta_fields .= ",{$meta_item}.meta_value as value{$meta_item}";
         }
     }
     $query = "SELECT u.ID, u.display_name, ud.meta_value as bio, u.user_email, u.user_url {$meta_fields} FROM {$wpdb->users} AS u";
     $query .= " LEFT JOIN {$wpdb->usermeta} AS ud ON (u.ID = ud.user_id AND ud.meta_key = 'description')";
     if (sizeof($meta) > 0) {
         foreach ($meta as $meta_item) {
             $query .= " LEFT JOIN {$wpdb->usermeta} AS {$meta_item} ON (u.ID = {$meta_item}.user_id AND {$meta_item}.meta_key = '{$meta_item}')";
         }
     }
     $query .= " WHERE u.display_name = {$name}";
     $query .= " GROUP BY u.ID";
     $authorQuery = $wpdb->get_results($query);
     $author_data = $authorQuery[0];
     $author = array();
     $author['avatar'] = get_avatar_url($author_data->ID, '150');
     $author['name'] = $author_data->display_name;
     $author['id'] = $author_data->ID;
     $author['bio'] = $author_data->bio;
     $author['email'] = $author_data->user_email;
     if (sizeof($meta) > 0) {
         foreach ($meta as $meta_item) {
             $meta_name = 'value' . $meta_item;
             $author[$meta_item] = $author_data->{$meta_name};
         }
     }
     wp_reset_query();
     return $author;
 }
开发者ID:jonnSmith,项目名称:jadeWP,代码行数:35,代码来源:wpAuthors.php


示例5: __get

 function __get($name)
 {
     if (is_numeric($name) && $name == (int) $name && $name == absint($name)) {
         return get_avatar_url($this->_user_id, array('size' => $name));
     }
     return '';
 }
开发者ID:peterwilsoncc,项目名称:rapid-mustache,代码行数:7,代码来源:user-avatars.php


示例6: questions_list_action

 public function questions_list_action()
 {
     if ($_GET['feature_id']) {
         $topic_ids = $this->model('feature')->get_topics_by_feature_id($_GET['feature_id']);
         if ($topic_ids) {
             $answers = $this->model('reader')->fetch_answers_list_by_topic_ids($topic_ids, $_GET['page'], 20);
         }
     } else {
         $answers = $this->model('reader')->fetch_answers_list($_GET['page'], 20);
     }
     $output = array();
     if ($answers) {
         foreach ($answers as $key => $val) {
             $question_ids[$val['question_id']] = $val['question_id'];
             $uids[$val['uid']] = $val['uid'];
         }
         $questions_info = $this->model('question')->get_question_info_by_ids($question_ids);
         $question_topics = $this->model('topic')->get_topics_by_item_ids($question_ids, 'question');
         $users_info = $this->model('account')->get_user_info_by_uids($uids, TRUE);
         foreach ($answers as $key => $val) {
             $output['answers'][$val['answer_id']] = array('answer_id' => $val['answer_id'], 'question_id' => $val['question_id'], 'avatar' => get_avatar_url($val['uid'], 'mid'), 'user_name' => $users_info[$val['uid']]['user_name'], 'signature' => $users_info[$val['uid']]['signature'], 'agree_count' => $val['agree_count'], 'agree_users' => $this->model('answer')->get_vote_user_by_answer_id($val['answer_id']), 'answer_content' => FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($val['answer_content']))), 'add_time' => date_friendly($val['add_time']), 'uid' => $val['uid']);
         }
         foreach ($questions_info as $key => $val) {
             $output['questions'][$val['question_id']] = array('question_id' => $val['question_id'], 'question_content' => $val['question_content'], 'question_detail' => FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($val['question_detail']))), 'answer_users' => $val['answer_users'], 'focus_count' => $val['focus_count'], 'view_count' => $val['view_count'], 'topics' => $question_topics[$val['question_id']]);
         }
     }
     echo json_encode($output);
 }
开发者ID:chenruixuan,项目名称:wecenter,代码行数:28,代码来源:ajax.php


示例7: my_custom_comments

function my_custom_comments($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    ?>
	<li <?php 
    comment_class();
    ?>
 id="li-comment-<?php 
    comment_ID();
    ?>
">
	<?php 
    if ($comment->comment_approved == '0') {
        ?>
		<em><?php 
        _e('Your comment is awaiting moderation.');
        ?>
</em>
	<?php 
    }
    ?>
	<?php 
    echo '<div class="pull-left"><div class="commentor-avatar" style="height: 90px; width: 90px; background: url(' . get_avatar_url($comment) . ') no-repeat center center; background-size: cover;"><div class="commentor-name">' . get_comment_author() . '</div></div></div>';
    comment_text();
    echo '<div class="clearfix"></div>';
}
开发者ID:codysaylor,项目名称:wordpress-barebones-boilerplate,代码行数:26,代码来源:functions.php


示例8: get_avatar_url

 protected function get_avatar_url($email, $avatar_size = 96)
 {
     $avatar_url = get_avatar_url($email, array('size' => $avatar_size));
     if (!$avatar_url || is_wp_error($avatar_url)) {
         return '';
     }
     return $avatar_url;
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:8,代码来源:class.json-api-post-jetpack.php


示例9: url_author_avatar

/**
 * @return false|string
 */
function url_author_avatar()
{
    $image_url = get_the_author_meta('author-avatar');
    if (empty($image_url)) {
        $image_url = get_avatar_url(get_the_author_meta('ID'));
    }
    return $image_url;
}
开发者ID:apsolut,项目名称:Yoast-theme-public,代码行数:11,代码来源:functions-links.php


示例10: index_action

 public function index_action()
 {
     if (!$this->user_id) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请先登录或注册')));
     }
     $this->per_page = get_setting('contents_per_page');
     if ($_GET['per_page']) {
         $this->per_page = intval($_GET['per_page']);
     }
     //$data = $this->model('myhome')->home_activity($this->user_id, (intval($_GET['page']) * $this->per_page) . ", {$this->per_page}");
     $data = $this->model('actions')->home_activity($this->user_id, intval($_GET['page']) * $this->per_page . ", {$this->per_page}");
     if (!is_array($data)) {
         $data = array();
     } else {
         $data_key = array('history_id', 'associate_action', 'user_info', 'answer_info', 'question_info', 'article_info', 'comment_info', 'add_time');
         $user_info_key = array('uid', 'user_name', 'signature');
         $article_info_key = array('id', 'title', 'message', 'comments', 'views', 'add_time');
         $answer_info_key = array('answer_id', 'answer_content', 'add_time', 'against_count', 'agree_count');
         $question_info_key = array('question_id', 'question_content', 'add_time', 'update_time', 'answer_count', 'agree_count');
         foreach ($data as $key => $val) {
             foreach ($val as $k => $v) {
                 if (!in_array($k, $data_key)) {
                     unset($data[$key][$k]);
                 }
             }
             if ($val['user_info']) {
                 foreach ($val['user_info'] as $k => $v) {
                     if (!in_array($k, $user_info_key)) {
                         unset($data[$key]['user_info'][$k]);
                     }
                 }
                 $data[$key]['user_info']['avatar_file'] = get_avatar_url($data[$key]['user_info']['uid'], 'mid');
             }
             if ($val['article_info']) {
                 foreach ($val['article_info'] as $k => $v) {
                     if (!in_array($k, $article_info_key)) {
                         unset($data[$key]['article_info'][$k]);
                     }
                 }
             }
             if ($val['answer_info']) {
                 foreach ($val['answer_info'] as $k => $v) {
                     if (!in_array($k, $answer_info_key)) {
                         unset($data[$key]['answer_info'][$k]);
                     }
                 }
             }
             if ($val['question_info']) {
                 foreach ($val['question_info'] as $k => $v) {
                     if (!in_array($k, $question_info_key)) {
                         unset($data[$key]['question_info'][$k]);
                     }
                 }
             }
         }
     }
     H::ajax_json_output(AWS_APP::RSM(array('total_rows' => count($data), 'rows' => array_values($data)), 1, null));
 }
开发者ID:nerverwind,项目名称:wecenter_ios_sdk,代码行数:58,代码来源:home.php


示例11: format_js_users_output

 public function format_js_users_output($data)
 {
     if ($data) {
         foreach ($data as $key => $val) {
             $output .= '<div class="item"><dl class="inf"><dt><a href="' . get_js_url('/people/' . $val['url_token']) . '">' . $val['user_name'] . '</a></dt><dd>回复了 ' . $val['answer_count'] . ' 个问题</dd><dd>获得 ' . $val['agree_count'] . ' 个赞同</dd></dl><div class="avatar"><a href=""><img src="' . get_avatar_url($val['uid'], 'mid') . '" /></a></div></div><!-- .item -->';
         }
     }
     return "document.write('" . addcslashes($output, "'") . "');";
 }
开发者ID:avldya,项目名称:wecenter,代码行数:9,代码来源:aws_offical_external.php


示例12: get_focus_users_action

 public function get_focus_users_action()
 {
     if ($focus_users = $this->model('topic')->get_focus_users_by_topic($_GET['topic_id'], 18)) {
         foreach ($focus_users as $key => $val) {
             $focus_users[$key]['avatar_file'] = get_avatar_url($val['uid'], 'mid');
             $focus_users[$key]['url'] = get_js_url('/people/' . $val['url_token']);
         }
     }
     H::ajax_json_output($focus_users);
 }
开发者ID:Vizards,项目名称:HeavenSpree,代码行数:10,代码来源:ajax.php


示例13: get_comments_for_posts

 function get_comments_for_posts($data, $post, $context)
 {
     $comments = get_comments(array('post_id' => $post['ID']));
     foreach ($comments as $comment) {
         $user_id = $comment->user_id;
         $author = ['ID' => $user_id, 'username' => get_the_author_meta('user_login', $user_id), 'name' => get_the_author_meta('display_name', $user_id), 'first_name' => get_the_author_meta('first_name', $user_id), 'last_name' => get_the_author_meta('last_name', $user_id), 'avatar' => get_avatar_url($user_id), 'description' => get_the_author_meta('description', $user_id)];
         $data['comments'][] = ['ID' => $comment->comment_ID, 'post' => $comment->comment_post_ID, 'content' => $comment->comment_content, 'author' => $author, 'date' => $comment->comment_date, 'date_gmt' => $comment->comment_date_gmt];
     }
     return $data;
 }
开发者ID:shahin8r,项目名称:comments-posts-wp-api,代码行数:10,代码来源:comments-post-wp-api.php


示例14: wp_slack_bbpress

/**
 * Plugin Name: WP Slack bbPress
 * Plugin URI:  https://github.com/rolfkleef/wp-slack-bbpress
 * Description: Send notifications to Slack channels for events in bbPress.
 * Version:     0.5
 * Author:      Rolf Kleef
 * Author URI:  https://drostan.org
 * License:     GPL2
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: wp-slack-bbpress
 */
function wp_slack_bbpress($events)
{
    $events['wp_slack_bbp_new_topic'] = array('action' => 'bbp_new_topic', 'description' => __('When a new topic is added in bbPress', 'wp-slack-bbpress'), 'message' => function ($topic_id, $forum_id, $anonymous_data, $topic_author) {
        return array(array('fallback' => sprintf(__('<%1$s|New topic "%2$s"> in forum <%3$s|%4$s>', 'wp-slack-bbpress'), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id)), 'pretext' => sprintf(__('New topic in forum <%1$s|%2$s>', 'wp-slack-bbpress'), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id)), 'author_name' => bbp_get_topic_author_display_name($topic_id), 'author_link' => bbp_get_topic_author_link($topic_id), 'author_icon' => get_avatar_url($topic_author, array('size' => 16)), 'title' => sprintf('%1$s', bbp_get_topic_title($topic_id)), 'title_link' => bbp_get_topic_permalink($topic_id), 'text' => html_entity_decode(bbp_get_topic_excerpt($topic_id, 150))));
    });
    $events['wp_slack_bbp_new_reply'] = array('action' => 'bbp_new_reply', 'description' => __('When a new reply is added in bbPress', 'wp-slack-bbpress'), 'message' => function ($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, $bool, $reply_to) {
        return array(array('fallback' => sprintf(__('<%1$s|New reply> in forum <%2$s|%3$s> on topic <%4$s|%5$s>', 'wp-slack-bbpress'), bbp_get_reply_url($reply_id), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id)), 'pretext' => sprintf(__('New reply in forum <%1$s|%2$s> on topic <%3$s|%4$s>', 'wp-slack-bbpress'), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id)), 'author_name' => bbp_get_reply_author_display_name($reply_id), 'author_link' => bbp_get_reply_author_link($reply_id), 'author_icon' => get_avatar_url($reply_author, array('size' => 16)), 'title' => sprintf(__('New reply to "%1$s"', 'wp-slack-bbpress'), bbp_get_topic_title($topic_id)), 'title_link' => bbp_get_reply_url($reply_id), 'text' => html_entity_decode(bbp_get_reply_excerpt($reply_id, 150))));
    });
    return $events;
}
开发者ID:rolfkleef,项目名称:wp-slack-bbpress,代码行数:21,代码来源:wp-slack-bbpress.php


示例15: get_author

 /**
  * get_author
  *
  * @return mixed
  */
 protected function get_author()
 {
     if (empty($this->author)) {
         if ($id = get_queried_object_id()) {
             $this->author = new \TimberUser($id);
             $this->author->thumbnail = new \TimberImage(get_avatar_url($this->author->id));
         }
     }
     return $this->author;
 }
开发者ID:benedict-w,项目名称:pressgang,代码行数:15,代码来源:author-controller.php


示例16: get_clean_user_info

 public function get_clean_user_info($user_info)
 {
     $user_info_key = array('uid', 'user_name', 'signature');
     if (is_array($user_info)) {
         foreach ($user_info as $k => $v) {
             if (!in_array($k, $user_info_key)) {
                 unset($user_info[$k]);
             }
         }
         $user_info['avatar_file'] = get_avatar_url($user_info['uid'], 'mid');
     }
     return $user_info;
 }
开发者ID:androiddream,项目名称:WeCenterMobile-Api,代码行数:13,代码来源:myapi.php


示例17: widget

 function widget($args, $instance)
 {
     global $comments, $comment;
     $cache = wp_cache_get('widget_recent_comments', 'widget');
     if (!is_array($cache)) {
         $cache = array();
     }
     if (!isset($args['widget_id'])) {
         $args['widget_id'] = $this->id;
     }
     if (isset($cache[$args['widget_id']])) {
         echo $cache[$args['widget_id']];
         return;
     }
     extract($args, EXTR_SKIP);
     $output = '';
     $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $number = !empty($instance['number']) ? absint($instance['number']) : 5;
     if (!$number) {
         $number = 5;
     }
     $comments = get_comments(apply_filters('widget_comments_args', array('number' => $number, 'status' => 'approve', 'post_status' => 'publish')));
     $output .= $before_widget;
     if ($title) {
         $output .= $before_title . $title . $after_title;
     }
     $output .= '<ul id="recentcomments" class="bw-sidebar-posts">';
     if ($comments) {
         // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
         $post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
         _prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
         foreach ((array) $comments as $comment) {
             if (Bw::get_option('enable_lazy_image')) {
                 $bw_image = "<img class='lazy' data-src='" . get_avatar_url($comment->user_id) . "' src='" . Bw::empty_img() . "' alt='' >";
             } else {
                 $bw_image = "<img src='" . get_avatar_url($comment->user_id) . "' alt='' >";
             }
             $output .= '<li class="recentcomments">';
             $output .= '<div class="thumb"><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . $bw_image . '</a></div>';
             $output .= '<div class="cont"><a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . get_comment_author_link() . '</a>';
             $output .= '<p>' . Bw::truncate($comment->comment_content, 7) . '</p></div>';
             $output .= '</li>';
         }
     }
     $output .= '</ul>';
     $output .= $after_widget;
     echo $output;
     $cache[$args['widget_id']] = $output;
     wp_cache_set('widget_recent_comments', $cache, 'widget');
 }
开发者ID:damiansu,项目名称:wordpress-es,代码行数:51,代码来源:Bw_widgets_recent_comments.php


示例18: user_info_action

 public function user_info_action()
 {
     if ($this->user_id == $_GET['uid']) {
         $user_info = $this->user_info;
     } else {
         if (!($user_info = $this->model('account')->get_user_info_by_uid($_GET['uid'], ture))) {
             H::ajax_json_output(array('uid' => null));
         }
     }
     if ($this->user_id != $user_info['uid']) {
         $user_follow_check = $this->model('follow')->user_follow_check($this->user_id, $user_info['uid']);
     }
     H::ajax_json_output(array('reputation' => $user_info['reputation'], 'agree_count' => $user_info['agree_count'], 'thanks_count' => $user_info['thanks_count'], 'type' => 'people', 'uid' => $user_info['uid'], 'user_name' => $user_info['user_name'], 'avatar_file' => get_avatar_url($user_info['uid'], 'mid'), 'signature' => $user_info['signature'], 'focus' => $user_follow_check ? true : false, 'is_me' => $this->user_id == $user_info['uid'] ? true : false, 'url' => get_js_url('/people/' . $user_info['url_token']), 'category_enable' => get_setting('category_enable') == 'Y' ? 1 : 0, 'verified' => $user_info['verified'], 'fans_count' => $user_info['fans_count']));
 }
开发者ID:Vizards,项目名称:HeavenSpree,代码行数:14,代码来源:ajax.php


示例19: get_focus_users_action

 public function get_focus_users_action()
 {
     if ($focus_users_info = $this->model('question')->get_focus_users_by_question($_GET['question_id'], 18)) {
         $question_info = $this->model('question')->get_question_info_by_id($_GET['question_id']);
         foreach ($focus_users_info as $key => $val) {
             if ($val['uid'] == $question_info['published_uid'] and $question_info['anonymous'] == 1) {
                 $focus_users[$key] = array('uid' => 0, 'user_name' => AWS_APP::lang()->_t('匿名用户'), 'avatar_file' => get_avatar_url(0, 'mid'));
             } else {
                 $focus_users[$key] = array('uid' => $val['uid'], 'user_name' => $val['user_name'], 'avatar_file' => get_avatar_url($val['uid'], 'mid'), 'url' => get_js_url('/people/' . $val['url_token']));
             }
         }
     }
     H::ajax_json_output($focus_users);
 }
开发者ID:tenstone,项目名称:wecenter,代码行数:14,代码来源:ajax.php


示例20: widget

	function widget($args, $instance) {
		global $post;
		
		$posts = get_field('post', 'widget_'.$args['widget_id']);


		if( $posts ) :
			echo $args['before_widget']; 
			?>

				<?php foreach($posts as $post) : ?>
				<?php setup_postdata($post); ?>
				<?php 
					$author_id = get_the_author_meta('ID');
					$author_image = get_field('image', 'user_'. $author_id);
					$author_img_url = get_avatar_url ( $author_id, $size = '40' );
					$author_url = get_author_posts_url($author_id);
					$excerpt = get_the_excerpt();
					$excerpt = (strlen($excerpt) > 150) ? '"'.substr($excerpt,0,150).'" ...' : $excerpt;

				 ?>

					<img class="image" src="<?php echo get_image(get_post_thumbnail_id($post->ID), array(180, 180)); ?>">
					<div class="script">
						<img src="<?php bloginfo('template_directory'); ?>/images/misc/editors-letter.png" alt="">	
					</div>
					<a href="<?php echo $author_url; ?>">
						<div class="author">
								<div class="image circle">
										<img src="<?php echo $author_img_url; ?>" />
								</div>
								<span class="name"><?php echo the_author_meta( "display_name", $author_id ); ?></span>
						</div>	
					</a>
					<div class="date">
						february 01,2015
					</div>
					
					<div class="bio">
						<?php echo $excerpt; ?>	
						<a class="read-more" href="<?php the_permalink(); ?>">Read Further &raquo;</a>	
					</div>
				<?php endforeach;	?>
			<? 
			echo $args['after_widget'];	
		endif;
		
		
	}
开发者ID:kishandchips,项目名称:thebankcorporate,代码行数:49,代码来源:editor.php



注:本文中的get_avatar_url函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_awpcp_option函数代码示例发布时间:2022-05-15
下一篇:
PHP get_avatar_filename函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap