Git Product home page Git Product logo

acf-editor-palette's Introduction

ACF Editor Palette

Latest Stable Version Total Downloads Build Status

A Gutenberg-like editor palette color picker field for Advanced Custom Fields.

Field Example

Features

  • Colors are automatically loaded from theme.json and/or the editor palette.
  • Return format includes the default palette keys as well as background and text color classes for convenience.
  • Default value can optionally be set using the color's slug.
  • Colors can optionally be allowed/excluded from the palette.

Requirements

Installation

Bedrock

Install via Composer:

$ composer require log1x/acf-editor-palette

Manual

Download the latest release .zip and install into wp-content/plugins.

Usage

Field Group Example

^ array:5 [▼
  "name" => "Green (500)"
  "slug" => "green-500"
  "color" => "#0e9f6e"
  "text" => "has-text-color has-green-500-color"
  "background" => "has-background has-green-500-background-color"
]

ACF Composer

If you are on Sage 10 and using my ACF Composer package:

$field
  ->addField('my_color_field', 'editor_palette')
    ->setConfig('default_value', 'green-500')
    ->setConfig('allowed_colors', ['green-500', 'blue-500'])
    ->setConfig('exclude_colors', ['green-50', 'green-100'])
    ->setConfig('return_format', 'slug');

Bug Reports

If you discover a bug in ACF Editor Palette, please open an issue.

Contributing

Contributing whether it be through PRs, reporting an issue, or suggesting an idea is encouraged and appreciated.

License

ACF Editor Palette is provided under the MIT License.

acf-editor-palette's People

Contributors

ajskelton avatar daverobertson avatar davidwebca avatar erikhartin avatar huubl avatar jamiewarb avatar log1x avatar mike-sheppard avatar zcuric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acf-editor-palette's Issues

Deprecation error with latest Admin Columns: ACF add-on (3.0.2)

Hi,

I'm using this plugin in conjunction with Admin Columns Pro and its ACF add on. Upon upgrading the ACF add-on to the latest v 3.0.2, the following error appears on visiting the list view of a CPT in the WP Admin:

ErrorException (E_USER_DEPRECATED)
ACA\ACF\Column::get_acf_field_option is <strong>deprecated</strong> since version NEWVERSION with no alternative available.

...which Whoops can't seem to get past. From the stack trace:

15
ACA\ACF\Column get_acf_field_option
/[...]/wp-content/plugins/acf-editor-palette/plugin.php101
14
class@anonymous/[...]/wp-content/plugins/acf-editor-palette/plugin.php:14$0 Log1x\AcfEditorPalette\{closure}
/[...]/wp-includes/class-wp-hook.php307
...

I'm not familiar with the ACP API, but changing line 101 from
$column->get_acf_field_option('type') !== $this->name ||
to
$column->get_type() !== $this->name ||
seemed to get things working again, per this doc. Not sure about any side-effects, etc...

HTH / Thanks!

Feature request: Collapse Color Picker

I will try to explain simply.

I think it would be cool if the color picker was collapsable (either through a setting or as default) making it behave like the default Gutenberg color picker or the default ACF color picker.

So basically make it clickable to open up a menu with all the colors.

JS Error in Block Editor

Hi there, I'm using 1.0.8 and WP5.8 & ACF 5.10.1 (same issue with ACF 5.9.x). And get a JS error relating to acf-editor-palette. I've tried loading via the ACF UI, and via AFC Composer, with the same results.

Any idea what might be going wrong?

In any case, thanks for all your great work on WP and Sage plugins. It makes working in WP bearable most of the time :)

Uncaught TypeError: __webpack_require__.r is not a function
    js http://xxx.nl.test/app/themes/zzz/public/scripts/editor.js?id=ee45f35702e56562532d:10
    n http://xxxx.nl.test/app/plugins/acf-editor-palette/public/js/field.js:1
    __webpack_exec__ http://xxx.nl.test/app/themes/zzz/public/scripts/editor.js?id=ee45f35702e56562532d:54
    <anonymous> http://xxx.nl.test/app/themes/zzz/public/scripts/editor.js?id=ee45f35702e56562532d:55
    e http://xxx.nl.test/app/plugins/acf-editor-palette/public/js/field.js:1
    <anonymous> http://xxx.nl.test/app/plugins/acf-editor-palette/public/js/field.js:1
    <anonymous> http://xxx.nl.test/app/plugins/acf-editor-palette/public/js/field.js:1
    <anonymous> http://xxx.nl.test/app/plugins/acf-editor-palette/public/js/field.js:1
editor.js:10:21
    js http://xxx.nl.test/app/themes/zzz/public/scripts/editor.js?id=ee45f35702e56562532d:10
    n http://xxx.nl.test/app/plugins/acf-editor-palette/public/js/field.js:1
    __webpack_exec__ http://xxx.nl.test/app/themes/zzz/public/scripts/editor.js?id=ee45f35702e56562532d:54
    <anonymous> http://xxx.nl.test/app/themes/zzz/public/scripts/editor.js?id=ee45f35702e56562532d:55
    e http://xxx.nl.test/app/plugins/acf-editor-palette/public/js/field.js:1
    e self-hosted:1222
    forEach self-hosted:205
    <anonymous> http://xxx.nl.test/app/plugins/acf-editor-palette/public/js/field.js:1
    <anonymous> http://xxx.nl.test/app/plugins/acf-editor-palette/public/js/field.js:1
    <anonymous> http://xxx.nl.test/app/plugins/acf-editor-palette/public/js/field.js:1

Some other plugins being used for context/possible compatibility issues, in WP:

"log1x/sage-html-forms": "^1.0",
    "log1x/acf-editor-palette": "^1.0.8",
    "log1x/modern-acf-options": "dev-master",
    "log1x/modern-login": "dev-master",
    "ibericode/html-forms": "^1.3",
    "wpackagist-plugin/duplicate-page": "^4.3",
    "wpackagist-plugin/enable-media-replace": "^3.5",
    "wpackagist-plugin/post-type-switcher": "^3.2",
    "wpackagist-plugin/safe-svg": "^1.9",
    "wpackagist-plugin/simple-history": "^2.38",
    "wpackagist-plugin/two-factor": "^0.7.0",
    "wpackagist-plugin/user-switching": "^1.5",
    "wpackagist-plugin/disable-comments": "^2.0"

In the Sage10 Theme dir:

    "php": "^7.3|^8.0",
    "log1x/acf-composer": "^2.0",
    "log1x/navi": "^2.0",
    "log1x/poet": "^2.0",
    "log1x/sage-directives": "^1.1",
    "log1x/sage-svg": "^1.0",
    "roots/acorn": "2.0.0-alpha.0"

Color pallet styling issue on multisite projects

Hello, Log1x ,

I wanted to inform you, that faced with issue related to the styles broken for the color palette in admin panel after updating the plugin to v1.1.8.

The problem affects multisite projects, non-multisite project works as expected.

Additionally, there is present following error in console: Refused to apply style from '.../plugins/acf-editor-pallette/public/css/field.css because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Notes:

  • non-multisite projects load the file field.d1c65e.css without any issues with plugin v1.1.8.

  • with downgrade plugin version to v.1.1.7 no such issues detected.

Versions comparing v1.1.7...v1.1.8

For additional info: the projects are using roots versions 3.3.1 and 4.3.

Thanks you for you support.

The clear button doesn't trigger a block update

Hi !

Awesome plugin !

I just have on issue with it : the clear button doesn't trigger an update, which means that the last selected color stays on until I save the post and reload the page.

Other than that it's brilliant, would be awesome to have it on wpackagist too !

Thanks !

EDIT : Saving and reloading doesn't register that the clear button has been clicked. The only way I've found to register the change is to edit another acf field, and it sometimes doesn't work either

Clearing field doesn't change what value is returned from database

Note: This may be related to #5, and may be fixed when that is.

#5 is, in short, when selecting a colour, the $field['value'] is coming back as an array of colours. The code expects it to be just be a slug.

While investigating this, I noticed that, when using the Clear button to remove the selected value, the $field['value'] still comes back with the previously selected colours array of values. This happens even when the field has a default value.

That means there's no way to clear the value and get back to a default value.

Reproduction steps are identical to those in #5, except with the addition of selecting a default value.

Error log filling up

It seems there's a line that's adding errors to the error log, shown in the screenshot below.

image

PHPStorm autocorrects this to:

$editor_color_palette = get_theme_support('editor-color-palette');
$palette = array_pop($editor_color_palette);

Allow field to work in options pages

Hi!

The field doesn't work properly in options pages, mainly because the wp-component file doesn't get enqueued. I've narrowed it down to line 275 : https://github.com/Log1x/acf-editor-palette/blob/master/src/Field.php#L275

What is this supposed to do? From what I understand, it enqueues the styles only if the wp-component script is not enqueued? Why is that?

Should it not be the reverse and could it not be simply added as an array of dependencies to wp_enqueue_style / wp_enqueue_scripts a few lines under?

Feature request: Support including the plugin with a theme

What I mean is that I want to bundle this plugin with a theme I'm creating. Including the plugin in functions.php works fine, except the css and js files don't load in the Full Site Editor. I've been tinkering trying to get it to work but have not been able to come up with a solution.

PHP Error in Field.php

Hello! Thank for you for this plugin, first off.

The issue I'm having is that it's crashing on my installation's admin interface — I'm unable to load a block's side panel that uses this field, for example, nor am I able to edit a field group that uses this field type. This might be an interaction with ACF 6.0.0, as I have other installations running ACF 5.12.x that are doing just fine.

Using the latest release (1.1.3) of this plugin. My error log is showing a multitude of these:

PHP Fatal error: Uncaught TypeError: current(): Argument #1 ($array) must be of type array, bool given in [client info removed]\wp-content\plugins\acf-editor-palette\src\Field.php:49
Stack trace:
#0 [client info removed]\wp-content\plugins\acf-editor-palette\src\Field.php(49): current()
#1 [client info removed]\wp-content\plugins\acf-editor-palette\src\Field.php(170): Log1x\AcfEditorPalette\Field->palette()
#2 [client info removed]\wp-includes\class-wp-hook.php(308): Log1x\AcfEditorPalette\Field->render_field_settings()
#3 [client info removed]\wp-includes\class-wp-hook.php(332): WP_Hook->apply_filters()
#4 [client info removed]\wp-includes\plugin.php(517): WP_Hook->do_action()
#5 [client info removed]\wp-content\plugins\advanced-custom-fields-pro\includes\admin\views\field-group-field.php(150): do_action()
#6 [client info removed]\wp-content\plugins\advanced-custom-fields-pro\includes\api\api-helpers.php(443): include('...')
#7 [client info removed]\wp-content\plugins\advanced-custom-fields-pro\includes\admin\views\field-group-fields.php(79): acf_get_view()
#8 [client info removed]\wp-content\plugins\advanced-custom-fields-pro\includes\api\api-helpers.php(443): include('...')
#9 [client info removed]\wp-content\plugins\advanced-custom-fields-pro\includes\admin\admin-field-group.php(483): acf_get_view()
#10 [client info removed]\wp-admin\includes\template.php(1409): acf_admin_field_group->mb_fields()
#11 [client info removed]\wp-admin\edit-form-advanced.php(688): do_meta_boxes()
#12 [client info removed]\wp-admin\post.php(206): require('...')
#13 {main}
thrown in [client info removed]\wp-content\plugins\acf-editor-palette\src\Field.php on line 49

Apparent issue with ACF Pro 5.10

Hi,

It would appear that the field group editing experience with the editor palette field is (sort of) broken with ACF Pro 5.10. Instead of displaying the color name and a swatch, it looks like the wrapper HTML is being displayed as well. See this screenshot.
Screen Shot 2021-08-27 at 9 28 21 AM

...confirmed it is 5.10 related as the labels render fine when I rolled back. Could this be related to the new HTML escaping defaults?

Thanks,
Ben

Returning slug when selected return value is color

I'm using v1.0.6 of the plugin.

I wanted to ask if you've encountered a similar issue at all to this.

With the following editor palette config, everything is displaying correctly in the CMS when editing a field.

However, the colours are returning the slug instead of the hex value, even when color is selected.

        [
            'name' => __('Primary 300', TEXT_DOMAIN),
            'slug' => 'blue-300',
            'color' => '#2e6ba6',
        ],
        [
            'name' => __('Primary 500', TEXT_DOMAIN),
            'slug' => 'blue-500',
            'color' => '#479ad6',
        ],
        [
            'name' => __('Primary 700', TEXT_DOMAIN),
            'slug' => 'blue-700',
            'color' => '#c1d3e5',
        ],
        [
            'name' => __('Secondary 300', TEXT_DOMAIN),
            'slug' => 'green-300',
            'color' => '#6bab45',
        ],
        [
            'name' => __('Secondary 500', TEXT_DOMAIN),
            'slug' => 'green-500',
            'color' => '#a0dd83',
        ],
        [
            'name' => __('Secondary 700', TEXT_DOMAIN),
            'slug' => 'green-700',
            'color' => '#d3e6c8',
        ],
        [
            'name' => __('Gray 200', TEXT_DOMAIN),
            'slug' => 'gray-200',
            'color' => '#333333',
        ],
        [
            'name' => __('Gray 300', TEXT_DOMAIN),
            'slug' => 'gray-300',
            'color' => '#828282',
        ],
        [
            'name' => __('Gray 400', TEXT_DOMAIN),
            'slug' => 'gray-400',
            'color' => '#bdbdbd',
        ],
        [
            'name' => __('Gray 500', TEXT_DOMAIN),
            'slug' => 'gray-500',
            'color' => '#e5e2de',
        ],
        [
            'name' => __('Gray 600', TEXT_DOMAIN),
            'slug' => 'gray-600',
            'color' => '#f1eee8',
        ],
        [
            'name' => __('Gray 700', TEXT_DOMAIN),
            'slug' => 'gray-700',
            'color' => '#f5f2ec',
        ],
        [
            'name' => __('Gray 800', TEXT_DOMAIN),
            'slug' => 'gray-800',
            'color' => '#faf7f2',
        ],
        [
            'name' => __('White', TEXT_DOMAIN),
            'slug' => 'white',
            'color' => '#ffffff',
        ],
        [
            'name' => __('Highlight Green Lime', TEXT_DOMAIN),
            'slug' => 'green-lime',
            'color' => '#d1f521',
        ],
        [
            'name' => __('Highlight Pink Ruby', TEXT_DOMAIN),
            'slug' => 'pink-ruby',
            'color' => '#eb4a6e',
        ],
        [
            'name' => __('Highlight Blue Turquoise', TEXT_DOMAIN),
            'slug' => 'blue-turquoise',
            'color' => '#0fc9ff',
        ],
        [
            'name' => __('Highlight Purple Amethyst', TEXT_DOMAIN),
            'slug' => 'purple-amethyst',
            'color' => '#a35cde',
        ],
        [
            'name' => __('Highlight Red Cinnabar', TEXT_DOMAIN),
            'slug' => 'red-cinnabar',
            'color' => '#e53d3d',
        ],
        [
            'name' => __('Highlight Green Shamrock', TEXT_DOMAIN),
            'slug' => 'green-shamrock',
            'color' => '#59de9e',
        ],
        [
            'name' => __('Highlight Pink Mauvelous', TEXT_DOMAIN),
            'slug' => 'pink-mauvelous',
            'color' => '#f28ab2',
        ],
        [
            'name' => __('Highlight Blue Midnight', TEXT_DOMAIN),
            'slug' => 'blue-midnight',
            'color' => '#0f215e',
        ],
        [
            'name' => __('Highlight Orange Flamingo', TEXT_DOMAIN),
            'slug' => 'orange-flamingo',
            'color' => '#f55c42',
        ],
        [
            'name' => __('Highlight Orange Peach', TEXT_DOMAIN),
            'slug' => 'orange-peach',
            'color' => '#ffa800',
        ],
        [
            'name' => __('Highlight Blue Viking', TEXT_DOMAIN),
            'slug' => 'blue-viking',
            'color' => '#5cc2d1',
        ],
        [
            'name' => __('Highlight Yellow Turbo', TEXT_DOMAIN),
            'slug' => 'yellow-turbo',
            'color' => '#ffe300',
        ],

image

image

image

Empty palette in editor

First of all - Love your ACF Composer!
I tried ACF Editor Palette just now with Sage 10 (dev-master), added an editor_palette field. The field looks empty in the WP editor:

Screenshot 2021-04-13 at 20 56 11
(so... there is nothing beneath this)

Steps to reproduce this problem:

  1. Install Sage 10 composer create-project roots/sage theme-name dev-master
  2. yarn + yarn start
  3. Add a color palette to Sage 10 app/setup.php (which is working with default WP blocks)
  4. Install ACF Pro and activate
  5. Install ACF Composer with composer require log1x/acf-composer + wp acorn vendor:publish (which throws an error but seems to succeed:
In VendorPublishCommand.php line 277:
Call to undefined function Illuminate\Foundation\Console\base_path() 

  1. Install ACF Editor Palette with composer require log1x/acf-editor-palette
  2. Generate Example wp acorn acf:field Example
  3. Use this code
$example
->addRepeater('items')
   ->addText('item')
->endRepeater()
->addField('new_color', 'editor_palette')
   ->setConfig('return_format', 'slug');

Curious to hear if I'm doing something wrong, or if this is a bug.
PHP version 7.4.15
Thanks!

exclude_colors returns empty string

Hello! First, thanks for the great plugin.

I just ran into an issue where lots of warnings get printed on screen when the field is in display: it seems to be related to the fact that exclude_colors, even though it's supposed to be a "multiple" select field, returns an empty string by default. Hence, the "in_array" check of Field.php:77 returns a warning.

An extra check for $field['exclude_colors'] being an array or not empty could be made first to resolve the issue.

Fatal Error from use of Union Types for PHP versions < 8

I'm working on updating some sites that are still on PHP 7.4. I'm in the process of getting them updated to 8.2, but in the meantime I needed to update this plugin to deal with the errors from the ACF 6.3 update.

When attempting to update this plugin I started getting the following error:

PHP Fatal error: During class fetch: Uncaught ParseError: syntax error, unexpected '|', expecting ';' or '{' in /nas/content/live/sitename/wp-content/plugins/acf-editor-palette/src/Concerns/Asset.php:39

Looking into it the manifest function has a Union Type which is only allowed in PHP 8+. The Repo still lists the PHP requirement as >= 7.2, so either that should be bumped up to 8 or the Union Type should be removed.

Fatal error after ACF PRO 6.3 update - Illegal offset type - /wp-content/plugins/acf-editor-palette/src/Concerns/Palette.php on line 48

I'm getting the following fatal error after updating to ACF Pro 6.3.

Fatal error: Uncaught Error: Illegal offset type
in /wp-content/plugins/acf-editor-palette/src/Concerns/Palette.php on line 48

Call stack:

Log1x\AcfEditorPalette\Field::palette()
wp-content/plugins/acf-editor-palette/src/Field.php:248
Log1x\AcfEditorPalette\Field::validate_value()
wp-includes/class-wp-hook.php:324
WP_Hook::apply_filters()
wp-includes/plugin.php:205
apply_filters()
wp-content/plugins/advanced-custom-fields-pro/includes/validation.php:335
acf_validate_value()
wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:1224
acf_get_block_validation_state()
wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:618
acf_rendered_block()
wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:530
acf_render_block_callback()
wp-includes/class-wp-block.php:463
WP_Block::render()
wp-includes/class-wp-block.php:443
WP_Block::render()
wp-includes/blocks.php:1705
render_block()
wp-includes/blocks.php:1743
do_blocks()
wp-includes/class-wp-hook.php:324
WP_Hook::apply_filters()
wp-includes/plugin.php:205
apply_filters()
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:1865
WP_REST_Posts_Controller::prepare_item_for_response()
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:569
WP_REST_Posts_Controller::get_item()
wp-includes/rest-api/class-wp-rest-server.php:1230
WP_REST_Server::respond_to_request()
wp-includes/rest-api/class-wp-rest-server.php:1063
WP_REST_Server::dispatch()
wp-includes/rest-api.php:555
rest_do_request()
wp-includes/rest-api.php:2922
rest_preload_api_request()
array_reduce()
wp-includes/block-editor.php:753
block_editor_rest_api_preload()
wp-admin/edit-form-blocks.php:77
require()
wp-admin/post.php:187

Override Palettes

Hey @Log1x would it be possible to expose the Palette $colors via an ACF field setting so we can override them for specific fields?

We have a few elements on a new build where a custom palette is used for Taxonomy/Term accent colors but we don't want to add to the theme color palette that's used everywhere else.

I've been able to append colour using a hacky workaround add_theme_support('editor-color-palette', $tinted_palette); + check if on the correct admin URL, but would be great if we could do something like:

$tinted_palette = [
    [
        'name' => 'Magenta',
        'slug' => 'magenta',
        'color' => '#ff00ff',
    ], 
    ...
];

$terms_options->addField('term_accent_color', 'editor_palette', [
  'colors' => $tinted_palette,
]);

Fatal Error: Class "Log1x\AcfEditorPalette\Field" not found

I'm getting a fatal error when installing this (both with composer and as a download):

2022/11/16 15:12:04 [error] 84649#84649: *199 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class "Log1x\AcfEditorPalette\Field" not found in [...]mu-plugins/acf-editor-palette-1.1.6/plugin.php:82

Bedrock/Trellis latest version
Sage10
PHP 8.1
ACF Pro 6.0.3
AcfEditorPalette 1.1.6

Full Trace:

2022/11/16 15:12:04 [error] 84649#84649: *199 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class "Log1x\AcfEditorPalette\Field" not found in /www/mysite/public/releases/20221116150920/web/app/mu-plugins/acf-editor-palette-1.1.6/plugin.php:82
Stack trace:
#0 /www/mysite/public/releases/20221116150920/web/wp/wp-includes/class-wp-hook.php(307): class@anonymous->Log1x\AcfEditorPalette\{closure}(5)
#1 /www/mysite/public/releases/20221116150920/web/wp/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
#2 /www/mysite/public/releases/20221116150920/web/wp/wp-includes/plugin.php(476): WP_Hook->do_action(Array)
#3 /www/mysite/public/releases/20221116150920/web/app/mu-plugins/advanced-custom-fields-pro/acf.php(297): do_action('acf/include_fie...', 5)
#4 /www/mysite/public/releases/20221116150920/web/wp/wp-includes/class-wp-hook.php(307): ACF->init('')
#5 /www/mysite/public/releases/20221116150920/web/wp/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)

Let me know how I can help!

Selection being forgotten

I am getting an issue where, when loading a page to edit that uses this field, the saved result is not being selected. Saving the page then erases the value, as it no longer has a value selected.

I believe it must be caused by the plugin not retrieving the value from the database correctly after its been stored.

Expected Outcome

When refreshing an edit screen with an editor palette on it, the chosen colour remains

Actual Outcome

When refreshing the page, no colour is selected anymore.

Steps to Reproduce

  1. Create a fresh WordPress install
  2. Add ACF Pro, and acf-editor-palette, and activate both plugins
  3. Create a new Field Group in ACF [see image 1].
Title: Test

Field label: palette
Field name: palette
Field type: Editor Palette
Return Format: Color
  1. Publish the field.
  2. Go to the Sample Post (or create a post if it's not there).
  3. Observe the editor palette widget on the post edit screen.
  4. Choose a colour, then click save (or publish).
  5. Observe the post is saved.
  6. Refresh the edit post screen.
  7. Observe the colour is no longer selected. [2]

[1]
image

[2]
image

Logs

I can see the following errors when I activate the Debug Bar plugin too:

file: "wp-content/plugins/acf-editor-palette-1.0.2/src/Field.php"
key: "f27a6d977a01bb7c9d4b91d6992bec8a"
line: 46
message: "Only variables should be passed by reference"
stack: (16) ["Log1x\A\Field->palette()", "Log1x\A\Field->render_field()", "do_action_ref_array('acf/render_field/type=editor_palette')", "_acf_apply_hook_variations()", "do_action('acf/render_field')", "acf_render_field()", "acf_render_field_wrap()", "acf_field_repeater->render_field()", "do_action_ref_array('acf/render_field/type=repeater')", "_acf_apply_hook_variations()", "do_action('acf/render_field')", "acf_render_field()", "acf_render_field_wrap()", "acf_render_fields()", "acf_ajax_fetch_block()", "do_action('wp_ajax_acf/ajax/fetch-block')"]
type: "notice"
file: "wp-includes/general-template.php"
key: "56cf8a85df762dcf16e266ed5153c259"
line: 4837
message: "Array to string conversion"
stack: (17) ["__checked_selected_helper()", "checked()", "Log1x\A\Field->render_field()", "do_action_ref_array('acf/render_field/type=editor_palette')", "_acf_apply_hook_variations()", "do_action('acf/render_field')", "acf_render_field()", "acf_render_field_wrap()", "acf_field_repeater->render_field()", "do_action_ref_array('acf/render_field/type=repeater')", "_acf_apply_hook_variations()", "do_action('acf/render_field')", "acf_render_field()", "acf_render_field_wrap()", "acf_render_fields()", "acf_ajax_fetch_block()", "do_action('wp_ajax_acf/ajax/fetch-block')"]
type: "notice"

Default color doesn't use the selected Return Format

Hi

Great plugin, thanks!

I have found an issue when using Default color with color, text class or background class Return Format.

Default color pre-selects the color in the color palette, but uses the color slug regardless of the selected Return Format. So where a default color is being used for text / background classes, it doesn't display this color in the Block editor preview.

On saving, the correct format is used in the front-end, but still not in the editor.

Only refreshing the page after saving, selecting another option then reselecting the default color or making a selection in another color palette in the same block returns the color in the selected format in the editor.

Add support for editor_palette to WP Graphql schemas

Thanks for this amazing plugin (and all the other ones you make, you're a real lifesaver!)

I use the roots stack along with acf-composer to build headless WP backends, and as useful as this plugin is, it doesn't natively resolve into Graphql fields.

I am presently adding a resolver myself in my themes (usually to setup.php) but am thinking you might want to include this as part of the plugin?


/**
 * Add "editor_palette' to the graphql schema.
 *
 * @return void
 */

 add_action( 'wpgraphql/acf/registry_init', function() {
    register_graphql_acf_field_type( 'editor_palette', [
      'graphql_type' => 'string',
      'resolve' => function ($root, $args, $context, $info, $field_type, $field_config ) {
        $value = $field_config->resolve_field($root, $args, $context, $info);
  
        if (is_null($value)) {
          return null;
        }

        return $value['slug'];
      },
    ]);
  });
  

you can see the WP Graphql developer reference for adding support for 3rd party ACf field types here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.