extras.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 Intergalactic 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 intergalactic_2_body_classes( $classes ) {
  16. if ( is_singular() ) {
  17. $classes[] = 'singular';
  18. }
  19. // Adds a class of single-thumbnail to single posts with a featured image
  20. if ( is_single() && intergalactic_2_has_post_thumbnail() && intergalactic_2_jetpack_featured_image_display() ) {
  21. $classes[] = 'single-thumbnail';
  22. }
  23. else if ( is_page() && has_post_thumbnail() && intergalactic_2_jetpack_featured_image_display() ) {
  24. $classes[] = 'single-thumbnail';
  25. }
  26. else if ( is_singular() && get_header_image() ) {
  27. $classes[] = 'single-thumbnail';
  28. }
  29. else {
  30. $classes[] = 'no-thumbnail';
  31. }
  32. // Adds class for header image
  33. if ( get_header_image() ) {
  34. $classes[] = 'has-custom-header';
  35. }
  36. if ( 'blank' == get_header_textcolor() && ! is_single() ) {
  37. $classes[] = 'but-no-site-title';
  38. }
  39. return $classes;
  40. }
  41. add_filter( 'body_class', 'intergalactic_2_body_classes' );
  42. /**
  43. * Add a pingback url auto-discovery header for singularly identifiable articles.
  44. */
  45. function intergalactic_2_pingback_header() {
  46. if ( is_singular() && pings_open() ) {
  47. echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
  48. }
  49. }
  50. add_action( 'wp_head', 'intergalactic_2_pingback_header' );