Changeset 11760
- Timestamp:
- 04/11/2022 06:26:45 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/includes/inline-styles.php
r11678 r11760 27 27 function render_layout_support_styles( $block_content, $block ) { 28 28 $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); 29 $support_layout = gutenberg_block_has_support( $block_type, array( '__experimentalLayout' ), false );29 $support_layout = block_has_support( $block_type, array( '__experimentalLayout' ), false ); 30 30 31 31 if ( ! $support_layout ) { … … 45 45 } 46 46 47 $ id = uniqid();48 $gap_value = _wp_array_get( $block, array( 'attrs', 'style', 'spacing', 'blockGap' ) );47 $class_name = wp_unique_id( 'wp-container-' ); 48 $gap_value = _wp_array_get( $block, array( 'attrs', 'style', 'spacing', 'blockGap' ) ); 49 49 // Skip if gap value contains unsupported characters. 50 50 // Regex for CSS value borrowed from `safecss_filter_attr`, and used here 51 51 // because we only want to match against the value, not the CSS attribute. 52 $gap_value = preg_match( '%[\\\(&=}]|/\*%', $gap_value ) ? null : $gap_value; 53 $style = gutenberg_get_layout_style( ".wp-container-$id", $used_layout, $has_block_gap_support, $gap_value ); 52 if ( is_array( $gap_value ) ) { 53 foreach ( $gap_value as $key => $value ) { 54 $gap_value[ $key ] = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value; 55 } 56 } else { 57 $gap_value = $gap_value && preg_match( '%[\\\(&=}]|/\*%', $gap_value ) ? null : $gap_value; 58 } 59 60 // If a block's block.json skips serialization for spacing or spacing.blockGap, 61 // don't apply the user-defined value to the styles. 62 $should_skip_gap_serialization = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'blockGap' ); 63 $style = wp_get_layout_style( ".$class_name", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization ); 54 64 // This assumes the hook only applies to blocks with a single wrapper. 55 65 // I think this is a reasonable limitation for that particular hook. 56 66 $content = preg_replace( 57 67 '/' . preg_quote( 'class="', '/' ) . '/', 58 'class=" wp-container-' . $id. ' ',68 'class="' . esc_attr( $class_name ) . ' ', 59 69 $block_content, 60 70 1 … … 78 88 */ 79 89 function render_elements_support_styles( $block_content, $block ) { 80 81 90 if ( ! $block_content ) { 91 return $block_content; 92 } 93 94 $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); 95 $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' ); 96 97 if ( $skip_link_color_serialization ) { 82 98 return $block_content; 83 99 } … … 89 105 90 106 /* 91 * For now we only care about link color.92 * This code in the future when we have a public API93 * should take advantage of WP_Theme_JSON_Gutenberg::compute_style_properties94 * and work for any element and style.95 */107 * For now we only care about link color. 108 * This code in the future when we have a public API 109 * should take advantage of WP_Theme_JSON::compute_style_properties 110 * and work for any element and style. 111 */ 96 112 if ( null === $link_color ) { 97 113 return $block_content; 98 114 } 99 115 100 $class_name = 'wp-elements-' . uniqid();116 $class_name = wp_unique_id( 'wp-elements-' ); 101 117 102 118 if ( strpos( $link_color, 'var:preset|color|' ) !== false ) { … … 108 124 $link_color_declaration = esc_html( safecss_filter_attr( "color: $link_color" ) ); 109 125 110 $style = " <style>.$class_name a{" . $link_color_declaration . ";}</style>\n";126 $style = ".$class_name a{" . $link_color_declaration . ';}'; 111 127 112 128 // Like the layout hook this assumes the hook only applies to blocks with a single wrapper. … … 167 183 'colors' => $block['attrs']['style']['color']['duotone'], 168 184 ); 169 $filter_property = gutenberg_get_duotone_filter_property( $filter_preset );170 $filter_id = gutenberg_get_duotone_filter_id( $filter_preset );171 $filter_svg = gutenberg_get_duotone_filter_svg( $filter_preset );185 $filter_property = wp_get_duotone_filter_property( $filter_preset ); 186 $filter_id = wp_get_duotone_filter_id( $filter_preset ); 187 $filter_svg = wp_get_duotone_filter_svg( $filter_preset ); 172 188 173 189 $scope = '.' . $filter_id;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)