extras.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 Libre 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 libre_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 there is no author bio available, add a class to better style the page title
  21. if ( is_author() && ! get_the_author_meta( 'description' ) ) {
  22. $classes[] = 'no-taxonomy-description';
  23. }
  24. // If there is no taxonomy description, add a class to better style the page title
  25. if ( ! is_author() && is_archive() && ! get_the_archive_description() || is_search() ) {
  26. $classes[] = 'no-taxonomy-description';
  27. }
  28. if ( ! is_active_sidebar( 'sidebar-1' ) &&
  29. ! is_page_template( 'templates/right-column-page.php' ) &&
  30. ! is_page_template( 'templates/full-width-page.php' ) ) {
  31. $classes[] = 'no-sidebar';
  32. }
  33. if ( is_singular() ) {
  34. $classes[] = 'singular';
  35. }
  36. return $classes;
  37. }
  38. add_filter( 'body_class', 'libre_2_body_classes' );
  39. /**
  40. * Add a pingback url auto-discovery header for singularly identifiable articles.
  41. */
  42. function libre_2_pingback_header() {
  43. if ( is_singular() && pings_open() ) {
  44. echo '<link rel="pingback" href="', bloginfo( 'pingback_url' ), '">';
  45. }
  46. }
  47. add_action( 'wp_head', 'libre_2_pingback_header' );