site-title.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Template part for displaying the site navigation.
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
  6. *
  7. * @package Pen
  8. */
  9. ob_start( 'pen_compress_html' );
  10. $description = false;
  11. $site_description_display = pen_option_get( 'header_sitedescription_display' );
  12. if ( $site_description_display ) {
  13. $description = get_bloginfo( 'description', 'display' );
  14. }
  15. $site_title_display = pen_option_get( 'header_sitetitle_display' );
  16. $classes_sitetitle = trim(
  17. implode(
  18. ' ',
  19. array_filter(
  20. array(
  21. $description ? 'pen_has_description' : '',
  22. 'pen_sitetitle_' . ( sanitize_html_class( $site_title_display ) ? 'show' : 'hide' ),
  23. )
  24. )
  25. )
  26. );
  27. $site_link = home_url( false );
  28. ?>
  29. <a href="<?php echo esc_url( $site_link ); ?>" id="site-title" class="<?php echo esc_attr( $classes_sitetitle ); ?>" rel="home">
  30. <span class="site-title <?php echo ( ! $site_title_display ) ? 'pen_element_hidden ' : ''; ?><?php pen_class_animation( 'header_sitetitle' ); /* phpcs:ignore */ ?>">
  31. <?php
  32. bloginfo( 'name' );
  33. ?>
  34. </span>
  35. <?php
  36. $description = wp_strip_all_tags( $description );
  37. if ( 200 < strlen( $description ) ) {
  38. $description = substr( $description, 0, 100 ) . ' &hellip;'; /* phpcs:ignore */
  39. }
  40. if ( $description || is_customize_preview() ) {
  41. // CSS "margin" relies on :not(:empty) here hence no indentation, newlines, etc.
  42. ?>
  43. <span class="site-description <?php pen_class_animation( 'header_sitedescription' ); /* phpcs:ignore */ ?>"><?php echo $description; /* phpcs:ignore */ ?></span>
  44. <?php
  45. }
  46. ?>
  47. </a>
  48. <?php
  49. echo ob_get_clean(); /* phpcs:ignore */