-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
98 lines (72 loc) · 3.13 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
<?php
function theme_scripts() {
$dirJS = new DirectoryIterator(get_stylesheet_directory() . '/js');
foreach ($dirJS as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) === 'js') {
$fullName = basename($file);
$name = substr(basename($fullName), 0, strpos(basename($fullName), '.'));
switch($name) {
case 'header': $deps = null; $last = false;
break;
case 'scripts': $deps = array('jquery'); $last = true;
break;
default : $deps = null; $last = true;
break;
}
wp_enqueue_script( $name, get_stylesheet_directory_uri() . '/js/' . $fullName, $deps, null, $last);
}
}
wp_dequeue_style('storefront-child-style');
$dirCSS = new DirectoryIterator(get_stylesheet_directory() . '/');
foreach ($dirCSS as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) === 'css') {
$fullName = basename($file);
$name = substr(basename($fullName), 0, strpos(basename($fullName), '.'));
switch($name) {
default : $deps = null; $last = false;
break;
}
wp_enqueue_style( $name, get_stylesheet_directory_uri() . '/' . $fullName, $deps, '0.0.6', $last);
}
}
}
function move_storefront_messages(){
if( is_product() ) {
remove_action( 'storefront_content_top','storefront_shop_messages',15 );
}
remove_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );
add_action( 'storefront_before_content', 'wc_print_notices', 1 );
}
function hide_stock_count( $html, $text, $product ) {
$availability = $product->get_availability();
if ( isset( $availability['class'] ) && 'in-stock' === $availability['class'] ) {
return '';
}
return $html;
}
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_head', 'rel_canonical');
remove_action( 'wp_head', 'wp_shortlink_wp_head');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'wp_head', 'move_storefront_messages' );
add_action( 'bournest_before_single_product_summary', 'woocommerce_template_single_title', 5);
add_action( 'wp_enqueue_scripts', 'theme_scripts', 50);
add_filter( 'woocommerce_stock_html', 'hide_stock_count', 10, 3 );
add_theme_support('woocommerce');
?>