template-functions.php 917 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Functions which enhance the theme by hooking into WordPress
  4. *
  5. * @package UIU_CSE
  6. */
  7. /**
  8. * Adds custom classes to the array of body classes.
  9. *
  10. * @param array $classes Classes for the body element.
  11. * @return array
  12. */
  13. function uiu_cse_body_classes( $classes ) {
  14. // Adds a class of hfeed to non-singular pages.
  15. if ( ! is_singular() ) {
  16. $classes[] = 'hfeed';
  17. }
  18. // Adds a class of no-sidebar when there is no sidebar present.
  19. if ( ! is_active_sidebar( 'sidebar-1' ) ) {
  20. $classes[] = 'no-sidebar';
  21. }
  22. return $classes;
  23. }
  24. add_filter( 'body_class', 'uiu_cse_body_classes' );
  25. /**
  26. * Add a pingback url auto-discovery header for single posts, pages, or attachments.
  27. */
  28. function uiu_cse_pingback_header() {
  29. if ( is_singular() && pings_open() ) {
  30. printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) );
  31. }
  32. }
  33. add_action( 'wp_head', 'uiu_cse_pingback_header' );