Advertisement
Guest User

classes.php

a guest
Nov 17th, 2013
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * Author: Philip M. Hofer (Frumph)
  5. * Author URI: http://frumph.net/
  6. * Version: 1.0.8
  7. *
  8. */
  9.  
  10. add_filter('body_class','comicpress_body_class');
  11.  
  12. function comicpress_body_class($classes = array()) {
  13. global $current_user, $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $post, $wp_query, $comicpress_is_signup;
  14.  
  15. get_currentuserinfo();
  16.  
  17. if (!empty($user_ID)) {
  18. $user_login = addslashes($current_user->user_login);
  19. if (!empty($user_login)) $classes[] = 'user-'.$user_login;
  20. } else {
  21. $classes[] = 'user-guest';
  22. }
  23.  
  24. if (comicpress_is_signup()) $classes[] = 'signup';
  25.  
  26. if($is_lynx) $classes[] = 'lynx';
  27. elseif($is_gecko) $classes[] = 'gecko';
  28. elseif($is_opera) $classes[] = 'opera';
  29. elseif($is_NS4) $classes[] = 'ns4';
  30. elseif($is_safari) $classes[] = 'safari';
  31. elseif($is_chrome) $classes[] = 'chrome';
  32. elseif($is_IE) $classes[] = 'ie';
  33. else $classes[] = 'unknown';
  34. if($is_iphone) $classes[] = 'iphone';
  35. if (wp_is_mobile()) $classes[] = 'is-mobile';
  36.  
  37.  
  38. // Hijacked from the hybrid theme, http://themehybrid.com/
  39. if (is_single()) {
  40. foreach ( (array)get_the_category( $wp_query->post->ID ) as $cat ) :
  41. $classes[] = 'single-category-' . sanitize_html_class( $cat->slug, $cat->term_id );
  42. endforeach;
  43. $classes[] = 'single-author-' . get_the_author_meta( 'user_nicename', $wp_query->post->post_author );
  44. }
  45.  
  46. if (is_page()) {
  47. if ( isset($wp_query->query_vars['pagename']) )
  48. $classes[] = 'page-' . $wp_query->query_vars['pagename'];
  49. }
  50.  
  51. if ( is_single() && is_sticky( $post->ID ) ) {
  52. $classes[] = 'sticky-post';
  53. }
  54.  
  55. // NOT hijacked from anything, doi! people should do this.
  56. $timestamp = current_time('timestamp');
  57. $rightnow = (int)date('Gi',$timestamp);
  58. $ampm = date('a', $timestamp);
  59. $classes[] = $ampm;
  60. // $classes[] = 'time-'.$rightnow;
  61. if ($rightnow > 559 && (int)$rightnow < 1800) $classes[] = 'day';
  62. if ($rightnow < 600 || (int)$rightnow > 1759) $classes[] = 'night';
  63.  
  64. if ($rightnow > 2329 || $rightnow < 30) $classes[] = 'midnight';
  65. if ($rightnow > 459 && $rightnow < 1130) $classes[] = 'morning';
  66. if ($rightnow > 1129 && $rightnow < 1230) $classes[] = 'noon';
  67. if ($rightnow > 1759 && $rightnow < 2330) $classes[] = 'evening';
  68.  
  69. $classes[] = strtolower(date('D', $timestamp));
  70.  
  71. if ( is_attachment() ) {
  72. $classes[] = 'attachment attachment-' . $wp_query->post->ID;
  73. $mime_type = explode( '/', get_post_mime_type() );
  74. foreach ( $mime_type as $type ) :
  75. $classes[] = 'attachment-' . $type;
  76. endforeach;
  77. }
  78.  
  79. if (comicpress_sidebars_disabled()) $classes[] = 'wide';
  80.  
  81. $layout = comicpress_themeinfo('layout');
  82. if (empty($layout)) $layout = '3c';
  83. $classes[] = 'layout-'.$layout;
  84.  
  85. return $classes;
  86. }
  87.  
  88. add_filter('post_class','comicpress_post_class');
  89.  
  90. function comicpress_post_class($classes = '') {
  91. global $post;
  92. static $post_alt;
  93.  
  94. $args = array(
  95. 'entry_tax' => array( 'category', 'post_tag' )
  96. );
  97.  
  98. /* Microformats. */
  99. $classes[] = 'uentry';
  100.  
  101. /* Post alt class. */
  102. $classes[] = 'postonpage-' . ++$post_alt;
  103.  
  104. if ( $post_alt % 2 )
  105. $classes[] = 'odd';
  106. else
  107. $classes[] = 'even';
  108.  
  109. /* Sticky class (only on home/blog page). */
  110. if( is_sticky() && is_home() )
  111. $classes[] = 'sticky';
  112.  
  113. /* Author class. */
  114. if ( !is_attachment() )
  115. $classes[] = 'post-author-' . sanitize_html_class( get_the_author_meta( 'user_nicename' ), get_the_author_meta( 'ID' ) );
  116.  
  117. /* User-created classes. */
  118. if ( !empty( $class ) ) :
  119. if ( !is_array( $class ) )
  120. $class = preg_split( '#\s+#', $class );
  121. $classes = array_merge( $classes, $class );
  122. endif;
  123.  
  124. /* Password-protected posts. */
  125. if ( post_password_required() )
  126. $classes[] = 'protected';
  127.  
  128. return $classes;
  129. }
  130.  
  131. add_filter('comment_class','comicpress_comment_class');
  132.  
  133. function comicpress_comment_class($classes = '') {
  134. global $current_user;
  135. /*
  136. * http://microid.org
  137. */
  138.  
  139. $email = get_comment_author_email();
  140. $url = get_comment_author_url();
  141. if(!empty($email) && !empty($url)) {
  142. $microid = 'microid-mailto+http:sha1:' . sha1(sha1('mailto:'.$email).sha1($url));
  143. $classes[] = $microid;
  144. }
  145. if ($current_user->user_email == $email) $classes[] = 'ucomment';
  146. return $classes;
  147. }
  148.  
  149. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement