Advertisement
Guest User

Ultra Site Title

a guest
Jun 2nd, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. if ( ! function_exists( 'ultra_display_logo' ) ) :
  2. /**
  3. * Display the logo.
  4. */
  5. function ultra_display_logo() {
  6. $logo = siteorigin_setting( 'header_logo' );
  7. if ( empty( $logo ) && function_exists( 'has_custom_logo' ) && has_custom_logo() ) {
  8. $logo = get_theme_mod( 'custom_logo' );
  9. }
  10. $logo = apply_filters( 'ultra_logo_image_id', $logo );
  11.  
  12. if ( empty( $logo ) ) {
  13.  
  14. // Just display the site title.
  15. if ( is_front_page() ) {
  16. $logo_html = '<h1 class="site-title">' . get_bloginfo( 'name' ) . '</h1>';
  17. } else {
  18. $logo_html = '<p class="site-title">' . get_bloginfo( 'name' ) . '</p>';
  19. }
  20. $logo_html = apply_filters( 'ultra_logo_text', $logo_html );
  21. }
  22. else {
  23. // Load the logo image.
  24. if ( is_array( $logo ) ) {
  25. list ( $src, $height, $width ) = $logo;
  26. }
  27. else {
  28. $image = wp_get_attachment_image_src( $logo, 'full' );
  29. $src = $image[0];
  30. $height = $image[2];
  31. $width = $image[1];
  32. }
  33.  
  34. // Add the logo attributes.
  35. $logo_attributes = apply_filters( 'ultra_logo_image_attributes', array(
  36. 'src' => $src,
  37. 'width' => round( $width ),
  38. 'height' => round( $height ),
  39. 'alt' => sprintf( esc_html__( '%s Logo', 'ultra' ), get_bloginfo( 'name' ) ),
  40. ) );
  41.  
  42. if ( siteorigin_setting( 'header_sticky' ) && siteorigin_setting( 'header_scale' ) ) $logo_attributes['data-scale'] = '1';
  43.  
  44. $logo_attributes_str = array();
  45. if ( ! empty( $logo_attributes ) ) {
  46. foreach ( $logo_attributes as $name => $val ) {
  47. if ( empty( $val ) ) continue;
  48. $logo_attributes_str[] = $name . '="' . esc_attr( $val ) . '" ';
  49. }
  50. }
  51.  
  52. $logo_html = apply_filters( 'ultra_logo_image', '<img '.implode( ' ', $logo_attributes_str ).' />' );
  53. }
  54.  
  55. // Echo the image.
  56. echo apply_filters( 'ultra_logo_html', $logo_html );
  57. }
  58. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement