gutenberg attributes

From the docs: If a selector is specified, the source behavior will be run against the corresponding element(s) contained within the block. You are telling your block to look at the same Element for the value of both your attributes.(The first p tag) Change the second selector to something like p:last-of-type or give your p … Read more

Gutenberg Shortcode Fail

The shortcode doesn’t work because it’s wrapped inside quotes — “[current_user]”. But a better explanation is, because it’s in a HTML attribute. And it’s not a Gutenberg or the block editor problem; even with <?php echo do_shortcode( ‘<input name=”name” value=”[current_user]” type=”hidden”>’ ); ?>, the shortcode would still remain as-is. Because shortcodes in HTML attributes are … Read more

Deprecated function not working in Gutenberg

Looking at the documentation from https://developer.wordpress.org/block-editor/developers/block-api/block-deprecation/ I think you may need the following migrate( { text } ) { return { content: text }; }, So in your case: migrate( { avatarSize } ) { avatarSize: { type: ‘number’, default: 70 } content: text }; }, Hopefully points you in the correct direction

How to change Block Controls Icon in Gutenberg?

There is a controls prop you can use which is an object. It goes inside. Controls has an icon key which takes a string which corresponds to a Dashicon slug. <BLockControls controls={[ icon=”wordpress” title=__(“Test”, “gutenberg-examples”), onClick: () => { doSomething }, isActive: false ]} />

Gutenberg Block Style CSS Class Is Not Applying on Backend

Turns out, you need to manually add the wrapper class in the edit function. Here’s the source – https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#classname I changed this line – <section className={`text-section-one`} style={{ backgroundColor: `${bgColor}`}} > to <section className= { `${props.className} text-section-one`} style={{ backgroundColor: `${bgColor}`}} > and it solved problem.