* * @since 1.0.0 */ public function transparent_header_logo() { $inherit_desk_logo = astra_get_option( 'different-transparent-logo', false ); $transparent_header_logo = astra_get_option( 'transparent-header-logo' ); if ( self::is_transparent_header() && '1' == $inherit_desk_logo && '' !== $transparent_header_logo ) { // Logo For None Effect. add_filter( 'astra_has_custom_logo', '__return_true' ); add_filter( 'get_custom_logo', array( $this, 'transparent_custom_logo' ), 10, 2 ); } } /** * Replace transparent header logo. * * @param sting $html Size name. * @param int $blog_id Icon. * * @return string html markup of logo. */ public function transparent_custom_logo( $html, $blog_id ) { $trans_logo = astra_get_option( 'transparent-header-logo' ); $transparent_header_devices = astra_get_option( 'transparent-header-on-devices' ); if ( '' !== $trans_logo ) { /* Replace transparent header logo and width */ add_filter( 'wp_get_attachment_image_attributes', array( $this, 'replace_trans_header_attr' ), 10, 3 ); $custom_logo_id = attachment_url_to_postid( $trans_logo ); $size = 'ast-transparent-logo-size'; if ( is_customize_preview() ) { $size = 'full'; } $html = sprintf( '', esc_url( home_url( '/' ) ), wp_get_attachment_image( $custom_logo_id, $size, false, array( 'class' => 'custom-logo', ) ) ); if ( 'mobile' === $transparent_header_devices ) { $html .= sprintf( '', esc_url( home_url( '/' ) ), wp_get_attachment_image( get_theme_mod( 'custom_logo' ), $size, false, array( 'class' => 'custom-logo', ) ) ); } if ( 'desktop' === $transparent_header_devices ) { $html .= sprintf( '', esc_url( home_url( '/' ) ), wp_get_attachment_image( get_theme_mod( 'custom_logo' ), $size, false, array( 'class' => 'custom-logo', ) ) ); } remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'replace_trans_header_attr' ) ); } return $html; } /** * Replace transparent header logo. * * @param array $attr Image. * @param object $attachment Image obj. * @param sting $size Size name. * * @return array Image attr. */ public function replace_trans_header_attr( $attr, $attachment, $size ) { $trans_logo = astra_get_option( 'transparent-header-logo' ); $custom_logo_id = attachment_url_to_postid( $trans_logo ); if ( $custom_logo_id == $attachment->ID ) { $attach_data = array(); if ( ! is_customize_preview() ) { $attach_data = wp_get_attachment_image_src( $attachment->ID, 'ast-transparent-logo-size' ); if ( isset( $attach_data[0] ) ) { $attr['src'] = $attach_data[0]; } } $file_type = wp_check_filetype( $attr['src'] ); $file_extension = $file_type['ext']; if ( 'svg' == $file_extension ) { $attr['class'] = 'astra-logo-svg'; } $diff_retina_logo = astra_get_option( 'different-transparent-retina-logo' ); if ( '1' == $diff_retina_logo ) { $retina_logo = astra_get_option( 'transparent-header-retina-logo' ); $attr['srcset'] = ''; if ( apply_filters( 'astra_transparent_header_retina', true ) && '' !== $retina_logo ) { $cutom_logo = wp_get_attachment_image_src( $custom_logo_id, 'full' ); $cutom_logo_url = $cutom_logo[0]; if ( astra_check_is_ie() ) { // Replace header logo url to retina logo url. $attr['src'] = $retina_logo; } $attr['srcset'] = $cutom_logo_url . ' 1x, ' . $retina_logo . ' 2x'; } } } return $attr; } /** * Add Meta Options * * @param array $meta_option Page Meta. * @return array */ public function add_options( $meta_option ) { $meta_option['theme-transparent-header-meta'] = array( 'sanitize' => 'FILTER_DEFAULT', ); return $meta_option; } /** * Transparent Header Meta Field markup * * Loads appropriate template file based on the style option selected in options panel. * * @param array $meta Page Meta. * @since 1.0.0 */ public function add_options_markup( $meta ) { /** * Get options */ $trans_header_meta = ( isset( $meta['theme-transparent-header-meta']['default'] ) ) ? $meta['theme-transparent-header-meta']['default'] : 'default'; $show_meta_field = ! astra_check_is_bb_themer_layout(); ?>


(int) $max_value, 'height' => 0, 'crop' => false, ); } return $sizes; } } } /** * Kicking this off by calling 'get_instance()' method */ Astra_Ext_Transparent_Header_Markup::get_instance();