Home › Forums › WoodMart support forum › Code problem
Code problem
- This topic has 7 replies, 2 voices, and was last updated 6 years ago by
leonidas.
-
AuthorPosts
-
February 28, 2019 at 2:18 pm #110261
leonidasParticipantHello
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 ‘‘; ?>
<?php if ( $has_sticky_logo ): ?>
<?php
$logo_sticky = $protocol . str_replace( array( ‘http://’, ‘https://’ ), ”, $logo_sticky_uploaded[‘url’] );
?>
” class=”woodmart-logo woodmart-sticky-logo” rel=”home”>
<?php echo ‘‘; ?>
<?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?
RegardsFebruary 28, 2019 at 3:36 pm #110276
Artem TemosKeymasterHi,
What kind of problem do you mean here? What exactly this code for?
Regards
February 28, 2019 at 4:12 pm #110280
leonidasParticipantIf 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://’, ‘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 ‘‘; ?>
<?php if ( $has_sticky_logo ): ?>
<?php
$logo_sticky = $protocol . str_replace( array( ‘http://’, ‘https://’ ), ”, $logo_sticky_uploaded[‘url’] );
?>
” class=”woodmart-logo woodmart-sticky-logo” rel=”home”>
<?php echo ‘‘; ?>
<?php endif ?>
</div>
</div>
<?php
}February 28, 2019 at 4:21 pm #110281
leonidasParticipantI also found that the shared code was at post #39407
March 1, 2019 at 7:12 am #110349
Artem TemosKeymasterTry 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>
March 1, 2019 at 7:37 am #110358
leonidasParticipantThe 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 LeonidasMarch 1, 2019 at 9:34 am #110401
Artem TemosKeymasterThis file is for child theme style CSS modification. You can disable it in the file functions.php in the child theme.
March 1, 2019 at 9:39 am #110406
leonidasParticipantThank
You can close the ticket -
AuthorPosts
The topic ‘Code problem’ is closed to new replies.
- You must be logged in to create new topics. Login / Register