- Timestamp:
- 12/13/2018 05:51:31 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block-parser.php
r44116 r44117 246 246 if ( 0 === $stack_depth ) { 247 247 if ( isset( $leading_html_start ) ) { 248 $this->output[] = (array) self::freeform( substr( 249 $this->document, 250 $leading_html_start, 251 $start_offset - $leading_html_start 252 ) ); 248 $this->output[] = (array) self::freeform( 249 substr( 250 $this->document, 251 $leading_html_start, 252 $start_offset - $leading_html_start 253 ) 254 ); 253 255 } 254 256 255 257 $this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ); 256 $this->offset = $start_offset + $token_length;258 $this->offset = $start_offset + $token_length; 257 259 return true; 258 260 } … … 269 271 case 'block-opener': 270 272 // track all newly-opened blocks on the stack 271 array_push( $this->stack, new WP_Block_Parser_Frame( 272 new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ), 273 $start_offset, 274 $token_length, 275 $start_offset + $token_length, 276 $leading_html_start 277 ) ); 273 array_push( 274 $this->stack, 275 new WP_Block_Parser_Frame( 276 new WP_Block_Parser_Block( $block_name, $attrs, array(), '' ), 277 $start_offset, 278 $token_length, 279 $start_offset + $token_length, 280 $leading_html_start 281 ) 282 ); 278 283 $this->offset = $start_offset + $token_length; 279 284 return true; … … 306 311 * block and add it as a new innerBlock to the parent 307 312 */ 308 $stack_top = array_pop( $this->stack );313 $stack_top = array_pop( $this->stack ); 309 314 $stack_top->block->innerHTML .= substr( $this->document, $stack_top->prev_offset, $start_offset - $stack_top->prev_offset ); 310 $stack_top->prev_offset = $start_offset + $token_length;315 $stack_top->prev_offset = $start_offset + $token_length; 311 316 312 317 $this->add_inner_block( … … 360 365 } 361 366 362 list( $match, $started_at ) = $matches[ 0];367 list( $match, $started_at ) = $matches[0]; 363 368 364 369 $length = strlen( $match ); 365 $is_closer = isset( $matches[ 'closer' ] ) && -1 !== $matches[ 'closer' ][ 1];366 $is_void = isset( $matches[ 'void' ] ) && -1 !== $matches[ 'void' ][ 1];367 $namespace = $matches[ 'namespace'];368 $namespace = ( isset( $namespace ) && -1 !== $namespace[ 1 ] ) ? $namespace[ 0] : 'core/';369 $name = $namespace . $matches[ 'name' ][ 0];370 $has_attrs = isset( $matches[ 'attrs' ] ) && -1 !== $matches[ 'attrs' ][ 1];370 $is_closer = isset( $matches['closer'] ) && -1 !== $matches['closer'][1]; 371 $is_void = isset( $matches['void'] ) && -1 !== $matches['void'][1]; 372 $namespace = $matches['namespace']; 373 $namespace = ( isset( $namespace ) && -1 !== $namespace[1] ) ? $namespace[0] : 'core/'; 374 $name = $namespace . $matches['name'][0]; 375 $has_attrs = isset( $matches['attrs'] ) && -1 !== $matches['attrs'][1]; 371 376 372 377 /* … … 375 380 */ 376 381 $attrs = $has_attrs 377 ? json_decode( $matches[ 'attrs' ][ 0], /* as-associative */ true )382 ? json_decode( $matches['attrs'][0], /* as-associative */ true ) 378 383 : json_decode( '{}', /* don't ask why, just verify in PHP */ false ); 379 384 … … 440 445 */ 441 446 function add_inner_block( WP_Block_Parser_Block $block, $token_start, $token_length, $last_offset = null ) { 442 $parent = $this->stack[ count( $this->stack ) - 1 ];447 $parent = $this->stack[ count( $this->stack ) - 1 ]; 443 448 $parent->block->innerBlocks[] = $block; 444 $parent->block->innerHTML .= substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset );445 $parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length;449 $parent->block->innerHTML .= substr( $this->document, $parent->prev_offset, $token_start - $parent->prev_offset ); 450 $parent->prev_offset = $last_offset ? $last_offset : $token_start + $token_length; 446 451 } 447 452 … … 462 467 463 468 if ( isset( $stack_top->leading_html_start ) ) { 464 $this->output[] = (array) self::freeform( substr( 465 $this->document, 466 $stack_top->leading_html_start, 467 $stack_top->token_start - $stack_top->leading_html_start 468 ) ); 469 $this->output[] = (array) self::freeform( 470 substr( 471 $this->document, 472 $stack_top->leading_html_start, 473 $stack_top->token_start - $stack_top->leading_html_start 474 ) 475 ); 469 476 } 470 477
Note: See TracChangeset
for help on using the changeset viewer.