Gutenberg block JavaScript localisation on Polyglots does not work

The first argument $handle of wp_set_script_translations() expects the script handle the text domain will be attached to. In your case it’s simpletoc and not simpletoc-js. The correct call would be: wp_set_script_translations( ‘simpletoc’, ‘simpletoc’ ); Another note: wp_set_script_translations() is available since WordPress 5.0 thus the function_exists() check isn’t necessary.

Block Validation Fails: ‘

I solved the problem by rendering my block’s content, a component, to a string and making that string the value of a RichText component in my block’s save function. To make my component a string, I used renderToString: // Create the content and the block const myContent = ( <MyComponent>{“Some content”}</MyComponent> ); const myBlock = … Read more

How to troubleshoot a custom Gutenberg block error: “This block has encountered an error and cannot be previewed”

Add this additional variable to your wp-config file: define ( ‘SCRIPT_DEBUG’, true); Also, inline styling directly in react is declared differently is similar but different in many ways than pure, vanilla CSS. For example, <ul class=”home-slider content-slider lightSlider lSFade” style=”height: 0px; padding-bottom: 71.9931%;”> is written in react as: <ul className={ ‘home-slider content-slider lightSlider lSFade’} style={{ … Read more

How to avoid duplicate dependencies in Gutenberg blocks

WordPress Dependency extraction plugin @wordpress/dependency-extraction-webpack-plugin basically makes your ES6 dependency imports use WordPress scripts instead of adding them to the bundle over and over. This makes modules registered and enqueued in WordPress (including but not limited to jquery, moment and react and wp.* modules) to be properly excluded from builds. You can add additional dependencies … Read more

How to change the Default block in the block-editor away from the paragraph block?

You can use the Gutenberg Block Template it is used to have a content placeholder for your Gutenberg content. https://developer.wordpress.org/block-editor/developers/block-api/block-templates/ <?php function myplugin_register_template() { $post_type_object = get_post_type_object( ‘post’ ); $post_type_object->template = array( array( ‘core/image’ ), ); } add_action( ‘init’, ‘myplugin_register_template’ );

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