-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
151 lines (124 loc) · 3.91 KB
/
Copy pathfunctions.php
File metadata and controls
151 lines (124 loc) · 3.91 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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
/**
* Set up Compilation theme
*/
if ( ! function_exists( 'compilation_setup' ) ) {
function compilation_setup() {
// Add translation
load_theme_textdomain( 'compilation', get_template_directory() . '/languages' );
// Enqueue editor stylesheet
add_editor_style( get_template_directory_uri() . '/style.css' );
// Remove core block patterns, we don't need that
remove_theme_support( 'core-block-patterns' );
}
}
add_action( 'after_setup_theme', 'compilation_setup' );
/**
* Enqueue theme notice stylesheet
*/
function compendium_scripts_admin( $hook ) {
wp_enqueue_style( 'compendium-admin-notice', get_template_directory_uri() . '/admin/css/admin-notice.css', array(), wp_get_theme()->get( 'Version' ) );
}
add_action( 'admin_enqueue_scripts', 'compendium_scripts_admin' );
/**
* Enqueue stylesheet
*/
function compilation_enqueue_stylesheet() {
wp_enqueue_style( 'compilation', get_template_directory_uri() . '/assets/css/style.css', array(), wp_get_theme()->get( 'Version' ) );
}
add_action( 'wp_enqueue_scripts', 'compilation_enqueue_stylesheet' );
/**
* Block pattern category
*/
function compilation_register_block_pattern_categories() {
register_block_pattern_category(
'compilation-pages',
array(
'label' => __( 'Pages', 'compilation' ),
'description' => __( 'Full page patterns included with the Compilation theme', 'compilation' ),
)
);
register_block_pattern_category(
'compilation-headers',
array(
'label' => __( 'Headers', 'compilation' ),
'description' => __( 'Header patterns included with the Compilation theme', 'compilation' ),
)
);
register_block_pattern_category(
'compilation-heroes',
array(
'label' => __( 'Heroes', 'compilation' ),
'description' => __( 'Hero patterns included with the Compilation theme', 'compilation' ),
)
);
register_block_pattern_category(
'compilation-footers',
array(
'label' => __( 'Footers', 'compilation' ),
'description' => __( 'Footer patterns included with the Compilation theme', 'compilation' ),
)
);
register_block_pattern_category(
'compilation-posts',
array(
'label' => __( 'Posts', 'compilation' ),
'description' => __( 'Post patterns included with the Compilation theme', 'compilation' ),
)
);
register_block_pattern_category(
'compilation-categories',
array(
'label' => __( 'Categories', 'compilation' ),
'description' => __( 'Taxonomy patterns included with the Compilation theme', 'compilation' ),
)
);
}
add_action( 'init', 'compilation_register_block_pattern_categories' );
/**
* Add block style variations
*/
function compilation_register_block_styles() {
$block_styles = array(
'core/query-pagination' => array(
'pagination-button' => __( 'Compilation', 'compilation' ),
),
'core/categories' => array(
'category-block' => __( '4 Column', 'compilation' ),
'category-block-3c' => __( '3 Column', 'compilation' ),
),
);
foreach ( $block_styles as $block => $styles ) {
foreach ( $styles as $style_name => $style_label ) {
register_block_style(
$block,
array(
'name' => $style_name,
'label' => $style_label,
)
);
}
}
}
add_action( 'init', 'compilation_register_block_styles' );
/**
* Load custom block styles only when the block is used
*/
function compilation_enqueue_custom_block_styles() {
// Scan the css folder to locate block styles.
$files = glob( get_template_directory() . '/assets/css/*.css' );
foreach ( $files as $file ) {
// Get the filename and core block name.
$filename = basename( $file, '.css' );
$block_name = str_replace( 'core-', 'core/', $filename );
wp_enqueue_block_style(
$block_name,
array(
'handle' => "compilation-block-{$filename}",
'src' => get_theme_file_uri( "assets/css/{$filename}.css" ),
'path' => get_theme_file_path( "assets/css/{$filename}.css" ),
)
);
}
}
add_action( 'init', 'compilation_enqueue_custom_block_styles' );