Skip to content

Commit

Permalink
fix(field): Fix default value return format (Fixes #26) (#40)
Browse files Browse the repository at this point in the history
* enhance(css): Add margin between the label and editor palette input
  • Loading branch information
Log1x authored Oct 29, 2022
1 parent a8e744e commit 7a30258
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion assets/css/field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}

.acf-input {
@apply max-w-xs;
@apply max-w-xs mt-2;

ul {
@apply list-none grid grid-cols-6 gap-y-3 m-0 p-0;
Expand Down
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.1.0
* Version: 1.1.1
* Author: Brandon Nifong
* Author URI: https://github.com/log1x
*/
Expand Down
2 changes: 1 addition & 1 deletion public/css/field.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/field.js": "/js/field.js?id=ffc7c64cd20bf0834b74",
"/css/field.css": "/css/field.css?id=80d77494b6548b463aa0"
"/css/field.css": "/css/field.css?id=5d81ea651b71d5759ed7"
}
4 changes: 4 additions & 0 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ public function format_value($value, $post_id, $field)
{
$format = $field['return_format'] ?? $this->defaults['return_format'];

if (is_string($value)) {
$value = $this->palette($value);
}

return $format === 'array' ? $value : ($value[$format] ?? $value);
}

Expand Down

0 comments on commit 7a30258

Please sign in to comment.