/** * My statistics */ public static function my_statistics() { $current_user_id = theme_cache::get_current_user_id(); ?> <div class="panel"> <div class="heading"> <i class="fa fa-pie-chart"></i> <?php echo ___('My statistics'); ?> </div> <div class="content"> <a class="media" href="<?php echo theme_custom_user_settings::get_tabs('history')['url']; ?> " title="<?php echo ___('Views my histories'); ?> "> <div class="media-left"> <img class="media-object" src="<?php echo theme_custom_point::get_point_img_url(); ?> " alt=""> </div> <div class="media-body"> <h4 class="media-heading"><strong class="total-point"><?php echo number_format(theme_custom_point::get_point($current_user_id)); ?> </strong></h4> </div> </a> <div class="row"> <!-- posts count --> <div class="g-phone-1-2"> <?php echo sprintf(___('My posts: %s'), '<a href="' . theme_cache::get_author_posts_url($current_user_id) . '">' . theme_custom_author_profile::get_count('works', $current_user_id) . '</a>'); ?> </div> <!-- comments count --> <div class="g-phone-1-2"> <?php echo sprintf(___('My comments: %s'), '<a href="' . theme_custom_author_profile::get_tabs('comments', $current_user_id)['url'] . '">' . theme_custom_author_profile::get_count('comments', $current_user_id) . '</a>'); ?> </div> <!-- followers count --> <div class="g-phone-1-2"> <?php echo sprintf(___('My followers: %s'), '<a href="' . theme_custom_author_profile::get_tabs('followers_count', $current_user_id)['url'] . '">' . theme_custom_author_profile::get_count('followers_count', $current_user_id) . '</a>'); ?> </div> <!-- following count --> <div class="g-tablet-1-2 g-desktop-1-3"> <?php echo sprintf(___('My following: %s'), '<a href="' . theme_custom_author_profile::get_tabs('following_count', $current_user_id)['url'] . '">' . theme_custom_author_profile::get_count('following_count', $current_user_id) . '</a>'); ?> </div> </div> </div> </div> <?php }
<?php global $current_user; get_currentuserinfo(); ?> <div class="panel"> <div class="content"> <?php /** * consume points to modify avatar */ $disabled = null; if (class_exists('theme_custom_point')) { $consume_points = abs(theme_custom_point::get_point_value('save-avatar')); $user_points = theme_custom_point::get_point($current_user->ID); if ($consume_points != 0) { ?> <div class="page-tip"> <?php /** * not enough points, can not modify */ if ($consume_points > $user_points) { $disabled = 'disabled'; echo status_tip('info', sprintf(___('You have %1$s %2$s, You need to collect %3$s %2$s to modify the avatar.'), '<strong>' . $user_points . '</strong>', theme_custom_point::get_point_name(), '<strong>' . ($consume_points - $user_points) . '</strong>')); } else { echo status_tip('info', sprintf(___('You have %1$s %2$s, modify avatar will consume %3$s %2$s.'), '<strong>' . $user_points . '</strong>', theme_custom_point::get_point_name(), '<strong>' . $consume_points . '</strong>')); } ?> </div> <?php
<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> </p> <p class="bomb-area-meta"> <?php echo esc_html($current_user->display_name); ?> </p> </div> </div><!-- .g-tablet-2-5 --> <div class="g-tablet-1-5 bomb-area-points"> <h4><?php echo ___('Bomb number'); ?>
<div class="panel"> <div class="content"> <?php echo theme_custom_point::get_point_des(); ?> <div class="media"> <div class="media-left"> <img class="media-object" src="<?php echo theme_custom_point::get_point_img_url(); ?> " alt=""> </div> <div class="media-body"> <h4 class="media-heading"> <strong class="total-point"><?php echo number_format(theme_custom_point::get_point(theme_cache::get_current_user_id())); ?> </strong> </h4> </div> </div> </div><!-- /.content --> <?php $history_list = theme_custom_point::get_history_list(array('posts_per_page' => 20)); if (empty($history_list)) { ?> <div class="content"> <div class="page-tip"><?php echo status_tip('info', ___('Your have not any history yet.')); ?> </div>
public static function process() { theme_features::check_referer(); theme_features::check_nonce(); $output = []; $type = isset($_REQUEST['type']) && is_string($_REQUEST['type']) ? $_REQUEST['type'] : null; $target_id = isset($_REQUEST['target']) && is_numeric($_REQUEST['target']) ? $_REQUEST['target'] : null; switch ($type) { case 'get-target': /** * check login */ $current_user_id = self::check_login(); /** * check times */ self::check_max_times(); /** * get target */ $target = self::check_target($target_id); $output = ['status' => 'success', 'points' => theme_custom_point::get_point($target_id), 'avatar' => theme_cache::get_avatar_url($target_id), 'name' => esc_html($target->display_name), 'msg' => ___('Target locked, bomb is ready.')]; die(theme_features::json_format($output)); /** * bomb */ /** * bomb */ case 'bomb': /** * check login */ $current_user_id = self::check_login(); /** * check times */ self::check_max_times(); /** * get target */ $target = self::check_target($target_id); /** * check points */ $points = isset($_REQUEST['points']) && is_numeric($_REQUEST['points']) ? $_REQUEST['points'] : null; if (!$points || !in_array($points, self::get_point_values())) { die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_point_value', 'msg' => ___('Sorry, the point value is invaild.'), 'points' => self::get_point_values()])); } /** * check target points */ $target_points = theme_custom_point::get_point($target_id); if ($points > $target_points) { die(theme_features::json_format(['status' => 'error', 'code' => 'target_points_not_enough', 'msg' => sprintf(___('Sorry, the target %s is not enough to bear your bomb.'), theme_custom_point::get_point_name())])); } /** * check attacker points */ $attacker_id = theme_cache::get_current_user_id(); $attacker_points = theme_custom_point::get_point($attacker_id); if ($points > $attacker_points) { die(theme_features::json_format(['status' => 'error', 'code' => 'attacker_points_not_enough', 'msg' => sprintf(___('Sorry, your %s is not enough to bomb target.'), theme_custom_point::get_point_name())])); } /** * pass */ $says = isset($_REQUEST['says']) && is_string($_REQUEST['says']) ? mb_substr($_REQUEST['says'], 0, 30) : false; /** * define $hit */ $hit = false; if (mt_rand(0, 100) <= self::get_victory_percent()) { $hit = true; } /** * define data */ $data = ['attacker-id' => $current_user_id, 'target-id' => $target_id, 'says' => $says, 'points' => $points, 'hit' => $hit]; /** add history for target */ self::add_history_for_target($data); /** add history for attacker */ self::add_history_for_attacker($data); //self::add_noti_for_target($current_user_id,$target_id,$points,$hit); /** * new target points */ $target_extra_points = self::get_extra_points_for_target($hit, $points); $new_target_points = $target_points + $target_extra_points; /** * new attacker points */ $attacker_extra_points = self::get_extra_points_for_attacker($hit, $points); $new_attacker_points = $attacker_points + $attacker_extra_points; /** update attacker points */ theme_custom_point::update_user_points($attacker_id, $new_attacker_points); /** update target points */ theme_custom_point::update_user_points($target_id, $new_target_points); $target_name = '<a href="' . theme_cache::get_author_posts_url($target_id) . '" target="_blank" class="author">' . esc_html($target->display_name) . '</a>'; /** * hit target */ if ($hit) { $output['msg'] = sprintf(___('Bombing successfully! Your bomb hit %1$s, you got %2$s %3$s. Target remaining %4$s %3$s.'), $target_name, '<strong class="plus">+' . $attacker_extra_points . '</strong>', theme_custom_point::get_point_name(), $new_target_points); /** * miss target */ } else { $output['msg'] = sprintf(___('Unlucky! %1$s miss your attack, you lost %2$s %3$s and remaining %4$s %3$s.'), $target_name, '<strong class="mins">' . $attacker_extra_points . '</strong>', theme_custom_point::get_point_name(), $new_attacker_points); } $output['hit'] = $hit; $output['status'] = 'success'; /** * set times */ self::set_times(self::get_times() + 1); die(theme_features::json_format($output)); default: die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_type_param', 'msg' => ___('Sorry, type param is invaild.')])); } }
" 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="form-group"> <?php $boxes = theme_point_lottery::get_box(); if (empty($boxes)) { echo status_tip('info', ___('No any lottery yet.')); } else { foreach ($boxes as $k => $box) { if ($box['type'] === 'point') { $icon = '<img src="' . theme_custom_point::get_point_img_url() . '" alt="icon" width="16" height="16">'; } else { $icon = '<i class="fa fa-yelp fa-fw"></i>';
/** * 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 }
public static function process() { $output = []; theme_features::check_referer(); theme_features::check_nonce(); $type = isset($_REQUEST['type']) && is_string($_REQUEST['type']) ? $_REQUEST['type'] : null; $user = isset($_POST['user']) && is_array($_POST['user']) ? $_POST['user'] : null; /** * get current */ global $current_user; get_currentuserinfo(); switch ($type) { /** * settings */ case 'settings': /** * check point is enough */ if (class_exists('theme_custom_point')) { /** get current user points */ $user_points = theme_custom_point::get_point($current_user->ID); if ($user_points - abs(theme_custom_point::get_point_value('save-' . $type)) < 0) { die(theme_features::json_format(['status' => 'error', 'code' => 'not_enough_point', 'msg' => ___('Sorry, your points are not enough to modify settings.')])); } } if (empty($_POST['user']) || !is_array($_POST['user'])) { $output['status'] = 'error'; $output['code'] = 'invaild_param'; $output['msg'] = ___('Invaild param.'); die(theme_features::json_format($output)); } $nickname = isset($user['nickname']) && is_string($user['nickname']) ? trim($user['nickname']) : null; if (empty($nickname)) { $output['status'] = 'error'; $output['code'] = 'invaild_nickname'; $output['msg'] = ___('Invaild nickname.'); die(theme_features::json_format($output)); } $url = isset($user['url']) && is_string($user['url']) ? esc_url($user['url']) : null; $des = isset($user['description']) && is_string($user['description']) ? $user['description'] : null; $user_id = wp_update_user(array('ID' => $current_user->ID, 'user_url' => $url, 'nickname' => $nickname, 'description' => $des, 'display_name' => $nickname)); if (is_wp_error($user_id)) { $output['status'] = 'error'; $output['code'] = $user_id->get_error_code(); $output['msg'] = $user_id->get_error_message(); die(theme_features::json_format($output)); } else { /** * add point history */ if (class_exists('theme_custom_point')) { $meta = ['type' => 'save-' . $type, 'points' => 0 - abs(theme_custom_point::get_point_value('save-' . $type)), 'timestamp' => current_time('timestamp')]; add_user_meta($current_user->ID, theme_custom_point::$user_meta_key['history'], $meta); /** * update points */ update_user_meta($current_user->ID, theme_custom_point::$user_meta_key['point'], $user_points - abs(theme_custom_point::get_point_value('save-' . $type))); /** * feelback */ $output['points'] = 0 - abs(theme_custom_point::get_point_value('save-' . $type)); } $output['status'] = 'success'; $output['msg'] = ___('Your settings have been saved.'); die(theme_features::json_format($output)); } break; /** * pwd */ /** * pwd */ case 'pwd': /** * twice pwd */ $new_pwd_1 = isset($user['new-pwd-1']) && is_string($user['new-pwd-1']) ? trim($user['new-pwd-1']) : null; $new_pwd_2 = isset($user['new-pwd-2']) && is_string($user['new-pwd-2']) ? trim($user['new-pwd-2']) : null; if (empty($new_pwd_1) || $new_pwd_1 !== $new_pwd_2) { $output['status'] = 'error'; $output['code'] = 'invaild_pwd_twice'; $output['msg'] = ___('Password invaild twice.'); die(theme_features::json_format($output)); } /** * old pwd */ $old_pwd = isset($user['old-pwd']) && is_string($user['old-pwd']) ? trim($user['old-pwd']) : null; if (empty($old_pwd) || !wp_check_password($old_pwd, $current_user->user_pass, $current_user->ID)) { $output['status'] = 'error'; $output['code'] = 'invaild_old_pwd'; $output['msg'] = ___('Invaild current password.'); die(theme_features::json_format($output)); } /** * change password */ wp_update_user(array('ID' => $current_user->ID, 'user_pass' => $new_pwd_1)); /** * set current, relogin */ wp_set_current_user($current_user->ID); wp_set_auth_cookie($current_user->ID); $output['status'] = 'success'; $output['msg'] = ___('Your new password has been saved.'); $output['redirect'] = theme_cache::home_url(); die(theme_features::json_format($output)); break; /** * avatar */ /** * avatar */ case 'avatar': /** * check point is enough */ if (class_exists('theme_custom_point')) { /** get current user points */ $user_points = theme_custom_point::get_point($current_user->ID); if ($user_points - abs(theme_custom_point::get_point_value('save-' . $type)) < 0) { die(theme_features::json_format(['status' => 'error', 'code' => 'not_enough_point', 'msg' => ___('Sorry, your points are not enough to modify avatar.')])); } } $base64 = isset($_POST['b4']) && is_string($_POST['b4']) ? explode(',', $_POST['b4']) : null; if (!isset($base64[0]) && strpos($base64[0], 'jpeg') === false) { $output['status'] = 'error'; $output['code'] = 'invaild_format'; $output['msg'] = ___('Sorry, your file is invaild format, please check it again.'); die(theme_features::json_format($output)); } $wp_uplaod_dir = wp_upload_dir(); $filename = $current_user->ID . '.jpg'; $filesub_url = '/avatar/' . $filename; $timestamp = '?v=' . $_SERVER['REQUEST_TIME']; if (!is_dir($wp_uplaod_dir['basedir'] . '/avatar')) { mkdir($wp_uplaod_dir['basedir'] . '/avatar', 0755, true); } $filepath = $wp_uplaod_dir['basedir'] . $filesub_url; $fileurl = $wp_uplaod_dir['baseurl'] . $filesub_url . $timestamp; $file_contents = file_put_contents($filepath, base64_decode($base64[1])); if ($file_contents === false) { $output['status'] = 'error'; $output['code'] = 'can_not_write_file'; $output['msg'] = ___('Sorry, system can not write file, please try again later or contact the administrator.'); die(theme_features::json_format($output)); } else { /** * add point history */ if (class_exists('theme_custom_point')) { $meta = ['type' => 'save-' . $type, 'points' => 0 - abs(theme_custom_point::get_point_value('save-' . $type)), 'timestamp' => current_time('timestamp')]; add_user_meta($current_user->ID, theme_custom_point::$user_meta_key['history'], $meta); /** * update points */ update_user_meta($current_user->ID, theme_custom_point::$user_meta_key['point'], $user_points - abs(theme_custom_point::get_point_value('save-' . $type))); /** * feelback */ $output['points'] = 0 - abs(theme_custom_point::get_point_value('save-' . $type)); } /** * update user meta for avatar */ $avatar_meta_key = class_exists('theme_custom_avatar') ? theme_custom_avatar::$user_meta_key['avatar'] : 'avatar'; update_user_meta($current_user->ID, $avatar_meta_key, $filesub_url . $timestamp); $output['status'] = 'success'; $output['avatar-url'] = $fileurl; $output['msg'] = ___('Congratulation! Your avatar has been updated. Page is redirecting, please wait...'); die(theme_features::json_format($output)); } break; default: $output['status'] = 'error'; $output['code'] = 'invaild_type_param'; $output['msg'] = ___('Sorry, the type param is invaild.'); die(theme_features::json_format($output)); } }
<?php if (theme_custom_point::get_point($author) > 0) { if (class_exists('theme_custom_point_bomb')) { ?> <a href="<?php echo theme_custom_point_bomb::get_tabs('bomb', get_the_author_meta('nicename', $author))['url']; ?> "> <i class="fa fa-bomb"></i> <?php echo theme_custom_point::get_point($author); ?> </a> <?php } else { echo theme_custom_point::get_point($author); } } else { ?> 0 <?php } ?> </td> </tr> <?php } ?> <!-- pm --> <?php if (class_exists('theme_custom_pm')) {
function widget($args, $instance) { global $post; $author_id = $post->post_author; echo $args['before_widget']; /** * author profile page url */ if (class_exists('theme_custom_author_profile')) { $author_url = theme_custom_author_profile::get_tabs('profile', $author_id)['url']; } else { $author_url = theme_cache::get_author_posts_url($author_id); } $description = theme_cache::get_the_author_meta('description', $author_id); ?> <div id="widget-author-card" class="widget-container content"> <a href="<?php echo $author_url; ?> " class="author-link" title="<?php echo ___('Views the author information detail'); ?> "> <?php echo theme_cache::get_avatar($author_id, 100); ?> <h3 class="author-card-name"> <?php echo theme_cache::get_the_author_meta('display_name', $author_id); ?> </h3> <?php if (class_exists('theme_custom_author_profile')) { ?> <small class="label label-<?php echo theme_custom_author_profile::get_roles($author_id)['label']; ?> "><?php echo theme_custom_author_profile::get_roles($author_id)['name']; ?> </small> <?php } ?> </a><!-- ./author-link --> <p class="author-card-description" title="<?php echo $description; ?> " > <?php if (empty($description)) { echo ___('The author is lazy, nothing writes here.'); } else { echo $description; } ?> </p> <?php if (class_exists('theme_custom_author_profile')) { ?> <div class="author-card-meta-links"> <!-- works count --> <a class="tooltip" href="<?php echo theme_custom_author_profile::get_tabs('works', $author_id)['url']; ?> " title="<?php echo ___('Views author posts'); ?> " target="_blank"> <span class="tx"><i class="fa fa-fw fa-<?php echo theme_custom_author_profile::get_tabs('works', $author_id)['icon']; ?> "></i></span> <span class="count"><?php echo (int) theme_custom_author_profile::get_tabs('works', $author_id)['count']; ?> </span> </a> <!-- comments count --> <a class="tooltip" href="<?php echo theme_custom_author_profile::get_tabs('comments', $author_id)['url']; ?> " title="<?php echo ___('Views author comments'); ?> " target="_blank"> <span class="tx"><i class="fa fa-fw fa-<?php echo theme_custom_author_profile::get_tabs('comments', $author_id)['icon']; ?> "></i></span> <span class="count"><?php echo (int) theme_custom_author_profile::get_tabs('comments', $author_id)['count']; ?> </span> </a> <!-- point --> <?php if (class_exists('theme_custom_point_bomb')) { if (class_exists('number_user_nicename')) { $target_id = number_user_nicename::$prefix_number + $author_id; } else { $target_id = $author_id; } ?> <!-- followers count --> <a class="tooltip" href="<?php echo theme_custom_point_bomb::get_tabs('bomb', $target_id)['url']; ?> " rel="nofollow" title="<?php echo ___('Bomb!'); ?> " target="_blank"> <span class="tx"><i class="fa fa-fw fa-bomb"></i></span> <span class="count"><?php echo theme_custom_point::get_point($author_id); ?> </span> </a> <?php } ?> <!-- pm --> <?php if (class_exists('theme_custom_pm')) { ?> <a target="_blank" class="tooltip" href="<?php echo theme_custom_pm::get_user_pm_url($author_id); ?> " title="<?php echo ___('Send a private message.'); ?> "> <span class="tx"><i class="fa fa-<?php echo theme_custom_pm::get_tabs('pm')['icon']; ?> "></i></span><span class="count"><?php echo __x('P.M.', 'Widget author card PM.'); ?> </span> </a> <?php } ?> </div> <?php } ?> </div> <?php echo $args['after_widget']; }
public static function action_update_postmeta($meta_id, $object_id, $meta_key, $meta_value) { if ($meta_key !== self::$post_meta_key) { return; } /** only run once */ static $i = 0; if ($i !== 0) { return; } ++$i; if (self::is_max_times($object_id)) { $user_id = theme_cache::get_post($object_id)->post_author; $new_point = theme_custom_point::get_point($user_id) + self::get_points_value(); /** update user point */ theme_custom_point::update_user_points($user_id, $new_point); /** add history */ self::add_history_views_per_hundred($object_id); /** add noti */ //self::add_noti_views_per_hundred($object_id); /** reset times */ self::reset_times($object_id); return; } /** * if new post, reset times */ if (self::get_times($object_id) == 0) { self::reset_times($object_id); } }