function widget($args, $instance) { $instance = array_merge(self::get_default_options(), $instance); echo $args['before_widget']; $comments = get_comments(array('status' => 'approve', 'number' => isset($instance['number']) ? (int) $instance['number'] : 6, 'type' => 'comment')); if (!empty($instance['title'])) { echo $args['before_title']; ?> <i class="fa fa-comments-o"></i> <?php echo $instance['title']; echo $args['after_title']; } if (!empty($comments)) { global $comment; $comment_bak = $comment; ?> <ul class="list-group"> <?php foreach ($comments as $comment) { /** * cache */ static $caches = []; /** author_name */ if (!isset($caches['author_name'][$comment->comment_author])) { $caches['author_name'][$comment->comment_author] = esc_html(get_comment_author()); } /** avatar placeholder */ if (!isset($caches['avatar_placeholder'])) { $caches['avatar_placeholder'] = theme_functions::$avatar_placeholder; } /** comment text */ $comment_text = str_sub(strip_tags(preg_replace('/<img[^>]+>/i', '[' . ___('Image') . ']', get_comment_text($comment->comment_ID))), 35); ?> <li class="list-group-item"> <a class="media tooltip top" href="<?php echo theme_cache::get_permalink($comment->comment_post_ID); ?> #comment-<?php echo $comment->comment_ID; ?> " title="<?php echo theme_cache::get_the_title($comment->comment_post_ID); ?> "> <div class="media-left"> <img class="avatar media-object" data-src="<?php echo esc_url(theme_cache::get_avatar_url($comment)); ?> " src="<?php echo $caches['avatar_placeholder']; ?> " alt="<?php echo $caches['author_name'][$comment->comment_author]; ?> " width="<?php echo self::$avatar_size; ?> " height="<?php echo self::$avatar_size; ?> "/> </div> <div class="media-body"> <h4 class="media-heading"> <span class="author"><?php echo $caches['author_name'][$comment->comment_author]; ?> </span> <time datetime="<?php echo get_comment_time('c'); ?> "> <small><?php echo friendly_date(get_comment_time('U')); ?> </small> </time> </h4> <div class="text"><?php echo $comment_text; ?> </div> </div> </a> </li> <?php } ?> </ul> <?php $comment = $comment_bak; } else { ?> <div class="content"> <div class="page-tip"><?php echo status_tip('info', ___('No any comment yet.')); ?> </div> </div> <?php } echo $args['after_widget']; }
<div class="panel"> <div class="content"> <?php echo theme_point_lottery::get_des(); ?> <form action="javascript:;" method="post" id="fm-lottery"> <div class="form-group my-info"> <span class="meta"> <img class="avatar" src="<?php echo theme_cache::get_avatar_url(theme_cache::get_current_user_id()); ?> " alt="<?php echo theme_cache::get_the_author_meta('display_name', theme_cache::get_current_user_id()); ?> " width="16" height="16"> <span class="author"><?php echo theme_cache::get_the_author_meta('display_name', theme_cache::get_current_user_id()); ?> </span> </span> <span class="meta"> <img src="<?php echo theme_custom_point::get_point_img_url(); ?> " alt="point-icon" width="16" height="16"> <span id="point-count"><?php echo theme_custom_point::get_point(theme_cache::get_current_user_id()); ?> </span><span id="modify-count"></span> </span> </div>
<div class="panel"> <div class="content"> <?php echo theme_custom_point_bomb::get_des(); ?> <div class="page-tip" id="fm-bomb-loading"><?php echo status_tip('loading', ___('Loading, please wait...')); ?> </div> <form class="form-horizontal" action="post" id="fm-bomb" method="javascript:;"> <div class="form-group"> <div class="g-tablet-2-5"> <div class="bomb-area bomb-area-attacker"> <p> <img id="bomb-attacker-avatar" src="<?php echo theme_cache::get_avatar_url($current_user->ID); ?> " alt="<?php echo ___('Avatar'); ?> " class="avatar" width="100" height="100" > </p> <p class="bomb-area-meta"> <?php echo $point_icon; ?> <strong id="bomb-attacker-points"> <?php echo theme_custom_point::get_point($current_user->ID); ?> </strong>
/** * Echo the user list within loop * * @param array $args * @return * @version 1.0.2 */ public static function the_user_list(array $args) { $args = array_merge(['classes' => 'g-phone-1-3', 'user_id' => null, 'extra_title' => '', 'extra' => 'point', 'target' => theme_functions::$link_target], $args); /** * extra point value */ switch ($args['extra']) { /** * user point */ case 'point': if (class_exists('theme_custom_point')) { $point_value = theme_custom_point::get_point($args['user_id']); } break; /** * user fav be_count */ /** * user fav be_count */ case 'fav': if (class_exists('custom_post_fav')) { $point_value = custom_post_fav::get_user_be_fav_count($args['user_id']); } break; /** * user posts count */ /** * user posts count */ case 'posts': if (class_exists('theme_custom_author_profile')) { $point_value = theme_custom_author_profile::get_count('works', $args['user_id']); } else { $point_value = count_user_posts($args['user_id']); } break; default: $point_value = null; } if (!empty($args['extra_title']) && $point_value) { $args['extra_title'] = str_replace('%', $point_value, $args['extra_title']); } $display_name = theme_cache::get_the_author_meta('display_name', $args['user_id']); $avatar_url = theme_cache::get_avatar_url($args['user_id']); ?> <div class="user-list <?php echo $args['classes']; ?> "> <a href="<?php echo theme_cache::get_author_posts_url($args['user_id']); ?> " title="<?php echo $display_name; ?> " target="<?php echo $args['target']; ?> " > <div class="avatar-container"> <img src="<?php echo theme_functions::$avatar_placeholder; ?> " data-src="<?php echo $avatar_url; ?> " alt="<?php echo $display_name; ?> " class="avatar"> </div> <h3 class="author"><?php echo $display_name; ?> </h3> <?php if ($args['extra']) { ?> <div class="extra"> <span class="<?php echo $args['extra']; ?> " title="<?php echo $args['extra_title']; ?> "> <?php echo number_format($point_value); ?> </span> </div> <?php } /** end args extra */ ?> </a> </div> <?php }
/** * list noti be-bomb */ public static function list_noti_be_bomb($noti) { if ($noti['type'] !== 'be-bomb') { return false; } if ($noti['hit']) { $points = '<strong class="label label-success">' . $noti['points'] . '</strong>'; } else { $points = '<strong class="label label-danger">+' . $noti['points'] . '</strong>'; } if (class_exists('number_user_nicename')) { $fight_back_url = self::get_tabs('bomb', $noti['attacker-id'] + number_user_nicename::$prefix_number)['url']; } else { $fight_back_url = self::get_tabs('bomb', $noti['attacker-id'])['url']; } ?> <div class="media"> <div class="media-left"> <a href="<?php theme_cache::get_author_posts_url($noti['attacker-id']); ?> "> <img src="<?php echo theme_cache::get_avatar_url($noti['attacker-id']); ?> " class="avatar media-object" alt="avatar" width="60" height="60"> </a> </div> <div class="media-body"> <h4 class="media-heading"> <a class="label label-default" href="<?php echo self::get_tabs('bomb')['url']; ?> "><i class="fa fa-<?php echo self::get_tabs('bomb')['icon']; ?> "></i> <?php echo ___('Bomb world'); ?> </a> <?php echo $points; ?> <?php theme_custom_point::the_time($noti); ?> <?php if ($noti['hit']) { ?> <a class="fight-back btn btn-danger btn-xs" href="<?php echo $fight_back_url; ?> " target="_blank"><strong><?php echo ___('It is time to fight back'); ?> <i class="fa fa-external-link"></i></strong></a> <?php } ?> </h4> <div class="excerpt"> <p> <?php $attacker_name = theme_cache::get_the_author_meta('display_name', $noti['attacker-id']); $attacker_name = '<a href="' . theme_cache::get_author_posts_url($noti['attacker-id']) . '" target="_blank">' . $attacker_name . '</a>'; if ($noti['hit']) { echo sprintf(___('%1$s bombed you and hit. You lost %2$s %3$s.'), $attacker_name, '<strong>' . (0 - abs($noti['points'])) . '</strong>', theme_custom_point::get_point_name()); } else { echo sprintf(___('%1$s bombed you but miss! You got %2$s %3$s.'), $attacker_name, '<strong>+' . abs($noti['points']) . '</strong>', theme_custom_point::get_point_name()); } ?> </p> </div> </div><!-- /.media-body --> </div><!-- /.media --> <?php }
public static function cache_request(array $output = []) { if (isset($_GET[self::$iden]) && is_array($_GET[self::$iden])) { $get = $_GET[self::$iden]; $post_id = isset($get['post-id']) && is_string($get['post-id']) ? (int) $get['post-id'] : null; $type = isset($get['type']) && is_string($get['type']) ? $get['type'] : null; switch ($type) { case 'get-comments': if (!$post_id) { return $output; } $post = theme_cache::get_post($post_id); $pages = theme_features::get_comment_pages_count(self::get_comments(['post_id' => $post->ID])); /** * cpage */ if (isset($get['capge']) && is_numeric($get['capge'])) { $cpage = (int) $get['capge']; } else { $cpage = theme_cache::get_option('default_comments_page') == 'newest' ? $pages : 1; } if (!theme_cache::is_user_logged_in()) { $commenter = wp_get_current_commenter(); $user_name = $commenter['comment_author']; $user_url = $commenter['comment_author_url']; $avatar_url = theme_cache::get_avatar_url($commenter['comment_author_email']); $user_email = $commenter['comment_author_email']; } else { global $current_user; get_currentuserinfo(); $user_name = $current_user->display_name; $user_url = theme_cache::get_author_posts_url($current_user->ID); $avatar_url = theme_cache::get_avatar_url($current_user->ID); } $output[self::$iden] = ['comments' => self::get_comments_list($post_id, $cpage), 'count' => $post ? $post->comment_count : 0, 'pages' => $pages, 'cpage' => $cpage, 'logged' => theme_cache::is_user_logged_in(), 'registration' => theme_cache::get_option('comment_registration'), 'user-name' => esc_html($user_name), 'user-url' => esc_url($user_url), 'avatar-url' => $avatar_url]; if (isset($user_email)) { $output[self::$iden]['user-email'] = $user_email; } break; } } return $output; }
public static function dynamic_request_process($datas) { if (theme_cache::is_user_logged_in()) { global $current_user; get_currentuserinfo(); $datas['user'] = array('logged' => true, 'display_name' => $current_user->display_name, 'posts_url' => theme_cache::get_author_posts_url($current_user->ID), 'logout_url' => wp_logout_url(theme_cache::home_url()), 'avatar_url' => theme_cache::get_avatar_url($current_user->ID)); } else { $datas['user'] = array('logged' => false); } return $datas; }
public static function get_userdata($user_id) { return ['name' => theme_cache::get_the_author_meta('display_name', $user_id), 'avatar' => theme_cache::get_avatar_url($user_id), 'description' => theme_cache::get_the_author_meta('description', $user_id), 'url' => theme_cache::get_author_posts_url($user_id)]; }
/** * list follow */ public static function list_noti_follow($noti) { if ($noti['type'] !== 'follow') { return false; } $follower_id = $v['follower-id']; ?> <div class="media"> <div class="media-left"> <a href="<?php comment_author_url(); ?> "> <img src="<?php echo theme_cache::get_avatar_url($follower_id); ?> " class="avatar media-object" alt="avatar" width="60" height="60"> </a> </div> <div class="media-body"> <h4 class="media-heading"> <?php echo sprintf(___('%s is following you.'), esc_url(get_comment_author_link())); ?> </h4> </div><!-- /.media-body --> </div><!-- /.media --> <?php }
public static function rank_img_content($args = []) { global $post; $args = array_merge(['classes' => '', 'lazyload' => true, 'excerpt' => true, 'index' => false, 'target' => theme_functions::$link_target], $args); $post_title = theme_cache::get_the_title($post->ID); $excerpt = get_the_excerpt(); if (!empty($excerpt)) { $excerpt = esc_html($excerpt); } $thumbnail_real_src = theme_functions::get_thumbnail_src($post->ID); ?> <div class="list-group-item <?php echo $args['classes']; ?> "> <div class="row"> <div class="g-tablet-1-6"> <a href="<?php echo theme_cache::get_permalink($post->ID); ?> " title="<?php echo $post_title; ?> " target="<?php echo $args['target']; ?> " class="thumbnail-container"> <?php if ($args['lazyload'] === true) { ?> <img class="thumbnail" src="<?php echo theme_functions::$thumbnail_placeholder; ?> " data-src="<?php echo $thumbnail_real_src; ?> " alt="<?php echo $post_title; ?> " width="<?php echo theme_functions::$thumbnail_size[1]; ?> " height="<?php echo theme_functions::$thumbnail_size[2]; ?> "> <?php } else { ?> <img class="thumbnail" src="<?php echo $thumbnail_real_src; ?> " alt="<?php echo $post_title; ?> " width="<?php echo theme_functions::$thumbnail_size[1]; ?> " height="<?php echo theme_functions::$thumbnail_size[2]; ?> "> <?php } ?> </a> </div> <div class="g-tablet-5-6"> <h3 class="media-heading"> <a href="<?php echo theme_cache::get_permalink($post->ID); ?> " title="<?php echo $post_title; ?> " target="<?php echo $args['target']; ?> " ><?php echo $post_title; ?> </a> </h3> <?php /** * output excerpt */ if ($args['excerpt'] === true) { ?> <div class="excerpt"><?php echo str_sub(strip_tags($excerpt), 200); ?> </div> <?php } ?> <div class="extra"> <div class="metas row"> <!-- author --> <a class="author meta g-phone-1-2 g-tablet-1-4 g-desktop-1-5" href="<?php echo theme_cache::get_author_posts_url($post->post_author); ?> " target="<?php echo $args['target']; ?> " > <img src="<?php echo theme_functions::$avatar_placeholder; ?> " data-src="<?php echo theme_cache::get_avatar_url($post->post_author); ?> " alt="avatar" width="16" height="16" class="avatar"> <?php echo theme_cache::get_the_author_meta('display_name', $post->post_author); ?> </a> <!-- category --> <div class="category meta g-phone-1-2 g-tablet-1-4 g-desktop-1-5"> <?php $cats = get_the_category_list('<i class="split"> / </i> '); if (!empty($cats)) { ?> <i class="fa fa-folder-open"></i> <?php echo $cats; ?> <?php } ?> </div> <!-- views --> <?php if (class_exists('theme_post_views') && theme_post_views::is_enabled()) { ?> <div class="view meta g-phone-1-2 g-tablet-1-4 g-desktop-1-5"> <i class="fa fa-play-circle"></i> <?php echo theme_post_views::get_views(); ?> </div> <?php } ?> <?php if (!wp_is_mobile()) { ?> <div class="comments meta g-phone-1-2 g-tablet-1-4 g-desktop-1-5"> <i class="fa fa-comment"></i> <?php echo (int) $post->comment_count; ?> </div> <?php } ?> <?php /** * point */ if (class_exists('custom_post_point')) { ?> <div class="point meta g-phone-1-2 g-tablet-1-4 g-desktop-1-5"> <i class="fa fa-paw"></i> <?php echo (int) custom_post_point::get_post_points_count($post->ID); ?> </div> <?php } ?> </div><!-- /.metas --> </div> <?php if ($args['index']) { ?> <i class="index"><?php echo $args['index']; ?> </i> <?php } ?> </div> </div> </div> <?php }