File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 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 */
Original file line number Diff line number Diff 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 ' ];
You can’t perform that action at this time.
0 commit comments