Пример #1
0
    public static function recent_posts()
    {
        $posts_per_page = 5;
        ?>
		<div class="panel">
			<div class="heading">
				<i class="fa fa-clock-o"></i>
				<?php 
        echo ___('My recent posts');
        ?>
			</div>
			<?php 
        global $post;
        $query = new WP_Query(array('posts_per_page' => $posts_per_page, 'author' => theme_cache::get_current_user_id()));
        if ($query->have_posts()) {
            ?>
				<ul class="list-group">
				<?php 
            foreach ($query->posts as $post) {
                setup_postdata($post);
                ?>
					<li class="list-group-item">
						<a href="<?php 
                echo theme_cache::get_permalink($post->ID);
                ?>
"><?php 
                echo theme_cache::get_the_title($post->ID);
                ?>
 <small><?php 
                echo friendly_date(get_the_time('U'));
                ?>
</small></a>
						
					</li>
					<?php 
            }
            wp_reset_postdata();
            ?>
				</ul>
				<?php 
        } else {
            ?>
				<div class="content"><?php 
            echo status_tip('info', ___('No posts yet'));
            ?>
</div>
				<?php 
        }
        ?>
		</div>
		<?php 
    }
Пример #2
0
/**
 * Post form
 *
 * @return 
 * @version 1.0.0
 */
function post_form($post_id = null)
{
    $edit = false;
    $post_title = null;
    $post_content = null;
    $post_excerpt = null;
    /**
     * edit
     */
    if (is_numeric($post_id)) {
        /**
         * check post exists
         */
        global $post;
        $post = theme_cache::get_post($post_id);
        if (!$post || !theme_custom_contribution::in_edit_post_status($post->post_status) || $post->post_type !== 'post') {
            ?>
			<div class="page-tip"><?php 
            echo status_tip('error', ___('Sorry, the post does not exist.'));
            ?>
</div>
			<?php 
            wp_reset_postdata();
            return false;
        }
        /**
         * check post category in collection category
         */
        if (class_exists('theme_custom_collection') && !empty(theme_custom_collection::get_cat_ids())) {
            foreach (get_the_category($post_id) as $v) {
                if (in_array($v->term_id, theme_custom_collection::get_cat_ids())) {
                    ?>
					<div class="page-tip"><?php 
                    echo status_tip('error', ___('Sorry, collection edits feature is not supported currently.'));
                    ?>
</div>
					<?php 
                    wp_reset_postdata();
                    return false;
                }
                break;
            }
        }
        /**
         * check author
         */
        if ($post->post_author != theme_cache::get_current_user_id()) {
            ?>
			<div class="page-tip"><?php 
            echo status_tip('error', ___('Sorry, you are not the post author, can not edit it.'));
            ?>
</div>
			<?php 
            return false;
            wp_reset_postdata();
        }
        setup_postdata($post);
        /**
         * check edit lock status
         */
        $lock_user_id = theme_custom_contribution::wp_check_post_lock($post_id);
        if ($lock_user_id) {
            ?>
			<div class="page-tip"><?php 
            echo status_tip('error', ___('Sorry, you can not edit this post now, because editor is editing. Please wait a minute...'));
            ?>
</div>
			<?php 
            return false;
        }
        $edit = true;
        $post_title = $post->post_title;
        $post_content = $post->post_content;
        $post_excerpt = stripslashes($post->post_excerpt);
    }
    ?>
	
	<?php 
    echo theme_custom_contribution::get_des();
    ?>
	<div id="fm-ctb-loading" class="page-tip"><?php 
    echo status_tip('loading', ___('Loading, please wait...'));
    ?>
</div>
	<form action="javascript:;" id="fm-ctb" class="form-horizontal" hidden>
		<div class="form-group">
			<label for="ctb-title" class="g-tablet-1-6 control-label">
				<?php 
    echo ___('Post title');
    ?>
			</label>
			<div class="g-tablet-5-6">
				<input 
					type="text" 
					name="ctb[post-title]"
					class="form-control" 
					id="ctb-title" 
					placeholder="<?php 
    echo ___('Post title (require)');
    ?>
" 
					title="<?php 
    echo ___('Post title must to write');
    ?>
" 
					value="<?php 
    echo esc_attr($post_title);
    ?>
" 
					required 
					autofocus
				>
			</div>
		</div>
		<!-- post excerpt -->
		<div class="form-group">
			<label for="ctb-excerpt" class="g-tablet-1-6 control-label">
				<?php 
    echo ___('Post excerpt');
    ?>
			</label>
			<div class="g-tablet-5-6">
				<textarea name="ctb[post-excerpt]" id="ctb-excerpt" rows="3" class="form-control" placeholder="<?php 
    echo ___('Your can write excerpt for describe the post, it will show every page nagination header.');
    ?>
"><?php 
    echo $post_excerpt;
    ?>
</textarea>
			</div>
		</div>
		<!-- post content -->
		<div class="form-group">
			<div class="g-tablet-1-1">
			<label for="ctb-content" >
				<?php 
    echo ___('Post content');
    ?>
			</label>
				<?php 
    wp_editor($post_content, 'ctb-content', ['textarea_name' => 'ctb[post-content]', 'drag_drop_upload' => false, 'teeny' => false, 'media_buttons' => false, 'editor_class' => 'form-control']);
    ?>
			</div>
		</div>
		
		
		<!-- upload image -->
		<div class="form-group">
			<div class="g-tablet-1-6 control-label">
				<i class="fa fa-image"></i>
				<?php 
    echo ___('Upload preview image');
    ?>
			</div>
			<div class="g-tablet-5-6">
				<div id="ctb-file-area">
					<div class="" id="ctb-file-btn">
						<i class="fa fa-upload"></i>
						<?php 
    echo ___('Select or Drag images');
    ?>
						<input type="file" id="ctb-file" multiple >
					</div>
				</div>
				<!-- upload progress -->
				<div id="ctb-file-progress-container" class="progress">
					<div id="ctb-file-progress" class="progress-bar progress-bar-success progress-bar-striped active"></div>
				</div>
				
				<!-- file tool -->
				<div id="ctb-file-tool" class="row">
					<div class="g-tablet-1-2">
					<!-- batch insert -->
						<a href="javascript:;" id="ctb-batch-insert-btn" class="btn btn-primary btn-block">
							<i class="fa fa-plug"></i> <?php 
    echo ___('Batch insert images to content');
    ?>
						</a>
					</div>
					<div class="g-tablet-1-2">
						<select id="ctb-split-number" class="form-control" title="<?php 
    echo ___('How many images to split with next-page tag?');
    ?>
">
							<option value="0"><?php 
    echo ___('Do not use next-page tag');
    ?>
</option>
							<?php 
    for ($i = 1; $i <= 10; ++$i) {
        ?>
								<option value="<?php 
        echo $i;
        ?>
"><?php 
        echo sprintf(___('%d image(s) / page'), $i);
        ?>
</option>
							<?php 
    }
    ?>
						</select>
					</div>
				</div>

				
				<!-- file completion -->
				<div id="ctb-file-completion"></div>

				
				<!-- files -->
				<div id="ctb-files" class="row"></div>
				
			</div>
		</div>

		
<!-- storage -->
<?php 
    if (class_exists('theme_custom_storage') && theme_custom_storage::is_enabled()) {
        ?>
	<div class="form-group theme_custom_storage-group">
		<div class="g-tablet-1-6 control-label">
			<i class="fa fa-cloud-download"></i>
			<?php 
        echo ___('Storage link');
        ?>
		</div>
		<div class="g-tablet-5-6">
			<?php 
        echo theme_custom_storage::display_frontend_contribution($post_id);
        ?>
		</div>
	</div>
<?php 
        /**
         * end theme_custom_storage
         */
    }
    ?>
		



		<!-- cats -->
		<div class="form-group">
			<div class="g-tablet-1-6 control-label">
				<i class="fa fa-folder-open"></i>
				<?php 
    echo ___('Category');
    ?>
			</div>
			<div class="g-tablet-5-6" id="ctb-cat-container">
				<?php 
    if ($edit) {
        $selected_cat_id = 0;
        $cats = get_the_category($post->ID);
        if (isset($cats[0]->term_id)) {
            $selected_cat_id = $cats[0]->term_id;
        }
        foreach ($cats as $cat) {
            if ($cat->parent != 0) {
                $selected_cat_id = $cat->term_id;
            }
        }
        wp_dropdown_categories(['id' => 'ctb-cat', 'name' => 'ctb[cat]', 'class' => 'form-control', 'selected' => $selected_cat_id, 'show_option_none' => ___('Select category'), 'hierarchical' => true, 'hide_empty' => false, 'include' => (array) theme_custom_contribution::get_cat_ids()]);
    }
    ?>
			</div>
		</div>





		
		<!-- tags -->
		<div class="form-group">
			<div class="g-tablet-1-6 control-label">
				<i class="fa fa-tags"></i> 
				<?php 
    echo ___('Pop. tags');
    ?>
			</div>
			<div class="g-tablet-5-6">
				<div class="checkbox-select">
					<?php 
    $tags_args = ['orderby' => 'count', 'order' => 'desc', 'hide_empty' => 0, 'number' => theme_custom_contribution::get_options('tags-number') ? theme_custom_contribution::get_options('tags-number') : 16];
    $tags_ids = theme_custom_contribution::get_options('tags');
    if (empty($tag_ids)) {
        $tags = get_tags($tags_args);
    } else {
        $tags = get_tags(['include' => implode($tags_ids), 'orderby' => 'count', 'order' => 'desc', 'hide_empty' => 0]);
    }
    /**
     * edit
     */
    if ($edit) {
        $exist_tags = [];
        $post_tags = get_the_tags($post->ID);
        if ($post_tags) {
            foreach ($post_tags as $v) {
                $v->selected = true;
                array_unshift($tags, $v);
            }
        }
    }
    foreach ($tags as $tag) {
        if ($edit) {
            if (isset($exist_tags[$tag->term_id])) {
                continue;
            } else {
                $exist_tags[$tag->term_id] = 1;
            }
        }
        $tag_name = esc_html($tag->name);
        ?>
						<label class="ctb-tag" for="ctb-tags-<?php 
        echo $tag->term_id;
        ?>
">
							<input 
								class="ctb-preset-tag" 
								type="checkbox" 
								id="ctb-tags-<?php 
        echo $tag->term_id;
        ?>
" 
								name="ctb[tags][]" 
								value="<?php 
        echo $tag_name;
        ?>
"
								hidden 
								<?php 
        echo isset($tag->selected) ? 'checked' : null;
        ?>
							>
							<span class="label label-default">
								<?php 
        echo $tag_name;
        ?>
							</span>
						</label>
						
					<?php 
    }
    ?>
				</div>
			</div>
		</div>
		
		<!-- custom tags -->
		<div class="form-group">
			<div class="g-tablet-1-6 control-label">
				<i class="fa fa-tag"></i> 
				<?php 
    echo ___('Custom tags');
    ?>
			</div>
			<div class="g-tablet-5-6">
				<div class="row">
					<?php 
    for ($i = 0; $i <= 3; ++$i) {
        ?>
						<div class="g-phone-1-2 g-tablet-1-4">
							<input id="ctb-custom-tag-<?php 
        echo $i;
        ?>
" class="ctb-custom-tag form-control" type="text" name="ctb[tags][]" placeholder="<?php 
        echo sprintf(___('Custom tag %d'), $i + 1);
        ?>
" >
						</div>
					<?php 
    }
    ?>
				</div>
			</div>
		</div>


		<!-- source -->
		<?php 
    if (class_exists('theme_custom_post_source') && theme_custom_post_source::is_enabled()) {
        if ($edit) {
            $post_source_meta = theme_custom_post_source::get_post_meta($post->ID);
        } else {
            $post_source_meta = null;
        }
        ?>
			<div class="form-group">
				<div class="g-tablet-1-6 control-label">
					<i class="fa fa-truck"></i> 
					<?php 
        echo ___('Source');
        ?>
				</div>
				<div class="g-tablet-5-6">
					<label class="radio-inline" for="theme_custom_post_source-source-original">
						<input 
							type="radio" 
							name="theme_custom_post_source[source]" 
							id="theme_custom_post_source-source-original" 
							value="original" 
							class="theme_custom_post_source-source-radio" 
							<?php 
        echo !isset($post_source_meta['source']) || $post_source_meta['source'] === 'original' ? 'checked' : null;
        ?>
 
							target="theme_custom_post_source-input-original" 
						>
						<?php 
        echo ___('Original');
        ?>
					</label>
					<label class="radio-inline" for="theme_custom_post_source-source-reprint">
						<input 
							type="radio" 
							name="theme_custom_post_source[source]" 
							id="theme_custom_post_source-source-reprint" 
							value="reprint" 
							class="theme_custom_post_source-source-radio" 
							<?php 
        echo isset($post_source_meta['source']) && $post_source_meta['source'] === 'reprint' ? 'checked' : null;
        ?>
 
							target="theme_custom_post_source-input-reprint" 
						>
						<?php 
        echo ___('Reprint');
        ?>
					</label>
					<div class="row theme_custom_post_source-inputs" id="theme_custom_post_source-input-reprint" >
						<div class="g-tablet-1-2">
							<div class="input-group">
								<label class="addon" for="theme_custom_post_source-reprint-url">
									<i class="fa fa-link"></i>
								</label>
								<input 
									type="url" 
									class="form-control" 
									name="theme_custom_post_source[reprint][url]" 
									id="theme_custom_post_source-reprint-url" 
									placeholder="<?php 
        echo ___('The source of work URL, includes http://');
        ?>
" 
									title="<?php 
        echo ___('The source of work URL, includes http://');
        ?>
"
									value="<?php 
        echo isset($post_source_meta['reprint']['url']) ? $post_source_meta['reprint']['url'] : null;
        ?>
"
								>
							</div>
						</div>
						<div class="g-tablet-1-2">
							<div class="input-group">
								<label class="addon" for="theme_custom_post_source-reprint-author">
									<i class="fa fa-user"></i>
								</label>
								<input 
									type="text" 
									class="form-control" 
									name="theme_custom_post_source[reprint][author]" 
									id="theme_custom_post_source-reprint-author" 
									placeholder="<?php 
        echo ___('Author');
        ?>
" 
									title="<?php 
        echo ___('Author');
        ?>
"
									value="<?php 
        echo isset($post_source_meta['reprint']['author']) ? esc_attr($post_source_meta['reprint']['author']) : null;
        ?>
"
								>
							</div>
						</div>
					</div>
				</div>
			</div>
		<?php 
    }
    /** end theme_custom_post_source */
    ?>

		
		<!-- submit -->
		<div class="form-group">
			<div class="g-tablet-1-6">
				<a href="javascript:;" id="ctb-quick-save" class="btn btn-block btn-default btn-lg" title="<?php 
    echo ___('The post data will be saved automatically per minute in your current borwser, you can also save it now manually.');
    ?>
">
					<i class="fa fa-save"></i> <?php 
    echo ___('Quick save');
    ?>
				</a>
			</div>
			<div class="g-tablet-5-6">
				
				<button type="submit" class="btn btn-lg btn-success btn-block submit" data-loading-text="<?php 
    echo ___('Sending, please wait...');
    ?>
">
					<i class="fa fa-check"></i> 
					<?php 
    echo $edit ? ___('Update') : ___('Submit');
    ?>
				</button>
				<input type="hidden" id="ctb-post-id" name="post-id" value="<?php 
    echo $edit ? $post->ID : 0;
    ?>
">
				<input type="hidden" name="type" value="post">
			</div>
		</div>
	</form>
	<?php 
    wp_reset_postdata();
}
Пример #3
0
<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>
Пример #4
0
 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.')]));
     }
 }
Пример #5
0
" 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>';
Пример #6
0
 /**
  * HOOK - Signin daily for user meta
  *
  * @version 1.0.0
  */
 public static function action_add_history_signin_daily()
 {
     $user_id = theme_cache::get_current_user_id();
     $current_timestamp = current_time('timestamp');
     /**
      * get the last sign-in time
      */
     $last_signin_timestamp = get_user_meta($user_id, self::$user_meta_key['last-signin'], true);
     /**
      * first sign-in
      */
     if (empty($last_signin_timestamp)) {
         update_user_meta($user_id, self::$user_meta_key['last-signin'], $current_timestamp);
         return;
     }
     $today_Ymd = date('Ymd', $current_timestamp);
     $last_signin_Ymd = date('Ymd', $last_signin_timestamp);
     /** IS logged today, return */
     if ($today_Ymd == $last_signin_Ymd) {
         return false;
     }
     /**
      * update $last_signin_timestamp
      */
     update_user_meta($user_id, self::$user_meta_key['last-signin'], $current_timestamp);
     /**
      * add history
      */
     $meta = array('type' => 'signin-daily', 'timestamp' => $current_timestamp);
     /**
      * add to history
      */
     self::add_history($user_id, $meta);
     /**
      * update point
      */
     $old_point = self::get_point($user_id);
     update_user_meta($user_id, self::$user_meta_key['point'], $old_point + (int) theme_options::get_options(__CLASS__)['points']['signin-daily']);
     return true;
 }
Пример #7
0
    public static function theme_comment($comment, $args, $depth)
    {
        global $post;
        $GLOBALS['comment'] = $comment;
        switch ($comment->comment_type) {
            default:
                $classes = ['media'];
                if (!empty($args['has_children'])) {
                    $classes[] = 'parent';
                }
                if ($comment->comment_approved == '0') {
                    $classes[] = 'moderation';
                }
                /**
                 * post author checker
                 */
                if ($comment->user_id == $post->post_author) {
                    $is_post_author = true;
                    $classes[] = 'is-post-author';
                } else {
                    $is_post_author = false;
                }
                /**
                 * check is my comment
                 */
                if ($comment->user_id != 0) {
                    if (theme_cache::get_current_user_id() == $comment->user_id) {
                        $classes[] = 'is-me';
                    }
                }
                /**
                 * author url
                 */
                $author_url = get_comment_author_url();
                if (!empty($author_url) && stripos($author_url, theme_cache::home_url()) === false) {
                    $author_nofollow = ' rel="external nofollow" ';
                } else {
                    $author_nofollow = null;
                }
                ?>
<li <?php 
                comment_class($classes);
                ?>
 id="comment-<?php 
                echo $comment->comment_ID;
                ?>
">
	<div id="comment-body-<?php 
                echo $comment->comment_ID;
                ?>
" class="comment-body">
	
		<?php 
                if ($comment->comment_parent == 0) {
                    ?>
			<div class="media-left">
				<?php 
                    if ($author_url) {
                        ?>
					<a href="<?php 
                        echo esc_url($author_url);
                        ?>
" class="avatar-link" target="_blank" <?php 
                        echo $author_nofollow;
                        ?>
 >
						<?php 
                        echo theme_cache::get_avatar($comment, 50);
                        ?>
					</a>
				<?php 
                    } else {
                        echo theme_cache::get_avatar($comment, 50);
                    }
                    ?>
			</div><!-- /.media-left -->
		<?php 
                }
                ?>
		
		<div class="media-body">

			<div class="comment-content">
				<?php 
                comment_text();
                ?>
				<?php 
                if ($comment->comment_approved == '0') {
                    ?>
					<div class="comment-awaiting-moderation"><?php 
                    echo status_tip('info', ___('Your comment is awaiting moderation.'));
                    ?>
</div>
				<?php 
                }
                ?>
			</div>

			<h4 class="media-heading">
				<span class="comment-meta-data author">
					<?php 
                if ($comment->comment_parent != 0) {
                    echo theme_cache::get_avatar($comment, 50), '&nbsp;';
                }
                comment_author_link();
                ?>
				</span>
				<time class="comment-meta-data time" datetime="<?php 
                echo get_comment_time('c');
                ?>
">
					<a href="<?php 
                echo esc_url(get_comment_link($comment->comment_ID));
                ?>
"><?php 
                echo friendly_date(get_comment_time('U'));
                ?>
</a>
				</time>
				<?php 
                if (!theme_cache::is_user_logged_in()) {
                    /**
                     * if needs register to comment
                     */
                    if (theme_cache::get_option('comment_registration')) {
                        static $reply_link;
                        if (!$reply_link) {
                            $reply_link = '<a rel="nofollow" class="comment-reply-login quick-login-btn" href="' . wp_login_url(theme_cache::get_permalink($comment->comment_post_ID)) . '">' . ___('Reply') . '</a>';
                        }
                    } else {
                        $reply_link = get_comment_reply_link(['add_below' => 'comment-body', 'depth' => $depth, 'max_depth' => $args['max_depth']], $comment, $post->ID);
                    }
                } else {
                    $reply_link = get_comment_reply_link(['add_below' => 'comment-body', 'depth' => $depth, 'max_depth' => $args['max_depth']], $comment, $post->ID);
                }
                $reply_link = preg_replace('/(href=)[^\\s]+/', '$1"javascript:;"', $reply_link);
                if (!empty($reply_link)) {
                    ?>
					<span class="comment-meta-data comment-reply reply">
						<?php 
                    echo $reply_link;
                    ?>
					</span><!-- .reply -->
				<?php 
                }
                ?>
			</h4>
		</div><!-- /.media-body -->
	</div><!-- /.comment-body -->
		<?php 
        }
    }
Пример #8
0
 public static function frontend_js_config(array $config)
 {
     if (!self::is_page()) {
         return $config;
     }
     $config[__CLASS__] = ['process_url' => theme_features::get_process_url(['action' => __CLASS__]), 'lang' => ['M01' => ___('Loading, please wait...'), 'M02' => ___('Enter to send P.M.'), 'M03' => ___('P.M. content'), 'M04' => ___('Send P.M.'), 'M05' => ___('Hello, I am %name%, welcome to chat with me what do you want.'), 'M06' => ___('P.M. is sending, please wait...'), 'M07' => ___('Me'), 'E01' => ___('Sorry, server is busy now, can not respond your request, please try again later.')], 'my_uid' => self::get_niceid(theme_cache::get_current_user_id()), 'userdata' => ['me' => ['name' => ___('Me'), 'url' => theme_cache::get_author_posts_url(theme_cache::get_current_user_id())]]];
     return $config;
 }
Пример #9
0
		</div>
	</div>
	<!-- description -->
	<div class="form-group">
		<label for="my-settings-des" class="control-label g-tablet-1-6">
			<i class="fa fa-newspaper-o"></i>
			<?php 
echo ___('Description');
?>
		</label>
		<div class="g-tablet-5-6">
			<textarea name="user[description]" class="form-control" id="my-settings-des" placeholder="<?php 
echo ___('Introduce yourself to everyone');
?>
" tabindex="1"><?php 
echo esc_attr(get_user_meta(theme_cache::get_current_user_id(), 'description', true));
?>
</textarea>
		</div>
	</div>
	<!-- submit -->
	<div class="form-group">
		<div class="g-tablet-1-6">&nbsp;</div>
		<div class="g-tablet-5-6">
			<div class="submit-tip"></div>
			<input type="hidden" name="type" value="settings">
			<button type="submit" class="submit btn btn-success btn-block btn-lg" data-loading-text="<?php 
echo ___('Saving, please wait...');
?>
">
				<i class="fa fa-check"></i>
Пример #10
0
 public static function get_query()
 {
     global $paged;
     return new WP_Query(['author' => theme_cache::get_current_user_id(), 'posts_per_page' => 20, 'post_status' => ['publish', 'pending'], 'post_type' => 'post', 'paged' => (int) $paged]);
 }
Пример #11
0
" class="tool tool-notification " title="<?php 
                echo ___('Your have new notification');
                ?>
">
								<i class="fa fa-bell fa-fw fa-spin"></i> 
							</a>
						<?php 
            }
            ?>
					<?php 
        }
        ?>

					<!-- pm -->
					<?php 
        if (class_exists('theme_custom_pm') && !theme_custom_pm::is_page() && theme_custom_pm::get_unread_count(theme_cache::get_current_user_id()) > 0) {
            ?>
						<a href="<?php 
            echo theme_custom_pm::get_tabs('pm')['url'];
            ?>
" class="tool tool-pm" title="<?php 
            echo ___('You have new P.M.');
            ?>
">
							<i class="fa fa-<?php 
            echo theme_custom_pm::get_tabs('pm')['icon'];
            ?>
 fa-fw fa-spin"></i>
						</a>
					<?php 
        }
Пример #12
0
 public static function wp_check_post_lock($post_id)
 {
     if (function_exists('wp_check_post_lock')) {
         return wp_check_post_lock($post_id);
     }
     if (!($lock = get_post_meta($post_id, '_edit_lock', true))) {
         return false;
     }
     $lock = explode(':', $lock);
     $time = $lock[0];
     $user = isset($lock[1]) ? $lock[1] : get_post_meta($post_id, '_edit_last', true);
     /** This filter is documented in wp-admin/includes/ajax-actions.php */
     $time_window = apply_filters('wp_check_post_lock_window', 150);
     if ($time && $time > time() - $time_window && $user != theme_cache::get_current_user_id()) {
         return $user;
     }
     return false;
 }
Пример #13
0
 public static function process()
 {
     $output = [];
     theme_features::check_referer();
     theme_features::check_nonce();
     $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
     switch ($type) {
         /**
          * case upload
          */
         case 'add-cover':
             /** 
              * if not image
              */
             $filename = isset($_FILES['img']['name']) ? $_FILES['img']['name'] : null;
             $file_ext = $filename ? array_slice(explode('.', $filename), -1, 1)[0] : null;
             $file_ext = strtolower($file_ext);
             if (!in_array($file_ext, self::$file_exts)) {
                 $output['status'] = 'error';
                 $output['code'] = 'invaild_file_type';
                 $output['msg'] = ___('Invaild file type.');
                 die(theme_features::json_format($output));
             }
             /** rename file name */
             $_FILES['img']['name'] = theme_cache::get_current_user_id() . '-' . current_time('YmdHis') . '-' . rand(100, 999) . '.' . $file_ext;
             /** 
              * pass
              */
             require_once ABSPATH . 'wp-admin/includes/image.php';
             require_once ABSPATH . 'wp-admin/includes/file.php';
             require_once ABSPATH . 'wp-admin/includes/media.php';
             $attach_id = media_handle_upload('img', 0);
             if (is_wp_error($attach_id)) {
                 $output['status'] = 'error';
                 $output['code'] = $attach_id->get_error_code();
                 $output['msg'] = $attach_id->get_error_message();
                 die(theme_features::json_format($output));
             } else {
                 $output['status'] = 'success';
                 $output['thumbnail'] = ['url' => esc_url(self::wp_get_attachment_image_src($attach_id, 'thumbnail')[0])];
                 $output['attach-id'] = $attach_id;
                 $output['msg'] = ___('Upload success.');
                 die(theme_features::json_format($output));
             }
             break;
             /**
              * post
              */
         /**
          * post
          */
         case 'post':
             $clt = isset($_POST['clt']) && is_array($_POST['clt']) ? $_POST['clt'] : null;
             if (is_null_array($clt)) {
                 $output['status'] = 'error';
                 $output['code'] = 'invaild_ctb_param';
                 $output['msg'] = ___('Invaild collection param.');
                 die(theme_features::json_format($output));
             }
             /**
              * get posts
              */
             $posts = isset($clt['posts']) && is_array($clt['posts']) ? $clt['posts'] : null;
             if (empty($posts)) {
                 $output['status'] = 'error';
                 $output['code'] = 'invaild_posts';
                 $output['msg'] = ___('Sorry, posts can not be empty.');
                 die(theme_features::json_format($output));
             }
             /**
              * post title
              */
             $post_title = isset($clt['post-title']) && is_string($clt['post-title']) ? esc_html(trim($clt['post-title'])) : null;
             if (empty($post_title)) {
                 $output['status'] = 'error';
                 $output['code'] = 'invaild_post_title';
                 $output['msg'] = ___('Please write the post title.');
                 die(theme_features::json_format($output));
             }
             /**
              * check thumbnail cover
              */
             $thumbnail_id = isset($clt['thumbnail-id']) && is_numeric($clt['thumbnail-id']) ? (int) $clt['thumbnail-id'] : null;
             if (empty($thumbnail_id)) {
                 $output['status'] = 'error';
                 $output['code'] = 'invaild_thumbnail_id';
                 $output['msg'] = ___('Please set an image as post thumbnail');
                 die(theme_features::json_format($output));
             }
             /**
              * post content
              */
             $post_content = isset($clt['post-content']) && is_string($clt['post-content']) ? strip_tags(trim($clt['post-content']), '<del><a><b><strong><em><i>') : null;
             if (empty($post_content)) {
                 $output['status'] = 'error';
                 $output['code'] = 'invaild_post_content';
                 $output['msg'] = ___('Please explain why you recommend this collection.');
                 die(theme_features::json_format($output));
             }
             /**
              * get posts template
              */
             $post_content = '<p>' . $post_content . '</p>' . self::get_preview($posts);
             /**
              * tags
              */
             $tags = isset($clt['tags']) && is_array($clt['tags']) ? $clt['tags'] : [];
             if (!empty($tags)) {
                 $tags = array_map(function ($tag) {
                     if (!is_string($tag)) {
                         return null;
                     }
                     return $tag;
                 }, $tags);
             }
             /**
              * post status
              */
             if (theme_cache::current_user_can('moderate_comments')) {
                 $post_status = 'publish';
             } else {
                 $post_status = 'pending';
             }
             /**
              * insert
              */
             $post_id = wp_insert_post(array('post_title' => $post_title, 'post_content' => fliter_script($post_content), 'post_status' => $post_status, 'post_author' => theme_cache::get_current_user_id(), 'post_category' => (array) self::get_options('cats'), 'tags_input' => $tags), true);
             if (is_wp_error($post_id)) {
                 $output['status'] = 'error';
                 $output['code'] = $post_id->get_error_code();
                 $output['msg'] = $post_id->get_error_message();
             } else {
                 /** set post thumbnail */
                 set_post_thumbnail($post_id, $thumbnail_id);
                 /**
                  * pending status
                  */
                 if ($post_status === 'pending') {
                     $output['status'] = 'success';
                     $output['msg'] = sprintf(___('Your collection submitted successful, it will be published after approve in a while. Thank you very much! How about %s again?'), '<a href="' . self::get_tabs('collection')['url'] . '">' . ___('write a new collection') . '</a>');
                     die(theme_features::json_format($output));
                 } else {
                     $output['status'] = 'success';
                     $output['msg'] = sprintf(___('Congratulation! Your post has been published. You can %s or %s.'), '<a href="' . theme_cache::get_permalink($post_id) . '" title="' . theme_cache::get_the_title($post_id) . '">' . ___('View it now') . '</a>', '<a href="' . self::get_tabs('collection')['url'] . '">' . ___('countinue to write a new collection') . '</a>');
                     /**
                      * add point
                      */
                     if (class_exists('theme_custom_point')) {
                         $post_publish_point = theme_custom_point::get_point_value('post-publish');
                         $output['point'] = array('value' => $post_publish_point, 'detail' => ___('Post published'));
                     }
                     die(theme_features::json_format($output));
                 }
             }
             break;
             /**
              * get post
              */
         /**
          * get post
          */
         case 'get-post':
             $post_id = isset($_REQUEST['post-id']) && is_numeric($_REQUEST['post-id']) ? $_REQUEST['post-id'] : null;
             if (!$post_id) {
                 $output['status'] = 'error';
                 $output['code'] = 'invaild_post_id';
                 $output['msg'] = ___('Sorry, the post id is invaild.');
                 die(theme_features::json_format($output));
             }
             global $post;
             $post = theme_cache::get_post($post_id);
             if (!$post || $post->post_type !== 'post') {
                 $output['status'] = 'error';
                 $output['code'] = 'post_not_exist';
                 $output['msg'] = ___('Sorry, the post do not exist, please type another post ID.');
                 //echo(json_encode($output));
                 die(theme_features::json_format($output));
             }
             setup_postdata($post);
             $output = ['status' => 'success', 'msg' => ___('Finished get the post data.'), 'thumbnail' => ['url' => theme_functions::get_thumbnail_src($post_id), 'size' => [theme_functions::$thumbnail_size[1], theme_functions::$thumbnail_size[2]]], 'title' => theme_cache::get_the_title($post_id), 'excerpt' => html_minify(str_sub(strip_tags(trim($post->post_content)), 120, '...'))];
             wp_reset_postdata();
             die(theme_features::json_format($output));
     }
     die(theme_features::json_format($output));
 }
Пример #14
0
 private static function set_follow($user_id)
 {
     if ($user_id == theme_cache::get_current_user_id()) {
         return false;
     }
     $target_metas = get_user_meta($user_id, self::$user_meta_key['following']);
     /**
      * if already is follower, remove the follower and recount following count
      */
     $old_target_follower_count = (int) get_user_meta($user_id, self::$user_meta_key['follower_count'], true);
     $old_my_following_count = (int) get_user_meta(theme_cache::get_current_user_id(), self::$user_meta_key['following'], true);
     if (!is_null_array($target_metas) && in_array(theme_cache::get_current_user_id(), $target_metas)) {
         /** opera target user meta */
         delete_user_meta($user_id, self::$user_meta_key['follower'], theme_cache::get_current_user_id());
         update_user_meta($user_id, self::$user_meta_key['follower_count'], $old_target_follower_count - 1);
         /** opera current user meta */
         delete_user_meta(theme_cache::get_current_user_id(), self::$user_meta_key['following'], $user_id);
         update_user_meta(theme_cache::get_current_user_id(), self::$user_meta_key['following_count'], $old_my_following_count - 1);
         return array('user_follower_count' => $old_target_follower_count - 1, 'my_following_count' => $old_my_following_count - 1);
     } else {
         /** opera target user meta */
         add_user_meta($user_id, $user_meta_key['follower'], theme_cache::get_current_user_id());
         update_user_meta($user_id, self::$user_meta_key['follower_count'], $old_target_follower_count + 1);
         /** opera current user meta */
         add_user_meta(theme_cache::get_current_user_id(), $user_meta_key['following'], theme_cache::get_current_user_id());
         update_user_meta(theme_cache::get_current_user_id(), self::$user_meta_key['following_count'], $old_my_following_count + 1);
         return array('user_follower_count' => $old_target_follower_count + 1, 'my_following_count' => $old_my_following_count + 1);
     }
 }
Пример #15
0
 public static function process()
 {
     $output = [];
     theme_features::check_referer();
     theme_features::check_nonce();
     $type = isset($_GET['type']) && is_string($_GET['type']) ? $_GET['type'] : null;
     $post_id = isset($_POST['post-id']) && is_numeric($_POST['post-id']) ? (int) $_POST['post-id'] : null;
     if (!$post_id) {
         $output['status'] = 'error';
         $output['code'] = 'invaild_post_id';
         $output['msg'] = ___('Invaild post id param.');
         die(theme_features::json_format($output));
     }
     $post = theme_cache::get_post($post_id);
     if (!$post || $post->post_type !== 'post') {
         die(theme_features::json_format(['status' => 'error', 'code' => 'post_not_exist', 'msg' => ___('Post does not exist.')]));
     }
     /**
      * check user logged
      */
     if (!theme_cache::is_user_logged_in()) {
         $output['status'] = 'error';
         $output['code'] = 'need_login';
         $output['msg'] = '<a href="' . wp_login_url(theme_cache::get_permalink($post->ID)) . '" title="' . ___('Go to log-in') . '">' . ___('Sorry, please log-in.') . '</a>';
         die(theme_features::json_format($output));
     }
     $rater_id = theme_cache::get_current_user_id();
     switch ($type) {
         /**
          * incr point
          */
         case 'incr':
             /**
              * points
              */
             $points = isset($_POST['points']) && is_numeric($_POST['points']) ? (int) $_POST['points'] : null;
             if (!in_array($points, self::get_point_values())) {
                 $output['status'] = 'error';
                 $output['code'] = 'invaild_point_value';
                 $output['msg'] = ___('Invaild point value.');
                 die(theme_features::json_format($output));
             }
             /**
              * incr post raters
              */
             $post_raters = self::incr_post_raters($post_id, $rater_id, $points);
             if ($post_raters !== true) {
                 die(theme_features::json_format($post_raters));
             } else {
                 /**
                  * incr post points
                  */
                 $points_count = self::incr_post_points_count($post_id, $points);
                 if (!$points_count) {
                     $output['status'] = 'error';
                     $output['code'] = 'error_incr_points_count';
                     $output['msg'] = ___('Sorry, system can not increase post points count.');
                     die(theme_features::json_format($output));
                 }
                 /**
                  * incr rater posts
                  */
                 $rater_posts = self::incr_rater_posts($post_id, $rater_id, $points);
                 if ($rater_posts !== true) {
                     $output['status'] = 'error';
                     $output['code'] = 'error_incr_rater_posts';
                     $output['msg'] = ___('System can not increase rater posts.');
                     die(theme_features::json_format($output));
                 }
                 /**
                  * increase post author points
                  */
                 theme_custom_point::incr_user_points($post->post_author, $points);
                 /**
                  * add point history for rater
                  */
                 self::add_history_for_rater($post_id, $rater_id, $points);
                 /**
                  * add point history for post author
                  */
                 self::add_history_for_post_author($post_id, $rater_id, $points);
                 /**
                  * decrease rater points
                  */
                 theme_custom_point::decr_user_points($rater_id, $points);
                 /**
                  * success
                  */
                 $output['status'] = 'success';
                 $output['points'] = (int) self::get_post_points_count($post_id);
                 $output['msg'] = ___('Operation successful, thank you for your participation.');
                 die(theme_features::json_format($output));
             }
             break;
         default:
             $output['status'] = 'error';
             $output['code'] = 'invaild_type';
             $output['msg'] = ___('Invaild type param.');
             die(theme_features::json_format($output));
     }
     die(theme_features::json_format($output));
 }
Пример #16
0
 public static function action_not_allow_login_backend()
 {
     /** 
      * if in backend
      */
     if (!defined('DOING_AJAX') || !DOING_AJAX) {
         /** 
          * if not administrator and not ajax,redirect to 
          */
         if (!theme_cache::current_user_can('moderate_comments')) {
             wp_safe_redirect(theme_cache::get_author_posts_url(theme_cache::get_current_user_id()));
             die;
         }
     }
 }
Пример #17
0
<div class="panel">
	<?php 
$current_user_id = theme_cache::get_current_user_id();
$notis = theme_notification::get_notifications(array('user_id' => $current_user_id));
$unreads = theme_notification::get_notifications(array('user_id' => $current_user_id, 'type' => 'unread'));
if (!empty($notis)) {
    ?>
		<ul class="list-group history-group">
			<?php 
    foreach ($notis as $k => $noti) {
        /**
         * Check the noti is read or unread
         */
        if (isset($noti['id']) && isset($unreads[$noti['id']])) {
            $unread_class = ' unread list-group-item-info';
        } else {
            $unread_class = null;
        }
        ?>
				<li class="list-group-item type-<?php 
        echo $noti['type'];
        ?>
 <?php 
        echo $unread_class;
        ?>
">
					<?php 
        do_action('list_noti', $noti);
        ?>
				</li><!-- /.list-group-item -->
			<?php 
Пример #18
0
 public static function get_notifications(array $args = [])
 {
     $defaults = array('user_id' => theme_cache::get_current_user_id(), 'type' => 'all', 'posts_per_page' => 20, 'paged' => 1, 'orderby' => 'desc');
     $args = array_merge($defaults, $args);
     if (empty($args['user_id'])) {
         return false;
     }
     /**
      * cache
      */
     static $caches = [];
     $cache_id = md5(serialize($args));
     if (isset($caches[$cache_id])) {
         return $caches[$cache_id];
     }
     $metas = (array) get_user_meta($args['user_id'], self::$user_meta_key['key']);
     if (empty($metas)) {
         return null;
     } else {
         krsort($metas);
     }
     switch ($args['type']) {
         case 'unread':
             $unreads = (array) get_user_meta($args['user_id'], self::$user_meta_key['unread_count'], true);
             if (!empty($unreads)) {
                 $unread_count = count($unreads);
                 $metas = array_slice($metas, 0, $unread_count);
             }
         default:
             //return $metas;
     }
     /**
      * check the paginavi
      */
     if ($args['posts_per_page'] > 0) {
         $start = ($args['paged'] - 1) * 10 - 1;
         if ($start < 0) {
             $start = 0;
         }
         $metas = array_slice($metas, $start, $args['posts_per_page']);
     }
     $caches[$cache_id] = $metas;
     unset($metas);
     return $caches[$cache_id];
 }