How to add custom table style for table block in gutenberg editor

The register_block_style function is what you’ll want. The basic implementation is register_block_style( ‘core/table’, array( ‘name’ => ‘my-table-style’, ‘label’ => ‘My Table Style’, ) ); When you select the style, it will add the is-style-my-table-style class to the block, which you can style using your style.css or other stylesheet. There are two other implementations, where you … Read more

Set default value for “Additional CSS class(es)” for specific block types

A simple solution would be to register custom block style variations for the core/columns block and let the user select your custom padding settings from these, instead of editing class names in the extra classes field (which isn’t too comfortable from a user’s perspective). Gutenberg automatically outputs class names in the form is-style-(name of block … Read more

useSelect second parameter

Short Answer The second parameter for useSelect is the second parameter for useCallback, so check the React website and you’d understand what the heck that second parameter is.. 🙂 Long Answer useSelect is a custom React hook which uses the core useCallback hook in React which returns a memoized callback which can avoid expensive calculations … Read more

How to get the Gallery form/section just like in Gutenberg block?

wp.media is the JavaScript API WordPress uses to display the media library modal. You can use it yourself by enqueueing a custom JS script on your admin page: wp_enqueue_script(‘media-upload’); wp_enqueue_media(); wp_enqueue_script( ‘pb-admin-script’, ‘admin.js’, array( ‘jquery’, ) ); Then work with it like this: HTML: <button class=”upload_image_button button button-primary”> <?php _e(‘Upload Image’, ‘pb’); ?> </button> <img … Read more