Skip to content

Commit

Permalink
v1.0.7 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x authored Feb 24, 2021
2 parents 2243b9b + c11da05 commit c9cdc90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Advanced Custom Fields: Editor Palette Field
* Plugin URI: https://github.com/log1x/acf-editor-palette
* Description: A Gutenberg-like editor palette color picker field for Advanced Custom Fields.
* Version: 1.0.6
* Version: 1.0.7
* Author: Brandon Nifong
* Author URI: https://github.com/log1x
*/
Expand Down
13 changes: 9 additions & 4 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class Field extends \acf_field
* @var array
*/
public $defaults = [
'return_format' => 'slug',
'default_value' => null,
'exclude_colors' => [],
'return_format' => 'slug',
];

/**
Expand Down Expand Up @@ -42,8 +43,9 @@ public function __construct(callable $plugin)
protected function palette($color = null)
{
$colors = [];
$palette = (array) get_theme_support('editor-color-palette');
$palette = array_pop($palette);
$palette = (array) current(
get_theme_support('editor-color-palette')
);

if (empty($palette)) {
return $color ?: $colors;
Expand Down Expand Up @@ -74,7 +76,10 @@ public function render_field($field)
}

$palette = array_filter($palette, function ($color) use ($field) {
return ! in_array($color['slug'], $field['exclude_colors'] ?? []);
return ! in_array(
$color['slug'],
! empty($field['exclude_colors']) && is_array($field['exclude_colors']) ? $field['exclude_colors'] : []
);
});

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

0 comments on commit c9cdc90

Please sign in to comment.