OSDN Git Service

WordPressテンプレート使用ショップデモデータ追加。
[magic3/magic3.git] / templates / shop-isle / inc / sections / shop_isle_banners_section.php
1 <?php
2 /**
3  * The Banners Section
4  *
5  * @package WordPress
6  * @subpackage Shop Isle
7  */
8
9                 /* BANNERS */
10
11
12                 $shop_isle_banners_hide = get_theme_mod( 'shop_isle_banners_hide' );
13                 $shop_isle_banners_title = get_theme_mod( 'shop_isle_banners_title' );
14
15 if ( isset( $shop_isle_banners_hide ) && $shop_isle_banners_hide != 1 ) :
16         echo '<section class="module-small home-banners">';
17                 elseif ( is_customize_preview() ) :
18                         echo '<section class="module-small home-banners shop_isle_hidden_if_not_customizer">';
19                 endif;
20
21                 if ( ( isset( $shop_isle_banners_hide ) && $shop_isle_banners_hide != 1) || is_customize_preview() ) :
22
23                         $shop_isle_banners = get_theme_mod(
24                                 'shop_isle_banners', json_encode(
25                                         array(
26                                                 array(
27                                                         'image_url' => get_template_directory_uri() . '/assets/images/banner1.jpg',
28                                                         'link' => '#',
29                                                 ),
30                                                 array(
31                                                         'image_url' => get_template_directory_uri() . '/assets/images/banner2.jpg',
32                                                         'link' => '#',
33                                                 ),
34                                                 array(
35                                                         'image_url' => get_template_directory_uri() . '/assets/images/banner3.jpg',
36                                                         'link' => '#',
37                                                 ),
38                                         )
39                                 )
40                         );
41
42                         if ( ! empty( $shop_isle_banners ) ) :
43
44                                 $shop_isle_banners_decoded = json_decode( $shop_isle_banners );
45
46                                 if ( ! empty( $shop_isle_banners_decoded ) ) :
47
48                                         echo '<div class="container">';
49
50                                         if ( ! empty( $shop_isle_banners_title ) ) {
51                                                 echo '<div class="row">';
52                                                 echo '<div class="col-sm-6 col-sm-offset-3">';
53                                                 echo '<h2 class="module-title font-alt product-banners-title">' . $shop_isle_banners_title . '</h2>';
54                                                 echo '</div>';
55                                                 echo '</div>';
56
57                                         } elseif ( is_customize_preview() ) {
58                                                 echo '<div class="row">';
59                                                 echo '<div class="col-sm-6 col-sm-offset-3">';
60                                                 echo '<h2 class="module-title font-alt product-banners-title shop_isle_hidden_if_not_customizer"></h2>';
61                                                 echo '</div>';
62                                                 echo '</div>';
63                                         }
64
65                                                 echo '<div class="row shop_isle_bannerss_section">';
66
67                                         foreach ( $shop_isle_banners_decoded as $shop_isle_banner ) :
68
69                                                 $image_url = ! empty( $shop_isle_banner->image_url ) ? apply_filters( 'shop_isle_translate_single_string', $shop_isle_banner->image_url, 'Banners section' ) : '';
70                                                 $link = ! empty( $shop_isle_banner->link ) ? apply_filters( 'shop_isle_translate_single_string', $shop_isle_banner->link, 'Banners section' ) : '';
71
72                                                 if ( ! empty( $image_url ) ) {
73
74                                                         $shop_isle_alt_image = '';
75                                                         $image_id = function_exists( 'attachment_url_to_postid' ) ? attachment_url_to_postid( $image_url ) : '';
76                                                         if ( ! empty( $image_id ) && $image_id !== 0 ) {
77                                                                 $shop_isle_alt_image = 'alt="' . esc_attr( get_post_meta( $image_id, '_wp_attachment_image_alt', true ) ) . '"';
78                                                         }
79
80                                                         echo '<div class="col-sm-4"><div class="content-box mt-0 mb-0"><div class="content-box-image">';
81
82                                                         if ( ! empty( $link ) ) {
83                                                                 echo '<a href="' . esc_url( $link ) . '"><img src="' . esc_url( $image_url ) . '" ' . $shop_isle_alt_image . '></a>';
84                                                         } else {
85                                                                 echo '<a><img src="' . esc_url( $image_url ) . '"></a>';
86                                                         }
87                                                         echo '</div></div></div>';
88
89                                                 }
90                                                 endforeach;
91
92                                                 echo '</div>';
93
94                                         echo '</div>';
95                                 endif;
96
97                         endif;
98                         echo '</section>';
99
100                         echo '<hr class="divider-w">';
101
102 endif;  /* END BANNERS */