extras.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 (
  30. ! is_page()
  31. && dyad_2_has_post_thumbnail( $post->ID ?? null )
  32. && dyad_2_jetpack_featured_image_display()
  33. ) {
  34. $classes[] = 'has-post-thumbnail';
  35. }
  36. //Has featured image?
  37. if ( is_page() && has_post_thumbnail() && dyad_2_jetpack_featured_image_display() ) {
  38. $classes[] = 'has-post-thumbnail';
  39. }
  40. $header_image = get_header_image();
  41. if ( ( ! dyad_2_has_banner_posts( 1 ) && ( is_home() || is_archive() || is_search() ) ) && '' == $header_image ) {
  42. $classes[] = 'no-featured-posts';
  43. }
  44. $classes[] = 'no-js';
  45. return $classes;
  46. }
  47. add_filter( 'body_class', 'dyad_2_body_classes' );