Changeset 44264 for trunk/src/wp-includes/class-wp-block-parser.php
- Timestamp:
- 12/17/2018 04:35:32 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43913,43921-43922,43937-43938,43946-43947,43952-43953,43967-43969
- Property svn:mergeinfo changed
-
trunk/src/wp-includes/class-wp-block-parser.php
r44261 r44264 64 64 65 65 function __construct( $name, $attrs, $innerBlocks, $innerHTML, $innerContent ) { 66 $this->blockName 67 $this->attrs 68 $this->innerBlocks 69 $this->innerHTML 66 $this->blockName = $name; 67 $this->attrs = $attrs; 68 $this->innerBlocks = $innerBlocks; 69 $this->innerHTML = $innerHTML; 70 70 $this->innerContent = $innerContent; 71 71 } … … 270 270 if ( 0 === $stack_depth ) { 271 271 if ( isset( $leading_html_start ) ) { 272 $this->output[] = (array) self::freeform( 273 substr( 274 $this->document, 275 $leading_html_start, 276 $start_offset - $leading_html_start 277 ) 278 ); 272 $this->output[] = (array) self::freeform( substr( 273 $this->document, 274 $leading_html_start, 275 $start_offset - $leading_html_start 276 ) ); 279 277 } 280 278 281 279 $this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ); 282 $this->offset 280 $this->offset = $start_offset + $token_length; 283 281 return true; 284 282 } … … 295 293 case 'block-opener': 296 294 // track all newly-opened blocks on the stack 297 array_push( 298 $this->stack, 299 new WP_Block_Parser_Frame( 300 new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ), 301 $start_offset, 302 $token_length, 303 $start_offset + $token_length, 304 $leading_html_start 305 ) 306 ); 295 array_push( $this->stack, new WP_Block_Parser_Frame( 296 new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ), 297 $start_offset, 298 $token_length, 299 $start_offset + $token_length, 300 $leading_html_start 301 ) ); 307 302 $this->offset = $start_offset + $token_length; 308 303 return true; … … 335 330 * block and add it as a new innerBlock to the parent 336 331 */ 337 $stack_top 338 $html 339 $stack_top->block->innerHTML 332 $stack_top = array_pop( $this->stack ); 333 $html = substr( $this->document, $stack_top->prev_offset, $start_offset - $stack_top->prev_offset ); 334 $stack_top->block->innerHTML .= $html; 340 335 $stack_top->block->innerContent[] = $html; 341 $stack_top->prev_offset 336 $stack_top->prev_offset = $start_offset + $token_length; 342 337 343 338 $this->add_inner_block( … … 391 386 } 392 387 393 list( $match, $started_at ) = $matches[ 0];388 list( $match, $started_at ) = $matches[ 0 ]; 394 389 395 390 $length = strlen( $match ); 396 $is_closer = isset( $matches[ 'closer'] ) && -1 !== $matches['closer'][1];397 $is_void = isset( $matches[ 'void'] ) && -1 !== $matches['void'][1];398 $namespace = $matches[ 'namespace'];399 $namespace = ( isset( $namespace ) && -1 !== $namespace[ 1] ) ? $namespace[0] : 'core/';400 $name = $namespace . $matches[ 'name'][0];401 $has_attrs = isset( $matches[ 'attrs'] ) && -1 !== $matches['attrs'][1];391 $is_closer = isset( $matches[ 'closer' ] ) && -1 !== $matches[ 'closer' ][ 1 ]; 392 $is_void = isset( $matches[ 'void' ] ) && -1 !== $matches[ 'void' ][ 1 ]; 393 $namespace = $matches[ 'namespace' ]; 394 $namespace = ( isset( $namespace ) && -1 !== $namespace[ 1 ] ) ? $namespace[ 0 ] : 'core/'; 395 $name = $namespace . $matches[ 'name' ][ 0 ]; 396 $has_attrs = isset( $matches[ 'attrs' ] ) && -1 !== $matches[ 'attrs' ][ 1 ]; 402 397 403 398 /* … … 406 401 */ 407 402 $attrs = $has_attrs 408 ? json_decode( $matches[ 'attrs'][0], /* as-associative */ true )403 ? json_decode( $matches[ 'attrs' ][ 0 ], /* as-associative */ true ) 409 404 : $this->empty_attrs; 410 405 … … 471 466 */ 472 467 function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) { 473 $parent 468 $parent = $this->stack[ count( $this->stack ) - 1 ]; 474 469 $parent->block->innerBlocks[] = (array) $block; 475 $html 470 $html = substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset ); 476 471 477 472 if ( ! empty( $html ) ) { 478 $parent->block->innerHTML 473 $parent->block->innerHTML .= $html; 479 474 $parent->block->innerContent[] = $html; 480 475 } 481 476 482 477 $parent->block->innerContent[] = null; 483 $parent->prev_offset 478 $parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length; 484 479 } 485 480 … … 500 495 501 496 if ( ! empty( $html ) ) { 502 $stack_top->block->innerHTML 497 $stack_top->block->innerHTML .= $html; 503 498 $stack_top->block->innerContent[] = $html; 504 499 } 505 500 506 501 if ( isset( $stack_top->leading_html_start ) ) { 507 $this->output[] = (array) self::freeform( 508 substr( 509 $this->document, 510 $stack_top->leading_html_start, 511 $stack_top->token_start - $stack_top->leading_html_start 512 ) 513 ); 502 $this->output[] = (array) self::freeform( substr( 503 $this->document, 504 $stack_top->leading_html_start, 505 $stack_top->token_start - $stack_top->leading_html_start 506 ) ); 514 507 } 515 508
Note: See TracChangeset
for help on using the changeset viewer.