mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Block Editor: Expose value of user_can_richedit()
.
In order for the Block Editor to know whether to allow visual editing, it needs to know the value of `user_can_richedit()`. Props youknowriad, danielbachhuber. Merges [43916] into trunk. Fixes #45375. Built from https://develop.svn.wordpress.org/trunk@44267 git-svn-id: http://core.svn.wordpress.org/trunk@44097 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9510a4f036
commit
e06611512c
@ -283,6 +283,7 @@ $editor_settings = array(
|
||||
'allowedMimeTypes' => get_allowed_mime_types(),
|
||||
'styles' => $styles,
|
||||
'imageSizes' => $available_image_sizes,
|
||||
'richEditingEnabled' => user_can_richedit(),
|
||||
'postLock' => $lock_details,
|
||||
'postLockUtils' => array(
|
||||
'nonce' => wp_create_nonce( 'lock-post_' . $post->ID ),
|
||||
|
@ -269,13 +269,11 @@ class WP_Block_Parser {
|
||||
*/
|
||||
if ( 0 === $stack_depth ) {
|
||||
if ( isset( $leading_html_start ) ) {
|
||||
$this->output[] = (array) self::freeform(
|
||||
substr(
|
||||
$this->output[] = (array) self::freeform( substr(
|
||||
$this->document,
|
||||
$leading_html_start,
|
||||
$start_offset - $leading_html_start
|
||||
)
|
||||
);
|
||||
) );
|
||||
}
|
||||
|
||||
$this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() );
|
||||
@ -294,16 +292,13 @@ class WP_Block_Parser {
|
||||
|
||||
case 'block-opener':
|
||||
// track all newly-opened blocks on the stack
|
||||
array_push(
|
||||
$this->stack,
|
||||
new WP_Block_Parser_Frame(
|
||||
array_push( $this->stack, new WP_Block_Parser_Frame(
|
||||
new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ),
|
||||
$start_offset,
|
||||
$token_length,
|
||||
$start_offset + $token_length,
|
||||
$leading_html_start
|
||||
)
|
||||
);
|
||||
) );
|
||||
$this->offset = $start_offset + $token_length;
|
||||
return true;
|
||||
|
||||
@ -390,22 +385,22 @@ class WP_Block_Parser {
|
||||
return array( 'no-more-tokens', null, null, null, null );
|
||||
}
|
||||
|
||||
list( $match, $started_at ) = $matches[0];
|
||||
list( $match, $started_at ) = $matches[ 0 ];
|
||||
|
||||
$length = strlen( $match );
|
||||
$is_closer = isset( $matches['closer'] ) && -1 !== $matches['closer'][1];
|
||||
$is_void = isset( $matches['void'] ) && -1 !== $matches['void'][1];
|
||||
$namespace = $matches['namespace'];
|
||||
$namespace = ( isset( $namespace ) && -1 !== $namespace[1] ) ? $namespace[0] : 'core/';
|
||||
$name = $namespace . $matches['name'][0];
|
||||
$has_attrs = isset( $matches['attrs'] ) && -1 !== $matches['attrs'][1];
|
||||
$is_closer = isset( $matches[ 'closer' ] ) && -1 !== $matches[ 'closer' ][ 1 ];
|
||||
$is_void = isset( $matches[ 'void' ] ) && -1 !== $matches[ 'void' ][ 1 ];
|
||||
$namespace = $matches[ 'namespace' ];
|
||||
$namespace = ( isset( $namespace ) && -1 !== $namespace[ 1 ] ) ? $namespace[ 0 ] : 'core/';
|
||||
$name = $namespace . $matches[ 'name' ][ 0 ];
|
||||
$has_attrs = isset( $matches[ 'attrs' ] ) && -1 !== $matches[ 'attrs' ][ 1 ];
|
||||
|
||||
/*
|
||||
* Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays
|
||||
* are associative arrays. If we use `array()` we get a JSON `[]`
|
||||
*/
|
||||
$attrs = $has_attrs
|
||||
? json_decode( $matches['attrs'][0], /* as-associative */ true )
|
||||
? json_decode( $matches[ 'attrs' ][ 0 ], /* as-associative */ true )
|
||||
: $this->empty_attrs;
|
||||
|
||||
/*
|
||||
@ -504,13 +499,11 @@ class WP_Block_Parser {
|
||||
}
|
||||
|
||||
if ( isset( $stack_top->leading_html_start ) ) {
|
||||
$this->output[] = (array) self::freeform(
|
||||
substr(
|
||||
$this->output[] = (array) self::freeform( substr(
|
||||
$this->document,
|
||||
$stack_top->leading_html_start,
|
||||
$stack_top->token_start - $stack_top->leading_html_start
|
||||
)
|
||||
);
|
||||
) );
|
||||
}
|
||||
|
||||
$this->output[] = (array) $stack_top->block;
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.1-alpha-44266';
|
||||
$wp_version = '5.1-alpha-44267';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user