Adding a custom PanelColorSettings control to a core block, and using the color slug in a custom className

Your code looks ok and would work in any other component other than colors, because colors need the higher-order-component withColors. In the past I struggled also dealing with the behaviour, that your are describing and found these two solutions: If you want to insert your own color component, check the second example from here https://awhitepixel.com/blog/add-custom-settings-to-existing-wordpress-gutenberg-blocks/. … Read more

Gutenberg blocks – processing server data within a block

There are multiple better ways to get a list of posts in a Gutenberg block, other than rendering serverside. First is to use the Wrodpress wrapper around Redux and select posts exactly like in the Gutenberg Handbook: edit: withSelect( function( select ) { return { posts: select( ‘core’ ).getEntityRecords( ‘postType’, ‘post’ ) }; } )( … Read more

add_meta_boxes action with refresh on save

So I managed to cobble something together with a bit of javascript… It’s hacky but somewhat elegant I think. add_action(‘admin_init’, function () { if ( current_user_can(“send_notifications”) ) { $post_types = [“post”, “go_live”]; foreach ($post_types as $post_type) { add_meta_box( ‘cabtv_notif_on_post’, ‘Notifications’, function ($post) { wp_nonce_field( ‘cabtv_notif_metabox’, ‘cabtv_notif_metabox’ ); $sent = (bool) get_post_meta( $post->ID, ‘cabtv_notifications_sent’, true ); … Read more

Gutenberg Custom Block

to 1. You closed registerBlockType too early and to avoid further react errors, you should print your return in the same line as return in your edit/save functions. var el = wp.element.createElement; wp.blocks.registerBlockType(‘test/blocks’, { title: ‘Test Blocks’, icon: ‘smiley’, category: ‘common’, attributes: { content: {type: ‘string’} }, edit: function(props) { return el( ‘div’, {}, el( … Read more