private static function get_views($post_id)
 {
     static $caches = [];
     if (!isset($caches[$post_id])) {
         $caches[$post_id] = (int) theme_post_views::get_views($post_id);
     }
     return $caches[$post_id];
 }
Ejemplo n.º 2
0
 public static function set_viewed_ids($post_id)
 {
     $expire = time() + self::$cookie_expire;
     self::$cookie = self::get_viewed_ids();
     if (empty(self::$cookie)) {
         self::$cookie = [$post_id];
         setcookie(__CLASS__, json_encode([$post_id]), $expire);
         return true;
     } else {
         if (!in_array($post_id, self::$cookie)) {
             self::$cookie[] = $post_id;
             setcookie(__CLASS__, json_encode(self::$cookie), $expire);
             return true;
         }
         return false;
     }
 }
Ejemplo n.º 3
0
    public static function archive_card_lg(array $args = [])
    {
        global $post;
        $args = array_merge(['classes' => 'g-tablet-1-4', 'lazyload' => true, 'target' => theme_functions::$link_target], $args);
        $args['classes'] .= ' card lg ';
        $thumbnail_real_src = theme_functions::get_thumbnail_src($post->ID);
        $permalink = theme_cache::get_permalink($post->ID);
        $post_title = theme_cache::get_the_title($post->ID);
        $author_display_name = theme_cache::get_the_author_meta('display_name', $post->post_author);
        ?>
		<article class="<?php 
        echo $args['classes'];
        ?>
">
			<div class="card-bg" >
				<a 
					href="<?php 
        echo $permalink;
        ?>
" 
					title="<?php 
        echo $post_title;
        ?>
" 
					class="thumbnail-container" 
					target="<?php 
        echo $args['target'];
        ?>
" 
				>
					<?php 
        /**
         * lazyload img
         */
        if ($args['lazyload']) {
            ?>
						<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 self::$thumbnail_size[1];
            ?>
" height="<?php 
            echo self::$thumbnail_size[2];
            ?>
" >
					<?php 
        } else {
            ?>
						<img class="thumbnail" src="<?php 
            echo $thumbnail_real_src;
            ?>
" alt="<?php 
            echo $post_title;
            ?>
" width="<?php 
            echo self::$thumbnail_size[1];
            ?>
" height="<?php 
            echo self::$thumbnail_size[2];
            ?>
" >
					<?php 
        }
        ?>

					<?php 
        if (class_exists('theme_colorful_cats')) {
            ?>
						<div class="card-cat">
							<?php 
            /**
             * cats
             */
            foreach (get_the_category($post->ID) as $cat) {
                $color = theme_colorful_cats::get_cat_color($cat->term_id, true);
                ?>
								<span style="background-color:rgba(<?php 
                echo $color['r'];
                ?>
,<?php 
                echo $color['g'];
                ?>
,<?php 
                echo $color['b'];
                ?>
,.8);"><?php 
                echo $cat->name;
                ?>
</span>
							<?php 
            }
            ?>
						</div>
					<?php 
        }
        ?>

				</a>
				<a 
					href="<?php 
        echo $permalink;
        ?>
" 
					title="<?php 
        echo $post_title;
        ?>
" 
					class="card-title" 
					target="<?php 
        echo $args['target'];
        ?>
" 
				>
					<h3><?php 
        echo $post_title;
        ?>
</h3>
				</a>
				<div class="card-meta">
					<a 
						href="<?php 
        echo theme_cache::get_author_posts_url($post->post_author);
        ?>
" 
						class="meta author" 
						title="<?php 
        echo $author_display_name;
        ?>
" 
						target="<?php 
        echo $args['target'];
        ?>
" 
					>
						<img width="32" height="32" src="<?php 
        echo theme_functions::$avatar_placeholder;
        ?>
" data-src="<?php 
        echo theme_cache::get_avatar_url($post->post_author);
        ?>
" alt="<?php 
        echo $author_display_name;
        ?>
" class="avatar"> <span class="tx"><?php 
        echo $author_display_name;
        ?>
</span>
					</a>
					<?php 
        /**
         * views
         */
        if (class_exists('theme_post_views') && theme_post_views::is_enabled()) {
            ?>
						<span class="meta views" title="<?php 
            echo ___('Views');
            ?>
"><i class="fa fa-play-circle"></i> <?php 
            echo theme_post_views::get_views($post->ID);
            ?>
</span>
					<?php 
        }
        ?>

					<!-- comments count -->
					<span class="meta comments-count" title="<?php 
        echo ___('Comments');
        ?>
">
						<i class="fa fa-comment"></i> <?php 
        echo (int) $post->comment_count;
        ?>
					</span>
				</div>
			</div>
		</article>
		<?php 
    }
Ejemplo n.º 4
0
    function form($instance = [])
    {
        $instance = array_merge(['title' => ___('Posts rank'), 'posts_per_page' => 6, 'date' => 'all', 'category__in' => [], 'content_type' => 'img', 'orderby' => 'latest'], $instance);
        ?>
		<p>
			<label for="<?php 
        echo self::get_field_id('title');
        ?>
"><?php 
        echo ___('Title (optional)');
        ?>
</label>
			<input 
				id="<?php 
        echo self::get_field_id('title');
        ?>
"
				class="widefat"
				name="<?php 
        echo self::get_field_name('title');
        ?>
" 
				type="text" 
				value="<?php 
        echo $instance['title'];
        ?>
" 
				placeholder="<?php 
        echo ___('Title (optional)');
        ?>
"
			/>
		</p>
		<p>
			<label for="<?php 
        echo self::get_field_id('posts_per_page');
        ?>
"><?php 
        echo ___('Post number (required)');
        ?>
</label>
			<input 
				id="<?php 
        echo self::get_field_id('posts_per_page');
        ?>
"
				class="widefat"
				name="<?php 
        echo self::get_field_name('posts_per_page');
        ?>
" 
				type="number" 
				value="<?php 
        echo $instance['posts_per_page'];
        ?>
" 
				placeholder="<?php 
        echo ___('Post number (required)');
        ?>
"
			/>
		</p>
		<p>
			<?php 
        echo ___('Categories: ');
        ?>
			<?php 
        self::get_cat_checkbox_list(self::get_field_name('category__in'), self::get_field_id('category__in'), $instance['category__in']);
        ?>
		</p>
		<!-- date -->
		<p>
			<label for="<?php 
        echo self::get_field_id('date');
        ?>
"><?php 
        echo ___('Date');
        ?>
</label>
			<select
				name="<?php 
        echo self::get_field_name('date');
        ?>
" 
				class="widefat"				
				id="<?php 
        echo self::get_field_id('date');
        ?>
"
			>
				<?php 
        foreach (self::get_rank_data() as $k => $v) {
            the_option_list($k, $v, $instance['date']);
        }
        ?>
			</select>
		</p>
		<p>
			<label for="<?php 
        echo self::get_field_id('content_type');
        ?>
"><?php 
        echo ___('Content type');
        ?>
</label>
			<select 
				name="<?php 
        echo self::get_field_name('content_type');
        ?>
" 
				class="widefat"
				id="<?php 
        echo self::get_field_id('content_type');
        ?>
"
			>
				<?php 
        /** 
         * image type
         */
        the_option_list('img', ___('Image type'), $instance['content_type']);
        /** 
         * text type
         */
        the_option_list('tx', ___('Text type'), $instance['content_type']);
        ?>
			</select>
		</p>
		<p>
			<label for="<?php 
        echo self::get_field_id('orderby');
        ?>
">
				<?php 
        echo ___('Order by');
        ?>
			</label>
			<select 
				name="<?php 
        echo self::get_field_name('orderby');
        ?>
" 
				class="widefat"
				id="<?php 
        echo self::get_field_id('orderby');
        ?>
"
			>
				
				<?php 
        /** 
         * orderby views
         */
        if (class_exists('theme_post_views') && theme_post_views::is_enabled()) {
            the_option_list('views', ___('Most views'), $instance['orderby']);
        }
        /** 
         * orderby thumb-up
         */
        if (class_exists('theme_post_thumb') && theme_post_thumb::is_enabled()) {
            the_option_list('thumb-up', ___('Thumb up'), $instance['orderby']);
        }
        /** 
         * orderby recommended
         */
        if (class_exists('theme_recommended_post')) {
            the_option_list('recommended', ___('Recommended'), $instance['orderby']);
        }
        /** 
         * orderby random
         */
        the_option_list('random', ___('Random'), $instance['orderby']);
        /** 
         * orderby latest
         */
        the_option_list('latest', ___('Latest'), $instance['orderby']);
        ?>
			</select>
		</p>
		<?php 
    }
Ejemplo n.º 5
0
    /** 
     * singular_content
     */
    public static function singular_content(array $args = [])
    {
        global $post;
        $args = array_merge(array('classes' => '', 'lazyload' => true), $args);
        /** 
         * classes
         */
        $args['classes'] .= ' singular-post panel ';
        ?>
		<article id="post-<?php 
        echo $post->ID;
        ?>
" <?php 
        post_class($args['classes']);
        ?>
>
			<h2 class="entry-title"><?php 
        echo theme_cache::get_the_title($post->ID);
        ?>
</h2>
			<header class="entry-header">
				<!-- category -->
				<?php 
        $cats = get_the_category_list('<i class="split"> / </i> ');
        if (!empty($cats)) {
            ?>
					<span class="entry-meta post-category" title="<?php 
            echo ___('Category');
            ?>
">
						<i class="fa fa-folder-open"></i>
						<?php 
            echo $cats;
            ?>
					</span>
				<?php 
        }
        ?>
				
				<!-- time -->
				<time class="entry-meta post-time" datetime="<?php 
        echo get_the_time('Y-m-d H:i:s');
        ?>
" title="<?php 
        echo get_the_time(___('M j, Y'));
        ?>
">
					<i class="fa fa-clock-o"></i>
					<?php 
        echo friendly_date(get_the_time('U'));
        ?>
				</time>
				
				<!-- views -->
				<?php 
        if (class_exists('theme_post_views') && theme_post_views::is_enabled()) {
            ?>
					<span class="entry-meta post-views" title="<?php 
            echo ___('Views');
            ?>
">
						<i class="fa fa-play-circle"></i>
						<span class="number" id="post-views-number-<?php 
            echo $post->ID;
            ?>
">-</span>
					</span>
				<?php 
        }
        ?>
				<?php 
        /** 
         * comment
         */
        $comment_count = (int) get_comments_number() . '';
        ?>
				<a href="#comments" class="entry-meta quick-comment comment-count" data-post-id="<?php 
        echo $post->ID;
        ?>
">
					<i class="fa fa-comment"></i>
					<span class="comment-count-number"><?php 
        echo $comment_count;
        ?>
</span>
				</a>
				<?php 
        /**
         * edit
         */
        if (class_exists('theme_custom_edit') && $post->post_author == theme_cache::get_current_user_id()) {
            ?>
					<a class="post-meta edit-post" href="<?php 
            echo theme_custom_edit::get_edit_post_link($post->ID);
            ?>
">
						<i class="fa fa-edit"></i> <?php 
            echo ___('Edit');
            ?>
					</a>
				<?php 
        }
        ?>
				
				
			</header>
			<div class="entry-body">
				<?php 
        /**
         * ad
         */
        if (class_exists('theme_adbox') && !empty(theme_adbox::display_frontend('below-post-title'))) {
            ?>
					<div class="ad-container ad-below-post-title"><?php 
            echo theme_adbox::display_frontend('below-post-title');
            ?>
</div>
					<?php 
        }
        ?>
			
				<!-- post-content -->
				<div class="entry-content content-reset">
					<?php 
        the_content();
        ?>
				</div>

				<?php 
        self::the_page_pagination();
        ?>

					
				<!-- post-footer -->
				<footer class="entry-footer">
					<?php 
        /** 
         * tags
         */
        $tags = get_the_tags();
        if (!empty($tags)) {
            ?>
						<div class="entry-tags">
							<?php 
            the_tags('', '');
            ?>
						</div>
						<?php 
        }
        ?>
					<?php 
        /** 
         * post-share
         */
        if (class_exists('theme_post_share') && theme_post_share::is_enabled()) {
            ?>
						<div class="entry-share">
							<?php 
            echo theme_post_share::display();
            ?>
						</div>
						<?php 
        }
        /** end post-share */
        ?>
					
				</footer>
			</div><!-- /.entry-body -->
			
		</article>
		<?php 
    }
Ejemplo n.º 6
0
    public static function display_frontend()
    {
        global $post;
        $meta = self::get_post_meta($post->ID);
        if (!$meta) {
            return;
        }
        ?>
		<a class="meta meta-post-storage" href="<?php 
        echo self::get_download_page_url($post->ID);
        ?>
" target="_blank" title="<?php 
        echo ___('Download');
        ?>
">
			<div id="post-storage-number-<?php 
        echo $post_id;
        ?>
" class="number">
				<?php 
        if (class_exists('theme_post_views') && theme_post_views::is_enabled()) {
            $number = (int) (theme_post_views::get_views($post_id) * 0.5 - mt_rand(1, 9));
            echo $number <= 0 ? 0 : number_format($number);
        }
        ?>
			</div>
			<div class="tx"><?php 
        echo ___('Download');
        ?>
</div>
		</a>
		<?php 
    }
Ejemplo n.º 7
0
                echo ___('Published');
                break;
            case 'pending':
                echo ___('Pending');
                break;
        }
        ?>
							</div>
						</td>
						<!-- views -->
						<?php 
        if (class_exists('theme_post_views') && theme_post_views::is_enabled()) {
            ?>
							<td class="edit-post-views">
								<?php 
            echo theme_post_views::get_views($post->ID);
            ?>
							</td>
						<?php 
        }
        ?>
					</tr>
					<?php 
    }
    ?>
				</tbody>
			</table>
		</div>
		<?php 
} else {
    ?>
Ejemplo n.º 8
0
    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 
    }