Advertisement
Misplon

Ultra Logo

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