extras.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Custom functions that act independently of the theme templates
  4. *
  5. * Eventually, some of the functionality here could be replaced by core features
  6. *
  7. * @package Dyad
  8. */
  9. /**
  10. * HTML Body classes
  11. *
  12. * @since 1.0
  13. * @version 1.0
  14. *
  15. * @param array $classes
  16. */
  17. // Add specific CSS class to body
  18. function dyad_2_body_classes( $classes ) {
  19. global $post;
  20. // Adds a class of group-blog to blogs with more than 1 published author.
  21. if ( is_multi_author() ) {
  22. $classes[] = 'group-blog';
  23. }
  24. //Singular?
  25. if ( is_singular() ) {
  26. $classes[] = 'is-singular';
  27. }
  28. //Has featured image?
  29. if ( ! is_page() && dyad_2_has_post_thumbnail( $post->ID ) && dyad_2_jetpack_featured_image_display() ) {
  30. $classes[] = 'has-post-thumbnail';
  31. }
  32. //Has featured image?
  33. if ( is_page() && has_post_thumbnail() && dyad_2_jetpack_featured_image_display() ) {
  34. $classes[] = 'has-post-thumbnail';
  35. }
  36. $header_image = get_header_image();
  37. if ( ( ! dyad_2_has_banner_posts( 1 ) && ( is_home() || is_archive() || is_search() ) ) && '' == $header_image ) {
  38. $classes[] = 'no-featured-posts';
  39. }
  40. $classes[] = 'no-js';
  41. return $classes;
  42. }
  43. add_filter( 'body_class', 'dyad_2_body_classes' );