Constructor.
Description
WP_Icons_Registry is a singleton class, so keep this protected.
For 7.0, the Icons Registry is closed for third-party icon registry, serving only a subset of core icons.
These icons are defined in @wordpress/packages (Gutenberg repository) as SVG files and as entries in a single manifest file. On init, the registry is loaded with those icons listed in the manifest.
Source
protected function __construct() {
$icons_directory = __DIR__ . '/images/icon-library/';
$manifest_path = __DIR__ . '/assets/icon-library-manifest.php';
if ( ! is_readable( $manifest_path ) ) {
wp_trigger_error(
__METHOD__,
__( 'Core icon collection manifest is missing or unreadable.' )
);
return;
}
$collection = include $manifest_path;
if ( empty( $collection ) ) {
wp_trigger_error(
__METHOD__,
__( 'Core icon collection manifest is empty or invalid.' )
);
return;
}
foreach ( $collection as $icon_name => $icon_data ) {
if (
empty( $icon_data['filePath'] )
|| ! is_string( $icon_data['filePath'] )
) {
_doing_it_wrong(
__METHOD__,
__( 'Core icon collection manifest must provide valid a "filePath" for each icon.' ),
'7.0.0'
);
return;
}
$this->register(
'core/' . $icon_name,
array(
'label' => $icon_data['label'],
'filePath' => $icons_directory . $icon_data['filePath'],
)
);
}
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.