Support » Developing with WordPress » Is it possible to add an element to formatting toolbar of a core block usin PHP?

  • What the title says. I followed the Formatting Toolbar API docs to create a dedicated block (in a plugin) that adds a custom class to selected elements in heading and paragraph core blocks toolbar.

    But that’s a “lot of” JSx code and dependencies just to add an element to an existing UI that does something simple (add a class to a specific word or group of words).

    I already know that custom block formats can be added from the functions.php file (or else) of a theme. Is there an equivalent way to do it to add toolbar elements in the dropdown?

    Maybe it’s not documented yet or I missed something.

    Thanks in advance.

    ps: if it’s not technically possible I’d be curious to understand why.

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

Viewing 1 replies (of 1 total)
  • Hi @julianoe,
    As of the last update in January 2022, directly adding elements to the formatting toolbar of a core block in WordPress through PHP is not a standard practice. WordPress primarily relies on JavaScript for such customizations due to the dynamic nature of the block editor. While it might appear complex, using JavaScript ensures a more flexible and interactive user experience. For the latest information, check the WordPress documentation or community discussions for updates on PHP-based toolbar customization.
    Hope this information is helpful.

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