$value['value'] ?? '', 'library' => $value['library'] ?? '', ]; $icon['font_family'] = Font_Icon_Svg_Data_Manager::get_font_family( $icon['library'] ); if ( ! $icon['font_family'] ) { return [ 'html' => '', 'url' => null, ]; } $icon_data = Font_Icon_Svg_Data_Manager::get_font_icon_svg_data( $icon ); $html = $this->build_svg( $icon_data ); return [ 'html' => $html, 'url' => null, ]; } private function build_svg( $icon_data ): string { if ( empty( $icon_data['path'] ) ) { return ''; } $attributes = [ 'viewBox' => '0 0 ' . $icon_data['width'] . ' ' . $icon_data['height'], 'xmlns' => 'http://www.w3.org/2000/svg', ]; $svg = '' . '' . ''; return $this->process_svg( $svg ); } private function process_svg( string $content ): string { $svg = new \WP_HTML_Tag_Processor( $content ); if ( ! $svg->next_tag( 'svg' ) ) { return ''; } $svg->set_attribute( 'fill', 'currentColor' ); $this->merge_inline_styles( $svg ); return ( new Svg_Sanitizer() )->sanitize( $svg->get_updated_html() ); } private function merge_inline_styles( \WP_HTML_Tag_Processor $svg ): void { $existing = trim( (string) $svg->get_attribute( 'style' ) ); $merged = empty( $existing ) ? self::SVG_INLINE_STYLES : rtrim( $existing, ';' ) . '; ' . self::SVG_INLINE_STYLES; $svg->set_attribute( 'style', $merged ); } }