-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnqueue Styles & Scripts in GP
43 lines (37 loc) · 1.44 KB
/
Enqueue Styles & Scripts in GP
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
/* Enqueue styles to editor iframe */
add_filter( 'generate_editor_styles', 'rbd_editor_iframe_styles', 50);
function rbd_editor_iframe_styles($editor_styles ) {
$editor_styles[] = '/style.css';
return $editor_styles;
};
/* Enqueue Customiser CSS to editor iframe */
add_filter( 'block_editor_settings_all', 'rbd_customiser_styles', 10, 2);
function rbd_customiser_styles($editor_settings, $editor_context) {
$custom_css_post = wp_get_custom_css_post();
if ($custom_css_post) {
$customiser_css = $custom_css_post->post_content;
$editor_settings['styles'][] = array( 'css' => $customiser_css );
}
return $editor_settings;
};
/* Enqueue custom script to editor */
add_action( 'enqueue_block_editor_assets', 'rbd_enqueue_block_editor_assets' );
function rbd_enqueue_block_editor_assets() {
$theme_dir = get_stylesheet_directory_uri();
wp_register_style( 'rbd-editor-styles', $theme_dir . '/editor/editor-style.css' );
wp_enqueue_style( 'rbd-editor-styles' );
// Editor script
wp_enqueue_script(
'rbd-editor-script',
$theme_dir . '/editor/editor-script.js',
array( 'wp-hooks' ),
time(),
true
);
}
/* Frontend custom styles */
add_action('wp_enqueue_scripts', 'rbd_enqueue_custom_styles', 20);
function rbd_enqueue_custom_styles(){
wp_register_style( 'rbd-child-custom', get_stylesheet_directory_uri(). '/custom/custom-style.css' );
wp_enqueue_style( 'rbd-child-custom' );
}