-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
95 lines (78 loc) · 2.19 KB
/
functions.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* functions.php
*
* @package cormorant
* @author Olein-jp
* @license GPL-2.0+
*/
if ( ! function_exists( 'cormorant_setup' ) ) {
/**
* Setup theme
*/
function cormorant_setup() {
// Add support for block styles.
add_theme_support( 'wp-block-styles' );
// Remove default block patterns.
remove_theme_support( 'core-block-patterns' );
// Add support for editor styles.
$files = glob( get_template_directory() . '/assets/css/block/*.css' );
$editor_styles = array( 'assets/css/style.css' );
foreach ( $files as $file ) {
$filename = 'assets/css/block/' . basename( $file, '.css' ) . '.css';
$editor_styles[] = $filename;
}
add_editor_style( $editor_styles );
// Add Translation
load_theme_textdomain( 'cormorant', get_template_directory() . '/languages' );
}
}
add_action( 'after_setup_theme', 'cormorant_setup' );
if ( ! function_exists( 'cormorant_styles' ) ) {
/**
* Enqueue styles
*/
function cormorant_styles() {
wp_enqueue_style(
'cormorant-styles',
get_template_directory_uri() . '/assets/css/style.css',
array(),
wp_get_theme( 'cormorant' )->get( 'Version' )
);
}
add_action( 'wp_enqueue_scripts', 'cormorant_styles' );
}
if ( ! function_exists( 'cormorant_enqueue_block_styles' ) ) {
/**
* Enqueue Block Style CSS
*
* @since 3.0.0
*/
function cormorant_enqueue_block_styles() {
$files = glob( get_template_directory() . '/assets/css/block/*.css' );
// Enqueue block styles only on frontend.
if ( ! is_admin() ) {
foreach ( $files as $file ) {
$filename = basename( $file, '.css' );
$block_name = str_replace( 'wp-block-', 'core/', $filename );
wp_enqueue_block_style(
$block_name,
array(
'handle' => "cormorant-block-{$filename}",
'src' => get_theme_file_uri( "/assets/css/block/{$filename}.css" ),
'path' => get_theme_file_path( "/assets/css/block/{$filename}.css" ),
)
);
}
}
}
add_action( 'init', 'cormorant_enqueue_block_styles' );
}
/**
* Include Registration of Block Styles
*/
require 'inc/block-styles/block-styles.php';
/**
* Include Registration of Block Categories and Patterns
*/
require 'inc/block-patterns/block-patterns.php';