Пример #1
0
 public static function wp_title($title, $sep)
 {
     if (!self::is_page()) {
         return $title;
     }
     $post = self::get_decode_post();
     if ($post) {
         return theme_cache::get_the_title($post->ID) . $sep . ___('storage download') . $sep . theme_cache::get_bloginfo('name');
     }
 }
Пример #2
0
 public static function display($args = [])
 {
     global $post;
     $opt = self::get_options();
     $img_url = theme_features::get_thumbnail_src($post->ID);
     $defaults = array('post_title_text' => theme_cache::get_the_title($post->ID), 'post_url' => theme_cache::get_permalink($post->ID), 'blog_name' => theme_cache::get_bloginfo('name'), 'blog_url' => theme_cache::home_url(), 'img_url' => esc_url($img_url), 'post_excerpt' => esc_attr(mb_substr(html_minify(strip_tags(get_the_excerpt())), 0, 120)), 'post_content' => esc_attr(mb_substr(html_minify(strip_tags(get_the_content())), 0, 120)), 'author' => theme_cache::get_the_author_meta('display_name', $post->post_author));
     $output_keywords = array_merge($defaults, $args);
     $tpl_keywords = array('%post_title_text%', '%post_url%', '%blog_name%', '%blog_url%', '%img_url%', '%post_excerpt%', '%post_content%', '%author%');
     $post_share_code = stripslashes(str_ireplace($tpl_keywords, $output_keywords, $opt['code']));
     echo $post_share_code;
 }
Пример #3
0
    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 
    }
 /**
  * output
  */
 public static function display_frontend()
 {
     global $post;
     $tpl_keywords = ['%post_title_text%', '%post_url%', '%blog_name%', '%blog_url%'];
     $output_keywords = [theme_cache::get_the_title($post->ID), theme_cache::get_permalink($post->ID), theme_cache::get_bloginfo('name'), theme_cache::home_url()];
     $codes = str_replace($tpl_keywords, $output_keywords, self::get_options('code'));
     echo stripslashes($codes);
 }
Пример #5
0
<?php

/**
 * Template name: Storage download page
 */
if (!class_exists('theme_custom_storage')) {
    die(___('Lacking the class theme_custom_storage'));
}
$target_post = theme_custom_storage::get_decode_post();
get_header();
?>
<div class="g">
	<div class="panel singular-post singular-download">
		<div class="heading">
			<h2 class="entry-title"><i class="fa fa-file fa-fw"></i> <?php 
echo sprintf(___('You are ready to download "%s"'), '<a href="' . theme_cache::get_permalink($target_post->ID) . '">' . theme_cache::get_the_title($target_post->ID) . '</a>');
?>
</h2>
		</div>
		<div class="entry-content content-reset">
			<?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        the_content();
    }
}
?>
		</div>
		<?php 
theme_custom_storage::download_info($target_post->ID);
Пример #6
0
    public static function display_backend()
    {
        $recomm_posts = self::get_ids();
        ?>
		<fieldset>
			<legend><i class="fa fa-fw fa-thumbs-o-up"></i> <?php 
        echo ___('Recommended posts');
        ?>
</legend>
			<p><?php 
        echo ___('Recommended posts will display on home page if enabled.');
        ?>
</p>
			<table class="form-table">
				<tbody>
					<tr>
						<th><label for="<?php 
        echo __CLASS__;
        ?>
-enabled"></label><?php 
        echo ___('Enable or not?');
        ?>
</th>
						<td>
							<select name="<?php 
        echo __CLASS__;
        ?>
[enabled]" id="<?php 
        echo __CLASS__;
        ?>
-enabled" class="widefat">
								<?php 
        the_option_list(-1, ___('Disable'), self::get_options('enabled'));
        ?>
								<?php 
        the_option_list(1, ___('Enable'), self::get_options('enabled'));
        ?>
							</select>
						</td>
					</tr>
					<tr>
						<th><label for="<?php 
        echo __CLASS__;
        ?>
-title"></label><?php 
        echo ___('Box title');
        ?>
</th>
						<td>
							<input type="text" name="<?php 
        echo __CLASS__;
        ?>
[title]" id="<?php 
        echo __CLASS__;
        ?>
-title" value="<?php 
        echo self::get_item('title');
        ?>
" class="widefat">
						</td>
					</tr>
					<tr>
						<th>
							<label for="<?php 
        echo __CLASS__;
        ?>
-icon"><?php 
        echo ___('Box icon');
        ?>
</label>
							<a href="//fortawesome.github.io/Font-Awesome/icons" target="_blank" title="<?php 
        echo ___('Views all icons');
        ?>
">#<?php 
        echo ___('ALL');
        ?>
</a>
						</th>
						<td>
							<input 
								type="text" 
								value="<?php 
        echo self::get_item('icon');
        ?>
" 
								list="<?php 
        echo __CLASS__;
        ?>
-icon-datalist" 
								name="<?php 
        echo __CLASS__;
        ?>
[icon]" 
								id="<?php 
        echo __CLASS__;
        ?>
-icon" 
								class="widefat" 
							><?php 
        icon_option_list(__CLASS__ . '-icon-datalist');
        ?>
						</td>
					</tr>
					<tr>
						<th><label for="<?php 
        echo __CLASS__;
        ?>
-number"></label><?php 
        echo ___('Show posts number');
        ?>
</th>
						<td>
							<input type="number" name="<?php 
        echo __CLASS__;
        ?>
[number]" id="<?php 
        echo __CLASS__;
        ?>
-number" min="4" step="4" value="<?php 
        echo self::get_item('number');
        ?>
" class="short-text">
						</td>
					</tr>
					<tr>
						<th scope="row"><?php 
        echo ___('Marked posts');
        ?>
</th>
						<td>
							<?php 
        if (!empty($recomm_posts)) {
            global $post;
            $query = new WP_Query(['posts_per_page' => -1, 'post__in' => $recomm_posts, 'ignore_sticky_posts' => true]);
            if ($query->have_posts()) {
                foreach ($query->posts as $post) {
                    setup_postdata($post);
                    ?>
<label for="<?php 
                    echo __CLASS__;
                    ?>
-<?php 
                    echo $post->ID;
                    ?>
" class="button">
	<input type="checkbox" id="<?php 
                    echo __CLASS__;
                    ?>
-<?php 
                    echo $post->ID;
                    ?>
" name="<?php 
                    echo __CLASS__;
                    ?>
[ids][]" value="<?php 
                    echo $post->ID;
                    ?>
" checked >
	#<?php 
                    echo $post->ID;
                    ?>
 <?php 
                    echo theme_cache::get_the_title($post->ID);
                    ?>
 
	<a href="<?php 
                    echo esc_url(get_edit_post_link($post->ID));
                    ?>
" target="_blank" title="<?php 
                    echo ___('Open in open window');
                    ?>
"><i class="fa fa-external-link"></i></a>
</label>
										<?php 
                }
                wp_reset_postdata();
            } else {
                echo status_tip('info', ___('No any post yet'));
            }
        } else {
            echo status_tip('info', ___('No any post yet'));
        }
        ?>
						</td>
					</tr>
				</tbody>
			</table>
		</fieldset>
		<?php 
    }
Пример #7
0
    /**
     * Display page list on select tag
     *
     * @param string $group_id
     * @param string $page_slug
     * @return
     * @version 1.2.0
     */
    public static function page_option_list($group_id, $iden)
    {
        static $pages = null;
        if ($pages === null) {
            $pages = get_pages();
        }
        $opt = theme_options::get_options($group_id);
        $page_id = isset($opt[$iden]) ? (int) $opt[$iden] : null;
        ob_start();
        ?>
		<select name="<?php 
        echo $group_id;
        ?>
[<?php 
        echo $iden;
        ?>
]" id="<?php 
        echo $group_id;
        ?>
-<?php 
        echo $iden;
        ?>
">
			<option value="-1"><?php 
        echo ___('Select page');
        ?>
</option>
			<?php 
        foreach ($pages as $page) {
            if ($page_id == $page->ID) {
                $selected = ' selected ';
            } else {
                $selected = null;
            }
            ?>
				<option value="<?php 
            echo $page->ID;
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo theme_cache::get_the_title($page->ID);
            ?>
</option>
				<?php 
        }
        ?>
		</select>
		<?php 
    }
Пример #8
0
 /**
  * HOOK - Add post-delete history to user meta
  *
  * @version 1.0.0
  */
 public static function action_add_history_post_delete($post_id)
 {
     $post = theme_cache::get_post($post_id);
     if (!$post) {
         return false;
     }
     /** unset published */
     if (class_exists('theme_custom_contribution')) {
         theme_custom_contribution::delete_once_published($post_id);
     }
     if ($post->post_type !== 'post') {
         return false;
     }
     $meta = array('type' => 'post-delete', 'post-title' => theme_cache::get_the_title($post->ID), 'timestamp' => current_time('timestamp'));
     /**
      * add to history
      */
     self::add_history($post->post_author, $meta);
     /**
      * point
      */
     $old_point = self::get_point($post->post_author);
     update_user_meta($post->post_author, self::$user_meta_key['point'], $old_point - self::get_point_value('post-delete'));
 }
Пример #9
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 
    }
    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();
    }
Пример #11
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 
    }
Пример #12
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));
 }
Пример #13
0
 private static function process_post()
 {
     $output = [];
     $ctb = isset($_POST['ctb']) && is_array($_POST['ctb']) ? array_filter($_POST['ctb']) : null;
     /** check ctb object */
     if (empty($ctb)) {
         $output['status'] = 'error';
         $output['code'] = 'invaild_ctb_param';
         $output['msg'] = ___('Invaild contribution param.');
         die(theme_features::json_format($output));
     }
     $edit_post_id = isset($_POST['post-id']) && is_numeric($_POST['post-id']) ? (int) $_POST['post-id'] : 0;
     $edit_again = false;
     /**
      * check edit
      */
     if ($edit_post_id != 0) {
         /** set edit again */
         $edit_again = true;
         //self::set_once_published($edit_post_id);
         /**
          * check post exists
          */
         $old_post = theme_cache::get_post($edit_post_id);
         if (!$old_post || $old_post->post_type !== 'post' || !self::in_edit_post_status($old_post->post_status)) {
             die(theme_features::json_format(['status' => 'error', 'code' => 'post_not_exist', 'msg' => ___('Sorry, the post does not exist.')]));
         }
         /**
          * check post author is myself
          */
         if ($old_post->post_author != theme_cache::get_current_user_id()) {
             die(theme_features::json_format(['status' => 'error', 'code' => 'post_not_exist', 'msg' => ___('Sorry, you are not the post author, can not edit it.')]));
         }
         /**
          * check post edit lock status
          */
         $lock_user_id = self::wp_check_post_lock($edit_post_id);
         if ($lock_user_id) {
             die(theme_features::json_format(['status' => 'error', 'code' => 'post_not_exist', 'msg' => ___('Sorry, the post does not exist.')]));
         }
     }
     /**
      * post title
      */
     $post_title = isset($ctb['post-title']) && is_string($ctb['post-title']) ? trim($ctb['post-title']) : null;
     if (!$post_title) {
         $output['status'] = 'error';
         $output['code'] = 'invaild_post_title';
         $output['msg'] = ___('Please write the post title.');
         die(theme_features::json_format($output));
     }
     /**
      * post excerpt
      */
     $post_excerpt = isset($ctb['post-excerpt']) && is_string($ctb['post-excerpt']) ? trim($ctb['post-excerpt']) : null;
     /**
      * post content
      */
     $post_content = isset($ctb['post-content']) && is_string($ctb['post-content']) ? trim($ctb['post-content']) : null;
     if (!$post_content) {
         $output['status'] = 'error';
         $output['code'] = 'invaild_post_content';
         $output['msg'] = ___('Please write the post content.');
         die(theme_features::json_format($output));
     }
     /**
      * check thumbnail cover
      */
     $thumbnail_id = isset($ctb['thumbnail-id']) && is_numeric($ctb['thumbnail-id']) ? (int) $ctb['thumbnail-id'] : null;
     if (!$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));
     }
     /**
      * cats
      */
     if ($edit_post_id == 0) {
         /** new post */
         $cat_ids = isset($ctb['cats']) && is_array($ctb['cats']) ? $ctb['cats'] : null;
         if (is_null_array($cat_ids)) {
             $output['status'] = 'error';
             $output['code'] = 'invaild_cat_id';
             $output['msg'] = ___('Please select a category.');
             die(theme_features::json_format($output));
         }
         /** edit post */
     } else {
         /**
          * get all cats
          */
         $cat_id = isset($ctb['cat']) && is_numeric($ctb['cat']) ? (int) $ctb['cat'] : null;
         if (empty($cat_id)) {
             $output['status'] = 'error';
             $output['code'] = 'invaild_cat_id';
             $output['msg'] = ___('Please select a category.');
             die(theme_features::json_format($output));
         }
         $cat_ids = [];
         theme_features::get_all_cats_by_child($cat_id, $cat_ids);
     }
     /**
      * tags
      */
     $tags = isset($ctb['tags']) && is_array($ctb['tags']) ? array_filter($ctb['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('publish_posts')) {
         $post_status = 'publish';
     } else {
         $post_status = 'pending';
     }
     /*****************************
      * PASS ALL, WRITE TO DB
      *****************************/
     /** edit post */
     if ($edit_post_id != 0) {
         $post_status = self::get_update_post_status($old_post->post_status);
         $post_id = wp_update_post(['ID' => $edit_post_id, 'post_title' => $post_title, 'post_status' => $post_status, 'post_type' => $old_post->post_type, 'post_excerpt' => fliter_script($post_excerpt), 'post_content' => fliter_script($post_content), 'post_category' => $cat_ids, 'tags_input' => $tags], true);
         /**
          * insert post
          */
     } else {
         $post_id = wp_insert_post(['post_title' => $post_title, 'post_excerpt' => fliter_script($post_excerpt), 'post_content' => fliter_script($post_content), 'post_status' => $post_status, 'post_author' => theme_cache::get_current_user_id(), 'post_category' => $cat_ids, 'tags_input' => $tags], true);
     }
     /**
      * check error
      */
     if (is_wp_error($post_id)) {
         $output['status'] = 'error';
         $output['code'] = $post_id->get_error_code();
         $output['msg'] = $post_id->get_error_message();
         die(theme_features::json_format($output));
     }
     /** end post error */
     /** set post thumbnail */
     set_post_thumbnail($post_id, $thumbnail_id);
     /**
      * set attachment parent
      */
     $attach_ids = isset($ctb['attach-ids']) && is_array($ctb['attach-ids']) ? array_map('intval', array_filter($ctb['attach-ids'])) : null;
     if ($attach_ids) {
         /** set attachment post parent */
         foreach ($attach_ids as $attach_id) {
             $post = theme_cache::get_post($attach_id);
             if (!$post || $post->post_type !== 'attachment') {
                 continue;
             }
             wp_update_post(['ID' => $attach_id, 'post_parent' => $post_id]);
         }
     }
     /** end set post thumbnail */
     /**
      * if new post
      */
     if ($edit_post_id == 0) {
         /**
          * pending status
          */
         if ($post_status === 'pending') {
             $output['status'] = 'success';
             $output['msg'] = ___('Your post submitted successful, it will be published after approve in a while.');
             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="javascript:location.href=location.href;">' . ___('countinue to write a new post') . '</a>');
             /**
              * add point
              */
             if ($edit_again && 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'));
             }
             /** end point */
         }
         /** end post status */
     } else {
         $output['status'] = 'success';
         if ($old_post->post_status == 'publish') {
             $output['msg'] = ___('Your post has updated successful.') . ' <a href="' . theme_cache::get_permalink($post_id) . '" target="_blank">' . ___('Views it now') . '</a>';
         } else {
             $output['msg'] = ___('Your post has updated successful.');
         }
         die(theme_features::json_format($output));
     }
     /** end post edit */
     die(theme_features::json_format($output));
 }
Пример #14
0
        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;
        ?>
" title="<?php 
        echo ___('Click to edit');
        ?>
"><?php 
        echo theme_cache::get_the_title($post->ID);
        ?>
</a></strong></h4>
							<div class="edit-post-action btn-group btn-group-xs">
								<a href="<?php 
        echo $post_edit_url;
        ?>
" class="btn btn-primary edit-post-action-edit">
									<i class="fa fa-pencil-square-o"></i> 
									<?php 
        echo ___('Edit');
        ?>
								</a>
								<a class="btn btn-default edit-post-action-view" href="<?php 
        echo theme_cache::get_permalink($post->ID);
        ?>
    /**
     * Start the element output.
     *
     * @see Walker_Nav_Menu::start_el()
     * @since 3.0.0
     *
     * @param string $output Passed by reference. Used to append additional content.
     * @param object $item   Menu item data object.
     * @param int    $depth  Depth of menu item. Used for padding.
     * @param array  $args   Not used.
     * @param int    $id     Not used.
     */
    public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
    {
        global $_wp_nav_menu_max_depth;
        $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
        ob_start();
        $item_id = esc_attr($item->ID);
        $removed_args = array('action', 'customlink-tab', 'edit-menu-item', 'menu-item', 'page-tab', '_wpnonce');
        $original_title = '';
        if ('taxonomy' == $item->type) {
            $original_title = get_term_field('name', $item->object_id, $item->object, 'raw');
            if (is_wp_error($original_title)) {
                $original_title = false;
            }
        } elseif ('post_type' == $item->type) {
            $original_object = theme_cache::get_post($item->object_id);
            $original_title = theme_cache::get_the_title($original_object->ID);
        }
        $classes = array('menu-item menu-item-depth-' . $depth, 'menu-item-' . esc_attr($item->object), 'menu-item-edit-' . (isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ? 'active' : 'inactive'));
        $title = $item->title;
        if (!empty($item->_invalid)) {
            $classes[] = 'menu-item-invalid';
            /* translators: %s: title of menu item which is invalid */
            $title = sprintf(__('%s (Invalid)'), $item->title);
        } elseif (isset($item->post_status) && 'draft' == $item->post_status) {
            $classes[] = 'pending';
            /* translators: %s: title of menu item in draft status */
            $title = sprintf(__('%s (Pending)'), $item->title);
        }
        $title = !isset($item->label) || '' == $item->label ? $title : $item->label;
        $submenu_text = '';
        if (0 == $depth) {
            $submenu_text = 'style="display: none;"';
        }
        ?>
		<li id="menu-item-<?php 
        echo $item_id;
        ?>
" class="<?php 
        echo implode(' ', $classes);
        ?>
">
			<dl class="menu-item-bar">
				<dt class="menu-item-handle">
					<span class="item-title"><span class="menu-item-title"><?php 
        echo esc_html($title);
        ?>
</span> <span class="is-submenu" <?php 
        echo $submenu_text;
        ?>
><?php 
        _e('sub item');
        ?>
</span></span>
					<span class="item-controls">
						<span class="item-type"><?php 
        echo esc_html($item->type_label);
        ?>
</span>
						<span class="item-order hide-if-js">
							<a href="<?php 
        echo wp_nonce_url(add_query_arg(array('action' => 'move-up-menu-item', 'menu-item' => $item_id), remove_query_arg($removed_args, admin_url('nav-menus.php'))), 'move-menu_item');
        ?>
" class="item-move-up"><abbr title="<?php 
        esc_attr_e('Move up');
        ?>
">&#8593;</abbr></a>
							|
							<a href="<?php 
        echo wp_nonce_url(add_query_arg(array('action' => 'move-down-menu-item', 'menu-item' => $item_id), remove_query_arg($removed_args, admin_url('nav-menus.php'))), 'move-menu_item');
        ?>
" class="item-move-down"><abbr title="<?php 
        esc_attr_e('Move down');
        ?>
">&#8595;</abbr></a>
						</span>
						<a class="item-edit" id="edit-<?php 
        echo $item_id;
        ?>
" title="<?php 
        esc_attr_e('Edit Menu Item');
        ?>
" href="<?php 
        echo isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ? admin_url('nav-menus.php') : add_query_arg('edit-menu-item', $item_id, remove_query_arg($removed_args, admin_url('nav-menus.php#menu-item-settings-' . $item_id)));
        ?>
"><?php 
        _e('Edit Menu Item');
        ?>
</a>
					</span>
				</dt>
			</dl>

			<div class="menu-item-settings" id="menu-item-settings-<?php 
        echo $item_id;
        ?>
">
				<?php 
        if ('custom' == $item->type) {
            ?>
					<p class="field-url description description-wide">
						<label for="edit-menu-item-url-<?php 
            echo $item_id;
            ?>
">
							<?php 
            _e('URL');
            ?>
<br />
							<input type="text" id="edit-menu-item-url-<?php 
            echo $item_id;
            ?>
" class="widefat code edit-menu-item-url" name="menu-item-url[<?php 
            echo $item_id;
            ?>
]" value="<?php 
            echo esc_attr($item->url);
            ?>
" />
						</label>
					</p>
				<?php 
        }
        ?>
				<p class="description description-thin">
					<label for="edit-menu-item-title-<?php 
        echo $item_id;
        ?>
">
						<?php 
        _e('Navigation Label');
        ?>
<br />
						<input type="text" id="edit-menu-item-title-<?php 
        echo $item_id;
        ?>
" class="widefat edit-menu-item-title" name="menu-item-title[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->title);
        ?>
" />
					</label>
				</p>
				<p class="description description-thin">
					<label for="edit-menu-item-attr-title-<?php 
        echo $item_id;
        ?>
">
						<?php 
        _e('Title Attribute');
        ?>
<br />
						<input type="text" id="edit-menu-item-attr-title-<?php 
        echo $item_id;
        ?>
" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->post_excerpt);
        ?>
" />
					</label>
				</p>
				<p class="field-link-target description">
					<label for="edit-menu-item-target-<?php 
        echo $item_id;
        ?>
">
						<input type="checkbox" id="edit-menu-item-target-<?php 
        echo $item_id;
        ?>
" value="_blank" name="menu-item-target[<?php 
        echo $item_id;
        ?>
]"<?php 
        checked($item->target, '_blank');
        ?>
 />
						<?php 
        _e('Open link in a new window/tab');
        ?>
					</label>
				</p>
				<!-- awesome icon -->
				<p class="description description-thin">
					<label for="edit-menu-item-awesome-<?php 
        echo $item_id;
        ?>
">
						<?php 
        __e('Awesome icon');
        ?>
 <a href="//fortawesome.github.io/Font-Awesome/icons" target="_blank" title="<?php 
        echo ___('Views all icons');
        ?>
">#<?php 
        echo ___('ALL');
        ?>
</a>
						<br />
						<input type="text" id="edit-menu-item-awesome-<?php 
        echo $item_id;
        ?>
" class="widefat edit-menu-item-awesome" name="menu-item-awesome[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo $item->awesome;
        ?>
" list="edit-menu-item-awesome-<?php 
        echo $item_id;
        ?>
-datalist">
						<?php 
        echo icon_option_list('edit-menu-item-awesome-' . $item_id . '-datalist');
        ?>
					</label>
				</p><!-- /awesome icon -->
				
				<p class="field-css-classes description description-thin">
					<label for="edit-menu-item-classes-<?php 
        echo $item_id;
        ?>
">
						<?php 
        _e('CSS Classes (optional)');
        ?>
<br />
						<input type="text" id="edit-menu-item-classes-<?php 
        echo $item_id;
        ?>
" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr(implode(' ', $item->classes));
        ?>
" />
					</label>
				</p>
				<!-- only show icon -->
				<p class="description description-thin field-hide-title">
					<label for="edit-menu-item-hide-title-<?php 
        echo $item_id;
        ?>
">
						<?php 
        echo ___('Toggle navigation label');
        ?>
<br>
						<select id="edit-menu-item-hide-title-<?php 
        echo $item_id;
        ?>
" class="widefat edit-menu-item-hide-title" name="menu-item-hide-title[<?php 
        echo $item_id;
        ?>
]" >
							<option value="-1"><?php 
        echo ___('Show navigation label');
        ?>
</option>
							<option value="1" <?php 
        echo isset($item->hide_title) && $item->hide_title == 1 ? 'select' : null;
        ?>
><?php 
        echo ___('Hide navigation label');
        ?>
</option>
						</select>
					</label>
				</p><!-- /only show icon -->
				
				<p class="field-xfn description description-thin">
					<label for="edit-menu-item-xfn-<?php 
        echo $item_id;
        ?>
">
						<?php 
        _e('Link Relationship (XFN)');
        ?>
<br />
						<input type="text" id="edit-menu-item-xfn-<?php 
        echo $item_id;
        ?>
" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->xfn);
        ?>
" />
					</label>
				</p>
				<p class="field-description description description-wide">
					<label for="edit-menu-item-description-<?php 
        echo $item_id;
        ?>
">
						<?php 
        _e('Description');
        ?>
<br />
						<textarea id="edit-menu-item-description-<?php 
        echo $item_id;
        ?>
" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php 
        echo $item_id;
        ?>
]"><?php 
        echo esc_html($item->description);
        // textarea_escaped
        ?>
</textarea>
						<span class="description"><?php 
        _e('The description will be displayed in the menu if the current theme supports it.');
        ?>
</span>
					</label>
				</p>

				<p class="field-move hide-if-no-js description description-wide">
					<label>
						<span><?php 
        _e('Move');
        ?>
</span>
						<a href="#" class="menus-move menus-move-up" data-dir="up"><?php 
        _e('Up one');
        ?>
</a>
						<a href="#" class="menus-move menus-move-down" data-dir="down"><?php 
        _e('Down one');
        ?>
</a>
						<a href="#" class="menus-move menus-move-left" data-dir="left"></a>
						<a href="#" class="menus-move menus-move-right" data-dir="right"></a>
						<a href="#" class="menus-move menus-move-top" data-dir="top"><?php 
        _e('To the top');
        ?>
</a>
					</label>
				</p>

				<div class="menu-item-actions description-wide submitbox">
					<?php 
        if ('custom' != $item->type && $original_title !== false) {
            ?>
						<p class="link-to-original">
							<?php 
            printf(__('Original: %s'), '<a href="' . esc_attr($item->url) . '">' . esc_html($original_title) . '</a>');
            ?>
						</p>
					<?php 
        }
        ?>
					<a class="item-delete submitdelete deletion" id="delete-<?php 
        echo $item_id;
        ?>
" href="<?php 
        echo wp_nonce_url(add_query_arg(array('action' => 'delete-menu-item', 'menu-item' => $item_id), admin_url('nav-menus.php')), 'delete-menu_item_' . $item_id);
        ?>
"><?php 
        _e('Remove');
        ?>
</a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php 
        echo $item_id;
        ?>
" href="<?php 
        echo esc_url(add_query_arg(array('edit-menu-item' => $item_id, 'cancel' => time()), admin_url('nav-menus.php')));
        ?>
#menu-item-settings-<?php 
        echo $item_id;
        ?>
"><?php 
        _e('Cancel');
        ?>
</a>
				</div>

				<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo $item_id;
        ?>
" />
				<input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->object_id);
        ?>
" />
				<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->object);
        ?>
" />
				<input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->menu_item_parent);
        ?>
" />
				<input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->menu_order);
        ?>
" />
				<input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->type);
        ?>
" />
			</div><!-- .menu-item-settings-->
			<ul class="menu-item-transport"></ul>
		<?php 
        $output .= ob_get_clean();
    }
Пример #16
0
								<img class="post-list-img" src="<?php 
        echo theme_functions::$thumbnail_placeholder;
        ?>
" data-src="<?php 
        echo esc_url($thumbnail_real_src);
        ?>
" alt="<?php 
        echo theme_cache::get_the_title($post->ID);
        ?>
" width="80" height="50"/>
							</a>
						</div>
						<div class="media-body">
							<div class="media-heading">
								<?php 
        echo sprintf(___('Published a comment in %1$s.'), '<a href="' . theme_cache::get_permalink($post->ID) . '">' . theme_cache::get_the_title($post->ID) . '</a>');
        ?>
							</div>
							<div class="excerpt">
								<?php 
        comment_text();
        ?>
							</div>
						</div>
					</div>
				</li>
				<?php 
    }
    /** end foreach comment */
    wp_reset_postdata();
    ?>
Пример #17
0
    private static function send_email($parent_comment, $child_comment)
    {
        if (!is_email($parent_comment->comment_author_email)) {
            return false;
        }
        /** if parent email equal child email, do nothing */
        if ($parent_comment->comment_author_email == $child_comment->comment_author_email) {
            return false;
        }
        $post_id = $parent_comment->comment_post_ID;
        $post_title = theme_cache::get_the_title($post_id);
        $post_url = theme_cache::get_permalink($post_id);
        $comment_url = esc_url(get_comment_link($child_comment));
        $mail_title = sprintf(___('[%s] Your comment has a reply in "%s".'), theme_cache::get_bloginfo('name'), $post_title);
        ob_start();
        ?>
<p>
	<?php 
        echo sprintf(___('Your comment: %s'), esc_html(get_comment_text($parent_comment->comment_ID)));
        ?>
</p>

<p>
	<?php 
        echo sprintf(___('%s\'s reply: %s'), get_comment_author($child_comment->comment_ID), get_comment_text($child_comment->comment_ID));
        ?>
</p>

<p>
	<?php 
        echo sprintf(___('Views the comment: %s'), '<a href="' . $comment_url . '" target="_blank">' . $comment_url . '</a>');
        ?>
</p>

		<?php 
        $mail_content = ob_get_contents();
        ob_end_clean();
        add_filter('wp_mail_content_type', __CLASS__ . '::set_html_content_type');
        wp_mail($parent_comment->comment_author_email, $mail_title, $mail_content);
        remove_filter('wp_mail_content_type', __CLASS__ . '::set_html_content_type');
    }
Пример #18
0
    public static function list_history_post_be_rate($history)
    {
        if ($history['type'] !== 'post-be-rate') {
            return false;
        }
        ?>
		<li class="list-group-item">
			<?php 
        theme_custom_point::the_list_icon('thumbs-up');
        ?>
			<?php 
        theme_custom_point::the_point_sign($history['points']);
        ?>
			
			<span class="history-text">
				<?php 
        $post = theme_cache::get_post($history['post-id']);
        if (!$post) {
            echo ___('The post has been deleted.');
        } else {
            echo sprintf(___('You post %1$s has been rated %2$d %3$s by %4$s.'), '<a href="' . theme_cache::get_permalink($history['post-id']) . '">' . theme_cache::get_the_title($history['post-id']) . '</a>', abs($history['points']), theme_custom_point::get_point_name(), esc_html(get_author_meta('display_name', $history['rater-id'])));
        }
        ?>
			</span>
			
			<?php 
        theme_custom_point::the_time($history);
        ?>
		</li>
		<?php 
    }
Пример #19
0
    function widget($args, $instance)
    {
        $instance = array_merge(self::get_default_options(), $instance);
        echo $args['before_widget'];
        $comments = get_comments(array('status' => 'approve', 'number' => isset($instance['number']) ? (int) $instance['number'] : 6, 'type' => 'comment'));
        if (!empty($instance['title'])) {
            echo $args['before_title'];
            ?>
			<i class="fa fa-comments-o"></i> 
			<?php 
            echo $instance['title'];
            echo $args['after_title'];
        }
        if (!empty($comments)) {
            global $comment;
            $comment_bak = $comment;
            ?>
			<ul class="list-group">
				<?php 
            foreach ($comments as $comment) {
                /**
                 * cache
                 */
                static $caches = [];
                /** author_name */
                if (!isset($caches['author_name'][$comment->comment_author])) {
                    $caches['author_name'][$comment->comment_author] = esc_html(get_comment_author());
                }
                /** avatar placeholder */
                if (!isset($caches['avatar_placeholder'])) {
                    $caches['avatar_placeholder'] = theme_functions::$avatar_placeholder;
                }
                /** comment text */
                $comment_text = str_sub(strip_tags(preg_replace('/<img[^>]+>/i', '[' . ___('Image') . ']', get_comment_text($comment->comment_ID))), 35);
                ?>
<li class="list-group-item">
	<a class="media tooltip top" href="<?php 
                echo theme_cache::get_permalink($comment->comment_post_ID);
                ?>
#comment-<?php 
                echo $comment->comment_ID;
                ?>
" title="<?php 
                echo theme_cache::get_the_title($comment->comment_post_ID);
                ?>
">
		<div class="media-left">
			<img class="avatar media-object" data-src="<?php 
                echo esc_url(theme_cache::get_avatar_url($comment));
                ?>
" src="<?php 
                echo $caches['avatar_placeholder'];
                ?>
" alt="<?php 
                echo $caches['author_name'][$comment->comment_author];
                ?>
" width="<?php 
                echo self::$avatar_size;
                ?>
" height="<?php 
                echo self::$avatar_size;
                ?>
"/>
		</div>
		<div class="media-body">
			<h4 class="media-heading">
				<span class="author"><?php 
                echo $caches['author_name'][$comment->comment_author];
                ?>
</span>
				<time datetime="<?php 
                echo get_comment_time('c');
                ?>
">
					<small><?php 
                echo friendly_date(get_comment_time('U'));
                ?>
</small>
				</time>
			</h4>
			<div class="text"><?php 
                echo $comment_text;
                ?>
</div>
		</div>
	</a>
</li>
				<?php 
            }
            ?>
			</ul>
			<?php 
            $comment = $comment_bak;
        } else {
            ?>
			<div class="content">
				<div class="page-tip"><?php 
            echo status_tip('info', ___('No any comment yet.'));
            ?>
</div>
			</div>
		<?php 
        }
        echo $args['after_widget'];
    }
Пример #20
0
    /**
     * list comment-reply
     */
    public static function list_noti_comment_reply($noti)
    {
        if ($noti['type'] !== 'comment-reply') {
            return false;
        }
        $comment = theme_notification::get_comment($noti['comment-id']);
        ?>
		<div class="media">
			<div class="media-left">
				<a href="<?php 
        echo comment_author_url($noti['comment-id']);
        ?>
">
					<img src="<?php 
        echo theme_functions::$avatar_placeholder;
        ?>
" data-src="<?php 
        echo theme_cache::get_avatar_url($comment->user_id);
        ?>
" class="avatar media-object" alt="avatar" width="60" height="60">
				</a>
			</div>
			<div class="media-body">
				<h4 class="media-heading">
					<span class="label label-default"><i class="fa fa-comments-o"></i> <?php 
        echo ___('Comment reply');
        ?>
</span> 
					<?php 
        echo sprintf(___('Your comment has a reply by %1$s in %2$s.'), get_comment_author_link($noti['comment-id']), '<a href="' . theme_cache::get_permalink($comment->comment_post_ID) . '#comment-' . $noti['comment-id'] . '">
							' . theme_cache::get_the_title($comment->comment_post_ID) . '
						</a>');
        ?>
				</h4>
				<div class="excerpt"><?php 
        comment_text($noti['comment-id']);
        ?>
</div>
			</div><!-- /.media-body -->
		</div><!-- /.media -->
		<?php 
    }
 function die_json_error_msg($id, $message)
 {
     die(json_encode(array('error' => sprintf(___('&quot;%1$s&quot; (ID %2$s) failed to resize. The error message was: %3$s'), theme_cache::get_the_title($id), $id, $message))));
 }
Пример #22
0
    /**
     * get_crumb
     * 
     * 
     * @return string The html code
     * @version 2.0.7
     * 
     */
    public static function get_crumb(array $args = [])
    {
        $args = array_merge(['header' => null, 'footer' => null], $args);
        $links = [];
        if (theme_cache::is_home()) {
            return null;
        }
        $links['home'] = '<a href="' . theme_cache::home_url() . '" class="home" title="' . ___('Back to Homepage') . '">
			<i class="fa fa-home fa-fw"></i>
			<span class="hide">' . ___('Back to Homepage') . '</span>
		</a>';
        $split = '<span class="split"><i class="fa fa-angle-right"></i></span>';
        /* category */
        if (theme_cache::is_category()) {
            $cat_curr = theme_features::get_current_cat_id();
            if ($cat_curr > 1) {
                $links_cat = get_category_parents($cat_curr, true, '%split%');
                $links_cats = explode('%split%', $links_cat);
                array_pop($links_cats);
                $links['category'] = implode($split, $links_cats);
                $links['curr_text'] = ___('Category Browser');
            }
            /* tag */
        } else {
            if (theme_cache::is_tag()) {
                $tag_id = theme_features::get_current_tag_id();
                $tag_obj = get_tag($tag_id);
                $links['tag'] = '<a href="' . esc_url(get_tag_link($tag_id)) . '">' . esc_html(theme_features::get_current_tag_name()) . '</a>';
                $links['curr_text'] = ___('Tags Browser');
                /* date */
            } else {
                if (theme_cache::is_date()) {
                    global $wp_query;
                    $day = $wp_query->query_vars['day'];
                    $month = $wp_query->query_vars['monthnum'];
                    $year = $wp_query->query_vars['year'];
                    /* day */
                    if (theme_cache::is_day()) {
                        $date_link = get_day_link(null, null, $day);
                        /* month */
                    } else {
                        if (theme_cache::is_month()) {
                            $date_link = get_month_link($year, $month);
                            /* year */
                        } else {
                            if (theme_cache::is_year()) {
                                $date_link = get_year_link($year);
                            }
                        }
                    }
                    $links['date'] = '<a href="' . $date_link . '">' . theme_cache::wp_title('', false) . '</a>';
                    $links['curr_text'] = ___('Date Browser');
                    /* search*/
                } else {
                    if (theme_cache::is_search()) {
                        // $nav_link = null;
                        $links['curr_text'] = sprintf(___('Search Result: %s'), esc_html(get_search_query()));
                        /* author */
                    } else {
                        if (theme_cache::is_author()) {
                            global $author;
                            $user = get_user_by('id', $author);
                            $links['author'] = '<a href="' . theme_cache::get_author_posts_url($author) . '">' . theme_cache::get_the_author_meta('display_name', $user->ID) . '</a>';
                            $links['curr_text'] = ___('Author posts');
                            /* archive */
                        } else {
                            if (theme_cache::is_archive()) {
                                $links['archive'] = '<a href="' . get_current_url() . '">' . theme_cache::wp_title('', false) . '</a>';
                                $links['curr_text'] = ___('Archive Browser');
                                /* Singular */
                            } else {
                                if (theme_cache::is_singular()) {
                                    global $post;
                                    /* The page parent */
                                    if ($post->post_parent) {
                                        $links['singluar'] = '<a href="' . theme_cache::get_permalink($post->post_parent) . '">' . theme_cache::get_the_title($post->post_parent) . '</a>';
                                    }
                                    /**
                                     * post / page
                                     */
                                    if (theme_features::get_current_cat_id() > 1) {
                                        $categories = get_the_category();
                                        foreach ($categories as $key => $row) {
                                            $parent_id[$key] = $row->category_parent;
                                        }
                                        array_multisort($parent_id, SORT_ASC, $categories);
                                        foreach ($categories as $cat) {
                                            $cat_name = esc_html($cat->name);
                                            $links['singluar'] = '<a href="' . esc_url(get_category_link($cat->cat_ID)) . '" title="' . sprintf(___('View all posts in %s'), $cat_name) . '">' . $cat_name . '</a>';
                                        }
                                    }
                                    $links['curr_text'] = theme_cache::get_the_title($post->ID);
                                    /* 404 */
                                } else {
                                    if (theme_cache::is_404()) {
                                        // $nav_link = null;
                                        $links['curr_text'] = ___('Not found');
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return '<div class="crumb-container">
		' . $args['header'] . '
		<nav class="crumb">
			' . implode($split, apply_filters('crumb_links', $links)) . '
		</nav>
		' . $args['footer'] . '
	</div>';
    }
Пример #23
0
    public static function filter_the_content($content)
    {
        if (!theme_cache::is_attachment()) {
            return $content;
        }
        global $post;
        $post_title = theme_cache::get_the_title($post->post_parent);
        if (!wp_attachment_is_image($post->ID)) {
            return $content;
        }
        $current_img_full = wp_get_attachment_image_src($post->ID, 'full');
        $current_img_thumbnail = wp_get_attachment_image_src($post->ID, 'thumbnail');
        $children = get_children(['post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'order' => 'ASC']);
        $children = array_values($children);
        $count = count($children);
        $child_posts = [];
        $current_post_index = 0;
        for ($i = 0; $i < $count; ++$i) {
            $child_img = wp_get_attachment_image_src($children[$i]->ID, 'thumbnail');
            $child_posts[$i] = ['id' => $children[$i]->ID, 'permalink' => theme_cache::get_permalink($children[$i]->ID) . '#main', 'src' => $child_img[0], 'w' => $child_img[1], 'h' => $child_img[2]];
            if ($children[$i]->ID == $post->ID) {
                $current_post_index = $i;
            }
        }
        unset($child_img);
        ob_start();
        ?>
		<div class="attachment-slide">
			<div class="attachment-slide-content">
				<?php 
        /** if current is last post */
        if ($current_post_index == $count - 1) {
            $url_next = 'javascript:;';
            $title_next = ___('Already last page');
        } else {
            $url_next = $child_posts[$current_post_index + 1]['permalink'];
            $title_next = ___('Next page');
        }
        ?>
				<a href="<?php 
        echo $url_next;
        ?>
" title="<?php 
        echo $title_next;
        ?>
">
					<img src="<?php 
        echo $current_img_full[0];
        ?>
" alt="" width="<?php 
        echo $current_img_full[1];
        ?>
" height="<?php 
        echo $current_img_full[2];
        ?>
">
				</a>
			</div>
			<div class="attachment-slide-thumbnail">
				<?php 
        for ($i = 0; $i < $count; ++$i) {
            $class_active = $post->ID === $child_posts[$i]['id'] ? 'active' : null;
            ?>
					<a class="<?php 
            echo $class_active;
            ?>
" href="<?php 
            echo $child_posts[$i]['permalink'];
            ?>
">
						<img src="<?php 
            echo $child_posts[$i]['src'];
            ?>
" alt="<?php 
            echo $post_title;
            ?>
" width="<?php 
            echo $child_posts[$i]['w'];
            ?>
" height="<?php 
            echo $child_posts[$i]['h'];
            ?>
">
					</a>
				<?php 
        }
        ?>
			</div>
		</div>
		<?php 
        $content = ob_get_contents();
        ob_end_clean();
        return $content;
    }
Пример #24
0
		<?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
				<div id="main" class="main">
					<article id="post-<?php 
        echo $post->ID;
        ?>
" <?php 
        post_class(['singular-post panel']);
        ?>
>
						<h2 class="entry-title">
							<?php 
        echo sprintf(___('The attachment of %s'), '<a href="' . theme_cache::get_permalink($post->post_parent) . '">' . theme_cache::get_the_title($post->post_parent) . '</a>');
        ?>
						</h2>

						<div class="entry-content content-reset">
							<?php 
        the_content();
        ?>
						</div>
						
						<footer class="entry-footer">
							<?php 
        /** 
         * post-share
         */
        if (class_exists('theme_post_share') && theme_post_share::is_enabled()) {