@@ -330,6 +330,7 @@ class WP_Theme_JSON {
330330 *
331331 * @since 6.2.0
332332 * @since 6.6.0 Added background-image properties.
333+ * @since 7.1.0 Added `background.gradient` to `background-image` paths.
333334 * @var array
334335 */
335336 const INDIRECT_PROPERTIES_METADATA = array (
@@ -348,6 +349,7 @@ class WP_Theme_JSON {
348349 ),
349350 'background-image ' => array (
350351 array ( 'background ' , 'backgroundImage ' , 'url ' ),
352+ array ( 'background ' , 'gradient ' ),
351353 ),
352354 );
353355
@@ -413,6 +415,7 @@ class WP_Theme_JSON {
413415 * Added support for `dimensions.width` and `dimensions.height`.
414416 * Added support for `typography.textIndent`.
415417 * @since 7.1.0 Added `viewport` property.
418+ * Added support for `background.gradient`.
416419 * @var array
417420 */
418421 const VALID_SETTINGS = array (
@@ -421,6 +424,7 @@ class WP_Theme_JSON {
421424 'background ' => array (
422425 'backgroundImage ' => null ,
423426 'backgroundSize ' => null ,
427+ 'gradient ' => null ,
424428 ),
425429 'border ' => array (
426430 'color ' => null ,
@@ -554,6 +558,7 @@ class WP_Theme_JSON {
554558 * @since 6.5.0 Added support for `dimensions.aspectRatio`.
555559 * @since 6.6.0 Added `background` sub properties to top-level only.
556560 * @since 7.0.0 Added support for `dimensions.width` and `dimensions.height`.
561+ * @since 7.1.0 Added `background.gradient`.
557562 * @var array
558563 */
559564 const VALID_STYLES = array (
@@ -563,6 +568,7 @@ class WP_Theme_JSON {
563568 'backgroundRepeat ' => null ,
564569 'backgroundSize ' => null ,
565570 'backgroundAttachment ' => null ,
571+ 'gradient ' => null ,
566572 ),
567573 'border ' => array (
568574 'color ' => null ,
@@ -1021,11 +1027,13 @@ public static function get_element_class_name( $element ) {
10211027 * @since 6.4.0 Added `background.backgroundImage`.
10221028 * @since 6.5.0 Added `background.backgroundSize` and `dimensions.aspectRatio`.
10231029 * @since 7.0.0 Added `dimensions.width` and `dimensions.height`.
1030+ * @since 7.1.0 Added `background.gradient`.
10241031 * @var array
10251032 */
10261033 const APPEARANCE_TOOLS_OPT_INS = array (
10271034 array ( 'background ' , 'backgroundImage ' ),
10281035 array ( 'background ' , 'backgroundSize ' ),
1036+ array ( 'background ' , 'gradient ' ),
10291037 array ( 'border ' , 'color ' ),
10301038 array ( 'border ' , 'radius ' ),
10311039 array ( 'border ' , 'style ' ),
@@ -2945,11 +2953,21 @@ protected static function compute_style_properties( $styles, $settings = array()
29452953 * For uploaded image (images with a database ID), apply size and position defaults,
29462954 * equal to those applied in block supports in lib/background.php.
29472955 */
2948- if ( 'background-image ' === $ css_property && ! empty ( $ value ) ) {
2949- $ background_styles = wp_style_engine_get_styles (
2950- array ( 'background ' => array ( 'backgroundImage ' => $ value ) )
2951- );
2952- $ value = $ background_styles ['declarations ' ][ $ css_property ];
2956+ if ( 'background-image ' === $ css_property ) {
2957+ $ background_image_input = array ();
2958+ if ( ! empty ( $ value ) ) {
2959+ $ background_image_input ['backgroundImage ' ] = $ value ;
2960+ }
2961+ $ gradient_value = $ styles ['background ' ]['gradient ' ] ?? null ;
2962+ if ( ! empty ( $ gradient_value ) ) {
2963+ $ background_image_input ['gradient ' ] = $ gradient_value ;
2964+ }
2965+ if ( ! empty ( $ background_image_input ) ) {
2966+ $ background_styles = wp_style_engine_get_styles (
2967+ array ( 'background ' => $ background_image_input )
2968+ );
2969+ $ value = $ background_styles ['declarations ' ][ $ css_property ] ?? null ;
2970+ }
29532971 }
29542972 if ( empty ( $ value ) && static ::ROOT_BLOCK_SELECTOR !== $ selector && ! empty ( $ styles ['background ' ]['backgroundImage ' ]['id ' ] ) ) {
29552973 if ( 'background-size ' === $ css_property ) {
0 commit comments