wp-includes/icons.php:166Returns the SVG markup for a registered icon.
$namestring$argsarrayoptionalarray()$sizeint|nulldefault: 24
$classstringdefault: empty string
$labelstringdefault: empty string
stringfunction wp_get_icon( $name, $args = array() ) { $icon = WP_Icons_Registry::get_instance()->get_registered_icon( $name ); if ( is_null( $icon ) ) { return ''; } $svg = $icon['content']; if ( empty( $svg ) ) { return ''; } $args = wp_parse_args( $args, array( 'size' => 24, 'class' => '', 'label' => '', ) ); $processor = new WP_HTML_Tag_Processor( $svg ); if ( ! $processor->next_tag( 'svg' ) ) { return ''; } if ( is_numeric( $args['size'] ) ) { $size = absint( $args['size'] ); $processor->set_attribute( 'width', (string) $size ); $processor->set_attribute( 'height', (string) $size ); } if ( ! empty( $args['class'] ) ) { foreach ( preg_split( '/\s+/', $args['class'], -1, PREG_SPLIT_NO_EMPTY ) as $class_name ) { $processor->add_class( $class_name ); } } if ( ! empty( $args['label'] ) ) { $processor->set_attribute( 'role', 'img' ); $processor->set_attribute( 'aria-label', $args['label'] ); $processor->remove_attribute( 'aria-hidden' ); $processor->remove_attribute( 'focusable' ); } else { $processor->set_attribute( 'aria-hidden', 'true' ); $processor->set_attribute( 'focusable', 'false' ); $processor->remove_attribute( 'role' ); $processor->remove_attribute( 'aria-label' ); } return $processor->get_updated_html();}Introduced in 7.1.0.
Signature, return type and hooks compared across 1 parsed release.
src/wp-includes/icons.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.