Changeset 53420 for trunk/src/wp-includes/blocks/gallery.php
- Timestamp:
- 05/20/2022 02:31:00 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/gallery.php
r53157 r53420 49 49 // Regex for CSS value borrowed from `safecss_filter_attr`, and used here 50 50 // because we only want to match against the value, not the CSS attribute. 51 $gap = preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap; 51 if ( is_array( $gap ) ) { 52 foreach ( $gap as $key => $value ) { 53 $gap[ $key ] = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value; 54 } 55 } else { 56 $gap = $gap && preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap; 57 } 58 52 59 $class = wp_unique_id( 'wp-block-gallery-' ); 53 60 $content = preg_replace( … … 57 64 1 58 65 ); 66 59 67 // --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default 60 68 // gap on the gallery. 61 $gap_value = $gap ? $gap : 'var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )'; 62 $style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_value . '; gap: ' . $gap_value . '}'; 69 $fallback_gap = 'var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )'; 70 $gap_value = $gap ? $gap : $fallback_gap; 71 $gap_column = $gap_value; 72 73 if ( is_array( $gap_value ) ) { 74 $gap_row = isset( $gap_value['top'] ) ? $gap_value['top'] : $fallback_gap; 75 $gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : $fallback_gap; 76 $gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column; 77 } 78 79 // Set the CSS variable to the column value, and the `gap` property to the combined gap value. 80 $style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}'; 81 63 82 // Ideally styles should be loaded in the head, but blocks may be parsed 64 83 // after that, so loading in the footer for now.
Note: See TracChangeset
for help on using the changeset viewer.