Repository navigation
Expand file tree
/
Copy pathenqueue-scripts.php
More file actions
79 lines (62 loc) · 4.47 KB
/
Copy pathenqueue-scripts.php
File metadata and controls
79 lines (62 loc) · 4.47 KB
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
<?php
/**
* Connect stylesheets & scripts
*
* @package pitchfork
*/
/**
* Register/enqueue scripts for Pitchfork.
*
* @return void
*/
function pitchfork_enqueue_scripts() {
// Get the theme data.
$the_theme = wp_get_theme();
$theme_version = $the_theme->get( 'Version' );
// Global styles.
$css_version = $theme_version . '.' . filemtime( get_template_directory() . '/dist/css/theme.css' );
wp_enqueue_style( 'pitchfork-styles', get_template_directory_uri() . '/dist/css/theme.css', array(), $css_version );
// Jquery + Bootstrap Bundle with PopperJS.
$bs_js_version = $theme_version . '.' . filemtime( get_template_directory() . '/src/unity-bootstrap-theme/js/bootstrap.bundle.min.js' );
wp_enqueue_script( 'bootstrap-bundle', get_template_directory_uri() . '/src/unity-bootstrap-theme/js/bootstrap.bundle.min.js', array(), $bs_js_version );
// Component header and footer.
wp_enqueue_script ( 'component-header-footer', get_template_directory_uri() . '/src/component-header-footer/asuHeaderFooter.umd.js', array( 'wp-element', 'wp-components' ), null, true );
// wp_enqueue_script ( 'component-footer-vendor', get_template_directory_uri() . '/src/component-footer/js/vendor.umd.js', array( 'wp-element', 'wp-components' ), null, false );
// wp_enqueue_script ( 'component-footer', get_template_directory_uri() . '/src/component-footer/js/asuFooter.umd.js', array( 'wp-element', 'wp-components' ), null, false );
// Custom scripts from the theme. Includes init files for above components.
$custom_js_version = $theme_version . '.' . filemtime( get_template_directory() . '/dist/js/custom.js' );
wp_enqueue_script( 'pitchfork-custom', get_template_directory_uri() . '/dist/js/custom.js', array('bootstrap-bundle'), $custom_js_version, true );
// Data layer events monitoring
wp_enqueue_script( 'component-data-layer', get_template_directory_uri() . '/src/unity-bootstrap-theme/js/data-layer.js', array(), null, false );
// Font Awesome. Kit licensed and distributed by ASU Engineering for use with this theme.
wp_enqueue_script ( 'font-awesome-kit', 'https://kit.fontawesome.com/51b562cd96.js', array(), null, false );
wp_script_add_data( 'font-awesome-kit', 'crossorigin', 'anonymous' );
}
add_action( 'wp_enqueue_scripts', 'pitchfork_enqueue_scripts' );
/**
* Register/enqueue scripts for Pitchfork.
*/
function pitchfork_enqueue_block_editor_assets() {
// Get the theme data.
$the_theme = wp_get_theme();
$theme_version = $the_theme->get( 'Version' );
// SASS fixes specifically for the admin area. (Gutenberg).
$admin_css_version = $theme_version . '.' . filemtime( get_template_directory() . '/dist/css/admin.css' );
wp_enqueue_style( 'pitchfork-admin-styles', get_template_directory_uri() . '/dist/css/admin.css', array(), $admin_css_version );
// Jquery + Bootstrap Bundle with PopperJS.
$bs_js_version = $theme_version . '.' . filemtime( get_template_directory() . '/src/unity-bootstrap-theme/js/bootstrap.bundle.min.js' );
wp_enqueue_script( 'bootstrap-bundle', get_template_directory_uri() . '/src/unity-bootstrap-theme/js/bootstrap.bundle.min.js', array(), $bs_js_version );
// Font Awesome. Kit distributed by ASU Engineering.
wp_enqueue_script ( 'font-awesome-kit', 'https://kit.fontawesome.com/51b562cd96.js', array(), null, false );
wp_script_add_data( 'font-awesome-kit', 'crossorigin', 'anonymous' );
// Applying heading highlight classes to core/headings block.
$js_heading_highlights = $theme_version . '.' . filemtime( get_template_directory() . '/dist/js/heading-highlights.js' );
wp_enqueue_script( 'uds-heading-highlights', get_template_directory_uri() . '/dist/js/heading-highlights.js', array( 'wp-rich-text', 'wp-element', 'wp-editor' ), $js_heading_highlights );
// Applying heading highlight classes to core/headings block.
$js_pagination_settings = $theme_version . '.' . filemtime( get_template_directory() . '/dist/js/pagination-settings.js' );
wp_enqueue_script( 'uds-pagination-settings', get_template_directory_uri() . '/dist/js/pagination-settings.js', array( 'wp-hooks', 'wp-element', 'wp-components', 'wp-block-editor', 'wp-data', 'wp-compose' ), $js_pagination_settings );
// Block modifications.
$blocks_js_version = $theme_version . '.' . filemtime( get_template_directory() . '/dist/js/block-variations.js' );
wp_enqueue_script( 'pitchfork-block-mods', get_template_directory_uri() . '/dist/js/block-variations.js', array( 'wp-blocks', 'wp-dom' ), $blocks_js_version , true );
}
add_action( 'enqueue_block_assets', 'pitchfork_enqueue_block_editor_assets' );