extras.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 Karuna
  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 karuna_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. if ( ! is_active_sidebar( 'sidebar-1' ) ) {
  25. $classes[] = 'no-sidebar';
  26. }
  27. //Always add a front-page class to the front page
  28. if ( is_front_page() && ! is_home() ) {
  29. $classes[] = 'page-template-front-page';
  30. }
  31. //If we have no active social links menu and the header text is hidden, narrow the top bar
  32. if ( ! has_nav_menu( 'jetpack-social-menu' ) && 'blank' == get_header_textcolor() ) {
  33. $classes[] = 'no-top-bar';
  34. }
  35. return $classes;
  36. }
  37. add_filter( 'body_class', 'karuna_body_classes' );