Skip to content

Commit ac790af

Browse files
authored
Merge pull request #12 from BeAPI/release/1.1.0
Release 1.1.0
2 parents 1a34564 + 0a5421e commit ac790af

23 files changed

+24658
-689
lines changed

.distignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ phpcs.xml.dist
2121
phpunit.xml.dist
2222
psalm.xml.dist
2323
README.md
24+
CHANGELOG.md
25+
CONTRIBUTING.md
2426
webpack.config.js
2527
yarn.lock

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
/phpcs.xml.dist export-ignore
1010
/psalm.xml export-ignore
1111
/README.md export-ignore
12+
/CONTRIBUTING.md export-ignore

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/vendor/
22
/node_modules/
3-
/assets/build/
3+
/build/

.plugin-data

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"version": "1.0.6",
2+
"version": "1.1.0",
33
"slug": "beapi-acf-palette"
44
}

.wp-env.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"plugins": [
3+
"."
4+
]
5+
}

CHANGELOG.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
Nothing yet.
11+
12+
## [1.1.0] - 2026-01-12
13+
14+
### Added
15+
16+
- New "Color Source" field setting to choose between three sources in theme.json:
17+
- `settings.color.palette` (default): Standard WordPress color palette
18+
- `custom.color`: Custom color definitions with slug as key and hex value (must be at root level)
19+
- `both`: Combines both settings and custom colors (custom takes priority on conflicts)
20+
- Automatic name generation from slugs for custom colors
21+
- Example: `environnement-400` → "Environnement 400"
22+
- Example: `services-publics-900` → "Services Publics 900"
23+
- Dynamic reloading of Include/Exclude color options via AJAX when source changes
24+
- AJAX endpoint `acf_palette_get_colors` for fetching colors based on selected source
25+
26+
### Changed
27+
28+
- Simplified Return Format options: removed "Label" option
29+
- **Slug**: Returns only the color slug (e.g., `"primary-orange"`)
30+
- **Hex Color**: Returns only the hex value (e.g., `"#FF6745"`)
31+
- **Both (Array)**: Returns array with `name`, `slug`, and `color`
32+
- Updated Array format structure for consistency:
33+
- Before: `['value' => '...', 'label' => '...', 'color' => '...']`
34+
- After: `['name' => '...', 'slug' => '...', 'color' => '...']`
35+
- Split color retrieval logic into separate methods (`get_settings_colors()`, `get_custom_colors()`, `get_both_colors()`)
36+
- Changed color source field layout from horizontal to vertical for better readability
37+
- Updated `get_theme_colors()` method to accept a `$source` parameter
38+
- All field methods now support the `color_source` parameter
39+
40+
### Fixed
41+
42+
- Fixed AJAX handler to use proper capability checks and custom nonce validation
43+
- Fixed custom colors retrieval to correctly read from root-level `custom.color` in theme.json
44+
- Improved security with `acf_palette_nonce` instead of generic `acf_nonce`
45+
46+
### Technical
47+
48+
- Added `get_settings_colors()` private method for `settings.color.palette`
49+
- Added `get_custom_colors()` private method for `custom.color`
50+
- Added `get_both_colors()` private method for combining both sources
51+
- Added `format_slug_to_name()` helper method for slug-to-name conversion
52+
- Added `ajax_get_colors()` method to handle AJAX requests
53+
- Added JavaScript AJAX handler in `editor.js` to reload color options dynamically
54+
- Added `updateSelectOptions()` JavaScript function to refresh Select2 dropdowns
55+
- Added `wp_localize_script()` for passing AJAX URL and nonce to JavaScript
56+
- Removed debug logs (`console.log` and `error_log`) from production code
57+
58+
## [1.0.6] - 2025-11-28
59+
60+
### Fixed
61+
62+
- Updated export-ignore list in `.gitattributes` for cleaner releases
63+
64+
## [1.0.5] - 2025-11-28
65+
66+
### Changed
67+
68+
- Updated PHP version requirement to 8.3
69+
70+
### Fixed
71+
72+
- Fixed potential undefined array key warnings
73+
74+
## [1.0.4] - 2025-11-27
75+
76+
### Changed
77+
78+
- Updated plugin metadata and autoloader configuration
79+
80+
## [1.0.3] - 2025-11-27
81+
82+
### Added
83+
84+
- Added autoload configuration
85+
86+
## [1.0.2] - 2025-11-27
87+
88+
### Fixed
89+
90+
- Updated package metadata in `composer.json`
91+
92+
## [1.0.1] - 2025-11-27
93+
94+
### Added
95+
96+
- Automated release workflow setup
97+
- Added `composer.lock` file
98+
99+
### Changed
100+
101+
- Removed Node.js build step from workflow
102+
- Removed obsolete workflow configurations
103+
- Set first radio option as selected by default
104+
105+
## [1.0.0] - 2025-08-08
106+
107+
### Added
108+
109+
- Initial release of ACF Color Palette plugin
110+
- Custom ACF field type "Theme Color" for selecting colors from theme.json
111+
- Support for `settings.color.palette` colors from theme.json
112+
- Color preview with color circle and hex code
113+
- Select2 integration for searchable dropdown
114+
- Field settings:
115+
- Allow Null: Option to allow no color selection
116+
- Default Value: Set a default color
117+
- Color Filter Method: Choose between "Exclude" or "Include" colors
118+
- Exclude Colors: Exclude specific colors from selection
119+
- Include Colors: Only include specific colors
120+
- Return Format: Value (Slug), Hex Color, Label, or Array
121+
- Return format options:
122+
- Value: Returns color slug
123+
- Hex: Returns hex color code
124+
- Label: Returns color name
125+
- Array: Returns complete color data
126+
- Support for multiple theme.json file locations
127+
- Color filtering based on inclusion/exclusion rules
128+
- Automatic color selection (first color or "No color" if null allowed)

CONTRIBUTING.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Local Dev
2+
3+
## Installation
4+
5+
```shell
6+
# Composer installation
7+
composer install -o
8+
./vendor/bin/psalm-plugin enable humanmade/psalm-plugin-wordpress
9+
10+
# Add playwright locally
11+
npx playwright install --with-deps
12+
13+
# Install dependencies
14+
npm install
15+
16+
# Env start, this will launch the environment with the PHP version specified into `.wp-env.json` and latest version of WordPress.
17+
npm run env:start
18+
19+
# Install and activate ACF pro, for example :
20+
npm run wp-cli -- wp plugin install --activate https://composer.beapi.fr/dist/wpengine/advanced-custom-fields-pro/wpengine-advanced-custom-fields-pro-6.2.7.zip
21+
```
22+
23+
## Créer une nouvelle fonctionnalité ou un correctif
24+
25+
À partir de la branche `develop` à jour, créez votre branche `feature/<topic>` si c'est une nouvelle fonctionnalité ou `fix/<topic>` si c'est un correctif.
26+
27+
## Merger votre fonctionnalité ou correctif
28+
29+
Créez une Pull Request de votre branche vers `main`.
30+
31+
## Créer une nouvelle branche de release
32+
33+
Une fois votre branche mergée sur `main`, créez une nouvelle branche `release/X.X.X` (X.X.X correspondant à la nouvelle version de votre release).
34+
35+
Modifiez les fichiers `.plugin-data` et `beapi-acf-palette.php` pour mettre à jour la version.
36+
37+
```plain
38+
{
39+
"version": "1.0.6",
40+
"slug": "beapi-acf-palette"
41+
}
42+
```
43+
44+
```php
45+
/*
46+
Version: 1.0.6
47+
*/
48+
49+
define( 'BEAPI_ACF_PALETTE_VERSION', '1.0.6' );
50+
```
51+
52+
Committez et poussez votre branche.
53+
54+
## Déployer une nouvelle release
55+
56+
Créez une Pull Request de votre branche `release/X.X.X` vers `main` et une autre Pull Request vers `develop`.
57+
58+
Une fois validée et mergée, un nouveau tag sera créé. Il faudra ensuite lancer la commande Satis pour mettre à jour <https://composer.beapi.fr/>.

README.md

Lines changed: 78 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,45 @@ Un nouveau type de champ ACF qui récupère automatiquement les couleurs défini
1515
- Le champ affichera automatiquement toutes les couleurs définies dans `wp-content/themes/[theme]/theme.json`
1616

1717
2. **Options du champ**
18+
- **Color Source** : Choisir la source des couleurs
19+
- `Settings Palette` : Uniquement `settings.color.palette`
20+
- `Custom Colors` : Uniquement `custom.color`
21+
- `Both` : Combine les deux sources (settings + custom)
1822
- **Allow Null** : Permet de ne pas sélectionner de couleur
1923
- **Default Value** : Valeur par défaut
2024
- **Color Filter Method** : Choisir entre exclure ou inclure des couleurs
2125
- **Exclude Colors** : Permet d'exclure certaines couleurs de la sélection
2226
- **Include Colors** : Permet de n'inclure que certaines couleurs spécifiques
23-
- **Return Format** : Format de retour (Value, Label, ou Array)
27+
- **Return Format** : Format de retour (Slug, Hex Color, ou Both)
2428

2529
3. **Formats de retour**
26-
- **Value (Slug)** : Retourne le slug de la couleur (ex: `primary-orange`)
30+
- **Slug** : Retourne le slug de la couleur (ex: `primary-orange`)
2731
- **Hex Color** : Retourne la valeur hexadécimale (ex: `#FF6745`)
28-
- **Label** : Retourne le nom de la couleur (ex: `Primaire orange`)
29-
- **Array** : Retourne un tableau avec `value`, `label` et `color`
32+
- **Both (Array)** : Retourne un tableau avec `name`, `slug` et `color`
3033

3134
#### Exemple d'utilisation en PHP
3235

3336
```php
34-
// Récupérer le slug (si configuré en "Value (Slug)")
37+
// Récupérer le slug (si configuré en "Slug")
3538
$color_slug = get_field('my_color_field');
39+
// 'primary-orange'
3640

3741
// Récupérer la valeur hexadécimale (si configuré en "Hex Color")
3842
$color_hex = get_field('my_color_field');
43+
// '#FF6745'
3944
echo "background-color: {$color_hex};";
4045

41-
// Récupérer le nom (si configuré en "Label")
42-
$color_name = get_field('my_color_field');
43-
44-
// Récupérer toutes les informations (si configuré en "Array")
46+
// Récupérer toutes les informations (si configuré en "Both (Array)")
4547
$color_data = get_field('my_color_field');
4648
// $color_data = [
47-
// 'value' => 'primary-orange',
48-
// 'label' => 'Primaire orange',
49+
// 'name' => 'Primaire orange',
50+
// 'slug' => 'primary-orange',
4951
// 'color' => '#FF6745'
5052
// ];
5153

52-
// Utilisation directe en CSS avec le format Array
53-
$color_hex = $color_data['color'];
54-
echo "background-color: {$color_hex};";
54+
// Utilisation avec le format Array
55+
echo "background-color: {$color_data['color']};";
56+
echo "Title: {$color_data['name']}";
5557
```
5658

5759
#### Méthodes de filtrage des couleurs
@@ -63,9 +65,11 @@ Le champ offre deux méthodes pour filtrer les couleurs disponibles :
6365

6466
Ces options sont mutuellement exclusives et s'affichent conditionnellement selon la méthode choisie.
6567

66-
#### Structure attendue du theme.json
68+
#### Sources de couleurs disponibles
69+
70+
Le plugin peut récupérer les couleurs depuis trois sources différentes dans le `theme.json` :
6771

68-
Le plugin s'attend à trouver les couleurs dans :
72+
##### 1. Settings Palette (par défaut)
6973

7074
```json
7175
{
@@ -83,6 +87,64 @@ Le plugin s'attend à trouver les couleurs dans :
8387
}
8488
```
8589

90+
##### 2. Custom Colors
91+
92+
```json
93+
{
94+
"$schema": "https://schemas.wp.org/trunk/theme.json",
95+
"version": 3,
96+
"custom": {
97+
"color": {
98+
"environnement-400": "#c9dcba",
99+
"environnement-900": "#395f0f",
100+
"entreprises-400": "#c1bcff",
101+
"entreprises-900": "#001cb7"
102+
}
103+
},
104+
"settings": {
105+
// ... autres paramètres
106+
}
107+
}
108+
```
109+
110+
Les couleurs custom utilisent une structure simplifiée où le slug est la clé et la couleur hex est la valeur. Le nom lisible est généré automatiquement à partir du slug :
111+
112+
- `environnement-400` → "Environnement 400"
113+
- `services-publics-900` → "Services Publics 900"
114+
115+
##### 3. Both (Settings + Custom)
116+
117+
Combine les couleurs des deux sources. Si un slug existe dans les deux sources, la version de `custom.color` sera prioritaire.
118+
119+
```json
120+
{
121+
"settings": {
122+
"color": {
123+
"palette": [
124+
{
125+
"name": "Primaire",
126+
"slug": "primary",
127+
"color": "#FF6745"
128+
}
129+
]
130+
}
131+
},
132+
"custom": {
133+
"color": {
134+
"environnement-400": "#c9dcba",
135+
"entreprises-400": "#c1bcff"
136+
}
137+
}
138+
}
139+
```
140+
141+
**Résultat avec "Both" :** Les 3 couleurs seront disponibles (`primary`, `environnement-400`, `entreprises-400`)
142+
143+
**Note :** Pour les couleurs custom, le nom est automatiquement généré à partir du slug. Par exemple :
144+
145+
- `environnement-400` devient "Environnement 400"
146+
- `services-publics-900` devient "Services Publics 900"
147+
86148
## Installation
87149

88150
1. Copier le plugin dans `wp-content/plugins/beapi-acf-palette/`

0 commit comments

Comments
 (0)