Conditional save return on Gutenberg Block

You should define your btntype attribute as type boolean and set its default to false (maybe better rename it to download then ;). And change it to true when the user selects the download option. If you want to conditionally add the download attribute in your save functions’ JSX use this syntax: <a href={ btnurl … Read more

UnitControl – Block has encountered an error

The problem in your code is that UnitControl is not actually defined anywhere: If you look at the example in the documentation, the UnitControl is defined as follows: import { __experimentalUnitControl as UnitControl } from ‘@wordpress/components’; I.e. It uses the __experimentalUnitControl component in wp.components and not wp.blockEditor, and secondly, it imports the component as UnitControl. … Read more

Gutenberg richtext block vaildation failed

The problem in your block is due to the selector value of your emailPlaceholder attribute — you set the value to span.kathyContactFormEmail, but there’s actually no span element with that class in your save() function (or the markup/HTML of the element returned by the function). What you have though, is an input with kathyContactFormEmail as … Read more

Adding inline JavaScript after wp_enqueue_scripts

i don’t know with version you use, but if you wan’t load stuff on the initialisation of js you can have it on file using js : ( function( wp ) { your stuff } )( window.wp ); if you really want inline use in php ; https://developer.wordpress.org/reference/functions/wp_add_inline_script/ wp_add_inline_script( ‘name_of_the_script_Woocommerce’, <script> your thing</script>, ‘after_or_before’ );