예제 #1
0
파일: widget.php 프로젝트: ClayMoreBoy/mx
    function widget($args = [], $instance = [])
    {
        $instance = array_merge(['title' => ___('User point rank'), 'total_number' => 100, 'rand_number' => 12], $instance);
        if ((int) $instance['total_number'] === 0 || (int) $instance['rand_number'] === 0) {
            return false;
        }
        echo $args['before_widget'];
        echo $args['before_title'];
        ?>
		<i class="fa fa-bar-chart"></i> <?php 
        echo $instance['title'];
        ?>
		<?php 
        echo $args['after_title'];
        $query = new WP_User_Query(['meta_key' => theme_custom_point::$user_meta_key['point'], 'orderby' => 'meta_value_num', 'order' => 'desc', 'number' => (int) $instance['total_number'], 'fields' => 'ID']);
        $users = $query->get_results();
        $count = count($users);
        if ($count < 2) {
            ?>
			<div class="content">
				<div class="page-tip"><?php 
            echo status_tip('info', ___('No matched user yet.'));
            ?>
</div>
			</div>
			<?php 
        } else {
            /**
             * rand
             */
            if ($instance['rand_number'] > $count) {
                $instance['rand_number'] = $count;
            }
            $rand_users = (array) array_rand($users, $instance['rand_number']);
            ?>
			<div class="content">
				<div class="user-lists row">
					<?php 
            $user = null;
            foreach ($rand_users as $k) {
                theme_functions::the_user_list(['user_id' => $users[$k], 'extra' => 'point', 'extra_title' => sprintf(__x('%s %s', 'eg. 20 points'), '%', theme_custom_point::get_point_name())]);
            }
            ?>
				</div>
			</div>
			<?php 
        }
        unset($query, $users, $rand_users);
        echo $args['after_widget'];
    }
예제 #2
0
$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 
    }
}
?>
<form id="fm-change-avatar" class="user-form form-horizontal" method="post" action="javascript:;">
	<fieldset <?php 
echo $disabled;
?>
>
		<legend class="label label-<?php 
echo $disabled ? 'default' : 'success';
?>
예제 #3
0
    public static function post_btn($post_id)
    {
        $point_img = theme_custom_point::get_point_img_url();
        $point_values = array_filter((array) self::get_point_values());
        $count_point_values = count($point_values);
        $default_point_value = $point_values[0];
        if ($count_point_values > 1) {
            sort($point_values);
        }
        ?>
		<div class="meta meta-post-point">
			<a 
				href="javascript:;" 
				class="post-point-btn" 
				title="<?php 
        echo sprintf(__x('Rate %d %s.', 'E.g. Rate 3 points'), $default_point_value, theme_custom_point::get_point_name());
        ?>
" 
				data-post-id="<?php 
        echo $post_id;
        ?>
" 
				data-points="<?php 
        echo $default_point_value;
        ?>
" 
			>
				<div id="post-point-number-<?php 
        echo $post_id;
        ?>
" class="number"><?php 
        echo number_format((int) self::get_post_points_count($post_id));
        ?>
</div>
				<div class="tx"><?php 
        echo ___('Rate it');
        ?>
</div>
			</a>
			<?php 
        if (!wp_is_mobile() && $count_point_values > 1) {
            ?>
				<div class="box">
					<?php 
            foreach ($point_values as $v) {
                $class = $v == $default_point_value ? 'active' : null;
                ?>
<a 
							href="javascript:;" 
							class="post-point-btn <?php 
                echo $class;
                ?>
" 
							title="<?php 
                echo sprintf(__x('Rate %d %s.', 'E.g. Rate 3 points'), $v, theme_custom_point::get_point_name());
                ?>
" 
							data-post-id="<?php 
                echo $post_id;
                ?>
" 
							data-points="<?php 
                echo $v;
                ?>
" 
						><?php 
                echo $v;
                ?>
</a><?php 
            }
            ?>
				</div>
			<?php 
        }
        ?>
		</div>
		<?php 
    }
예제 #4
0
    /**
     * 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 
    }
예제 #5
0
echo theme_custom_author_profile::get_tabs('comments', $author)['url'];
?>
">
						<?php 
$count_comments = theme_features::get_user_comments_count($author);
echo (int) $count_comments != 0 ? $count_comments : '-';
?>
						</a>
					</td>
				</tr>
				<?php 
if (class_exists('theme_custom_point')) {
    ?>
					<tr>
						<th><?php 
    echo theme_custom_point::get_point_name();
    ?>
</th>
						<td>
							<?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);
            ?>
    public static function list_noti($meta)
    {
        if ($meta['type'] !== self::$type_key) {
            return;
        }
        global $post;
        $post = theme_cache::get_post($meta['post-id']);
        setup_postdata($post);
        ?>
		<div class="media">
			<div class="media-left">
				<img src="<?php 
        echo theme_functions::$thumbnail_placeholder;
        ?>
" alt="<?php 
        echo ___('Preview image');
        ?>
" data-src="<?php 
        echo theme_functions::get_thumbnail_src($post->ID);
        ?>
" width="60" height="60" class="post-thumbnail media-object avatar">
			</div>
			<div class="media-body">
				<h4 class="media-heading">
					<span class="label label-default">
						<i class="fa fa-eye"></i> 
						<?php 
        echo ___('Per hundred views');
        ?>
					</span>
					<strong class="label label-danger">+<?php 
        echo $meta['points'];
        ?>
</strong> 
					<?php 
        theme_notification::the_time($meta);
        ?>
				</h4>
				<div class="excerpt">
					<p>
					<?php 
        echo sprintf(___('Your post %1$s reached per hundred views, %2$s %3$s. Views are %4$s.'), '<a href="' . theme_cache::get_permalink($post->ID) . '" target="_blank">' . theme_cache::get_the_title($post->ID) . ' <i class="fa fa-external-link"></i></a>', '<strong>+' . $meta['points'] . '</strong>', theme_custom_point::get_point_name(), '<strong>' . $meta['views'] . '</strong>');
        ?>
					</p>
				</div>
			</div><!-- /.media-body -->
		</div><!-- /.media -->
		<?php 
        wp_reset_postdata();
    }
예제 #7
0
    /**
     * list special-event
     */
    public static function list_noti_special_event($noti)
    {
        if ($noti['type'] !== 'special-event') {
            return false;
        }
        ?>
		<div class="media">
			<div class="media-left">
				<i class="fa fa-bullhorn"></i>
			</div>
			<div class="media-body">
				<h4 class="media-heading">
					<span class="label label-default"><i class="fa fa-info-circle"></i> <?php 
        echo ___('Special event');
        ?>
</span> 
					<?php 
        echo ___('Special event');
        ?>
					<?php 
        if ($noti['point'] > 0) {
            $tip_type = 'success';
            $sign = '+';
        } else {
            $tip_type = 'danger';
            $sign = '';
        }
        ?>
					<span class="label label-<?php 
        echo $tip_type;
        ?>
">
					<?php 
        echo theme_custom_point::get_point_name();
        ?>
					<?php 
        echo $sign, $noti['point'];
        ?>
</label>
				</h4>
				<div class="excerpt"><p><?php 
        echo $noti['event'];
        ?>
</p></div>
			</div>
		</div>
		<?php 
    }