extras.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 Button 2
  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 button_2_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. if ( ! is_active_sidebar( 'sidebar-1' ) && ! has_nav_menu( 'jetpack-social-menu' ) ) {
  21. $classes[] = 'no-sidebar';
  22. }
  23. $bgimage = get_background_image();
  24. $bgimage = basename( $bgimage ); //Get the background's filename
  25. if ( 'buttonbg20170303.png' !== $bgimage ) {
  26. //If not using the default background, apply a special body class
  27. $classes[] = 'user-background';
  28. }
  29. return $classes;
  30. }
  31. add_filter( 'body_class', 'button_2_body_classes' );
  32. /**
  33. * Add a pingback url auto-discovery header for singularly identifiable articles.
  34. */
  35. function button_2_pingback_header() {
  36. if ( is_singular() && pings_open() ) {
  37. echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
  38. }
  39. }
  40. add_action( 'wp_head', 'button_2_pingback_header' );