WP_Icons_Registry::get_content
Retrieves the content of a registered icon.
Method of the class: WP_Icons_Registry{}
No Hooks.
Returns
String|null. The content of the icon, if found.
Usage
// protected - for code of main (parent) or child class $result = $this->get_content( $icon_name );
- $icon_name(string) (required)
- Icon name including namespace.
WP_Icons_Registry::get_content() WP Icons Registry::get content code WP 7.0
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'];
}