Welcart Beldad 1.4.1 をリリースしました。主な修正点は以下のとおりです。
ヘッダー画像のリンク先設定が効かない不具合を修正
テンプレート修正 : header.php 186行目~237行目あたり【変更前】
<?php if ( is_home() || is_front_page() ) : ?>
<?php
$headers = get_uploaded_header_images();
$headers_count = count( $headers );
?>
<div id="main-visual" class="main-visual">
<?php
if ( $headers ) :
if ( 1 < $headers_count ) :
?>
<div class="flex-row">
<div class="flexslider">
<?php endif; ?>
<ul class="slides">
<?php foreach ( $headers as $key => $value ) : ?>
<?php
// this code is refered to: http://frankiejarrett.com/get-an-attachment-id-by-url-in-wordpress/
// in order to get attachment id from image url.
$parse_url = explode( parse_url( WP_CONTENT_URL, PHP_URL_PATH ), $value['url'] );
$this_host = str_ireplace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) );
$file_host = str_ireplace( 'www.', '', parse_url( $value['url'], PHP_URL_HOST ) );
if ( ! isset( $parse_url[1] ) || empty( $parse_url[1] ) || ( $this_host != $file_host ) ) {
return;
}
global $wpdb;
$img_id = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->prefix}posts WHERE guid RLIKE %s;", $parse_url[1] ) );
$img_meta = get_post( $img_id[0] );
?>
<li class="list" data-thumb="<?php echo $value['url']; ?>">
<?php if ( false === $img_meta->post_content && ( strpos( $img_meta->post_content, 'jpg' ) ) ) : ?>
<a href="<?php echo esc_html( $img_meta->post_content ); ?>">
<?php endif; ?>
<img src="<?php echo $value['url']; ?>">
<?php if ( false === $img_meta->post_content && ( strpos( $img_meta->post_content, 'jpg' ) ) ) : ?>
</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php if ( 1 < $headers_count ) : ?>
</div>
</div>
<?php
endif;
else :
if ( has_header_image() ) :
?>
<div><img src="<?php header_image(); ?>" alt="*"></div>
<?php
endif;
endif;
?>
</div><!-- #main-visual -->
<?php
endif;
【変更後】
<?php
if ( is_home() || is_front_page() ) :
$headers = get_uploaded_header_images();
$headers_count = count( $headers );
?>
<div id="main-visual" class="main-visual">
<?php
if ( $headers ) :
if ( 1 < $headers_count ) :
?>
<div class="flex-row">
<div class="flexslider">
<?php
endif;
?>
<ul class="slides">
<?php
foreach ( $headers as $key => $value ) :
$img_id = $value['attachment_id'];
$img_width = ( ! empty( $value['width'] ) ) ? ' width="' . $value['width'] . '"' : '';
$img_height = ( ! empty( $value['height'] ) ) ? ' height="' . $value['height'] . '"' : '';
$img_meta = get_post( $img_id );
?>
<li class="list" data-thumb="<?php echo esc_attr( $value['url'] ); ?>">
<?php if ( ! empty( $img_meta->post_content ) ) : ?>
<a href="<?php echo esc_url( $img_meta->post_content ); ?>">
<?php endif; ?>
<img src="<?php echo esc_url( $value['url'] ); ?>"<?php echo esc_attr( $img_width ); ?><?php echo esc_attr( $img_height ); ?> alt="<?php echo esc_attr( $value['alt_text'] ); ?>" />
<?php if ( ! empty( $img_meta->post_content ) ) : ?>
</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php
if ( 1 < $headers_count ) :
?>
</div>
</div>
<?php
endif;
else :
if ( has_header_image() ) :
?>
<div><img src="<?php header_image(); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"></div>
<?php
endif;
endif;
?>
</div><!-- #main-visual -->
<?php
endif;



