Support » Plugin: Central Color Palette » Append and Enforce not doing anything

  • Resolved douglasuk

    (@douglasuk)


    This is just what I have been looking for, for several weeks. It hasn’t come up on any of the searches I’ve been doing on plugins: I stumbled over it when I started to look into what it would take to program it.

    As a fairly new WordPress user, I use the block editor (didn’t know any better at first and now I may as well stick with them). My main requirement has, therefore, been to have theme colours available in the Gutenberg color picker. (Yes, I’m a Brit, so ‘color’ has a ‘u’ in it for me: it’s how we pronounce the word, too. Thank you for the en-GB translation!)

    With Central Colour Palette I can get my theme’s colours to appear and make it easy for my authors to use the right colours, at last. However, the two options under “Add to block editor” option on the settings page don’t seem to be effective.

    I’d like to show my theme colours as well as the original ones but only my theme colours show up. I thought that “Append to existing palette” option would do that but it makes no difference: I can’t see what it is supposed to do.

    Likewise, but less urgent for me, the “Enforce colours” option does nothing. I guess it is meant to remove the Custom Colour link? It doesn’t.

    WordPress info:
    – Version: 5.3.2
    – PHP version: 7.3.13
    – Multisite?: no

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Daniel Menȝies

    (@kungtiger)

    Thanks for the feedback. I’m glad it’s of use to you.

    For clarification: Append to existing palette does what it says, only if your current theme registered colours for the new block editor via add_theme_support("editor-color-palette", ...) (ref Block Editor Handbook – Block Color Palettes). If that’s the case my plugin can append to them.

    Now there’s a catch: WordPress offers some default colours and those aren’t provided by a theme and can not be retrieve and added to. They simply disappear when you set a palette via add_theme_support or appear when you haven’t.

    To be fair, that label should really say Append to existing theme palette if the current theme actually got one. Something for future-me to fix.

    Re Enforce colours: There’s a long winded reason for that option. The gist is that there can be an edge case in which the colours of my plugin would be rendered useless or at least partially useless. This has something to do with CSS’s Specificity and the way the new block editor assigns colors (Block Editor Handbook – Block Color Palettes: on a CSS class basis, see last part of that section).

    Let’s say a theme’s template uses a <div id="main-header"> HTML on each page and assigns some CSS #main-header { color: red; } to it, and let’s also say you’ve added a colour via my plugin, #000099 a dark blue, and somehow used it on that header. Internally my plugin would generate some CSS on every page: .has-central-palette-1-color { color: #000099; }. Now, #main-header takes precedence over .has-central-palette-1-color and no matter what colour you’d selected it would stay red.

    In order to avoid such a mess (which is actually due to an ill designed theme) my plugin offers that Enforce colours option which adds an !important to every colour inside its generated CSS on every page.

    In short: if all your colours show up in every place you’ve used it on your front page, just don’t check Enforce colours.

    douglasuk

    (@douglasuk)

    Thank you very much for your comprehensive reply.

    My theme doesn’t offer a colour pallete, at least not in the free version.

    I have just extracted the WordPress default colours (disabled the plugin and peeked at the code on the editor) and converted them into hex values. I can now add whichever ones I want as part of my personalised colouring via your plugin.

    Should you be interested (or even want to offer them as an option) the values are:

    Pale pink = rgb(247, 141, 167) #F78DA7
    Vivid red = rgb(207, 46, 46) #CF2E2E
    Luminous vivid orange = rgb(255, 105, 0) #FF6900
    Luminous vivid amber = rgb(252, 185, 0) #FCB900
    Light green cyan = rgb(123, 220, 181) #7BDCB5
    Vivid green cyan = rgb(0, 208, 132) #00D084
    Pale cyan blue = rgb(142, 209, 252) #8ED1FC
    Vivid cyan blue = rgb(6, 147, 227) #0693E3
    Vivid purple = rgb(155, 81, 224) #9B51E0
    Very light grey = rgb(238, 238, 238) #EEEEEE
    Cyan bluish grey = rgb(171, 184, 195) #ABB8C3
    Very dark grey = rgb(49, 49, 49) #313131

    To be fair, that label should really say Append to existing theme palette if the current theme actually got one. Something for future-me to fix.

    If I may suggest, the simpler label is fine but perhaps add a query-mark helper with pop-up text to give the fuller explanation. The same with Enforce colours.

    Thank you for your help and for the plugin. Given that I’m somewhat colour-blind, it helps to have the predefined colours available, rather than make even more of a mess of my site!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.