-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
80 lines (67 loc) · 2.41 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
<?php
/**
* Functions for Lovelace.
*
* @version 0.1
*/
/**
* Remove the migrate script from the list of jQuery dependencies.
*
* @see https://github.com/cedaro/dequeue-jquery-migrate
*
* @param WP_Scripts $scripts WP_Scripts scripts object. Passed by reference.
*/
function lovelace_dequeue_jquery_migrate( $scripts ) {
if ( ! is_admin() && ! empty( $scripts->registered['jquery'] ) ) {
$jquery_dependencies = $scripts->registered['jquery']->deps;
$scripts->registered['jquery']->deps = array_diff( $jquery_dependencies, [ 'jquery-migrate' ] );
}
}
add_action( 'wp_default_scripts', 'lovelace_dequeue_jquery_migrate' );
/**
* Dequeue assets from parent theme.
*/
function lovelace_dequeue_assets() {
// remove custom fonts
wp_dequeue_style( 'atomic-blocks-fonts' );
wp_deregister_style( 'atomic-blocks-fonts' );
// remove Font Awesome
wp_dequeue_style( 'font-awesome' );
wp_deregister_style( 'font-awesome' );
wp_dequeue_style( 'atomic-blocks-fontawesome' );
wp_deregister_style( 'atomic-blocks-fontawesome' );
}
add_action ( 'wp_enqueue_scripts', 'lovelace_dequeue_assets', 100 );
/**
* Dequeue customizer style from parent theme we don’t actually need.
*/
function lovelace_dequeue_customizer_style() {
// remove customizer in-site CSS
wp_styles()->add_data( 'atomic-blocks-style', 'after', '' );
}
add_action ( 'wp_print_styles', 'lovelace_dequeue_customizer_style' );
/**
* Enqueue our custom scripts and styles.
*/
function lovelace_enqueue_assets() {
// check for SCRIPT_DEBUG
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min' );
// enqueue parent theme CSS
$css_file = get_template_directory() . '/style.css';
$css_url = get_template_directory_uri() . '/style.css';
wp_enqueue_style( 'atomic-blocks-style', $css_url, [], filemtime( $css_file ) );
// include Lovelace theme CSS
$css_file = get_stylesheet_directory() . '/style' . $suffix . '.css';
$css_url = get_stylesheet_directory_uri() . '/style' . $suffix . '.css';
wp_enqueue_style( 'lovelace-style', $css_url, [], filemtime( $css_file ) );
}
add_action( 'wp_enqueue_scripts', 'lovelace_enqueue_assets' );
/**
* Remove customizer sections from parent theme.
*/
function lovelace_remove_customizer_sections() {
global $wp_customize;
$wp_customize->remove_section( 'atomic_blocks_theme_options' );
$wp_customize->remove_section( 'colors' );
}
add_action( 'customize_register', 'lovelace_remove_customizer_sections', 20 );