forked from inc2734/my-snow-monkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
my-snow-monkey.php
67 lines (60 loc) · 1.42 KB
/
my-snow-monkey.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
<?php
/**
* Plugin name: My Snow Monkey
* Description: Olein Design 制作の My Snow Monkey
* Version: 1.0.0
*
* @package my-snow-monkey
* @author inc2734
* @license GPL-2.0+
*/
/**
* Snow Monkey 以外のテーマを利用している場合は有効化してもカスタマイズが反映されないようにする
*/
$theme = wp_get_theme( get_template() );
if ( 'snow-monkey' !== $theme->template && 'snow-monkey/resources' !== $theme->template ) {
return;
}
/**
* Directory url of this plugin
*
* @var string
*/
define( 'MY_SNOW_MONKEY_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
/**
* Directory path of this plugin
*
* @var string
*/
define( 'MY_SNOW_MONKEY_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
/**
* Register style
*/
add_action(
'wp_enqueue_scripts',
function () {
wp_enqueue_style(
'my-snow-monkey-style',
MY_SNOW_MONKEY_URL . '/build/css/style.css',
array( Framework\Helper::get_main_style_handle() ),
filemtime( MY_SNOW_MONKEY_PATH . '/build/css/style.css' )
);
wp_enqueue_script(
'my-snow-monkey-scripts',
MY_SNOW_MONKEY_URL . '/build/js/scripts.js',
null,
filemtime( MY_SNOW_MONKEY_PATH . '/build/js/scripts.js' ),
true
);
}
);
/**
* Register Style for Editor
*/
add_action(
'after_setup_theme',
function () {
add_theme_support( 'editor-styles' );
add_editor_style( MY_SNOW_MONKEY_URL . '/build/css/editor-style.css' );
}
);