Skip to content

Commit c9cdc90

Browse files
authored
v1.0.7 (#22)
2 parents 2243b9b + c11da05 commit c9cdc90

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin Name: Advanced Custom Fields: Editor Palette Field
55
* Plugin URI: https://github.com/log1x/acf-editor-palette
66
* Description: A Gutenberg-like editor palette color picker field for Advanced Custom Fields.
7-
* Version: 1.0.6
7+
* Version: 1.0.7
88
* Author: Brandon Nifong
99
* Author URI: https://github.com/log1x
1010
*/

src/Field.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ class Field extends \acf_field
1212
* @var array
1313
*/
1414
public $defaults = [
15-
'return_format' => 'slug',
1615
'default_value' => null,
16+
'exclude_colors' => [],
17+
'return_format' => 'slug',
1718
];
1819

1920
/**
@@ -42,8 +43,9 @@ public function __construct(callable $plugin)
4243
protected function palette($color = null)
4344
{
4445
$colors = [];
45-
$palette = (array) get_theme_support('editor-color-palette');
46-
$palette = array_pop($palette);
46+
$palette = (array) current(
47+
get_theme_support('editor-color-palette')
48+
);
4749

4850
if (empty($palette)) {
4951
return $color ?: $colors;
@@ -74,7 +76,10 @@ public function render_field($field)
7476
}
7577

7678
$palette = array_filter($palette, function ($color) use ($field) {
77-
return ! in_array($color['slug'], $field['exclude_colors'] ?? []);
79+
return ! in_array(
80+
$color['slug'],
81+
! empty($field['exclude_colors']) && is_array($field['exclude_colors']) ? $field['exclude_colors'] : []
82+
);
7883
});
7984

8085
$active = is_array($field['value']) ? $field['value']['slug'] : $field['value'];

0 commit comments

Comments
 (0)