WP_Icons_Registry::get_content( string $icon_name ): string|null

In this article

Retrieves the content of a registered icon.

Parameters

$icon_namestringrequired
Icon name including namespace.

Return

string|null The content of the icon, if found.

Source

protected function get_content( $icon_name ) {
	if ( ! isset( $this->registered_icons[ $icon_name ]['content'] ) ) {
		$content = file_get_contents(
			$this->registered_icons[ $icon_name ]['filePath']
		);
		$content = $this->sanitize_icon_content( $content );

		if ( empty( $content ) ) {
			wp_trigger_error(
				__METHOD__,
				__( 'Icon content does not contain valid SVG markup.' )
			);
			return null;
		}

		$this->registered_icons[ $icon_name ]['content'] = $content;
	}
	return $this->registered_icons[ $icon_name ]['content'];
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.