Changeset 62738 for trunk/src/wp-includes/blocks/icon.php
- Timestamp:
- 07/14/2026 05:03:51 PM (3 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/blocks/icon.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/icon.php
r62577 r62738 17 17 function render_block_core_icon( $attributes ) { 18 18 if ( empty( $attributes['icon'] ) ) { 19 return;20 }21 22 $registry = WP_Icons_Registry::get_instance();23 $icon = $registry->get_registered_icon( $attributes['icon'] );24 25 if ( is_null( $icon ) ) {26 19 return; 27 20 } … … 87 80 ); 88 81 89 $processor = new WP_HTML_Tag_Processor( $icon['content'] ); 90 $processor->next_tag( 'svg' ); 82 $svg = wp_get_icon( 83 $attributes['icon'], 84 array( 85 // Width is applied via the dimensions block support styles below. 86 'size' => null, 87 'class' => $styles['classnames'] ?? '', 88 'label' => $attributes['ariaLabel'] ?? '', 89 ) 90 ); 91 91 92 if ( ! empty( $styles['css'] ) ) { 93 $processor->set_attribute( 'style', $styles['css'] ); 94 } 95 if ( ! empty( $styles['classnames'] ) ) { 96 $processor->add_class( $styles['classnames'] ); 92 if ( '' === $svg ) { 93 return; 97 94 } 98 95 99 $aria_label = ! empty( $attributes['ariaLabel'] ) ? $attributes['ariaLabel'] : ''; 96 $processor = new WP_HTML_Tag_Processor( $svg ); 97 if ( $processor->next_tag( 'svg' ) ) { 98 if ( ! empty( $styles['css'] ) ) { 99 $processor->set_attribute( 'style', $styles['css'] ); 100 } 100 101 101 if ( ! $aria_label ) { 102 // Icon is decorative, hide it from screen readers. 103 $processor->set_attribute( 'aria-hidden', 'true' ); 104 $processor->set_attribute( 'focusable', 'false' ); 105 } else { 106 $processor->set_attribute( 'role', 'img' ); 107 $processor->set_attribute( 'aria-label', $aria_label ); 102 // Apply flip classes to the SVG. 103 $flip_horizontal = $attributes['flipHorizontal'] ?? false; 104 $flip_vertical = $attributes['flipVertical'] ?? false; 105 106 if ( $flip_horizontal ) { 107 $processor->add_class( 'is-flip-horizontal' ); 108 } 109 if ( $flip_vertical ) { 110 $processor->add_class( 'is-flip-vertical' ); 111 } 112 113 $rotation = isset( $attributes['rotation'] ) ? (int) $attributes['rotation'] : 0; 114 115 if ( $rotation ) { 116 $current_style = $processor->get_attribute( 'style' ) ?? ''; 117 $rotation_css = 'rotate: ' . $rotation . 'deg;'; 118 if ( $current_style ) { 119 $processor->set_attribute( 'style', $current_style . ' ' . $rotation_css ); 120 } else { 121 $processor->set_attribute( 'style', $rotation_css ); 122 } 123 } 124 125 $svg = $processor->get_updated_html(); 108 126 } 109 127 110 // Return the updated SVG markup. 111 $svg = $processor->get_updated_html(); 112 $attributes = get_block_wrapper_attributes(); 113 return sprintf( '<div %s>%s</div>', $attributes, $svg ); 128 $wrapper_attributes = get_block_wrapper_attributes(); 129 return sprintf( '<div %s>%s</div>', $wrapper_attributes, $svg ); 114 130 } 115 131
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)