-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
141 lines (108 loc) · 4.12 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
add_theme_support('post-thumbnails');
function load_scripts(){
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', get_stylesheet_directory_uri() . '/src/js/plugins/jquery.js', false, '2.1.4', true);
wp_enqueue_script('jquery');
}
wp_enqueue_script('plugins', get_stylesheet_directory_uri() . '/dist/plugins.min.js', null, '', true);
wp_enqueue_script('scripts', get_stylesheet_directory_uri() . '/dist/scripts.min.js', null, '', true);
wp_enqueue_style( 'styles', get_template_directory_uri() . '/dist/styles.min.css', array(), '1.0', 'all' );
}
add_action( 'wp_enqueue_scripts', 'load_scripts' );
if ( function_exists( 'register_nav_menu' ) ) {
register_nav_menu( 'menu', 'Menu Principal');
register_nav_menu( 'footer-menu', 'Menu do Rodapé');
}
add_theme_support('woocommerce', array(
'thumbnail_image_width' => 255,
'single_image_width' => 255,
'product_grid' => array(
'default_rows' => 10,
'min_rows' => 5,
'max_rows' => 10,
'default_columns' => 4,
'min_columns' => 4,
'max_columns' => 4,
)
));
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
if ( ! isset( $content_width ) ) {
$content_width = 600;
}
add_image_size( 'banners-slider', 1920, 800, array( 'center', 'center' ) );
if( class_exists( 'WooCommerce' )){
require get_template_directory() . '/src/inc/wc-modifications.php';
}
function get_img_uri() {
return get_template_directory_uri() . '/src/img';
}
/**
* Show cart contents / total Ajax
*/
add_filter( 'woocommerce_add_to_cart_fragments', 'fancy_lab_woocommerce_header_add_to_cart_fragment' );
function fancy_lab_woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>
<span class="items"><?php echo WC()->cart->get_cart_contents_count(); ?></span>
<?php
$fragments['span.items'] = ob_get_clean();
return $fragments;
}
// Função de mostrar banners
function get_banners(){
global $banners;
$banner = array();
$args = array('post_type'=>'banner','post_status'=>'publish','posts_per_page'=>-1);
$banners = new Wp_Query($args);
while($banners->have_posts()){
$banners->the_post();
$banner_image = get_field('banner');
$banner_responsive = get_field('banner_responsivo');
$link = get_field('link');
$banner_link_post = get_field('link_post');
$banner_link_categoria = get_field('link_categoria');
$banner_link_personalizado = get_field('link_personalizado');
$banner_legenda = get_field('legenda');
$banner_sublegenda = get_field('sublegenda');
$banner_legenda_pos = get_field('posicao_legenda');
$banner_legenda_style = get_field('estilo_legenda');
$banner_link = '';
$html = '<div>';
if($link){ //verifica se tem link
if($link == 'post'){
$banner_link = $banner_link_post;
}
elseif($link == 'categoria'){
$banner_link = get_category_link($banner_link_categoria);
}
elseif($link == 'personalizado'){
$banner_link = $banner_link_personalizado;
}
$html .= '<a href="'.$banner_link.'">';
}
$html .= '<div class="banner-item">';
$html .= '<img src="'.$banner_image['url'].'" alt="'.get_the_title().'">';
if ($banner_legenda) { //verifica se tem legenda
$html .= '<div class="legenda '.$banner_legenda_pos .'">
<div class="legenda-inner">
<h1 class="'.$banner_legenda_style.'"><span>'.$banner_legenda.'</span></h1>
<h4 class="'.$banner_legenda_style.'">'. $banner_sublegenda .'</h4>
<div class="banner-btn">Saiba mais</div>
</div>
</div>';
}
$html .= '</div>';
if($link){ //fecha a tag de link
$html .= '</a>';
$banner_link = '';
}
$html .= '</div>';
echo $html;
}
wp_reset_postdata();
}