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

Gutenberg block get categories in SelectControl

The problem is that calling wp.data.select triggers a fetch and the data takes some time to be available. Until that happens the value returned is an empty array. My suggestion here is to use wp.data.useSelect, which is a React hook made specifically for this, so the component re-renders when there is a change in the … Read more

Gutenberg: How to Change Post Status Programmatically?

You need to call savePost after calling editPost. Referring to the source’s way of handling it:https://github.com/WordPress/gutenberg/blob/trunk/packages/editor/src/components/post-visibility/index.js it shows savePost being called right after changing the visibility. In practice: import { PluginPostStatusInfo } from ‘@wordpress/edit-post’; import { __ } from ‘@wordpress/i18n’; import { registerPlugin } from ‘@wordpress/plugins’; import { ToggleControl } from ‘@wordpress/components’; import { useSelect, … Read more

Gutenberg moving core blocks between categories

Although I’m unsure on how to achieve this in php, within javascript you can change the category by hooking into the blocks.registerBlockType hook. Here is a small example how it would work, although I’d recommend using lodash to deepClone the settings object to keep everything immutable. const rearrangeBlockCategories = { ‘core/table’: ‘common’, }; wp.hooks.addFilter(‘blocks.registerBlockType’, ‘[namespace]’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)