-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfunctions.php
258 lines (202 loc) · 7.82 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<?php
/**
* Wabi functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Wabi
* @since Wabi 1.0
*/
if ( ! function_exists( 'wabi_support' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* @since Wabi 1.0
*
* @return void
*/
function wabi_support() {
// Add support for block styles.
add_theme_support( 'wp-block-styles' );
// Enqueue editor styles.
add_editor_style( array( 'style.css' ) );
}
endif;
add_action( 'after_setup_theme', 'wabi_support' );
if ( ! function_exists( 'wabi_styles' ) ) :
/**
* Enqueue styles.
*
* @since Wabi 1.0
*
* @return void
*/
function wabi_styles() {
$theme_version = wp_get_theme()->get( 'Version' );
$version_string = is_string( $theme_version ) ? $theme_version : false;
// Register main stylesheet.
wp_register_style(
'wabi-style',
get_template_directory_uri() . '/style.css',
array(),
$version_string
);
// Enqueue main stylesheet.
wp_enqueue_style( 'wabi-style' );
// Add inline styles.
wp_add_inline_style( 'wabi-style', wabi_accent_colors() );
}
endif;
add_action( 'wp_enqueue_scripts', 'wabi_styles' );
if ( ! function_exists( 'wabi_block_styles' ) ) :
/**
* Enqueue block style scripts.
*
* @since Wabi 1.0
*
* @return void
*/
function wabi_block_styles() {
$theme_version = wp_get_theme()->get( 'Version' );
$version_string = is_string( $theme_version ) ? $theme_version : false;
wp_enqueue_script(
'wabi-block-styles',
get_theme_file_uri( '/assets/js/block-styles.js' ),
array( 'wp-blocks' ),
$theme_version,
true
);
}
endif;
add_action( 'enqueue_block_editor_assets', 'wabi_block_styles' );
if ( ! function_exists( 'wabi_inline_editor_styles' ) ) :
/**
* Enqueue editor styles.
*
* @since Wabi 1.0
*
* @return void
*/
function wabi_inline_editor_styles() {
// Add editor styles inline.
wp_add_inline_style( 'wp-block-library', wabi_editor_styles() );
wp_add_inline_style( 'wp-block-library', wabi_accent_colors() );
}
endif;
add_action( 'admin_init', 'wabi_inline_editor_styles' );
if ( ! function_exists( 'wabi_accent_colors' ) ) :
/**
* Set accent color variables.
* Called by functions wabi_styles() and wabi_inline_editor_styles() above.
*
* @since Wabi 1.0
*
* @return string
*/
function wabi_accent_colors() {
return '
.is-primary-accent {
--wp--custom--color--accent: var(--wp--preset--color--primary);
--wp--custom--color--accent-alt: var(--wp--preset--color--secondary);
}
.is-secondary-accent {
--wp--custom--color--accent: var(--wp--preset--color--secondary);
--wp--custom--color--accent-alt: var(--wp--preset--color--primary);
}
.is-tertiary-accent {
--wp--custom--color--accent: var(--wp--preset--color--tertiary);
--wp--custom--color--accent-alt: var(--wp--preset--color--quarternary);
}
.is-quarternary-accent {
--wp--custom--color--accent: var(--wp--preset--color--quarternary);
--wp--custom--color--accent-alt: var(--wp--preset--color--tertiary);
}
.is-quinary-accent {
--wp--custom--color--accent: var(--wp--preset--color--quinary);
--wp--custom--color--accent-alt: var(--wp--preset--color--senary);
}
.is-senary-accent {
--wp--custom--color--accent: var(--wp--preset--color--senary);
--wp--custom--color--accent-alt: var(--wp--preset--color--quinary);
}
.is-background-accent {
--wp--custom--color--accent: var(--wp--preset--color--background);
--wp--custom--color--accent-alt: var(--wp--preset--color--foreground);
}
';
}
endif;
if ( ! function_exists( 'wabi_editor_styles' ) ) :
/**
* Get editor styles.
* Called by function wabi_inline_editor_styles() above.
*
* @since Wabi 1.0
*
* @return string
*/
function wabi_editor_styles() {
$palette = wp_get_global_settings( array( 'layout', 'wideSize' ) );
return "
.post-type-post:not(.is-iceberg) .edit-post-visual-editor__post-title-wrapper {
margin-top: 0 !important;
padding-bottom: var(--wp--preset--spacing--30);
padding-top: var(--wp--preset--spacing--30);
margin-bottom: 3.5rem !important;
}
.post-type-post:not(.is-iceberg) .edit-post-visual-editor__post-title-wrapper {
background: var(--wp--custom--color--accent);
}
.post-type-post:not(.is-iceberg) .edit-post-visual-editor__post-title-wrapper > * {
max-width: $palette !important;
}
.post-type-post:not(.is-iceberg) .edit-post-visual-editor__post-title-wrapper {
margin-top: 0 !important;
padding-bottom: var(--wp--preset--spacing--30);
padding-top: var(--wp--preset--spacing--30);
margin-bottom: 3.5rem !important;
}
.post-type-post:not(.is-iceberg) .edit-post-visual-editor__post-title-wrapper h1 {
color: var(--wp--custom--color--hero-text);
}
.editor-styles-wrapper .block-editor-block-list__layout.is-root-container > p + h1,
.editor-styles-wrapper .block-editor-block-list__layout.is-root-container > p + h2,
.editor-styles-wrapper .block-editor-block-list__layout.is-root-container > p + h3,
.editor-styles-wrapper .block-editor-block-list__layout.is-root-container > p + h4 {
margin-top: var(--wp--preset--spacing--60) !important;
}
.is-primary-accent .editor-styles-wrapper {
--wp--custom--color--accent: var(--wp--preset--color--primary);
--wp--custom--color--accent-alt: var(--wp--preset--color--secondary);
}
.is-secondary-accent .editor-styles-wrapper {
--wp--custom--color--accent: var(--wp--preset--color--secondary);
--wp--custom--color--accent-alt: var(--wp--preset--color--primary);
}
.is-tertiary-accent .editor-styles-wrapper {
--wp--custom--color--accent: var(--wp--preset--color--tertiary);
--wp--custom--color--accent-alt: var(--wp--preset--color--quarternary);
}
.is-quarternary-accent .editor-styles-wrapper {
--wp--custom--color--accent: var(--wp--preset--color--quarternary);
--wp--custom--color--accent-alt: var(--wp--preset--color--tertiary);
}
.is-quinary-accent .editor-styles-wrapper {
--wp--custom--color--accent: var(--wp--preset--color--quinary);
--wp--custom--color--accent-alt: var(--wp--preset--color--senary);
}
.is-senary-accent .editor-styles-wrapper {
--wp--custom--color--accent: var(--wp--preset--color--senary);
--wp--custom--color--accent-alt: var(--wp--preset--color--quinary);
}
.is-background-accent .editor-styles-wrapper {
--wp--custom--color--accent: var(--wp--preset--color--background);
--wp--custom--color--accent-alt: var(--wp--preset--color--background);
}
";
}
endif;
// Add block patterns
require get_template_directory() . '/inc/block-patterns.php';
// Add accent color functionality
require get_template_directory() . '/inc/accent-color.php';