Home Forums WoodMart support forum Code problem

Code problem

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #110261

    leonidas
    Participant

    Hello
    Some time ago I asked you if it is possible to correct this issue of image 1.

    You fixed the issue with this code you have gave me:
    function woodmart_header_block_logo() {

    $header_color_scheme = woodmart_get_opt( ‘header_color_scheme’ );

    // Get the logo
    $logo = WOODMART_IMAGES . ‘/wood-logo-dark.svg’;
    $logo_white = WOODMART_IMAGES . ‘/wood-logo-white.svg’;

    $protocol = woodmart_http() . “://”;

    $logo_uploaded = woodmart_get_opt(‘logo’);
    $logo_white_uploaded = woodmart_get_opt(‘logo-white’);
    $logo_sticky_uploaded = woodmart_get_opt(‘logo-sticky’);
    $has_sticky_logo = ( isset( $logo_sticky_uploaded[‘url’] ) && ! empty( $logo_sticky_uploaded[‘url’] ) );

    if(isset($logo_white_uploaded[‘url’]) && $logo_white_uploaded[‘url’] != ”) {
    $logo_white = $logo_white_uploaded[‘url’];
    }
    if(isset($logo_uploaded[‘url’]) && $logo_uploaded[‘url’] != ”) {
    $logo = $logo_uploaded[‘url’];
    }

    if( $header_color_scheme == ‘light’ ) {
    $logo = $logo_white;
    }

    $logo = $protocol. str_replace(array(‘http://’, ‘https://’), ”, $logo);

    ?>
    <div class=”site-logo”>
    <div class=”woodmart-logo-wrap<?php if( $has_sticky_logo ) echo ” switch-logo-enable”; ?>”>
    ” class=”woodmart-logo woodmart-main-logo” rel=”home”>
    <?php echo ‘' . get_bloginfo( 'name' ) . '‘; ?>

    <?php if ( $has_sticky_logo ): ?>
    <?php
    $logo_sticky = $protocol . str_replace( array( ‘http://&#8217;, ‘https://&#8217; ), ”, $logo_sticky_uploaded[‘url’] );
    ?>
    ” class=”woodmart-logo woodmart-sticky-logo” rel=”home”>
    <?php echo ‘' . get_bloginfo( 'name' ) . '‘; ?>

    <?php endif ?>
    </div>
    </div>
    <?php
    }

    After the version 3.3 the code stopped working.
    How do we make it again functional and solve the same issue?
    Regards

    #110276

    Artem Temos
    Keymaster

    Hi,

    What kind of problem do you mean here? What exactly this code for?

    Regards

    #110280

    leonidas
    Participant

    If you look at the previous image you will see that according to Gtmetrix I must specify the image dimensions of my logo.
    Before 3.3 version when I used the code below (that you gave me in a previous post) I successfully removed Gtemetrix notice.
    Now the code doesn’t work.
    If it is not possible to modify the code do you now another way?

    function woodmart_header_block_logo() {

    $header_color_scheme = woodmart_get_opt( ‘header_color_scheme’ );

    // Get the logo
    $logo = WOODMART_IMAGES . ‘/wood-logo-dark.svg’;
    $logo_white = WOODMART_IMAGES . ‘/wood-logo-white.svg’;

    $protocol = woodmart_http() . “://”;

    $logo_uploaded = woodmart_get_opt(‘logo’);
    $logo_white_uploaded = woodmart_get_opt(‘logo-white’);
    $logo_sticky_uploaded = woodmart_get_opt(‘logo-sticky’);
    $has_sticky_logo = ( isset( $logo_sticky_uploaded[‘url’] ) && ! empty( $logo_sticky_uploaded[‘url’] ) );

    if(isset($logo_white_uploaded[‘url’]) && $logo_white_uploaded[‘url’] != ”) {
    $logo_white = $logo_white_uploaded[‘url’];
    }
    if(isset($logo_uploaded[‘url’]) && $logo_uploaded[‘url’] != ”) {
    $logo = $logo_uploaded[‘url’];
    }

    if( $header_color_scheme == ‘light’ ) {
    $logo = $logo_white;
    }

    $logo = $protocol. str_replace(array(‘http://&#8217;, ‘https://&#8217;), ”, $logo);

    ?>
    <div class=”site-logo”>
    <div class=”woodmart-logo-wrap<?php if( $has_sticky_logo ) echo ” switch-logo-enable”; ?>”>
    ” class=”woodmart-logo woodmart-main-logo” rel=”home”>
    <?php echo ‘' . get_bloginfo( 'name' ) . '‘; ?>

    <?php if ( $has_sticky_logo ): ?>
    <?php
    $logo_sticky = $protocol . str_replace( array( ‘http://&#8217;, ‘https://&#8217; ), ”, $logo_sticky_uploaded[‘url’] );
    ?>
    ” class=”woodmart-logo woodmart-sticky-logo” rel=”home”>
    <?php echo ‘' . get_bloginfo( 'name' ) . '‘; ?>

    <?php endif ?>
    </div>
    </div>
    <?php
    }

    #110281

    leonidas
    Participant

    I also found that the shared code was at post #39407

    #110349

    Artem Temos
    Keymaster

    Try to create header-elements/logo.php file in the child theme with the following code and specify your logo dimensions there

    <?php
    // Get the logo
    $logo 		= WOODMART_IMAGES . '/wood-logo-dark.svg';
    
    $protocol = woodmart_http() . "://";
    
    $has_sticky_logo = ( isset( $params['sticky_image']['url'] ) && ! empty( $params['sticky_image']['url'] ) );
    
    if(isset($params['image']['url']) && $params['image']['url'] != '') {
    	$logo = $params['image']['url'];
    }
    
    if(isset($params['image']['id']) && $params['image']['id'] != '') {
    	$attachment = wp_get_attachment_image_src( $params['image']['id'], 'full' );
    	if( isset( $attachment[0] ) && ! empty( $attachment[0] ) )
    		$logo = $attachment[0];
    }
    
    $logo = $protocol. str_replace(array('http://', 'https://'), '', $logo);
    
    $width = isset($params['width']) ? (int) $params['width'] : 150;
    $sticky_width = isset($params['sticky_width']) ? (int) $params['sticky_width'] : 150;
    
    ?>
    <div class="site-logo">
    	<div class="woodmart-logo-wrap<?php if( $has_sticky_logo ) echo " switch-logo-enable"; ?>">
    		<a href="<?php echo esc_url( home_url('/') ); ?>" class="woodmart-logo woodmart-main-logo" rel="home">
    			<?php echo '<img src="' . $logo . '" alt="' . get_bloginfo( 'name' ) . '" width="100" height="50" style="max-width: ' . esc_attr( $width ) . 'px;" />'; ?>
    		</a>
    		<?php if ( $has_sticky_logo ): ?>
    			<?php
    				$logo_sticky = $protocol . str_replace( array( 'http://', 'https://' ), '', $params['sticky_image']['url'] );
    			 ?>
    			<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="woodmart-logo woodmart-sticky-logo" rel="home">
    				<?php echo '<img src="' . $logo_sticky . '" alt="' . get_bloginfo( 'name' ) . '" width="100" height="50" style="max-width: ' . esc_attr( $sticky_width ) . 'px;" />'; ?>
    			</a>
    		<?php endif ?>
    	</div>
    </div>
    #110358

    leonidas
    Participant

    The code worked well.
    I have another question to ask.
    Look at the first image .
    You will see another Gtemtrix notice to inline a small css file.
    When I click inside style.css I don’t see any content except this one of the second image.
    Is this logical?How do I prevent this to happen?
    Regards Leonidas

    #110401

    Artem Temos
    Keymaster

    This file is for child theme style CSS modification. You can disable it in the file functions.php in the child theme.

    #110406

    leonidas
    Participant

    Thank
    You can close the ticket

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Code problem’ is closed to new replies.