コード例 #1
0
ファイル: functions.php プロジェクト: ClayMoreBoy/mx
    public static function archive_card_sm(array $args = [])
    {
        global $post;
        $args = array_merge(['classes' => 'g-tablet-1-4', 'lazyload' => true, 'category' => true, 'target' => theme_functions::$link_target], $args);
        $args['classes'] .= ' card sm ';
        $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 <?php 
        post_class($args['classes']);
        ?>
>
			<div class="card-bg" >
				<?php 
        if (class_exists('theme_colorful_cats') && $args['category']) {
            ?>
					<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 
					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 
        }
        ?>
				</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>
					<time class="meta time" datetime="<?php 
        echo get_the_time('Y-m-d H:i:s', $post->ID);
        ?>
" title="<?php 
        echo get_the_time(___('M j, Y'), $post->ID);
        ?>
">
						<?php 
        echo friendly_date(get_the_time('U', $post->ID));
        ?>
					</time>
				</div>
			</div>
		</article>
		<?php 
    }
コード例 #2
0
ファイル: custom-api.php プロジェクト: ClayMoreBoy/mx
 public static function get_postdata()
 {
     global $post;
     $output = (array) $post;
     /**
      * get post content
      */
     setup_postdata($post);
     ob_start();
     the_content();
     $output['post_content'] = ob_get_contents();
     ob_end_clean();
     $output['post_content'] = str_replace('[&hellip;]', '...', $output['post_content']);
     $output['post_excerpt'] = get_the_excerpt();
     $output['post_categories'] = array_map(function ($cat) {
         return self::get_cat_data($cat);
     }, get_the_category($post->ID));
     /**
      * post url
      */
     $output['url'] = theme_cache::get_permalink($post->ID);
     /**
      * post author
      */
     $output['post_author'] = self::get_userdata($post->post_author);
     /**
      * thumbnail
      */
     $sizes = ['thumbnail', 'medium'];
     foreach ($sizes as $size) {
         $output['thumbnail'][$size] = theme_functions::get_thumbnail_src($post->ID, $size);
     }
     /**
      * storage
      */
     if (class_exists('theme_custom_storage')) {
         $output['download_page'] = theme_custom_storage::get_download_page_url($post->ID);
     }
     return $output;
 }
コード例 #3
0
    public static function widget_rank_img_content($args = [])
    {
        global $post;
        $args = array_merge(['classes' => '', 'lazyload' => true, 'excerpt' => false, 'target' => '_blank'], $args);
        $thumbnail_real_src = theme_functions::get_thumbnail_src($post->ID);
        $post_title = theme_cache::get_the_title($post->ID);
        ?>
		<li class="list-group-item <?php 
        echo $args['classes'];
        ?>
">
			<a 
				class="list-group-item-bg media" 
				href="<?php 
        echo theme_cache::get_permalink($post->ID);
        ?>
" 
				title="<?php 
        echo $post_title;
        ?>
" 
				target="<?php 
        echo $args['target'];
        ?>
" 
			>
				<div class="media-left">
					<div class="thumbnail-container">
						<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];
        ?>
" 
						>
					</div>
				</div>
				<div class="media-body">
					<h3 class="media-heading"><?php 
        echo $post_title;
        ?>
</h3>
					<div class="metas row">
						<?php 
        if (class_exists('theme_post_views') && theme_post_views::is_enabled()) {
            ?>
							<div class="view meta g-phone-1-2">
								<i class="fa fa-play-circle"></i> 
								<?php 
            echo theme_post_views::get_views();
            ?>
							</div>
						<?php 
        }
        ?>

						<div class="comments meta g-phone-1-2">
							<i class="fa fa-comment"></i> 
							<?php 
        echo (int) $post->comment_count;
        ?>
						</div>
					</div>
				</div>			
			</a>
		</li>
		<?php 
    }
コード例 #4
0
    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();
    }
コード例 #5
0
ファイル: custom-collection.php プロジェクト: ClayMoreBoy/mx
 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));
 }
コード例 #6
0
ファイル: page-account-edit.php プロジェクト: ClayMoreBoy/mx
</th>
						<?php 
    }
    ?>
					</tr>
				</thead>
				<tbody>
				<?php 
    foreach ($wp_query->posts as $post) {
        setup_postdata($post);
        $post_edit_url = theme_custom_edit::get_edit_post_link($post->ID);
        ?>
					<tr>
						<td class="edit-post-thumbnail">
							<img class="post-list-img" src="<?php 
        echo theme_functions::get_thumbnail_src($post->ID);
        ?>
" alt="<?php 
        echo theme_cache::get_the_title($post->ID);
        ?>
" width="<?php 
        echo theme_functions::$thumbnail_size[1];
        ?>
" height="<?php 
        echo theme_functions::$thumbnail_size[2];
        ?>
"/>
						</td>
						<td class="edit-post-title">
							<h4><strong><a href="<?php 
        echo $post_edit_url;
コード例 #7
0
ファイル: author-comments.php プロジェクト: ClayMoreBoy/mx
    ?>
		<div class="content">
			<div class="page-tip"><?php 
    echo status_tip('info', ___('No comment yet.'));
    ?>
</div>
		</div>
		<?php 
} else {
    global $comment, $post;
    ?>
		<ul class="list-group">
			<?php 
    foreach ($comments as $comment) {
        $post = theme_cache::get_post($comment->comment_post_ID);
        $thumbnail_real_src = theme_functions::get_thumbnail_src($post->ID);
        ?>
				<li class="list-group-item">
					<div class="media">
						<div class="media-left">
							<a href="<?php 
        echo theme_cache::get_permalink($post->ID);
        ?>
">
								<img class="post-list-img" src="<?php 
        echo theme_functions::$thumbnail_placeholder;
        ?>
" data-src="<?php 
        echo esc_url($thumbnail_real_src);
        ?>
" alt="<?php 
コード例 #8
0
ファイル: custom-page-rank.php プロジェクト: ClayMoreBoy/mx
    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 
    }