Ejemplo n.º 1
2
 /**
  * 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.
      */
     return apply_filters('get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args);
 }
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 function __get($name)
 {
     if (is_numeric($name) && $name == (int) $name && $name == absint($name)) {
         return get_avatar_url($this->_user_id, array('size' => $name));
     }
     return '';
 }
Ejemplo n.º 6
0
 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);
 }
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>';
}
 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;
 }
Ejemplo n.º 9
0
/**
 * @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;
}
Ejemplo n.º 10
0
 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));
 }
Ejemplo n.º 11
0
 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, "'") . "');";
 }
Ejemplo n.º 12
0
 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);
 }
 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;
 }
Ejemplo n.º 14
0
/**
 * 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;
}
Ejemplo n.º 15
0
 /**
  * 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;
 }
Ejemplo n.º 16
0
 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;
 }
 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');
 }
Ejemplo n.º 18
0
 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']));
 }
Ejemplo n.º 19
0
 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);
 }
Ejemplo n.º 20
0
	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;
		
		
	}
Ejemplo n.º 21
0
/**
 * Retrieves the avatar url for a user who provided a user ID or email address.
 *
 * get_avatar() doesn't return just the URL, so we have to extract it here.
 *
 * @since 4.4.0
 * @deprecated WPAPI-2.0 rest_get_avatar_urls()
 * @see rest_get_avatar_urls()
 *
 * @param string $email Email address.
 * @return string URL for the user's avatar, empty string otherwise.
 */
function rest_get_avatar_url($email)
{
    _deprecated_function('rest_get_avatar_url', 'WPAPI-2.0', 'rest_get_avatar_urls');
    // Use the WP Core `get_avatar_url()` function introduced in 4.2.
    if (function_exists('get_avatar_url')) {
        return esc_url_raw(get_avatar_url($email));
    }
    $avatar_html = get_avatar($email);
    // Strip the avatar url from the get_avatar img tag.
    preg_match('/src=["|\'](.+)[\\&|"|\']/U', $avatar_html, $matches);
    if (isset($matches[1]) && !empty($matches[1])) {
        return esc_url_raw($matches[1]);
    }
    return '';
}
 /**
  * Frontend view
  *
  * @param type $args array.
  * @param type $instance array.
  *
  * @since 1.1
  */
 public function widget($args, $instance)
 {
     // Include assets
     $this->frontend_assets();
     foreach ($this->instance_default as $key => $value) {
         $instance[$key] = !empty($instance[$key]) ? $instance[$key] : $value;
     }
     $user_info = get_userdata($instance['user_id']);
     if (!empty($user_info->user_email)) {
         $gravatar_url = get_avatar_url($user_info->user_email, array('size' => 512));
         if (!empty($instance['image'])) {
             $main_avatar = $instance['image'];
         } elseif (!empty($gravatar_url)) {
             $main_avatar = $gravatar_url;
         }
         echo View::make('widgets/front-end/about-author', array('before_widget' => $args['before_widget'], 'before_title' => $args['before_widget'], 'after_title' => $args['after_title'], 'after_widget' => $args['after_widget'], 'title' => Utils::array_get($instance, 'title'), 'avatar' => $main_avatar, 'name' => $user_info->display_name, 'description' => $user_info->description, 'url' => Utils::array_get($instance, 'url'), 'text_link' => Utils::array_get($instance, 'text_link')));
     }
 }
Ejemplo n.º 23
0
	function print_summary($link, $length = 0) {
		global $current_user, $globals;
		static $comment_counter = 0;

		if(!$this->read) return;
		$comment_counter++;
		echo '<li id="ccontainer-'.$this->id.'">';
		echo '<div class="comment-body" id="comment-'.$comment_counter.'"><a href="'.$link->get_relative_permalink().'#comment-'.$comment_counter.'"><strong>#'.$comment_counter.'</strong></a>';
		echo '&nbsp;&nbsp;&nbsp;<span id="c-'.$this->id.'">'. "\n";
		//if($globals['external_ads']) echo "<!-- google_ad_section_start -->\n";
		$this->print_text($length);
		//if($globals['external_ads']) echo "<!-- google_ad_section_end -->\n";
		echo '</span></div>';
		echo '<div class="comment-info">';
		echo _('escrito por'). ' <a href="'.$globals['base_url'].'user.php?login='******'">'.$this->username.'</a> '._('hace').' '.txt_time_diff($this->date);
		echo '<img src="'.get_avatar_url($this->author, $this->avatar, $this->email, 20).'" width="20" height="20" alt="'.$this->username.'" title="avatar" /></div>';
		echo "</li>\n";
	}
Ejemplo n.º 24
0
function aa_func_20153529023505()
{
    $assets = get_template_directory_uri() . "/assets";
    /**
     * ==================== Stylesheets ======================
     */
    wp_enqueue_style('aa-bootstrap-style', $assets . '/vendor/bootstrap-sass/assets/stylesheets/bootstrap.css');
    wp_enqueue_style('aa-font-awesome', $assets . '/vendor/font-awesome/scss/font-awesome.css');
    wp_enqueue_style('aa-vendors', $assets . '/vendor/vendors.css');
    wp_enqueue_style('template-base-styles', get_bloginfo('stylesheet_url'));
    /**
     * ==================== Javascipts ======================
     */
    // jQuery JavaScript Library v2.1.4
    wp_deregister_script('jquery');
    wp_register_script('jquery', $assets . '/vendor/jquery/dist/jquery.min.js', array(), false, true);
    wp_enqueue_script('jquery');
    /**
     * ==================== tmp dev scripts ======================
     */
    $tmpboofer = $assets . '/js/_boofer/';
    wp_enqueue_script('aa-bootstrap', $tmpboofer . 'bootstrap-uglify.js', array(), false, true);
    wp_enqueue_script('aa-ng-components', $tmpboofer . 'angular-components.js', array(), false, true);
    wp_enqueue_script('aa-ng-mvc', $tmpboofer . 'angular-mvc-uglify.js', array(), false, true);
    $all_opts = wp_load_alloptions();
    $site_options = ['blogname' => $all_opts['blogname'], 'blogdescription' => $all_opts['blogdescription'], 'admin_email' => $all_opts['admin_email'], 'show_on_front' => $all_opts['show_on_front'], 'page_on_front' => $all_opts['page_on_front'], 'page_for_posts' => aa_getpostslugbyid($all_opts['page_for_posts']), 'posts_per_page' => $all_opts['posts_per_page'], 'active_plugins' => join('|', unserialize($all_opts['active_plugins']))];
    $ajax_data = array('site_url' => get_site_url(), 'ajax_url' => admin_url('admin-ajax.php'), 'template_uri' => get_template_directory_uri(), 'plugins_url' => plugins_url(), 'site_options' => $site_options, 'woo_opts' => aa_woocommerce_options(), 'current_user_id' => get_current_user_id(), 'current_user_avatar' => false);
    if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        $ajax_data['current_user_avatar'] = get_avatar_url(get_current_user_id());
        $ajax_data['user_login'] = $current_user->user_login;
        $ajax_data['user_email'] = $current_user->user_email;
    }
    wp_localize_script('aa-ng-mvc', 'aa_ajax_var', $ajax_data);
    /**
     * ==================== Production Script ======================
     * Include after compile
     */
    //	wp_enqueue_script( 'aa-site-scrips', $assets . '/js/site-scripts.js', array(), false, true );
    //	wp_localize_script( 'aa-site-scrips', 'aa_ajax_var', $ajax_data );
}
Ejemplo n.º 25
0
 /**
  * @internal
  * @param false|object $coauthor co-author object
  */
 protected function init($coauthor = false)
 {
     $this->id = $coauthor->ID;
     $this->first_name = $coauthor->first_name;
     $this->last_name = $coauthor->last_name;
     $this->user_nicename = $coauthor->user_nicename;
     $this->description = $coauthor->description;
     /**
      * @property string name
      */
     $this->display_name = $coauthor->display_name;
     $this->_link = get_author_posts_url(null, $coauthor->user_nicename);
     // 96 is the default wordpress avatar size
     $avatar_url = get_the_post_thumbnail_url($this->id, 96);
     if (CoAuthorsPlus::$prefer_gravatar || !$avatar_url) {
         $avatar_url = get_avatar_url($coauthor->user_email);
     }
     if ($avatar_url) {
         $this->avatar = new \Timber\Image($avatar_url);
     }
 }
 /**
  * Frontend view
  *
  * @param type $args array.
  * @param type $instance array.
  */
 public function widget($args, $instance)
 {
     foreach ($this->instance_default as $key => $value) {
         ${$key} = !empty($instance[$key]) ? $instance[$key] : $value;
     }
     // Custom js
     wp_register_script('tm-about-author-script-frontend', plugins_url('assets/js/frontend.min.js', __FILE__), '', '', true);
     wp_enqueue_script('tm-about-author-script-frontend');
     // Custom styles
     wp_register_style('tm-about-author-frontend', plugins_url('assets/css/frontend.min.css', __FILE__));
     wp_enqueue_style('tm-about-author-frontend');
     $user_info = get_userdata($user_id);
     if (!empty($user_info->user_email)) {
         $gravatar_url = get_avatar_url($user_info->user_email, array('size' => 512));
         if (!empty($image)) {
             $main_avatar = $image;
         } elseif (!empty($gravatar_url)) {
             $main_avatar = $gravatar_url;
         }
         require __DIR__ . '/views/frontend.php';
     }
 }
Ejemplo n.º 27
0
}
include_once 'pager.php';
global $db, $globals;
if (!isset($globals['link_id']) && !empty($_GET['id'])) {
    $globals['link_id'] = intval($_GET['id']);
}
if (!$globals['link_id'] > 0) {
    die;
}
if (!isset($_GET['p'])) {
    $favorites_page = 1;
} else {
    $favorites_page = intval($_GET['p']);
}
$favorites_page_size = 20;
$favorites_offset = ($favorites_page - 1) * $favorites_page_size;
$favorites_users = $db->get_var("SELECT count(*) FROM favorites WHERE favorite_link_id=" . $globals['link_id']);
$favorites = $db->get_results("SELECT favorite_user_id, user_avatar, user_login, date_format(favorite_date,'%d/%m %T') as date FROM favorites, users WHERE favorite_link_id=" . $globals['link_id'] . " AND user_id = favorite_user_id LIMIT {$favorites_offset},{$favorites_page_size}");
if (!$favorites) {
    return;
}
echo '<div class="voters-list">';
foreach ($favorites as $vote) {
    echo '<div class="item">';
    echo '<a href="' . get_user_uri($vote->user_login, 'favorites') . '" title="' . $vote->date . '">';
    echo '<img src="' . get_avatar_url($vote->favorite_user_id, $vote->user_avatar, 20) . '" width="20" height="20" alt="' . $vote->user_login . '"/>';
    echo $vote->user_login . '</a>';
    echo '</div>';
}
echo "</div>\n";
do_contained_pages($globals['link_id'], $favorites_users, $favorites_page, $favorites_page_size, 'get_link_favorites.php', 'voters', 'voters-container');
Ejemplo n.º 28
0
     break;
 default:
     $tab_option = 4;
     if (is_numeric($argv[0]) && ($post_id = intval($argv[0])) > 0 || is_numeric($argv[1]) && ($post_id = intval($argv[1])) > 0) {
         // Individual post
         $user->id = $db->get_var("select post_user_id from posts where post_id={$post_id}");
         if (!$user->read()) {
             do_error(_('usuario no encontrado'), 404);
         }
         $globals['permalink'] = 'http://' . get_server_name() . post_get_base_url($post_id);
         // Fill title
         $summary = text_to_summary($db->get_var("SELECT post_content from posts where post_id = {$post_id}"), 250);
         $globals['description'] = _('Autor') . ": {$user->username}, " . _('Resumen') . ': ' . $summary;
         $page_title = text_to_summary($summary, 120);
         if ($user->avatar) {
             $globals['thumbnail'] = get_avatar_url($user->id, $user->avatar, 80);
         }
         //$page_title = sprintf(_('nota de %s'), $user->username) . " ($post_id)";
         $globals['search_options']['u'] = $user->username;
         $where = "post_id = {$post_id}";
         $order_by = "";
         $limit = "";
         $rows = 1;
     } else {
         // User is specified
         $user->username = $db->escape($argv[0]);
         if (!$user->read() || $user->disabled()) {
             do_error(_('usuario no encontrado'), 404);
         }
         switch ($argv[1]) {
             case '_friends':
/**
* @param $email
* @param $width
* @return array|bool|mixed|string
*/
function jetpack_og_get_image_gravatar($email, $width)
{
    $image = '';
    if (function_exists('get_avatar_url')) {
        $avatar = get_avatar_url($email, $width);
        if (!empty($avatar)) {
            if (is_array($avatar)) {
                $image = $avatar[0];
            } else {
                $image = $avatar;
            }
        }
    } else {
        $has_filter = has_filter('pre_option_show_avatars', '__return_true');
        if (!$has_filter) {
            add_filter('pre_option_show_avatars', '__return_true');
        }
        $avatar = get_avatar($email, $width);
        if (!$has_filter) {
            remove_filter('pre_option_show_avatars', '__return_true');
        }
        if (!empty($avatar) && !is_wp_error($avatar)) {
            if (preg_match('/src=["\']([^"\']+)["\']/', $avatar, $matches)) {
                $image = wp_specialchars_decode($matches[1], ENT_QUOTES);
            }
        }
    }
    return $image;
}
Ejemplo n.º 30
0
     echo '<div class="voters" id="voters">';
     // AdSense
     do_banner_story();
     print_story_tabs($tab_option);
     echo '<fieldset><legend>' . _('registro de eventos de la noticia') . '</legend>';
     echo '<div id="voters-container">';
     $logs = $db->get_results("select logs.*, user_id, user_login, user_avatar from logs, users where log_type in ('link_new', 'link_publish', 'link_discard', 'link_edit', 'link_geo_edit', 'link_depublished') and log_ref_id={$link->id} and user_id= log_user_id order by log_date asc");
     if ($logs) {
         //echo '<div class="voters-list">';
         foreach ($logs as $log) {
             echo '<div style="width:100%; display: block; clear: both; border-bottom: 1px solid #FFE2C5;">';
             echo '<div style="width:30%; float: left;padding: 4px 0 4px 0;">' . $log->log_date . '</div>';
             echo '<div style="width:24%; float: left;padding: 4px 0 4px 0;"><strong>' . $log->log_type . '</strong></div>';
             echo '<div style="width:45%; float: left;padding: 4px 0 4px 0;">';
             echo '<a href="' . get_user_uri($log->user_login) . '" title="' . $log->date . '">';
             echo '<img src="' . get_avatar_url($log->log_user_id, $log->user_avatar, 20) . '" width="20" height="20" alt="' . $log->user_login . '"/>&nbsp;';
             echo $log->user_login;
             echo '</a>';
             echo '</div>';
             echo '</div>';
         }
         //echo '</div>';
     } else {
         echo _('no hay registros');
     }
     echo '</div><br />';
     echo '</fieldset>';
     echo '</div>';
     break;
 case 5:
     // Micro sneaker