1. <?php
  2.  
  3. if ( isset( $_GET['latestblogpost'] ) )
  4. add_action( 'template_redirect', 'comicpress_latest_blog_post_jump' );
  5.  
  6. function comicpress_latest_blog_post_jump() {
  7. $catnum = 0;
  8. if (isset($_GET['latestblogpost'])) $catnum = (int)esc_attr($_GET['latestblogpost']);
  9. if (!empty($catnum)) {
  10. $args = array(
  11. 'numberposts' => 1,
  12. 'post_type' => 'post',
  13. 'orderby' => 'post_date',
  14. 'order' => 'DESC',
  15. 'post_status' => 'publish',
  16. 'category__in' => array($catnum)
  17. );
  18. $qposts = get_posts( $args );
  19. } else {
  20. $args = array(
  21. 'numberposts' => 1,
  22. 'post_type' => 'post',
  23. 'orderby' => 'post_date',
  24. 'order' => 'DESC',
  25. 'post_status' => 'publish'
  26. );
  27. $qposts = get_posts( $args );
  28. }
  29. if (is_array($qposts)) {
  30. $qposts = reset($qposts);
  31. wp_redirect( get_permalink( $qposts->ID ) );
  32. } else {
  33. wp_redirect( home_url() );
  34. }
  35. wp_reset_query();
  36. exit;
  37. }
  38.  
  39. if (!function_exists('comicpress_display_post_title')) {
  40. function comicpress_display_post_title() {
  41. global $post, $wp_query;
  42. $get_post_title = '';
  43. if ((comicpress_themeinfo('disable_page_titles') && is_page()) || (comicpress_themeinfo('disable_post_titles') && !is_page()) || (is_page('chat') || is_page('forum'))) return;
  44. if (is_page()) {
  45. $post_title = "<h2 class=\"page-title\">";
  46. } else {
  47. $post_title = "<h2 class=\"post-title\">";
  48. }
  49. if (is_page_template('blog.php') || is_home() || is_front_page()) $post_title .= "<a href=\"".get_permalink()."\">";
  50. $get_post_title .= get_the_title();
  51. if (!$get_post_title) $get_post_title = '( No Title )';
  52. $post_title .= $get_post_title;
  53. if (is_page_template('blog.php') || is_home() || is_front_page()) $post_title .= "</a>";
  54. $post_title .= "</h2>\r\n";
  55. echo apply_filters('comicpress_display_post_title',$post_title);
  56. }
  57. }
  58.  
  59. if (!function_exists('comicpress_display_post_thumbnail')) {
  60. function comicpress_display_post_thumbnail($size = 'thumbnail') {
  61. global $post, $wp_query;
  62. if ($post->post_type == 'post') {
  63. $post_thumbnail = '';
  64. $link = get_post_meta( $post->ID, 'link', true );
  65. if (empty($link)) $link = get_permalink();
  66. if ( has_post_thumbnail() ) {
  67. if (is_home()) {
  68. $post_thumbnail = '<div class="post-image"><center><a href="'.$link.'" rel="featured-image" title="Link to '.get_the_title().'">'.get_the_post_thumbnail($post->ID, $size).'</a></center></div>'."\r\n";
  69. } else
  70. $post_thumbnail = '<div class="post-image"><center>'.get_the_post_thumbnail($post->ID, $size).'</center></div>'."\r\n";
  71. } else {
  72. $url_image = get_post_meta($post->ID, 'featured-image', true);
  73. if (!empty($url_image)) $post_thumbnail = '<div class="post-image"><center><a href="'.$link.'" rel="featured-image" title="Link to "'.get_the_title().'"><img src="'.$url_image.'" title="'.get_the_title().'" alt="'.get_the_title().'"></a></center></div>'."\r\n";
  74. }
  75. echo apply_filters('comicpress_display_post_thumbnail', $post_thumbnail);
  76. }
  77. }
  78. }
  79.  
  80. if (!function_exists('comicpress_display_author_gravatar')) {
  81. function comicpress_display_author_gravatar() {
  82. global $post, $wp_query, $is_IE;
  83. if (is_page()) return;
  84. if (comicpress_themeinfo('enable_post_author_gravatar')) {
  85. $author_get_gravatar = get_avatar(get_the_author_meta('email'), 82, comicpress_random_default_avatar(get_the_author_meta('email'),get_the_author_meta('display_name')));
  86. if (!$is_IE) $author_get_gravatar = str_replace('photo', 'photo instant nocorner itxtalt', $author_get_gravatar);
  87. $author_gravatar = "<div class=\"post-author-gravatar\">".$author_get_gravatar."</div>\r\n";
  88. echo apply_filters('comicpress_display_author_gravatar', $author_gravatar);
  89. }
  90. }
  91. }
  92.  
  93. if (!function_exists('comicpress_display_post_calendar')) {
  94. function comicpress_display_post_calendar() {
  95. global $post, $wp_query;
  96. if (is_page()) return;
  97. if (comicpress_themeinfo('enable_post_calendar')) {
  98. $post_calendar = "<div class=\"post-calendar-date\"><div class=\"calendar-date\"><span>".get_the_time('M')."</span>".get_the_time('d')."</div></div>\r\n";
  99. echo apply_filters('comicpress_display_post_calendar', $post_calendar);
  100. }
  101. }
  102. }
  103.  
  104. if (!function_exists('comicpress_display_post_author')) {
  105. function comicpress_display_post_author() {
  106. global $post, $authordata;
  107. if (!comicpress_themeinfo('disable_author_info_in_posts')) {
  108. $post_author = "<span class=\"post-author\">".__('by','comicpress')." <a href=\"".get_author_posts_url( $authordata->ID, $authordata->user_nicename )."\">".get_the_author()."</a></span>\r\n";
  109. echo apply_filters('comicpress_display_post_author',$post_author);
  110. }
  111. }
  112. }
  113.  
  114. if (!function_exists('comicpress_display_post_date')) {
  115. function comicpress_display_post_date() {
  116. global $post;
  117. if (!comicpress_themeinfo('disable_date_info_in_posts')) {
  118. $post_date = "<span class=\"posted-on\">".__('on&nbsp;','comicpress')."</span><span class=\"post-date\">".get_the_date(get_option('date_format'))."</span>\r\n";
  119. echo apply_filters('comicpress_display_post_date',$post_date);
  120. }
  121. }
  122. }
  123.  
  124. if (!function_exists('comicpress_display_post_time')) {
  125. function comicpress_display_post_time() {
  126. global $post;
  127. if (!comicpress_themeinfo('disable_date_info_in_posts') && !comicpress_themeinfo('disable_posted_at_time_in_posts')) {
  128. $post_time = "<span class=\"posted-at\">".__('at&nbsp;','comicpress')."</span><span class=\"post-time\">".get_the_time(get_option('time_format'))."</span>\r\n";
  129. echo apply_filters('comicpress_display_post_time',$post_time);
  130. }
  131. }
  132. }
  133.  
  134. if (!function_exists('comicpress_display_modified_date_time')) {
  135. function comicpress_display_modified_date_time() {
  136. global $post;
  137. if (!comicpress_themeinfo('disable_date_info_in_posts') && comicpress_themeinfo('enable_last_modified_in_posts')) {
  138. $u_time = get_the_time('U');
  139. $u_modified_time = get_the_modified_time('U');
  140. if ($u_modified_time != $u_time) {
  141. $post_date_time = '<span class="posted-last-modified"> '.__('and modified on','comicpress').' '.get_the_modified_date(get_option('date_format')).'. ';
  142. if (!comicpress_themeinfo('disable_posted_at_time_in_posts')) $post_date_time .= '<span class="posted-last-modified-time"> '.__('at','comicpress').' '.get_the_modified_time(get_option('time_format')).'</span>'."\r\n";
  143. echo apply_filters('comicpress_display_modified_date_time', $post_date_time);
  144. }
  145. }
  146. }
  147. }
  148.  
  149. if (!function_exists('comicpress_display_post_category')) {
  150. function comicpress_display_post_category() {
  151. global $post;
  152. $post_category = '';
  153. if (!comicpress_is_bbpress() && !comicpress_themeinfo('disable_categories_in_posts') && !is_attachment() && ($post->post_type == 'post')) {
  154. $post_category = "<div class=\"post-cat\">". __('Posted In: ','comicpress') .get_the_category_list(', ')."</div>\r\n";
  155. }
  156. echo apply_filters('comicpress_display_post_category', $post_category);
  157. }
  158. }
  159.  
  160. if (!function_exists('comicpress_display_post_tags')) {
  161. function comicpress_display_post_tags() {
  162. global $post;
  163. if (!comicpress_themeinfo('disable_tags_in_posts')) {
  164. $post_tags = "<div class=\"post-tags\">".get_the_tag_list(__('&#9492; Tags: ','comicpress'), ', ', '<br />')."</div>\r\n";
  165. echo apply_filters('comicpress_display_post_tags', $post_tags);
  166. }
  167. }
  168. }
  169.  
  170. if (!function_exists('comicpress_display_comment_link')) {
  171. function comicpress_display_comment_link() {
  172. global $post;
  173. if ($post->comment_status == 'open' && !is_singular()) { ?>
  174. <div class="comment-link">
  175. <?php comments_popup_link('<span class="comment-balloon comment-balloon-empty">&nbsp;</span>'.__('Comment&nbsp;','comicpress'), '<span class="comment-balloon">1</span> '.__('Comment ','comicpress'), '<span class="comment-balloon">%</span> '.__('Comments ','comicpress')); ?>
  176. </div>
  177. <?php
  178. }
  179. }
  180. }
  181.  
  182. if (!function_exists('comicpress_display_blog_navigation')) {
  183. function comicpress_display_blog_navigation() {
  184. global $post, $wp_query;
  185. if (comicpress_themeinfo('enable_comments_on_homepage') && (comicpress_themeinfo('home_post_count') == '1')) {
  186. $temp_single = $wp_query -> is_single;
  187. $wp_query -> is_single = true;
  188. }
  189. if (is_single() && !is_page() && !is_archive() && !is_search() && ($post->post_type == 'post')) { ?>
  190. <div class="blognav">
  191. <?php previous_post_link('<span class="blognav-prev">%link</span>',__('&lsaquo; Prev','comicpress'), false); ?>
  192. <?php next_post_link('<span class="blognav-next">%link</span>',__('Next &rsaquo;','comicpress'), false); ?>
  193. <div class="clear"></div>
  194. </div>
  195. <?php }
  196. if (comicpress_themeinfo('enable_comments_on_homepage') && (comicpress_themeinfo('home_post_count') == '1')) {
  197. $wp_query -> is_single = $temp_single;
  198. }
  199. }
  200. }
  201.  
  202. if (!function_exists('comicpress_display_the_content')) {
  203. function comicpress_display_the_content() {
  204. global $post, $wp_query;
  205. if ((is_archive() || is_search()) && (comicpress_themeinfo('excerpt_or_content_in_archive') == 'excerpt') && !comicpress_is_bbpress()) {
  206. do_action('comicpress-display-the-content-before');
  207. the_excerpt();
  208. do_action('comicpress-display-the-content-after');
  209. } else {
  210. if (!is_single()) { global $more; $more = 0; }
  211. do_action('comicpress-display-the-content-before');
  212. the_content(__('&darr; Read the rest of this entry...','comicpress'));
  213. do_action('comicpress-display-the-content-after');
  214. }
  215. }
  216. }
  217.  
  218. if (!function_exists('comicpress_display_post')) {
  219. function comicpress_display_post() {
  220. global $post, $wp_query;
  221. if (!comicpress_is_bbpress()) comicpress_display_blog_navigation(); ?>
  222. <div <?php post_class(); ?>>
  223. <?php comicpress_display_post_thumbnail(); ?>
  224. <div class="post-head"><?php do_action('comicpress-post-head'); ?></div>
  225. <div class="post-content">
  226. <div class="post-info">
  227. <?php
  228. if (!comicpress_is_bbpress()) comicpress_display_author_gravatar();
  229. if (!comicpress_is_bbpress()) comicpress_display_post_calendar();
  230. if (is_sticky()) { ?><div class="sticky-image">Featured Post</div><?php }
  231. if (function_exists('comicpress_show_mood_in_post')) comicpress_show_mood_in_post();
  232. ?>
  233. <div class="post-text">
  234. <?php
  235. comicpress_display_post_title();
  236. if (!is_page()) {
  237. comicpress_display_post_author();
  238. comicpress_display_post_date(); comicpress_display_post_time(); comicpress_display_modified_date_time();
  239. if ($post->post_type == 'post') { edit_post_link(__('Edit','comicpress'), ' <span class="post-edit">', '</span>'); }
  240. comicpress_display_post_category();
  241. if (function_exists('the_ratings') && $post->post_type == 'post') { the_ratings(); }
  242. do_action('comicpress-post-info');
  243. do_action('comic-post-info');
  244. } ?>
  245. </div>
  246. </div>
  247. <div class="clear"></div>
  248. <div class="entry">
  249. <?php comicpress_display_the_content(); ?>
  250. <div class="clear"></div>
  251. <?php do_action('comic-transcript'); ?>
  252. </div>
  253. <?php wp_link_pages(array('before' => '<div class="linkpages"><span class="linkpages-pagetext">Pages:</span> ', 'after' => '</div>', 'next_or_number' => 'number')); ?>
  254. <div class="clear"></div>
  255. <?php if (!is_page()) { ?>
  256. <div class="post-extras">
  257. <?php
  258. comicpress_display_post_tags();
  259. do_action('comicpress-post-extras');
  260. comicpress_display_comment_link();
  261. ?>
  262. <div class="clear"></div>
  263. </div>
  264. <?php } else
  265. edit_post_link(__('Edit this page.','comicpress'), '', ''); ?>
  266. </div>
  267. <div class="post-foot"><?php do_action('comic-post-foot'); ?><?php do_action('comicpress-post-foot'); ?></div>
  268. </div>
  269. <?php
  270. do_action('comic-post-extras');
  271. comments_template('', true);
  272. }
  273. }
  274.  
  275. ?>