-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathhandler.php
More file actions
68 lines (62 loc) · 1.39 KB
/
handler.php
File metadata and controls
68 lines (62 loc) · 1.39 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
<?php
/**
* Asset Handler.
*
* @package KnowTheCode\GitContributing\Asset
* @since 1.0.0
* @author Git Contributing Team
* @link https://knowthecode.io
* @license GNU-2.0+
*/
namespace KnowTheCode\GitContributing\Asset;
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_plugin_script' );
/**
* Enqueues the plugin's script(s).
*
* @since 1.0.0
*
* @return void
*/
function enqueue_plugin_script() {
$file = _is_in_development_mode()
? '/assets/dist/project.min.js'
: '/assets/scripts/project.js';
wp_enqueue_script(
'git_contributing_script',
_get_plugin_url() . $file,
array( 'jquery' ),
_get_asset_version( $file ),
true
);
}
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_plugin_css' );
/**
* Enqueues the plugin's stylesheet.
*
* @since 1.0.0
*
* @return void
*/
function enqueue_plugin_css() {
$file = _is_in_development_mode()
? '/assets/dist/project.min.css'
: '/assets/css/project.css';
wp_enqueue_style(
'git_contributing_styles',
_get_plugin_url() . $file,
array(),
_get_asset_version( $file )
);
}
/**
* Get's the asset file's version number by using it's modification timestamp.
*
* @since 1.0.0
*
* @param string $relative_path Relative path to the asset file.
*
* @return bool|int
*/
function _get_asset_version( $relative_path ) {
return filemtime( _get_plugin_directory() . $relative_path );
}