Changeset 59418
- Timestamp:
- 11/19/2024 04:42:17 AM (2 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r59359 r59418 2723 2723 $node_path = array( 'styles', 'blocks', $name ); 2724 2724 if ( $include_node_paths_only ) { 2725 $nodes[] = array( 2725 $variation_paths = array(); 2726 if ( $include_variations && isset( $node['variations'] ) ) { 2727 foreach ( $node['variations'] as $variation => $variation_node ) { 2728 $variation_paths[] = array( 2729 'path' => array( 'styles', 'blocks', $name, 'variations', $variation ), 2730 ); 2731 } 2732 } 2733 $node = array( 2726 2734 'path' => $node_path, 2727 2735 ); 2736 if ( ! empty( $variation_paths ) ) { 2737 $node['variations'] = $variation_paths; 2738 } 2739 $nodes[] = $node; 2728 2740 } else { 2729 2741 $selector = null; -
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r59335 r59418 2497 2497 array( 2498 2498 'path' => array( 'styles', 'blocks', 'core/group', 'elements', 'link' ), 2499 ), 2500 ); 2501 2502 $this->assertEquals( $expected, $block_nodes ); 2503 } 2504 2505 /** 2506 * This test covers `get_block_nodes` with the `$include_node_paths_only` 2507 * and `include_block_style_variations` options. 2508 * 2509 * @ticket 62399 2510 */ 2511 public function test_return_block_node_paths_with_variations() { 2512 $theme_json = new ReflectionClass( 'WP_Theme_JSON' ); 2513 2514 $func = $theme_json->getMethod( 'get_block_nodes' ); 2515 $func->setAccessible( true ); 2516 2517 $theme_json = array( 2518 'version' => WP_Theme_JSON::LATEST_SCHEMA, 2519 'styles' => array( 2520 'typography' => array( 2521 'fontSize' => '16px', 2522 ), 2523 'blocks' => array( 2524 'core/button' => array( 2525 'color' => array( 2526 'background' => 'red', 2527 ), 2528 'variations' => array( 2529 'cheese' => array( 2530 'color' => array( 2531 'background' => 'cheese', 2532 ), 2533 ), 2534 ), 2535 ), 2536 'core/group' => array( 2537 'color' => array( 2538 'background' => 'blue', 2539 ), 2540 'variations' => array( 2541 'apricot' => array( 2542 'color' => array( 2543 'background' => 'apricot', 2544 ), 2545 ), 2546 ), 2547 ), 2548 ), 2549 ), 2550 ); 2551 2552 $block_nodes = $func->invoke( 2553 null, 2554 $theme_json, 2555 array(), 2556 array( 2557 'include_node_paths_only' => true, 2558 'include_block_style_variations' => true, 2559 ) 2560 ); 2561 2562 $expected = array( 2563 array( 2564 'path' => array( 'styles', 'blocks', 'core/button' ), 2565 'variations' => array( 2566 array( 2567 'path' => array( 'styles', 'blocks', 'core/button', 'variations', 'cheese' ), 2568 ), 2569 ), 2570 ), 2571 array( 2572 'path' => array( 'styles', 'blocks', 'core/group' ), 2573 'variations' => array( 2574 array( 2575 'path' => array( 'styles', 'blocks', 'core/group', 'variations', 'apricot' ), 2576 ), 2577 ), 2499 2578 ), 2500 2579 );
Note: See TracChangeset
for help on using the changeset viewer.