How to add template colors to custom block options in WordPress Gutenberg editor sidebar?

How can I add template colors (i.e., those black and pastel shades) to ColorPalette (“Input border color”)? In Gutenberg, you can get the block color palette in two ways: Use getSettings() in the block editor’s data (core/block-editor). E.g. import { select } from ‘@wordpress/data’; const colorPalette = select( ‘core/block-editor’ ).getSettings().colors; // PS: You can also … Read more

Multiple requests external data api dynamic block gutenberg

You could use transients: function requestApi() { $cache_key = ‘your_transient_name’; $values = get_transient( $cache_key ); // if no data in the cache if ( $values === false ) { // build the URL for wp_remote_get() function $arguments = [ ‘method’ => ‘GET’, ]; $request = wp_remote_get( ‘https://example.com.br/api/endpoint/product-id’, $arguments ); if ( !is_wp_error( $request ) && … Read more

Function not working inside of a function in functions.php

Remove the function inside the function, and instead call the wp_register_script and register_block_type inside the large function. Finally, remove the inner add_action() call, so you only have the ending one for the large function. function irm_lockdown_author_role() { if (isset($userrole->roles[0])) { $current_role = $userrole->roles[0]; } else { $current_role=”no_role”; } if (‘author’ == $current_role) { /* function … Read more

How to lock innerBlocks within a block variation?

I think I’ve figured this out. Instead of creating a block variation, I just created a brand new block using a block template. import { registerBlockType } from “@wordpress/blocks”; import { useBlockProps, InnerBlocks } from “@wordpress/block-editor”; const BLOCKS_TEMPLATE = [ [“core/heading”, { level: 2, placeholder: “Heading” }], [“core/gallery”, {}], ]; registerBlockType(“logo-grid”, { apiVersion: 2, title: … Read more

Can you make a custom gutenberg block that allows the gutenberg editor within it?

Shucks, no sooner than the second I desperately resort to asking here, I run into the answer. So for anyone else who just wants a straight answer and not some 45 minute video that never gets to the point… acf_register_block_type( array( ‘title’ => __( ‘Wrapper’, ‘client_textdomain’ ), ‘name’ => ‘wrapper’, ‘render_template’ => ‘partials/blocks/wrapper.php’, ‘mode’ => … Read more