A WordPress theme I used to use on www.chriswiegman.com.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

287 lines
7.9 KiB

  1. <?php
  2. /**
  3. * The template for all single posts
  4. *
  5. * @since 5.0.0
  6. *
  7. * @package CW\Theme\Templates\Single
  8. *
  9. * @author Chris Wiegman <chris@chriswiegman.com>
  10. */
  11. namespace CW\Theme\Templates\Single;
  12. use CW\Theme\Functions\Template_Tags;
  13. get_header();
  14. ?>
  15. <div id="primary" class="content-area">
  16. <main id="main" class="site-main" role="main">
  17. <?php
  18. while ( have_posts() ) {
  19. the_post();
  20. ?>
  21. <article id="post-<?php esc_attr( the_ID() ); ?>" <?php post_class(); ?>>
  22. <?php
  23. $title = get_the_title();
  24. $permalink = esc_url( get_permalink() );
  25. if ( has_post_thumbnail() && ! has_post_format( 'image' ) ) {
  26. printf( '<div class="featured-image"><a class="post-header-image" href="%s" rel="bookmark" title="%s">%s</a></div>', esc_url( $permalink ), esc_attr( $title ), get_the_post_thumbnail() );
  27. }
  28. ?>
  29. <header class="entry-header">
  30. <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
  31. <div class="entry-meta">
  32. <?php Template_Tags\posted_on(); ?>
  33. </div>
  34. <!-- .entry-meta -->
  35. </header>
  36. <!-- .entry-header -->
  37. <div class="entry-content">
  38. <?php the_content(); ?>
  39. <?php
  40. wp_link_pages(
  41. array(
  42. 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'chriswiegman' ),
  43. 'after' => '</div>',
  44. )
  45. );
  46. ?>
  47. </div>
  48. <!-- .entry-content -->
  49. </article><!-- #post-## -->
  50. <?php
  51. if ( ! is_page() ) {
  52. do_action( 'cw_before_author' );
  53. $links = array(
  54. 'facebook' => get_the_author_meta( 'facebook' ),
  55. 'github' => get_the_author_meta( 'github' ),
  56. 'wordpress' => get_the_author_meta( 'wordpress' ),
  57. 'twitter' => get_the_author_meta( 'twitter' ),
  58. 'google' => get_the_author_meta( 'googleplus' ),
  59. );
  60. $profiles = array();
  61. foreach ( $links as $link => $url ) {
  62. if ( strstr( $url, 'http' ) ) {
  63. $url = wp_parse_url( $url, PHP_URL_PATH );
  64. $url = substr( $url, 1 );
  65. }
  66. $profiles[ $link ]['url'] = $url;
  67. $profiles[ $link ]['length'] = strlen( $url );
  68. }
  69. echo '<div class="author-box">';
  70. echo get_avatar( get_the_author_meta( 'ID' ), 100 );
  71. if ( strlen( get_the_author_meta( 'url' ) ) > 1 ) {
  72. echo '<strong>About <a href="' . esc_url( get_the_author_meta( 'url' ) ) . '" target="_blank" title="' . esc_attr( get_the_author_meta( 'website_title' ) ) . '">' . esc_html( get_the_author_meta( 'display_name' ) ) . '</a></strong>';
  73. } else {
  74. echo '<strong>About ' . esc_html( get_the_author_meta( 'display_name' ) ) . '</strong>';
  75. }
  76. echo '<p>' . wp_kses_post( get_the_author_meta( 'description' ) ) . '</p>';
  77. if (
  78. (
  79. isset( $profiles['facebook'] ) &&
  80. isset( $profiles['facebook']['length'] ) &&
  81. 1 < $profiles['facebook']['length']
  82. ) ||
  83. (
  84. isset( $profiles['linkedin'] ) &&
  85. isset( $profiles['linkedin']['length'] ) &&
  86. 1 < $profiles['linkedin']['length']
  87. ) ||
  88. (
  89. isset( $profiles['google'] ) &&
  90. isset( $profiles['google']['length'] ) &&
  91. 1 < $profiles['google']['length']
  92. ) ||
  93. (
  94. isset( $profiles['twitter'] ) &&
  95. isset( $profiles['twitter']['length'] ) &&
  96. 1 < $profiles['twitter']['length']
  97. ) ||
  98. (
  99. isset( $profiles['wordpress'] ) &&
  100. isset( $profiles['wordpress']['length'] ) &&
  101. 1 < $profiles['wordpress']['length']
  102. ) ||
  103. (
  104. isset( $profiles['github'] ) &&
  105. isset( $profiles['github']['length'] ) &&
  106. 1 < $profiles['github']['length']
  107. )
  108. ) {
  109. if (
  110. (
  111. isset( $profiles['facebook'] ) &&
  112. isset( $profiles['facebook']['length'] ) &&
  113. 1 >= $profiles['facebook']['length']
  114. ) &&
  115. (
  116. isset( $profiles['linkedin'] ) &&
  117. isset( $profiles['linkedin']['length'] ) &&
  118. 1 >= $profiles['linkedin']['length']
  119. ) &&
  120. (
  121. isset( $profiles['google'] ) &&
  122. isset( $profiles['google']['length'] ) &&
  123. 1 >= $profiles['google']['length']
  124. ) &&
  125. (
  126. isset( $profiles['twitter'] ) &&
  127. isset( $profiles['twitter']['length'] ) &&
  128. 1 >= $profiles['twitter']['length']
  129. ) &&
  130. (
  131. isset( $profiles['wordpress'] ) &&
  132. isset( $profiles['wordpress']['length'] ) &&
  133. 1 >= $profiles['wordpress']['length']
  134. ) &&
  135. (
  136. isset( $profiles['github'] ) &&
  137. isset( $profiles['github']['length'] ) &&
  138. 1 >= $profiles['github']['length']
  139. )
  140. ) {
  141. echo '<p id="authcontact">Follow ' . esc_attr( get_the_author_meta( 'first_name' ) ) . ' on <a href="http://twitter.com/' . esc_attr( $profiles['twitter']['url'] ) . '" target="_blank" title="' . esc_attr( get_the_author_meta( 'display_name' ) ) . ' on Twitter">Twitter</a></p>';
  142. } else {
  143. echo '<p id="authcontact">Find ' . esc_html( get_the_author_meta( 'first_name' ) ) . ' on ';
  144. $links = array();
  145. if (
  146. isset( $profiles['facebook'] ) &&
  147. isset( $profiles['facebook']['length'] ) &&
  148. 1 < $profiles['facebook']['length']
  149. ) {
  150. $links[] = '<a href="https://facebook.com/' . esc_attr( $profiles['facebook']['url'] ) . '" target="_blank" title="' . esc_attr( get_the_author_meta( 'display_name' ) ) . ' on Facebook">Facebook</a>';
  151. }
  152. if (
  153. isset( $profiles['google'] ) &&
  154. isset( $profiles['google']['length'] ) &&
  155. 1 < $profiles['google']['length']
  156. ) {
  157. $links[] = '<a href="https://plus.google.com/' . esc_attr( $profiles['google']['url'] ) . '?rel=author" rel="author" target="_blank" title="' . esc_attr( get_the_author_meta( 'display_name' ) ) . ' on Google+">Google+</a>';
  158. }
  159. if (
  160. isset( $profiles['github'] ) &&
  161. isset( $profiles['github']['length'] ) &&
  162. 1 < $profiles['github']['length']
  163. ) {
  164. $links[] = '<a href="https://github.com/' . esc_attr( $profiles['github']['url'] ) . '" target="_blank" title="' . esc_attr( get_the_author_meta( 'display_name' ) ) . ' on GitHub">GitHub</a>';
  165. }
  166. if (
  167. isset( $profiles['wordpress'] ) &&
  168. isset( $profiles['wordpress']['length'] ) &&
  169. 1 < $profiles['wordpress']['length']
  170. ) {
  171. $links[] = '<a href="https://profiles.wordpress.org/' . esc_attr( $profiles['wordpress']['url'] ) . '" target="_blank" title="' . esc_attr( get_the_author_meta( 'display_name' ) ) . ' on WordPress.org">WordPress.org</a>';
  172. }
  173. if (
  174. isset( $profiles['linkedin'] ) &&
  175. isset( $profiles['linkedin']['length'] ) &&
  176. 1 < $profiles['linkedin']['length']
  177. ) {
  178. $links[] = '<a href="https://www.linkedin.com/in/' . esc_attr( $profiles['linkedin']['url'] ) . '/" target="_blank" title="' . esc_attr( get_the_author_meta( 'display_name' ) ) . ' on LinkedIn">LinkedIn</a>';
  179. }
  180. if (
  181. isset( $profiles['twitter'] ) &&
  182. isset( $profiles['twitter']['length'] ) &&
  183. 1 < $profiles['twitter']['length']
  184. ) {
  185. $links[] = '<a href="https://twitter.com/' . esc_attr( $profiles['twitter']['url'] ) . '" target="_blank" title="' . esc_attr( get_the_author_meta( 'display_name' ) ) . ' on Twitter">Twitter</a>';
  186. }
  187. $link_count = count( $links );
  188. for ( $i = 0; $i < $link_count; $i ++ ) {
  189. // @codingStandardsIgnoreStart
  190. if ( 1 <= $i ) {
  191. echo ', ';
  192. }
  193. if ( $i === ( $link_count - 1 ) ) {
  194. echo 'and ';
  195. }
  196. echo $links[ $i ];
  197. // @codingStandardsIgnoreEnd
  198. }
  199. echo '.</p>';
  200. }
  201. }
  202. echo '</div>';
  203. // If comments are open or we have at least one comment, load up the comment template.
  204. if ( comments_open() || 0 !== get_comments_number() ) {
  205. comments_template();
  206. }
  207. Template_Tags\post_nav();
  208. }
  209. }
  210. ?>
  211. </main>
  212. <!-- #main -->
  213. </div><!-- #primary -->
  214. <?php
  215. get_sidebar();
  216. get_footer();