forked from tonik/theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassets.php
61 lines (54 loc) · 1.55 KB
/
assets.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
<?php
namespace Tonik\Theme\App\Http;
/*
|-----------------------------------------------------------------
| Theme Assets
|-----------------------------------------------------------------
|
| This file is for registering your theme stylesheets and scripts.
| In here you should also deregister all unwanted assets which
| can be shiped with various third-parity plugins.
|
*/
use function Tonik\Theme\App\asset_path;
/**
* Registers theme stylesheet files.
*
* @return void
*/
function register_stylesheets() {
wp_enqueue_style('app', asset_path('css/app.css'));
}
add_action('wp_enqueue_scripts', 'Tonik\Theme\App\Http\register_stylesheets');
/**
* Registers theme script files.
*
* @return void
*/
function register_scripts() {
wp_enqueue_script('app', asset_path('js/app.js'), ['jquery'], null, true);
}
add_action('wp_enqueue_scripts', 'Tonik\Theme\App\Http\register_scripts');
/**
* Registers editor stylesheets.
*
* @return void
*/
function register_editor_stylesheets() {
add_editor_style(asset_path('css/app.css'));
}
add_action('admin_init', 'Tonik\Theme\App\Http\register_editor_stylesheets');
/**
* Moves front-end jQuery script to the footer.
*
* @param \WP_Scripts $wp_scripts
* @return void
*/
function move_jquery_to_the_footer($wp_scripts) {
if (! is_admin()) {
$wp_scripts->add_data('jquery', 'group', 1);
$wp_scripts->add_data('jquery-core', 'group', 1);
$wp_scripts->add_data('jquery-migrate', 'group', 1);
}
}
add_action('wp_default_scripts', 'Tonik\Theme\App\Http\move_jquery_to_the_footer');