forked from mikedoubintchik/wordpress-child-theme-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·47 lines (39 loc) · 1.74 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
<?php
// Define Environment
define( 'WP_ENV', getenv( 'WP_ENV' ) ? getenv( 'WP_ENV' ) : 'development' );
// Check Environment
if ( WP_ENV === 'development' || WP_ENV === 'staging' ) {
$GLOBALS['$asset_root'] = 'build';
$GLOBALS['$styles'] = "style.css";
$GLOBALS['$js'] = "main.js";
} else {
$GLOBALS['$asset_root'] = "dist";
$GLOBALS['$styles'] = "style.min.css";
$GLOBALS['$js'] = "main.min.js";
}
// Enqueue Styles
add_action( 'wp_enqueue_scripts', 'theme_child_enqueue_styles' );
function theme_child_enqueue_styles() {
// Parent Theme Styles
wp_enqueue_style( 'parent/styles', get_template_directory_uri() . '/style.css' );
// Child Theme Styles
wp_enqueue_style( 'child/styles', get_stylesheet_directory_uri() . '/' . $GLOBALS['$asset_root'] . '/css/' . $GLOBALS['$styles'] );
}
// Enqueue Scripts
add_action( 'wp_enqueue_scripts', 'theme_child_enqueue_scripts' );
function theme_child_enqueue_scripts() {
// Child Theme Scripts
wp_register_script( 'child/scripts', get_stylesheet_directory_uri() . '/' . $GLOBALS['$asset_root'] . '/js/' . $GLOBALS['$js'], array( 'jquery' ), '1.0', true );
wp_enqueue_script( 'child/scripts' );
// jQuery
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', ( '//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js' ), false, null, true );
wp_enqueue_script( 'jquery' );
}
// If using Docker Starter, uncomment this in your development environment
add_action( 'wp_footer', function () { ?>
<script id="__bs_script__">//<![CDATA[
document.write("<script async src='http://HOST:3000/browser-sync/browser-sync-client.js?v=2.18.11'><\/script>".replace("HOST", location.hostname));
//]]>
</script>
<?php } );