t_options(); if ( $options['disable_featured_image'] && is_singular() ) { remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' ); remove_action( 'generate_before_content', 'generate_blog_single_featured_image' ); remove_action( 'generate_after_header', 'generate_blog_single_featured_image' ); remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' ); remove_action( 'generate_after_header', 'generate_featured_page_header' ); } if ( $options['site_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'site-logo' ) ) { if ( '' !== $options['site_header_merge'] ) { add_action( 'generate_after_logo', array( $this, 'add_site_logo' ) ); } else { add_filter( 'theme_mod_custom_logo', array( $this, 'replace_logo' ) ); if ( $options['retina_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'retina-logo' ) ) { add_filter( 'generate_retina_logo', array( $this, 'replace_logo' ) ); } } } if ( $options['navigation_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'navigation-logo' ) ) { if ( $options['site_header_merge'] && GeneratePress_Elements_Helper::does_option_exist( 'sticky-navigation' ) ) { add_action( 'generate_inside_navigation', array( $this, 'add_navigation_logo' ) ); } else { add_filter( 'generate_navigation_logo', array( $this, 'replace_logo' ) ); } } if ( $options['mobile_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'mobile-logo' ) ) { if ( 'merge' === $options['site_header_merge'] ) { add_action( 'generate_inside_mobile_header', array( $this, 'add_mobile_header_logo' ) ); } else { add_filter( 'generate_mobile_header_logo', array( $this, 'replace_logo' ) ); } } if ( $options['navigation_location'] ) { add_filter( 'generate_navigation_location', array( $this, 'navigation_location' ) ); } if ( '' !== $options['site_header_merge'] ) { add_action( 'generate_before_header', array( $this, 'merged_header_start' ), 1 ); add_action( 'generate_after_header', array( $this, 'merged_header_end' ), 8 ); if ( 'contained' === $options['container'] ) { add_filter( 'generate_header_class', array( $this, 'site_header_classes' ) ); } } if ( $options['content'] ) { self::remove_template_elements(); } } /** * Returns our custom logos if set within the Page Header. * * @since 1.7 * * @return string New URLs to images. */ public static function replace_logo() { $filter = current_filter(); $options = self::get_options(); if ( 'theme_mod_custom_logo' === $filter ) { return $options['site_logo']; } if ( 'generate_retina_logo' === $filter ) { return wp_get_attachment_url( $options['retina_logo'] ); } if ( 'generate_navigation_logo' === $filter ) { return wp_get_attachment_url( $options['navigation_logo'] ); } if ( 'generate_mobile_header_logo' === $filter ) { return wp_get_attachment_url( $options['mobile_logo'] ); } } /** * Adds a new site logo element if our header is merged on desktop only. * * @since 1.7 */ public static function add_site_logo() { $options = self::get_options(); $logo_url = wp_get_attachment_url( $options['site_logo'] ); $retina_logo_url = wp_get_attachment_url( $options['retina_logo'] ); if ( ! $logo_url ) { return; } $attr = apply_filters( 'generate_page_hero_logo_attributes', array( 'class' => 'header-image', 'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), 'src' => $logo_url, 'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), ) ); if ( '' !== $retina_logo_url ) { $attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x'; // Add dimensions to image if retina is set. This fixes a container width bug in Firefox. $data = wp_get_attachment_metadata( $options['site_logo'] ); if ( ! empty( $data ) ) { $attr['width'] = $data['width']; $attr['height'] = $data['height']; } } $attr = array_map( 'esc_attr', $attr ); $html_attr = ''; foreach ( $attr as $name => $value ) { $html_attr .= " $name=" . '"' . $value . '"'; } echo apply_filters( 'generate_page_hero_logo_output', sprintf( // WPCS: XSS ok, sanitization ok. '
', esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), $html_attr ), $logo_url, $html_attr ); } /** * Adds the custom navigation logo if needed. * Only needed if there's a sticky navigation. * * @since 1.7 */ public static function add_navigation_logo() { $options = self::get_options(); printf( ' ', esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), esc_url( wp_get_attachment_url( $options['navigation_logo'] ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ) ); } /** * Adds the custom mobile header if needed. * Only needed if there's a sticky navigation. * * @since 1.7 */ public static function add_mobile_header_logo() { $options = self::get_options(); if ( 'title' === GeneratePress_Elements_Helper::does_option_exist( 'mobile-header-branding' ) ) { return; } printf( '', esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), esc_url( wp_get_attachment_url( $options['mobile_logo'] ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ) ); } /** * Set the navigation location if set. * * @since 1.7 * * @return string The navigation location. */ public static function navigation_location() { $options = self::get_options(); if ( 'no-navigation' === $options['navigation_location'] ) { return ''; } else { return $options['navigation_location']; } } /** * The opening merged header element. * * @since 1.7 */ public static function merged_header_start() { echo '