extras.php 969 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 Scratchpad
  8. */
  9. /**
  10. * Adds custom classes to the array of body classes.
  11. *
  12. * @param array $classes Classes for the body element.
  13. * @return array
  14. */
  15. function scratchpad_body_classes( $classes ) {
  16. // Adds a class of group-blog to blogs with more than 1 published author.
  17. if ( is_multi_author() ) {
  18. $classes[] = 'group-blog';
  19. }
  20. // Adds a class of hfeed to non-singular pages.
  21. if ( ! is_singular() ) {
  22. $classes[] = 'hfeed';
  23. }
  24. // Adds a class when sidebar widget is unused
  25. if ( ! is_active_sidebar( 'sidebar-1' ) ) {
  26. $classes[] = 'no-sidebar';
  27. }
  28. // Add a class if has custom header image
  29. $header_image = get_header_image();
  30. if ( ! empty( $header_image ) ) {
  31. $classes[] = 'has-header-image';
  32. }
  33. return $classes;
  34. }
  35. add_filter( 'body_class', 'scratchpad_body_classes' );