Pass PHP vars to gutenberg sidebar
Pass PHP vars to gutenberg sidebar
Pass PHP vars to gutenberg sidebar
I managed to get it to work, here is the correct code: JS file const { __ } = wp.i18n; const { registerBlockType } = wp.blocks; const { InspectorControls} = wp.blockEditor; const { PanelBody,ToggleControl } = wp.components; const BlockEdit = (props) => { const { attributes, setAttributes } = props; const { haveRead } = … Read more
WordPress filter post content with PHP before editing it in Gutenberg
I know it’s been awhile, but yes. You can check if a post uses blocks, check out has_blocks() : https://developer.wordpress.org/reference/functions/has_blocks/ I’m using it when filtering content, to see if I need to parse blocks or not.
How to get current post id in Gutenberg Block save function?
Gutenberg block missing classes inside editor
How to identify what templates are being loaded in a block-based theme [closed]
How to add extra option to WP core gallery block?
I solve this problem by myself. The detail is here. https://github.com/WordPress/gutenberg/issues/28509
You would do this with the format API, for example, this code from the handbook will add a <samp> tag around text: import { registerFormatType, toggleFormat } from ‘@wordpress/rich-text’; import { RichTextToolbarButton } from ‘@wordpress/block-editor’; const MyCustomButton = ( props ) => { return <RichTextToolbarButton icon=’editor-code’ title=”Sample output” onClick={ () => { props.onChange( toggleFormat( props.value, … Read more