wp-includes/class-wp-icons-registry.php:14Core class used for interacting with registered icons.
$registered_iconsarray[]protected$instanceWP_Icons_Registry|nullprotected staticclass WP_Icons_Registry { /** * Registered icons array. * * @since 7.0.0 * @var array[] */ protected $registered_icons = array(); /** * Container for the main instance of the class. * * @since 7.0.0 * @var WP_Icons_Registry|null */ protected static $instance = null; /** * Constructor. * * WP_Icons_Registry is a singleton class, so keep this protected. * * Icons are populated via `_wp_register_default_icons()` during the * `init` action. Third-party icons can be registered via * {@see wp_register_icon()} once their collection is registered. * * @since 7.0.0 */ protected function __construct() {} /** * Registers an icon. * * @since 7.0.0 * @since 7.1.0 The icon name must be namespaced in the form "collection/icon-name". * * @param string $icon_name Namespaced icon name in the form "collection/icon-name" * (e.g. "core/arrow-left"). * @param array $icon_properties { * List of properties for the icon. * * @type string $label Required. A human-readable label for the icon. * @type string $content Optional. SVG markup for the icon. * If not provided, the content will be retrieved from the `file_path` if set. * If both `content` and `file_path` are not set, the icon will not be registered. * @type string $file_path Optional. The full path to the file containing the icon content. * } * @return bool True if the icon was registered with success and false otherwise. */ public function register( $icon_name, $icon_properties ) { if ( ! isset( $icon_name ) || ! is_string( $icon_name ) ) { _doing_it_wrong( __METHOD__, __( 'Icon name must be a string.' ), '7.0.0' ); return false; } // Require a namespaced name in the form "collection/icon-name". if ( ! str_contains( $icon_name, '/' ) ) { _doing_it_wrong( __METHOD__, __( 'Icon name must be namespaced in the form "collection/icon-name".' ), '7.1.0' ); return false; } // Split the namespaced name into a collection slug and an unqualified icon name. list( $collection, $unqualified_name ) = explode( '/', $icon_name, 2 ); if ( preg_match( '/[A-Z]/', $unqualified_name ) ) { _doing_it_wrong( __METHOD__, __( 'Icon names must not contain uppercase characters.' ), '7.1.0' ); return false; }Introduced in 7.0.0. One change between 7.0.4 and 7.1.0.
Signature, return type and hooks compared across 2 parsed releases.
unregister() added.verified against sourcesrc/wp-includes/class-wp-icons-registry.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.