public static function get_url() { static $cache = null; if ($cache === null) { $cache = theme_cache::get_permalink(get_page_by_path(self::$page_slug)->ID); } return $cache; }
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; }
public static function get_comment_text($comment_content, $comment) { /** * has parent */ if ($comment->comment_parent != 0) { $parent_comment = theme_cache::get_comment($comment->comment_parent); $parent_author = theme_cache::get_comment_author($parent_comment->comment_ID); $comment_content = '<a href="' . theme_cache::get_permalink($parent_comment->comment_post_ID) . '#comment-' . $parent_comment->comment_ID . '" class="at" rel="nofollow">@' . $parent_author . '</a> ' . $comment_content; } return $comment_content; }
<?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);
/** * get_link_page_url * * @param int $page * @return string The link page url * @version 1.0.1 */ public static function get_link_page_url($page = 1, $add_fragment = null) { global $wp_rewrite, $post; if (1 == $page) { $url = theme_cache::get_permalink($post->ID); } else { if ('' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending'))) { $url = add_query_arg('page', $page, theme_cache::get_permalink()); } elseif ('page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID) { $url = trailingslashit(theme_cache::get_permalink($post->ID)) . user_trailingslashit("{$wp_rewrite->pagination_base}/" . $page, 'single_paged'); } else { $url = trailingslashit(theme_cache::get_permalink($post->ID)) . user_trailingslashit($page, 'single_paged'); } } return $add_fragment ? esc_url($url) . '#' . $add_fragment : esc_url($url); }
/** * 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); }
public static function get_page_url() { if (self::get_options('page') > 0) { return theme_cache::get_permalink(self::get_options('page')); } return false; }
/** * Get sign page tabs * * @param string $key Page tab type * @param string $redirect Redirect url when login success * @return mix/array * @version 1.0.0 */ public static function get_tabs($key = null, $redirect = null) { static $baseurl = null; if ($baseurl === null) { $baseurl = theme_cache::get_permalink(theme_cache::get_page_by_path(self::$page_slug)->ID); } if ($redirect === null) { $redirect = get_query_var('redirect'); } if (!empty($redirect)) { $baseurl = add_query_arg(['redirect' => $redirect], $baseurl); } $tabs = ['login' => ['text' => ___('Login'), 'icon' => 'user', 'url' => add_query_arg(['tab' => 'login'], $baseurl)], 'register' => ['text' => ___('Register'), 'icon' => 'user-plus', 'url' => add_query_arg(['tab' => 'register'], $baseurl)], 'recover' => ['text' => ___('Recover password'), 'icon' => 'question-circle', 'url' => add_query_arg(['tab' => 'recover'], $baseurl)], 'reset' => ['text' => ___('Reset password'), 'icon' => 'history', 'url' => add_query_arg(['tab' => 'reset'], $baseurl)]]; if ($key) { return isset($tabs[$key]) ? $tabs[$key] : false; } return $tabs; }
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 }
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 }
/** * Theme respond */ public static function theme_respond() { global $post; ?> <div id="respond" class="panel"> <a href="javascript:;" id="cancel-comment-reply-link" class="none" title="<?php echo ___('Cancel reply'); ?> ">×</a> <div class="content"> <div class="page-tip" id="respond-loading-ready"> <?php echo status_tip('loading', ___('Loading, please wait...')); ?> </div> <p id="respond-must-login" class="well hide-on-logged none"> <?php echo sprintf(___('You must be %s to post a comment.'), '<a href="' . esc_url(wp_login_url(theme_cache::get_permalink($post->ID))) . '#respond' . '"><strong>' . ___('log-in') . '</strong></a>'); ?> </p> <form id="commentform" action="javascript:;" method="post" class="comment-form media none" > <div class="media"> <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="<?php echo $post->ID; ?> "> <input type="hidden" name="comment_parent" id="comment_parent" value="0"> <div class="media-left hidden-phone"> <img id="respond-avatar" src="<?php echo theme_functions::$avatar_placeholder; ?> " alt="avatar" class="media-object avatar" width="100" height="100"> </div> <div class="media-body"> <?php /** * for visitor */ $req = theme_cache::get_option('require_name_email'); ?> <!-- author name --> <div id="area-respond-visitor" class="row"> <div class="g-tablet-1-2"> <div class="form-group"> <input type="text" class="form-control" name="author" id="comment-form-author" placeholder="<?php echo ___('Nickname'); echo $req ? ' * ' : null; ?> " <?php echo $req ? ' required ' : null; ?> title="<?php echo ___('Whats your nickname?'); ?> " > </div><!-- /.form-group --> </div><!-- /.g-tablet-1-2 --> <!-- author email --> <div class="g-tablet-1-2"> <div class="form-group"> <input type="email" class="form-control" name="email" id="comment-form-email" placeholder="<?php echo ___('Email'); echo $req ? ' * ' : null; ?> " <?php echo $req ? ' required ' : null; ?> title="<?php echo ___('Whats your Email?'); ?> " > </div><!-- /.form-group --> </div><!-- /.g-tablet-1-2 --> </div><!-- /.row --> <div class="form-group form-group-textarea"> <textarea name="comment" id="comment-form-comment" class="form-control" rows="3" placeholder="<?php echo ___('Hi, have something to say?'); ?> " title="<?php echo ___('Nothing to say?'); ?> " required ></textarea> </div> <div class="form-group btn-group-submit"> <?php /** * theme comment emotion pop btn */ if (class_exists('theme_comment_emotion') && (theme_comment_emotion::is_enabled('kaomoji') || theme_comment_emotion::is_enabled('img'))) { theme_comment_emotion::display_frontend('pop'); } ?> <?php /** * theme comment emotion */ if (class_exists('theme_comment_emotion') && (theme_comment_emotion::is_enabled('kaomoji') || theme_comment_emotion::is_enabled('img'))) { theme_comment_emotion::display_frontend('pop-btn'); } ?> <button type="submit" class="submit btn btn-success" title="<?php echo ___('Post comment'); ?> "> <i class="fa fa-check"></i> <?php echo ___('Post comment'); ?> </button> </div><!-- .form-group --> </div><!-- /.media-body --> </div><!-- /.media --> </form> </div> </div> <?php }
public static function keywords_convert($content) { global $post; $meta = self::get_post_meta($post->ID); $source_url = isset($meta['reprint']['url']) ? esc_url($meta['reprint']['url']) : ___('unknow'); $source_author_name = isset($meta['reprint']['author']) ? esc_html($meta['reprint']['author']) : ___('unknow'); return str_replace(['%site_name%', '%site_url%', '%post_author_name%', '%post_author_url%', '%post_url%', '%source_url%', '%source_author_name%'], [theme_cache::get_bloginfo('name'), theme_cache::home_url(), theme_cache::get_the_author_meta('display_name', $post->post_author), theme_cache::get_author_posts_url($post->post_author), theme_cache::get_permalink($post->ID), $source_url, $source_author_name], $content); }
private static function get_preview(array $posts = []) { /** * check posts count number */ $count = count($posts); if ($count < self::get_posts_number('min')) { $output['status'] = 'error'; $output['code'] = 'not_enough_posts'; $output['msg'] = ___('Sorry, your posts are not enough, please add more posts.'); die(theme_features::json_format($output)); } if ($count > self::get_posts_number('max')) { $output['status'] = 'error'; $output['code'] = 'too_many_posts'; $output['msg'] = ___('Sorry, your post are too many, please reduce some posts and try again.'); die(theme_features::json_format($output)); } /** * template */ $tpl = ''; /** * check each posts value */ foreach ($posts as $k => $v) { /** post id */ $post_id = isset($v['post-id']) && is_string($v['post-id']) ? trim($v['post-id']) : null; if (empty($post_id)) { $output['status'] = 'error'; $output['code'] = 'invaild_post_content'; $output['list-id'] = $k; $output['msg'] = ___('Sorry, the post id is invaild, please try again.'); die(theme_features::json_format($output)); } /** title */ $title = isset($v['post-title']) && is_string($v['post-title']) ? strip_tags(trim($v['post-title'])) : null; if (empty($title)) { $output['status'] = 'error'; $output['code'] = 'invaild_post_title'; $output['list-id'] = $k; $output['msg'] = ___('Sorry, the post title is invaild, please try again.'); die(theme_features::json_format($output)); } /** content */ $content = isset($v['post-content']) && is_string($v['post-content']) ? trim($v['post-content']) : null; if (empty($content)) { $output['status'] = 'error'; $output['code'] = 'invaild_post_content'; $output['list-id'] = $k; $output['msg'] = ___('Sorry, the post content is invaild, please try again.'); die(theme_features::json_format($output)); } /** thumbmail */ $thumbnail = isset($v['thumbnail-url']) && is_string($v['thumbnail-url']) ? esc_url(trim($v['thumbnail-url'])) : null; if (empty($thumbnail)) { $output['status'] = 'error'; $output['code'] = 'invaild_post_thumbnail'; $output['list-id'] = $k; $output['msg'] = ___('Sorry, the post thumbnail is invaild, please try again.'); die(theme_features::json_format($output)); } /** check post exists */ $url = esc_url(theme_cache::get_permalink($v['post-id'])); if (empty($url)) { $output['status'] = 'error'; $output['code'] = 'post_not_exist'; $output['list-id'] = $k; $output['msg'] = ___('Sorry, the post do not exist, please try again.'); die(theme_features::json_format($output)); } /** * create template */ $tpl .= self::get_list_tpl(['post_id' => $post_id, 'preview' => false, 'hash' => $k, 'url' => $url, 'thumbnail' => $thumbnail, 'title' => $title, 'content' => $content]); } return '<div class="collection-list list-group">' . html_minify($tpl) . '</div>'; }
"><?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); ?> " target="_blank"> <i class="fa fa-link"></i> <?php echo ___('View'); ?> </a> </div> </td> <td class="edit-post-categories hidden-xs"> <?php echo get_the_category_list(' / '); ?> </td> <td class="edit-post-date">
<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(); ?>
public static function list_history_post_reply($history) { if ($history['type'] !== 'post-reply') { return false; } ?> <li class="list-group-item"> <?php theme_custom_point::the_list_icon('comments-o'); ?> <?php self::the_point_sign(self::get_point_value('post-reply')); ?> <span class="history-text"> <?php $comment = get_comment($history['comment-id']); if (!$comment) { echo ___('The comment has been deleted.'); } else { $post = theme_cache::get_post($comment->comment_post_ID); if (!$post) { echo ___('The post has been deleted.'); } else { echo sprintf(___('Your post %1$s has a new comment by %2$s.'), '<a href="' . theme_cache::get_permalink($post->ID) . '">' . theme_cache::get_the_title($post->ID) . '</a>', '<span class="comment-author">' . get_comment_author_link($history['comment-id']) . '</span>'); } } ?> </span> <?php self::the_time($history); ?> </li> <?php }
/** * 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 }
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'); }
/** * Get thumbnail data * * @param int $attach_id * @param array $output * @return array * @version 1.0.0 */ public static function get_thumbnail_data($attach_id, array $output = []) { $output['attach-page-url'] = theme_cache::get_permalink($attach_id); foreach (['thumbnail', 'medium', 'large', 'full'] as $size) { $output[$size] = ['url' => self::wp_get_attachment_image_src($attach_id, $size)[0], 'width' => self::wp_get_attachment_image_src($attach_id, $size)[1], 'height' => self::wp_get_attachment_image_src($attach_id, $size)[2]]; } return $output; }
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']; }
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(); }
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 }
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('[…]', '...', $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; }
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; }
<?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()) {