How To Apply Different Styles To All Blocks Based on Post Meta Value?

I was able to solve this problem by using the admin_body_class filter to add a class name to the <body> element of the admin page, and writing selectors for that class in my stylesheet. add_filter( ‘admin_body_class’, ‘add_status_classes’ ); function add_status_classes( $classes ) { $post_meta = get_post_meta( get_the_ID() ); $is_darkmode = $post_meta[‘_is_post_dark_mode’]; if ( $is_darkmode ) … Read more

Use of CSS classes in editor-blocks.css file

Searching the editor source code: https://github.com/WordPress/gutenberg does not show much results. I suggest search the theme source code these classes to see where they are applied. (If you press . while viewing the code on github you will get a VSCode editor) register_block_type is used to add the block date in WordPress. Typically with these … Read more

Gutenberg Block empty after reload of editor

I was able to make your block save and load on refresh by changing the edit to so: edit: function(props) { return [ el( ‘div’, { className : props.className }, el( ‘div’, null, el( RichText, { multiline: null, formattingControls: [‘link’], onChange: function (element) { props.setAttributes({link: element}); }, tagName: ‘div’, value: props.attributes.link, } ) ) ) … Read more