@lebtiga/sonic-agent 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +223 -0
- package/README.md +61 -0
- package/bin/sonic.js +304 -0
- package/lib/index.js +20 -0
- package/lib/installer.js +156 -0
- package/lib/license.js +48 -0
- package/package.json +46 -0
- package/plugin/.claude-plugin/plugin.json +13 -0
- package/plugin/README.md +100 -0
- package/plugin/agents/sonic.md +80 -0
- package/plugin/commands/sonic-build.md +145 -0
- package/plugin/commands/sonic-help.md +71 -0
- package/plugin/skills/accessibility-qa/SKILL.md +160 -0
- package/plugin/skills/accessibility-qa/templates/accessibility-qa-report-template.md +123 -0
- package/plugin/skills/accessibility-qa/templates/wcag-compliance-statement.md +70 -0
- package/plugin/skills/aka-wireframe-wp/SKILL.md +149 -0
- package/plugin/skills/aka-wireframe-wp/assets/aka-framework-theme/README.md +190 -0
- package/plugin/skills/aka-wireframe-wp/assets/aka-framework-theme/footer.php +49 -0
- package/plugin/skills/aka-wireframe-wp/assets/aka-framework-theme/functions.php +395 -0
- package/plugin/skills/aka-wireframe-wp/assets/aka-framework-theme/header.php +58 -0
- package/plugin/skills/aka-wireframe-wp/assets/aka-framework-theme/index.php +39 -0
- package/plugin/skills/aka-wireframe-wp/assets/aka-framework-theme/page-answer.php +62 -0
- package/plugin/skills/aka-wireframe-wp/assets/aka-framework-theme/page-authority-hub.php +122 -0
- package/plugin/skills/aka-wireframe-wp/assets/aka-framework-theme/page-knowledge.php +58 -0
- package/plugin/skills/aka-wireframe-wp/assets/aka-framework-theme/style.css +633 -0
- package/plugin/skills/aka-wireframe-wp/references/content-generator.md +371 -0
- package/plugin/skills/aka-wireframe-wp/references/internal-linker.md +430 -0
- package/plugin/skills/aka-wireframe-wp/references/orchestrator.md +269 -0
- package/plugin/skills/aka-wireframe-wp/references/prompts-library.md +880 -0
- package/plugin/skills/aka-wireframe-wp/references/seo-optimizer.md +433 -0
- package/plugin/skills/aka-wireframe-wp/references/strategy-planner.md +317 -0
- package/plugin/skills/aka-wireframe-wp/references/wordpress-deployer.md +545 -0
- package/plugin/skills/authority-site-builder/SKILL.md +138 -0
- package/plugin/skills/brand-philosophy/SKILL.md +77 -0
- package/plugin/skills/freepik-spaces/SKILL.md +122 -0
- package/plugin/skills/freepik-spaces/docs/automation-guide.md +233 -0
- package/plugin/skills/freepik-spaces/docs/research-notes.md +264 -0
- package/plugin/skills/freepik-spaces/plans/naseberry-demo-plan.md +320 -0
- package/plugin/skills/freepik-spaces/templates/naseberry-demo.json +302 -0
- package/plugin/skills/freepik-spaces/templates/saas-demo.json +212 -0
- package/plugin/skills/frontend-design/LICENSE.txt +177 -0
- package/plugin/skills/frontend-design/SKILL.md +77 -0
- package/plugin/skills/programmatic-seo/SKILL.md +236 -0
- package/plugin/skills/programmatic-seo/references/playbooks.md +293 -0
- package/plugin/skills/seo-qa/SKILL.md +132 -0
- package/plugin/skills/seo-qa/templates/schema-localbusiness.json +49 -0
- package/plugin/skills/seo-qa/templates/schema-service.json +36 -0
- package/plugin/skills/seo-qa/templates/seo-qa-report-template.md +90 -0
- package/plugin/skills/visual-identity/SKILL.md +109 -0
- package/plugin/skills/visual-identity/templates/style-guide-template.md +108 -0
- package/plugin/skills/website-image-gen/SKILL.md +82 -0
- package/plugin/skills/website-image-gen/templates/blog-featured.md +56 -0
- package/plugin/skills/website-image-gen/templates/hero-service-photo.md +56 -0
- package/plugin/skills/wordpress-pro/SKILL.md +105 -0
- package/plugin/skills/wordpress-pro/references/gutenberg-blocks.md +870 -0
- package/plugin/skills/wordpress-pro/references/hooks-filters.md +845 -0
- package/plugin/skills/wordpress-pro/references/performance-security.md +1012 -0
- package/plugin/skills/wordpress-pro/references/plugin-architecture.md +1041 -0
- package/plugin/skills/wordpress-pro/references/theme-development.md +858 -0
- package/plugin/sops/SOP-Sonic 777/authority-site-sop.html +1100 -0
- package/plugin/sops/SOP-WORDPRESS-330-PAGE-SITES.md +926 -0
- package/scripts/postinstall.js +109 -0
|
@@ -0,0 +1,858 @@
|
|
|
1
|
+
# Theme Development
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Template Hierarchy
|
|
6
|
+
|
|
7
|
+
WordPress uses a specific hierarchy to determine which template file renders content. Understanding this hierarchy is essential for proper theme development.
|
|
8
|
+
|
|
9
|
+
### Hierarchy Order (Most Specific to General)
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
1. Custom Template (page-{custom}.php)
|
|
13
|
+
2. Specific Template (single-{post-type}-{slug}.php)
|
|
14
|
+
3. Type Template (single-{post-type}.php)
|
|
15
|
+
4. Archive Template (archive-{post-type}.php)
|
|
16
|
+
5. General Template (single.php, archive.php)
|
|
17
|
+
6. Index Fallback (index.php)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Complete Template Map
|
|
21
|
+
|
|
22
|
+
```php
|
|
23
|
+
<?php
|
|
24
|
+
/**
|
|
25
|
+
* Template hierarchy reference for WordPress 6.4+
|
|
26
|
+
*
|
|
27
|
+
* Homepage:
|
|
28
|
+
* front-page.php → home.php → index.php
|
|
29
|
+
*
|
|
30
|
+
* Single Post:
|
|
31
|
+
* single-{post-type}-{slug}.php → single-{post-type}.php → single.php → singular.php → index.php
|
|
32
|
+
*
|
|
33
|
+
* Page:
|
|
34
|
+
* {custom-template}.php → page-{slug}.php → page-{id}.php → page.php → singular.php → index.php
|
|
35
|
+
*
|
|
36
|
+
* Category:
|
|
37
|
+
* category-{slug}.php → category-{id}.php → category.php → archive.php → index.php
|
|
38
|
+
*
|
|
39
|
+
* Custom Taxonomy:
|
|
40
|
+
* taxonomy-{taxonomy}-{term}.php → taxonomy-{taxonomy}.php → taxonomy.php → archive.php → index.php
|
|
41
|
+
*
|
|
42
|
+
* Custom Post Type Archive:
|
|
43
|
+
* archive-{post-type}.php → archive.php → index.php
|
|
44
|
+
*
|
|
45
|
+
* Author:
|
|
46
|
+
* author-{nicename}.php → author-{id}.php → author.php → archive.php → index.php
|
|
47
|
+
*
|
|
48
|
+
* Date:
|
|
49
|
+
* date.php → archive.php → index.php
|
|
50
|
+
*
|
|
51
|
+
* Search:
|
|
52
|
+
* search.php → index.php
|
|
53
|
+
*
|
|
54
|
+
* 404:
|
|
55
|
+
* 404.php → index.php
|
|
56
|
+
*
|
|
57
|
+
* Attachment:
|
|
58
|
+
* {mime-type}.php → attachment.php → single-attachment-{slug}.php → single.php → singular.php → index.php
|
|
59
|
+
*/
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Classic Theme Structure
|
|
65
|
+
|
|
66
|
+
### Minimal Theme Requirements
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
theme-name/
|
|
70
|
+
├── style.css # Required: Theme metadata
|
|
71
|
+
├── index.php # Required: Main template fallback
|
|
72
|
+
├── functions.php # Theme setup and functionality
|
|
73
|
+
├── header.php # Site header
|
|
74
|
+
├── footer.php # Site footer
|
|
75
|
+
├── sidebar.php # Widget area
|
|
76
|
+
├── single.php # Single post template
|
|
77
|
+
├── page.php # Page template
|
|
78
|
+
├── archive.php # Archive template
|
|
79
|
+
├── search.php # Search results
|
|
80
|
+
├── 404.php # Not found page
|
|
81
|
+
├── comments.php # Comment template
|
|
82
|
+
├── screenshot.png # Theme preview (1200x900)
|
|
83
|
+
└── assets/
|
|
84
|
+
├── css/
|
|
85
|
+
├── js/
|
|
86
|
+
└── images/
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### style.css Header
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
/*
|
|
93
|
+
Theme Name: Theme Name
|
|
94
|
+
Theme URI: https://example.com/theme
|
|
95
|
+
Author: Author Name
|
|
96
|
+
Author URI: https://example.com
|
|
97
|
+
Description: A custom WordPress theme with modern features.
|
|
98
|
+
Version: 1.0.0
|
|
99
|
+
Requires at least: 6.4
|
|
100
|
+
Tested up to: 6.5
|
|
101
|
+
Requires PHP: 8.1
|
|
102
|
+
License: GNU General Public License v2 or later
|
|
103
|
+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
104
|
+
Text Domain: theme-name
|
|
105
|
+
Tags: custom-background, custom-logo, custom-menu, featured-images, threaded-comments
|
|
106
|
+
*/
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### functions.php Setup
|
|
110
|
+
|
|
111
|
+
```php
|
|
112
|
+
<?php
|
|
113
|
+
declare(strict_types=1);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Theme functions and definitions
|
|
117
|
+
*
|
|
118
|
+
* @package Theme_Name
|
|
119
|
+
* @since 1.0.0
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
namespace ThemeName;
|
|
123
|
+
|
|
124
|
+
// Prevent direct access
|
|
125
|
+
defined('ABSPATH') || exit;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Theme setup
|
|
129
|
+
*/
|
|
130
|
+
function theme_setup(): void {
|
|
131
|
+
// Make theme translation-ready
|
|
132
|
+
load_theme_textdomain('theme-name', get_template_directory() . '/languages');
|
|
133
|
+
|
|
134
|
+
// Add default posts and comments RSS feed links
|
|
135
|
+
add_theme_support('automatic-feed-links');
|
|
136
|
+
|
|
137
|
+
// Let WordPress manage the document title
|
|
138
|
+
add_theme_support('title-tag');
|
|
139
|
+
|
|
140
|
+
// Enable featured images
|
|
141
|
+
add_theme_support('post-thumbnails');
|
|
142
|
+
add_image_size('theme-featured', 1200, 630, true);
|
|
143
|
+
add_image_size('theme-card', 600, 400, true);
|
|
144
|
+
|
|
145
|
+
// Register navigation menus
|
|
146
|
+
register_nav_menus([
|
|
147
|
+
'primary' => esc_html__('Primary Menu', 'theme-name'),
|
|
148
|
+
'footer' => esc_html__('Footer Menu', 'theme-name'),
|
|
149
|
+
'mobile' => esc_html__('Mobile Menu', 'theme-name'),
|
|
150
|
+
]);
|
|
151
|
+
|
|
152
|
+
// Switch to HTML5 markup
|
|
153
|
+
add_theme_support('html5', [
|
|
154
|
+
'search-form',
|
|
155
|
+
'comment-form',
|
|
156
|
+
'comment-list',
|
|
157
|
+
'gallery',
|
|
158
|
+
'caption',
|
|
159
|
+
'style',
|
|
160
|
+
'script',
|
|
161
|
+
'navigation-widgets',
|
|
162
|
+
]);
|
|
163
|
+
|
|
164
|
+
// Enable selective refresh for widgets
|
|
165
|
+
add_theme_support('customize-selective-refresh-widgets');
|
|
166
|
+
|
|
167
|
+
// Add custom logo support
|
|
168
|
+
add_theme_support('custom-logo', [
|
|
169
|
+
'height' => 100,
|
|
170
|
+
'width' => 400,
|
|
171
|
+
'flex-height' => true,
|
|
172
|
+
'flex-width' => true,
|
|
173
|
+
]);
|
|
174
|
+
|
|
175
|
+
// Add responsive embed support
|
|
176
|
+
add_theme_support('responsive-embeds');
|
|
177
|
+
|
|
178
|
+
// Add editor styles
|
|
179
|
+
add_theme_support('editor-styles');
|
|
180
|
+
add_editor_style('assets/css/editor-style.css');
|
|
181
|
+
|
|
182
|
+
// Wide and full alignment support
|
|
183
|
+
add_theme_support('align-wide');
|
|
184
|
+
|
|
185
|
+
// Block styles
|
|
186
|
+
add_theme_support('wp-block-styles');
|
|
187
|
+
}
|
|
188
|
+
add_action('after_setup_theme', __NAMESPACE__ . '\\theme_setup');
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Enqueue scripts and styles
|
|
192
|
+
*/
|
|
193
|
+
function enqueue_assets(): void {
|
|
194
|
+
$theme_version = wp_get_theme()->get('Version');
|
|
195
|
+
$assets_path = get_template_directory() . '/assets';
|
|
196
|
+
$assets_uri = get_template_directory_uri() . '/assets';
|
|
197
|
+
|
|
198
|
+
// Main stylesheet
|
|
199
|
+
wp_enqueue_style(
|
|
200
|
+
'theme-name-style',
|
|
201
|
+
$assets_uri . '/css/main.css',
|
|
202
|
+
[],
|
|
203
|
+
filemtime($assets_path . '/css/main.css')
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
// Main JavaScript
|
|
207
|
+
wp_enqueue_script(
|
|
208
|
+
'theme-name-script',
|
|
209
|
+
$assets_uri . '/js/main.js',
|
|
210
|
+
[],
|
|
211
|
+
filemtime($assets_path . '/js/main.js'),
|
|
212
|
+
true
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
// Localize script with data
|
|
216
|
+
wp_localize_script('theme-name-script', 'themeNameData', [
|
|
217
|
+
'ajaxUrl' => admin_url('admin-ajax.php'),
|
|
218
|
+
'nonce' => wp_create_nonce('theme_name_nonce'),
|
|
219
|
+
'homeUrl' => home_url('/'),
|
|
220
|
+
]);
|
|
221
|
+
|
|
222
|
+
// Comment reply script
|
|
223
|
+
if (is_singular() && comments_open() && get_option('thread_comments')) {
|
|
224
|
+
wp_enqueue_script('comment-reply');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\enqueue_assets');
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Register widget areas
|
|
231
|
+
*/
|
|
232
|
+
function register_sidebars(): void {
|
|
233
|
+
register_sidebar([
|
|
234
|
+
'name' => esc_html__('Main Sidebar', 'theme-name'),
|
|
235
|
+
'id' => 'sidebar-main',
|
|
236
|
+
'description' => esc_html__('Add widgets here.', 'theme-name'),
|
|
237
|
+
'before_widget' => '<section id="%1$s" class="widget %2$s">',
|
|
238
|
+
'after_widget' => '</section>',
|
|
239
|
+
'before_title' => '<h3 class="widget-title">',
|
|
240
|
+
'after_title' => '</h3>',
|
|
241
|
+
]);
|
|
242
|
+
|
|
243
|
+
register_sidebar([
|
|
244
|
+
'name' => esc_html__('Footer Widgets', 'theme-name'),
|
|
245
|
+
'id' => 'sidebar-footer',
|
|
246
|
+
'description' => esc_html__('Footer widget area.', 'theme-name'),
|
|
247
|
+
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
|
248
|
+
'after_widget' => '</div>',
|
|
249
|
+
'before_title' => '<h4 class="widget-title">',
|
|
250
|
+
'after_title' => '</h4>',
|
|
251
|
+
]);
|
|
252
|
+
}
|
|
253
|
+
add_action('widgets_init', __NAMESPACE__ . '\\register_sidebars');
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Set content width
|
|
257
|
+
*/
|
|
258
|
+
function set_content_width(): void {
|
|
259
|
+
$GLOBALS['content_width'] = apply_filters('theme_name_content_width', 1200);
|
|
260
|
+
}
|
|
261
|
+
add_action('after_setup_theme', __NAMESPACE__ . '\\set_content_width', 0);
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Child Theme Development
|
|
267
|
+
|
|
268
|
+
### When to Use Child Themes
|
|
269
|
+
|
|
270
|
+
**Use Child Themes When:**
|
|
271
|
+
- Customizing an existing theme
|
|
272
|
+
- Making CSS modifications to a parent theme
|
|
273
|
+
- Overriding specific template files
|
|
274
|
+
- Adding functionality without modifying parent theme
|
|
275
|
+
|
|
276
|
+
**Use Custom Themes When:**
|
|
277
|
+
- Building from scratch
|
|
278
|
+
- Significant structural changes needed
|
|
279
|
+
- Different design system requirements
|
|
280
|
+
|
|
281
|
+
### Child Theme Structure
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
theme-name-child/
|
|
285
|
+
├── style.css # Required: Child theme metadata
|
|
286
|
+
├── functions.php # Child theme functions
|
|
287
|
+
├── screenshot.png # Child theme preview
|
|
288
|
+
└── templates/ # Template overrides
|
|
289
|
+
└── parts/
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Child Theme style.css
|
|
293
|
+
|
|
294
|
+
```css
|
|
295
|
+
/*
|
|
296
|
+
Theme Name: Theme Name Child
|
|
297
|
+
Theme URI: https://example.com/theme-child
|
|
298
|
+
Description: Child theme for Theme Name
|
|
299
|
+
Author: Author Name
|
|
300
|
+
Author URI: https://example.com
|
|
301
|
+
Template: theme-name
|
|
302
|
+
Version: 1.0.0
|
|
303
|
+
Requires at least: 6.4
|
|
304
|
+
Tested up to: 6.5
|
|
305
|
+
Requires PHP: 8.1
|
|
306
|
+
License: GNU General Public License v2 or later
|
|
307
|
+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
308
|
+
Text Domain: theme-name-child
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
/* Child theme styles below */
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Child Theme functions.php
|
|
315
|
+
|
|
316
|
+
```php
|
|
317
|
+
<?php
|
|
318
|
+
declare(strict_types=1);
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Child theme functions
|
|
322
|
+
*
|
|
323
|
+
* @package Theme_Name_Child
|
|
324
|
+
*/
|
|
325
|
+
|
|
326
|
+
namespace ThemeNameChild;
|
|
327
|
+
|
|
328
|
+
defined('ABSPATH') || exit;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Enqueue parent and child theme styles
|
|
332
|
+
*/
|
|
333
|
+
function enqueue_styles(): void {
|
|
334
|
+
$parent_style = 'theme-name-style';
|
|
335
|
+
|
|
336
|
+
// Enqueue parent theme stylesheet
|
|
337
|
+
wp_enqueue_style(
|
|
338
|
+
$parent_style,
|
|
339
|
+
get_template_directory_uri() . '/assets/css/main.css',
|
|
340
|
+
[],
|
|
341
|
+
wp_get_theme()->parent()->get('Version')
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
// Enqueue child theme stylesheet
|
|
345
|
+
wp_enqueue_style(
|
|
346
|
+
'theme-name-child-style',
|
|
347
|
+
get_stylesheet_uri(),
|
|
348
|
+
[$parent_style],
|
|
349
|
+
wp_get_theme()->get('Version')
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
add_action('wp_enqueue_scripts', __NAMESPACE__ . '\\enqueue_styles');
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Override parent theme functions as needed
|
|
356
|
+
*/
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## Block Theme Development (FSE)
|
|
362
|
+
|
|
363
|
+
WordPress 6.4+ fully supports Full Site Editing with block themes.
|
|
364
|
+
|
|
365
|
+
### Block Theme Structure
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
block-theme/
|
|
369
|
+
├── style.css # Theme metadata
|
|
370
|
+
├── theme.json # Global settings and styles
|
|
371
|
+
├── functions.php # Theme functions (minimal for block themes)
|
|
372
|
+
├── templates/ # Block templates (HTML)
|
|
373
|
+
│ ├── index.html # Required: Main fallback
|
|
374
|
+
│ ├── front-page.html # Homepage
|
|
375
|
+
│ ├── single.html # Single posts
|
|
376
|
+
│ ├── page.html # Pages
|
|
377
|
+
│ ├── archive.html # Archives
|
|
378
|
+
│ ├── search.html # Search results
|
|
379
|
+
│ └── 404.html # Not found
|
|
380
|
+
├── parts/ # Template parts
|
|
381
|
+
│ ├── header.html
|
|
382
|
+
│ ├── footer.html
|
|
383
|
+
│ └── sidebar.html
|
|
384
|
+
├── patterns/ # Block patterns
|
|
385
|
+
│ └── hero-section.php
|
|
386
|
+
└── assets/
|
|
387
|
+
├── fonts/
|
|
388
|
+
└── images/
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### theme.json (WordPress 6.4+)
|
|
392
|
+
|
|
393
|
+
```json
|
|
394
|
+
{
|
|
395
|
+
"$schema": "https://schemas.wp.org/trunk/theme.json",
|
|
396
|
+
"version": 3,
|
|
397
|
+
"settings": {
|
|
398
|
+
"appearanceTools": true,
|
|
399
|
+
"useRootPaddingAwareAlignments": true,
|
|
400
|
+
"layout": {
|
|
401
|
+
"contentSize": "800px",
|
|
402
|
+
"wideSize": "1200px"
|
|
403
|
+
},
|
|
404
|
+
"color": {
|
|
405
|
+
"defaultDuotone": false,
|
|
406
|
+
"defaultGradients": false,
|
|
407
|
+
"defaultPalette": false,
|
|
408
|
+
"palette": [
|
|
409
|
+
{
|
|
410
|
+
"color": "#1a1a2e",
|
|
411
|
+
"name": "Primary",
|
|
412
|
+
"slug": "primary"
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
"color": "#16213e",
|
|
416
|
+
"name": "Secondary",
|
|
417
|
+
"slug": "secondary"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"color": "#0f3460",
|
|
421
|
+
"name": "Accent",
|
|
422
|
+
"slug": "accent"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"color": "#e94560",
|
|
426
|
+
"name": "Highlight",
|
|
427
|
+
"slug": "highlight"
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"color": "#ffffff",
|
|
431
|
+
"name": "Base",
|
|
432
|
+
"slug": "base"
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"color": "#f8f9fa",
|
|
436
|
+
"name": "Base Alt",
|
|
437
|
+
"slug": "base-alt"
|
|
438
|
+
}
|
|
439
|
+
]
|
|
440
|
+
},
|
|
441
|
+
"typography": {
|
|
442
|
+
"fluid": true,
|
|
443
|
+
"fontFamilies": [
|
|
444
|
+
{
|
|
445
|
+
"fontFamily": "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif",
|
|
446
|
+
"name": "System Font",
|
|
447
|
+
"slug": "system"
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"fontFamily": "'Inter', sans-serif",
|
|
451
|
+
"fontFace": [
|
|
452
|
+
{
|
|
453
|
+
"fontFamily": "Inter",
|
|
454
|
+
"fontWeight": "400",
|
|
455
|
+
"fontStyle": "normal",
|
|
456
|
+
"src": ["file:./assets/fonts/inter-regular.woff2"]
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"fontFamily": "Inter",
|
|
460
|
+
"fontWeight": "600",
|
|
461
|
+
"fontStyle": "normal",
|
|
462
|
+
"src": ["file:./assets/fonts/inter-semibold.woff2"]
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
"fontFamily": "Inter",
|
|
466
|
+
"fontWeight": "700",
|
|
467
|
+
"fontStyle": "normal",
|
|
468
|
+
"src": ["file:./assets/fonts/inter-bold.woff2"]
|
|
469
|
+
}
|
|
470
|
+
],
|
|
471
|
+
"name": "Inter",
|
|
472
|
+
"slug": "inter"
|
|
473
|
+
}
|
|
474
|
+
],
|
|
475
|
+
"fontSizes": [
|
|
476
|
+
{
|
|
477
|
+
"fluid": {
|
|
478
|
+
"min": "0.875rem",
|
|
479
|
+
"max": "1rem"
|
|
480
|
+
},
|
|
481
|
+
"name": "Small",
|
|
482
|
+
"size": "1rem",
|
|
483
|
+
"slug": "small"
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
"fluid": {
|
|
487
|
+
"min": "1rem",
|
|
488
|
+
"max": "1.125rem"
|
|
489
|
+
},
|
|
490
|
+
"name": "Medium",
|
|
491
|
+
"size": "1.125rem",
|
|
492
|
+
"slug": "medium"
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
"fluid": {
|
|
496
|
+
"min": "1.25rem",
|
|
497
|
+
"max": "1.5rem"
|
|
498
|
+
},
|
|
499
|
+
"name": "Large",
|
|
500
|
+
"size": "1.5rem",
|
|
501
|
+
"slug": "large"
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"fluid": {
|
|
505
|
+
"min": "1.75rem",
|
|
506
|
+
"max": "2.25rem"
|
|
507
|
+
},
|
|
508
|
+
"name": "Extra Large",
|
|
509
|
+
"size": "2.25rem",
|
|
510
|
+
"slug": "x-large"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"fluid": {
|
|
514
|
+
"min": "2.5rem",
|
|
515
|
+
"max": "3.5rem"
|
|
516
|
+
},
|
|
517
|
+
"name": "Huge",
|
|
518
|
+
"size": "3.5rem",
|
|
519
|
+
"slug": "huge"
|
|
520
|
+
}
|
|
521
|
+
]
|
|
522
|
+
},
|
|
523
|
+
"spacing": {
|
|
524
|
+
"spacingScale": {
|
|
525
|
+
"steps": 7
|
|
526
|
+
},
|
|
527
|
+
"spacingSizes": [
|
|
528
|
+
{
|
|
529
|
+
"name": "XS",
|
|
530
|
+
"size": "0.5rem",
|
|
531
|
+
"slug": "xs"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
"name": "S",
|
|
535
|
+
"size": "1rem",
|
|
536
|
+
"slug": "s"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
"name": "M",
|
|
540
|
+
"size": "1.5rem",
|
|
541
|
+
"slug": "m"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
"name": "L",
|
|
545
|
+
"size": "2rem",
|
|
546
|
+
"slug": "l"
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
"name": "XL",
|
|
550
|
+
"size": "3rem",
|
|
551
|
+
"slug": "xl"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
"name": "XXL",
|
|
555
|
+
"size": "4rem",
|
|
556
|
+
"slug": "xxl"
|
|
557
|
+
}
|
|
558
|
+
],
|
|
559
|
+
"units": ["%", "px", "em", "rem", "vh", "vw"]
|
|
560
|
+
},
|
|
561
|
+
"blocks": {
|
|
562
|
+
"core/button": {
|
|
563
|
+
"border": {
|
|
564
|
+
"radius": true
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
"core/pullquote": {
|
|
568
|
+
"border": {
|
|
569
|
+
"color": true,
|
|
570
|
+
"radius": true,
|
|
571
|
+
"style": true,
|
|
572
|
+
"width": true
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
"styles": {
|
|
578
|
+
"color": {
|
|
579
|
+
"background": "var(--wp--preset--color--base)",
|
|
580
|
+
"text": "var(--wp--preset--color--primary)"
|
|
581
|
+
},
|
|
582
|
+
"typography": {
|
|
583
|
+
"fontFamily": "var(--wp--preset--font-family--system)",
|
|
584
|
+
"fontSize": "var(--wp--preset--font-size--medium)",
|
|
585
|
+
"lineHeight": "1.6"
|
|
586
|
+
},
|
|
587
|
+
"spacing": {
|
|
588
|
+
"padding": {
|
|
589
|
+
"top": "var(--wp--preset--spacing--m)",
|
|
590
|
+
"right": "var(--wp--preset--spacing--m)",
|
|
591
|
+
"bottom": "var(--wp--preset--spacing--m)",
|
|
592
|
+
"left": "var(--wp--preset--spacing--m)"
|
|
593
|
+
}
|
|
594
|
+
},
|
|
595
|
+
"elements": {
|
|
596
|
+
"link": {
|
|
597
|
+
"color": {
|
|
598
|
+
"text": "var(--wp--preset--color--accent)"
|
|
599
|
+
},
|
|
600
|
+
":hover": {
|
|
601
|
+
"color": {
|
|
602
|
+
"text": "var(--wp--preset--color--highlight)"
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
"button": {
|
|
607
|
+
"border": {
|
|
608
|
+
"radius": "4px"
|
|
609
|
+
},
|
|
610
|
+
"color": {
|
|
611
|
+
"background": "var(--wp--preset--color--accent)",
|
|
612
|
+
"text": "var(--wp--preset--color--base)"
|
|
613
|
+
},
|
|
614
|
+
":hover": {
|
|
615
|
+
"color": {
|
|
616
|
+
"background": "var(--wp--preset--color--highlight)"
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
},
|
|
620
|
+
"heading": {
|
|
621
|
+
"typography": {
|
|
622
|
+
"fontFamily": "var(--wp--preset--font-family--inter)",
|
|
623
|
+
"fontWeight": "700",
|
|
624
|
+
"lineHeight": "1.2"
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
"h1": {
|
|
628
|
+
"typography": {
|
|
629
|
+
"fontSize": "var(--wp--preset--font-size--huge)"
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
"h2": {
|
|
633
|
+
"typography": {
|
|
634
|
+
"fontSize": "var(--wp--preset--font-size--x-large)"
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
"blocks": {
|
|
639
|
+
"core/site-title": {
|
|
640
|
+
"typography": {
|
|
641
|
+
"fontFamily": "var(--wp--preset--font-family--inter)",
|
|
642
|
+
"fontSize": "var(--wp--preset--font-size--large)",
|
|
643
|
+
"fontWeight": "700"
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
"core/navigation": {
|
|
647
|
+
"typography": {
|
|
648
|
+
"fontSize": "var(--wp--preset--font-size--small)"
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
"templateParts": [
|
|
654
|
+
{
|
|
655
|
+
"area": "header",
|
|
656
|
+
"name": "header",
|
|
657
|
+
"title": "Header"
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
"area": "footer",
|
|
661
|
+
"name": "footer",
|
|
662
|
+
"title": "Footer"
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"area": "uncategorized",
|
|
666
|
+
"name": "sidebar",
|
|
667
|
+
"title": "Sidebar"
|
|
668
|
+
}
|
|
669
|
+
],
|
|
670
|
+
"customTemplates": [
|
|
671
|
+
{
|
|
672
|
+
"name": "blank",
|
|
673
|
+
"postTypes": ["page", "post"],
|
|
674
|
+
"title": "Blank"
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
"name": "full-width",
|
|
678
|
+
"postTypes": ["page"],
|
|
679
|
+
"title": "Full Width"
|
|
680
|
+
}
|
|
681
|
+
]
|
|
682
|
+
}
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
### Block Template Example (templates/single.html)
|
|
686
|
+
|
|
687
|
+
```html
|
|
688
|
+
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
|
|
689
|
+
|
|
690
|
+
<!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
|
|
691
|
+
<main class="wp-block-group">
|
|
692
|
+
<!-- wp:post-featured-image {"align":"wide"} /-->
|
|
693
|
+
|
|
694
|
+
<!-- wp:group {"style":{"spacing":{"margin":{"top":"var:preset|spacing|l"}}}} -->
|
|
695
|
+
<div class="wp-block-group">
|
|
696
|
+
<!-- wp:post-title {"level":1} /-->
|
|
697
|
+
|
|
698
|
+
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"},"style":{"spacing":{"blockGap":"var:preset|spacing|s"}}} -->
|
|
699
|
+
<div class="wp-block-group">
|
|
700
|
+
<!-- wp:post-date /-->
|
|
701
|
+
<!-- wp:post-author {"showAvatar":false} /-->
|
|
702
|
+
<!-- wp:post-terms {"term":"category"} /-->
|
|
703
|
+
</div>
|
|
704
|
+
<!-- /wp:group -->
|
|
705
|
+
</div>
|
|
706
|
+
<!-- /wp:group -->
|
|
707
|
+
|
|
708
|
+
<!-- wp:post-content {"layout":{"type":"constrained"}} /-->
|
|
709
|
+
|
|
710
|
+
<!-- wp:post-terms {"term":"post_tag","prefix":"Tags: "} /-->
|
|
711
|
+
|
|
712
|
+
<!-- wp:comments {"className":"wp-block-comments-query-loop"} -->
|
|
713
|
+
<div class="wp-block-comments wp-block-comments-query-loop">
|
|
714
|
+
<!-- wp:comments-title /-->
|
|
715
|
+
<!-- wp:comment-template -->
|
|
716
|
+
<!-- wp:group {"style":{"spacing":{"margin":{"bottom":"var:preset|spacing|m"}}}} -->
|
|
717
|
+
<div class="wp-block-group">
|
|
718
|
+
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
|
|
719
|
+
<div class="wp-block-group">
|
|
720
|
+
<!-- wp:avatar {"size":48} /-->
|
|
721
|
+
<!-- wp:comment-author-name /-->
|
|
722
|
+
<!-- wp:comment-date /-->
|
|
723
|
+
</div>
|
|
724
|
+
<!-- /wp:group -->
|
|
725
|
+
<!-- wp:comment-content /-->
|
|
726
|
+
<!-- wp:comment-reply-link /-->
|
|
727
|
+
</div>
|
|
728
|
+
<!-- /wp:group -->
|
|
729
|
+
<!-- /wp:comment-template -->
|
|
730
|
+
<!-- wp:comments-pagination -->
|
|
731
|
+
<!-- wp:comments-pagination-previous /-->
|
|
732
|
+
<!-- wp:comments-pagination-numbers /-->
|
|
733
|
+
<!-- wp:comments-pagination-next /-->
|
|
734
|
+
<!-- /wp:comments-pagination -->
|
|
735
|
+
<!-- wp:post-comments-form /-->
|
|
736
|
+
</div>
|
|
737
|
+
<!-- /wp:comments -->
|
|
738
|
+
</main>
|
|
739
|
+
<!-- /wp:group -->
|
|
740
|
+
|
|
741
|
+
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
### Template Part Example (parts/header.html)
|
|
745
|
+
|
|
746
|
+
```html
|
|
747
|
+
<!-- wp:group {"tagName":"header","className":"site-header","layout":{"type":"constrained"},"style":{"spacing":{"padding":{"top":"var:preset|spacing|m","bottom":"var:preset|spacing|m"}}}} -->
|
|
748
|
+
<header class="wp-block-group site-header">
|
|
749
|
+
<!-- wp:group {"layout":{"type":"flex","justifyContent":"space-between","flexWrap":"wrap"}} -->
|
|
750
|
+
<div class="wp-block-group">
|
|
751
|
+
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
|
|
752
|
+
<div class="wp-block-group">
|
|
753
|
+
<!-- wp:site-logo {"width":50} /-->
|
|
754
|
+
<!-- wp:site-title /-->
|
|
755
|
+
</div>
|
|
756
|
+
<!-- /wp:group -->
|
|
757
|
+
|
|
758
|
+
<!-- wp:navigation {"ref":123,"layout":{"type":"flex","setCascadingProperties":true},"style":{"spacing":{"blockGap":"var:preset|spacing|m"}}} /-->
|
|
759
|
+
</div>
|
|
760
|
+
<!-- /wp:group -->
|
|
761
|
+
</header>
|
|
762
|
+
<!-- /wp:group -->
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
---
|
|
766
|
+
|
|
767
|
+
## Block Patterns
|
|
768
|
+
|
|
769
|
+
### Registering Block Patterns
|
|
770
|
+
|
|
771
|
+
```php
|
|
772
|
+
<?php
|
|
773
|
+
/**
|
|
774
|
+
* patterns/hero-section.php
|
|
775
|
+
*
|
|
776
|
+
* Title: Hero Section
|
|
777
|
+
* Slug: theme-name/hero-section
|
|
778
|
+
* Categories: featured, banner
|
|
779
|
+
* Keywords: hero, banner, call to action
|
|
780
|
+
* Block Types: core/template-part/header
|
|
781
|
+
* Viewport Width: 1400
|
|
782
|
+
*/
|
|
783
|
+
|
|
784
|
+
declare(strict_types=1);
|
|
785
|
+
|
|
786
|
+
defined('ABSPATH') || exit;
|
|
787
|
+
?>
|
|
788
|
+
|
|
789
|
+
<!-- wp:cover {"url":"<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/hero-bg.jpg","dimRatio":60,"overlayColor":"primary","align":"full","style":{"spacing":{"padding":{"top":"var:preset|spacing|xxl","bottom":"var:preset|spacing|xxl"}}}} -->
|
|
790
|
+
<div class="wp-block-cover alignfull">
|
|
791
|
+
<span aria-hidden="true" class="wp-block-cover__background has-primary-background-color has-background-dim-60 has-background-dim"></span>
|
|
792
|
+
<img class="wp-block-cover__image-background" src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/hero-bg.jpg" alt="" />
|
|
793
|
+
<div class="wp-block-cover__inner-container">
|
|
794
|
+
<!-- wp:group {"layout":{"type":"constrained"}} -->
|
|
795
|
+
<div class="wp-block-group">
|
|
796
|
+
<!-- wp:heading {"textAlign":"center","level":1,"textColor":"base","fontSize":"huge"} -->
|
|
797
|
+
<h1 class="wp-block-heading has-text-align-center has-base-color has-text-color has-huge-font-size"><?php esc_html_e('Welcome to Our Site', 'theme-name'); ?></h1>
|
|
798
|
+
<!-- /wp:heading -->
|
|
799
|
+
|
|
800
|
+
<!-- wp:paragraph {"align":"center","textColor":"base","fontSize":"large"} -->
|
|
801
|
+
<p class="has-text-align-center has-base-color has-text-color has-large-font-size"><?php esc_html_e('Discover amazing content and features that will help you succeed.', 'theme-name'); ?></p>
|
|
802
|
+
<!-- /wp:paragraph -->
|
|
803
|
+
|
|
804
|
+
<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
|
|
805
|
+
<div class="wp-block-buttons">
|
|
806
|
+
<!-- wp:button {"backgroundColor":"highlight","textColor":"base"} -->
|
|
807
|
+
<div class="wp-block-button"><a class="wp-block-button__link has-base-color has-highlight-background-color has-text-color has-background wp-element-button"><?php esc_html_e('Get Started', 'theme-name'); ?></a></div>
|
|
808
|
+
<!-- /wp:button -->
|
|
809
|
+
|
|
810
|
+
<!-- wp:button {"className":"is-style-outline"} -->
|
|
811
|
+
<div class="wp-block-button is-style-outline"><a class="wp-block-button__link wp-element-button"><?php esc_html_e('Learn More', 'theme-name'); ?></a></div>
|
|
812
|
+
<!-- /wp:button -->
|
|
813
|
+
</div>
|
|
814
|
+
<!-- /wp:buttons -->
|
|
815
|
+
</div>
|
|
816
|
+
<!-- /wp:group -->
|
|
817
|
+
</div>
|
|
818
|
+
</div>
|
|
819
|
+
<!-- /wp:cover -->
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
### Registering Patterns in functions.php
|
|
823
|
+
|
|
824
|
+
```php
|
|
825
|
+
<?php
|
|
826
|
+
/**
|
|
827
|
+
* Register block pattern categories
|
|
828
|
+
*/
|
|
829
|
+
function register_pattern_categories(): void {
|
|
830
|
+
register_block_pattern_category('theme-name-patterns', [
|
|
831
|
+
'label' => __('Theme Name Patterns', 'theme-name'),
|
|
832
|
+
]);
|
|
833
|
+
}
|
|
834
|
+
add_action('init', __NAMESPACE__ . '\\register_pattern_categories');
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
---
|
|
838
|
+
|
|
839
|
+
## Best Practices
|
|
840
|
+
|
|
841
|
+
### Do
|
|
842
|
+
|
|
843
|
+
- Use `theme.json` for all design tokens in block themes
|
|
844
|
+
- Leverage fluid typography for responsive text
|
|
845
|
+
- Create reusable template parts for header/footer
|
|
846
|
+
- Register block patterns for common layouts
|
|
847
|
+
- Use CSS custom properties from `theme.json`
|
|
848
|
+
- Implement proper accessibility (skip links, ARIA)
|
|
849
|
+
- Test in the Site Editor and frontend
|
|
850
|
+
|
|
851
|
+
### Do Not
|
|
852
|
+
|
|
853
|
+
- Mix classic theme files with block theme templates
|
|
854
|
+
- Hardcode colors or sizes in templates
|
|
855
|
+
- Skip the `$schema` property in `theme.json`
|
|
856
|
+
- Ignore mobile responsiveness in patterns
|
|
857
|
+
- Override core block styles excessively
|
|
858
|
+
- Forget to escape translatable strings in patterns
|