Skip to content

Commit 03f5319

Browse files
committed
Add colors in php instead of theme json
1 parent 1b490d3 commit 03f5319

File tree

2 files changed

+79
-62
lines changed

2 files changed

+79
-62
lines changed

inc/Services/Editor.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function get_service_name(): string {
3737
* @param Service_Container $container
3838
*/
3939
public function boot( Service_Container $container ): void {
40+
$this->after_theme_setup();
4041
/**
4142
* Load editor style css for admin and frontend
4243
*/
@@ -57,6 +58,84 @@ public function boot( Service_Container $container ): void {
5758
add_filter( 'allowed_block_types_all', [ $this, 'gutenberg_blocks_allowed' ], 10, 2 );
5859
}
5960

61+
/**
62+
* Register :
63+
* - theme_supports
64+
* - color palettes
65+
* - font sizes
66+
* - etc.
67+
*
68+
*/
69+
private function after_theme_setup(): void {
70+
71+
//color palettes
72+
add_theme_support(
73+
'editor-color-palette',
74+
[
75+
[
76+
'name' => __( 'Black', 'beapi-frontend-framework' ),
77+
'slug' => 'black',
78+
'color' => '#000'
79+
],
80+
[
81+
'name' => __( 'White', 'beapi-frontend-framework' ),
82+
'slug' => 'white',
83+
'color' => '#fff'
84+
],
85+
[
86+
'name' => __( 'Yellow 500', 'beapi-frontend-framework' ),
87+
'slug' => 'yellow-500',
88+
'color' => '#ffe600'
89+
],
90+
[
91+
'name' => __( 'Grey 100', 'beapi-frontend-framework' ),
92+
'slug' => 'grey-100',
93+
'color' => '#eee'
94+
],
95+
[
96+
'name' => __( 'Grey 200', 'beapi-frontend-framework' ),
97+
'slug' => 'grey-200',
98+
'color' => '#ccc'
99+
],
100+
[
101+
'name' => __( 'Grey 300', 'beapi-frontend-framework' ),
102+
'slug' => 'grey-300',
103+
'color' => '#aaa'
104+
],
105+
[
106+
'name' => __( 'Grey 400', 'beapi-frontend-framework' ),
107+
'slug' => 'grey-400',
108+
'color' => '#999'
109+
],
110+
[
111+
'name' => __( 'Grey 500', 'beapi-frontend-framework' ),
112+
'slug' => 'grey-500',
113+
'color' => '#888'
114+
],
115+
[
116+
'name' => __( 'Grey 600', 'beapi-frontend-framework' ),
117+
'slug' => 'grey-600',
118+
'color' => '#777'
119+
],
120+
[
121+
'name' => __( 'Grey 700', 'beapi-frontend-framework' ),
122+
'slug' => 'grey-700',
123+
'color' => '#555'
124+
],
125+
[
126+
'name' => __( 'Grey 800', 'beapi-frontend-framework' ),
127+
'slug' => 'grey-800',
128+
'color' => '#333'
129+
],
130+
[
131+
'name' => __( 'Grey 900', 'beapi-frontend-framework' ),
132+
'slug' => 'grey-900',
133+
'color' => '#111'
134+
],
135+
]
136+
);
137+
}
138+
60139
/**
61140
* editor style
62141
*/

theme.json

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,68 +13,6 @@
1313
"width": true
1414
},
1515
"color": {
16-
"palette": [
17-
{
18-
"name": "Noir",
19-
"slug": "black",
20-
"color": "#000"
21-
},
22-
{
23-
"name": "Blanc",
24-
"slug": "white",
25-
"color": "#fff"
26-
},
27-
{
28-
"name": "Jaune 500",
29-
"slug": "yellow-500",
30-
"color": "#ffe600"
31-
},
32-
{
33-
"name": "Gris 100",
34-
"slug": "grey-100",
35-
"color": "#eee"
36-
},
37-
{
38-
"name": "Gris 200",
39-
"slug": "grey-200",
40-
"color": "#ccc"
41-
},
42-
{
43-
"name": "Gris 300",
44-
"slug": "grey-300",
45-
"color": "#aaa"
46-
},
47-
{
48-
"name": "Gris 400",
49-
"slug": "grey-400",
50-
"color": "#999"
51-
},
52-
{
53-
"name": "Gris 500",
54-
"slug": "grey-500",
55-
"color": "#888"
56-
},
57-
{
58-
"name": "Gris 600",
59-
"slug": "grey-600",
60-
"color": "#777"
61-
},
62-
{
63-
"name": "Gris 700",
64-
"slug": "grey-700",
65-
"color": "#555"
66-
},
67-
{
68-
"name": "Gris 800",
69-
"slug": "grey-800",
70-
"color": "#333"
71-
},
72-
{
73-
"name": "Gris 900",
74-
"slug": "grey-900",
75-
"color": "#111"
76-
}
77-
],
7816
"defaultDuotone": false,
7917
"defaultGradients": false,
8018
"defaultPalette": false

0 commit comments

Comments
 (0)