Changeset 51386
- Timestamp:
- 07/09/2021 01:05:05 AM (3 years ago)
- Location:
- branches/5.8
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.8
-
branches/5.8/src/wp-includes/class-wp-theme-json.php
r51364 r51386 1107 1107 foreach ( $to_replace as $property_path ) { 1108 1108 $path = array_merge( $metadata['path'], $property_path ); 1109 $node = _wp_array_get( $incoming_data, $path, array());1110 if ( ! empty( $node ) ) {1109 $node = _wp_array_get( $incoming_data, $path, null ); 1110 if ( isset( $node ) ) { 1111 1111 _wp_array_set( $this->theme_json, $path, $node ); 1112 1112 } -
branches/5.8/tests/phpunit/tests/theme/wpThemeJson.php
r51312 r51386 669 669 670 670 /** 671 * @ticket 53175 672 */ 673 public function test_merge_incoming_data_empty_presets() { 674 $theme_json = new WP_Theme_JSON( 675 array( 676 'version' => WP_Theme_JSON::LATEST_SCHEMA, 677 'settings' => array( 678 'color' => array( 679 'duotone' => array( 680 array( 681 'slug' => 'value', 682 'colors' => array( 'red', 'green' ), 683 ), 684 ), 685 'gradients' => array( 686 array( 687 'slug' => 'gradient', 688 'gradient' => 'gradient', 689 ), 690 ), 691 'palette' => array( 692 array( 693 'slug' => 'red', 694 'color' => 'red', 695 ), 696 ), 697 ), 698 'spacing' => array( 699 'units' => array( 'px', 'em' ), 700 ), 701 'typography' => array( 702 'fontSizes' => array( 703 array( 704 'slug' => 'size', 705 'value' => 'size', 706 ), 707 ), 708 ), 709 ), 710 ) 711 ); 712 713 $theme_json->merge( 714 new WP_Theme_JSON( 715 array( 716 'version' => WP_Theme_JSON::LATEST_SCHEMA, 717 'settings' => array( 718 'color' => array( 719 'duotone' => array(), 720 'gradients' => array(), 721 'palette' => array(), 722 ), 723 'spacing' => array( 724 'units' => array(), 725 ), 726 'typography' => array( 727 'fontSizes' => array(), 728 ), 729 ), 730 ) 731 ) 732 ); 733 734 $actual = $theme_json->get_raw_data(); 735 $expected = array( 736 'version' => WP_Theme_JSON::LATEST_SCHEMA, 737 'settings' => array( 738 'color' => array( 739 'duotone' => array(), 740 'gradients' => array( 741 'theme' => array(), 742 ), 743 'palette' => array( 744 'theme' => array(), 745 ), 746 ), 747 'spacing' => array( 748 'units' => array(), 749 ), 750 'typography' => array( 751 'fontSizes' => array( 752 'theme' => array(), 753 ), 754 ), 755 ), 756 ); 757 758 $this->assertEqualSetsWithIndex( $expected, $actual ); 759 } 760 761 /** 762 * @ticket 53175 763 */ 764 public function test_merge_incoming_data_null_presets() { 765 $theme_json = new WP_Theme_JSON( 766 array( 767 'version' => WP_Theme_JSON::LATEST_SCHEMA, 768 'settings' => array( 769 'color' => array( 770 'duotone' => array( 771 array( 772 'slug' => 'value', 773 'colors' => array( 'red', 'green' ), 774 ), 775 ), 776 'gradients' => array( 777 array( 778 'slug' => 'gradient', 779 'gradient' => 'gradient', 780 ), 781 ), 782 'palette' => array( 783 array( 784 'slug' => 'red', 785 'color' => 'red', 786 ), 787 ), 788 ), 789 'spacing' => array( 790 'units' => array( 'px', 'em' ), 791 ), 792 'typography' => array( 793 'fontSizes' => array( 794 array( 795 'slug' => 'size', 796 'value' => 'size', 797 ), 798 ), 799 ), 800 ), 801 ) 802 ); 803 804 $theme_json->merge( 805 new WP_Theme_JSON( 806 array( 807 'version' => WP_Theme_JSON::LATEST_SCHEMA, 808 'settings' => array( 809 'color' => array( 810 'custom' => false, 811 ), 812 'spacing' => array( 813 'customMargin' => false, 814 ), 815 'typography' => array( 816 'customLineHeight' => false, 817 ), 818 ), 819 ) 820 ) 821 ); 822 823 $actual = $theme_json->get_raw_data(); 824 $expected = array( 825 'version' => WP_Theme_JSON::LATEST_SCHEMA, 826 'settings' => array( 827 'color' => array( 828 'custom' => false, 829 'duotone' => array( 830 array( 831 'slug' => 'value', 832 'colors' => array( 'red', 'green' ), 833 ), 834 ), 835 'gradients' => array( 836 'theme' => array( 837 array( 838 'slug' => 'gradient', 839 'gradient' => 'gradient', 840 ), 841 ), 842 ), 843 'palette' => array( 844 'theme' => array( 845 array( 846 'slug' => 'red', 847 'color' => 'red', 848 ), 849 ), 850 ), 851 ), 852 'spacing' => array( 853 'customMargin' => false, 854 'units' => array( 'px', 'em' ), 855 ), 856 'typography' => array( 857 'customLineHeight' => false, 858 'fontSizes' => array( 859 'theme' => array( 860 array( 861 'slug' => 'size', 862 'value' => 'size', 863 ), 864 ), 865 ), 866 ), 867 ), 868 ); 869 870 $this->assertEqualSetsWithIndex( $expected, $actual ); 871 } 872 873 /** 671 874 * @ticket 52991 672 875 */
Note: See TracChangeset
for help on using the changeset viewer.