$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>user roles - Custom Gutenberg Block and unfiltered_html capability|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

user roles - Custom Gutenberg Block and unfiltered_html capability

matteradmin9PV0评论

This is more a "am I understanding this right" kind of question:

When I create a custum Gutenberg Block that should be used by an user of role Editor(which has no unfiltered_html capability on a multisite), I am limited to whatever html wordpress allows this user to post.

Example:

My save function has jsx like this:

<p style={myStyles}>{props.attributes.text}</p>

which gets rendered to

<p style="opacity:0.5">Hello World</p>

This would get filtered out and the block would not work.

Additionally, this Block would work for a Super-Admin and when he creates a post using this block and an Editor comes in later to adapt it, it would break the block, because it expects the mark-up that was filtered out.

Is this the expected behaviour?

This is more a "am I understanding this right" kind of question:

When I create a custum Gutenberg Block that should be used by an user of role Editor(which has no unfiltered_html capability on a multisite), I am limited to whatever html wordpress allows this user to post.

Example:

My save function has jsx like this:

<p style={myStyles}>{props.attributes.text}</p>

which gets rendered to

<p style="opacity:0.5">Hello World</p>

This would get filtered out and the block would not work.

Additionally, this Block would work for a Super-Admin and when he creates a post using this block and an Editor comes in later to adapt it, it would break the block, because it expects the mark-up that was filtered out.

Is this the expected behaviour?

Share Improve this question edited Feb 7, 2019 at 13:38 mtthias asked Feb 7, 2019 at 11:12 mtthiasmtthias 1862 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The recommended way of using RichText Component inside save function is -

     <RichText.Content
            tagName="p"
            style={ styles }
            className={ className ? className : undefined }
            value={ content }
            dir={ direction }
        />

See, how this core paragraph block is doing it. Instead of using normal HTML use RichText Content on text fields

Post a comment

comment list (0)

  1. No comments so far