-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Gallery Block: Support gaps that define column/row gaps to avoid PHP Warning/Fatal #41125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e06e1de
8f5f156
8599cb6
46a7e40
19eedef
1e5fadf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,18 +48,32 @@ function block_core_gallery_render( $attributes, $content ) { | |
| // Skip if gap value contains unsupported characters. | ||
| // Regex for CSS value borrowed from `safecss_filter_attr`, and used here | ||
| // because we only want to match against the value, not the CSS attribute. | ||
| $gap = preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap; | ||
| if ( is_array( $gap ) ) { | ||
| foreach ( $gap as $key => $value ) { | ||
| $gap[ $key ] = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value; | ||
| } | ||
| } else { | ||
| $gap = $gap_value && preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap; | ||
| } | ||
|
|
||
| $class = wp_unique_id( 'wp-block-gallery-' ); | ||
| $content = preg_replace( | ||
| '/' . preg_quote( 'class="', '/' ) . '/', | ||
| 'class="' . $class . ' ', | ||
| $content, | ||
| 1 | ||
| ); | ||
|
|
||
| // --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default | ||
| // gap on the gallery. | ||
| $gap_value = $gap ? $gap : 'var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )'; | ||
| $style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_value . '; gap: ' . $gap_value . '}'; | ||
| if ( is_array( $gap_value ) ) { | ||
| $gap_row = isset( $gap_value['top'] ) ? $gap_value['top'] : '0.5em'; | ||
| $gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : '0.5em'; | ||
| $gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column; | ||
ramonjd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| $style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_value . '; gap: ' . $gap_value . '}'; | ||
|
||
| // Ideally styles should be loaded in the head, but blocks may be parsed | ||
| // after that, so loading in the footer for now. | ||
| // See https://core.trac.wordpress.org/ticket/53494. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.