Title: WP_Icon_Collections_Registry::register
Published: August 20, 2026

---

# WP_Icon_Collections_Registry::register( string $collection_slug, array $collection_properties ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#wp--skip-link--target)

Registers an icon collection.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#parameters)󠁿

 `$collection_slug`stringrequired

Icon collection slug.

`$collection_properties`arrayrequired

List of properties for the icon collection.

 * `label` string
 * Required. A human-readable label for the icon collection.
 * `description` string
 * Optional. A human-readable description for the icon collection.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#return)󠁿

 bool True if the collection was registered successfully, false otherwise.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#source)󠁿

    ```php
    public function register( $collection_slug, $collection_properties ) {
    	if ( ! isset( $collection_slug ) || ! is_string( $collection_slug ) ) {
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'Icon collection slug must be a string.' ),
    			'7.1.0'
    		);
    		return false;
    	}

    	if ( ! preg_match( '/^[a-z0-9]([a-z0-9_-]*[a-z0-9])?$/', $collection_slug ) ) {
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'Icon collection slug must start and end with a lowercase letter or digit and contain only lowercase letters, digits, hyphens, and underscores.' ),
    			'7.1.0'
    		);
    		return false;
    	}

    	if ( $this->is_registered( $collection_slug ) ) {
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'Icon collection is already registered.' ),
    			'7.1.0'
    		);
    		return false;
    	}

    	if ( ! is_array( $collection_properties ) ) {
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'Icon collection properties must be an array.' ),
    			'7.1.0'
    		);
    		return false;
    	}

    	$allowed_keys = array_fill_keys( array( 'label', 'description' ), 1 );
    	foreach ( array_keys( $collection_properties ) as $key ) {
    		if ( ! array_key_exists( $key, $allowed_keys ) ) {
    			_doing_it_wrong(
    				__METHOD__,
    				sprintf(
    					/* translators: %s: The name of a user-provided key. */
    					__( 'Invalid icon collection property: "%s".' ),
    					$key
    				),
    				'7.1.0'
    			);
    			return false;
    		}
    	}

    	if ( ! isset( $collection_properties['label'] ) || ! is_string( $collection_properties['label'] ) ) {
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'Icon collection label must be a string.' ),
    			'7.1.0'
    		);
    		return false;
    	}

    	if ( isset( $collection_properties['description'] ) && ! is_string( $collection_properties['description'] ) ) {
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'Icon collection description must be a string.' ),
    			'7.1.0'
    		);
    		return false;
    	}

    	$defaults = array(
    		'description' => '',
    	);

    	$collection = array_merge(
    		$defaults,
    		$collection_properties,
    		array( 'slug' => $collection_slug )
    	);

    	$this->registered_collections[ $collection_slug ] = $collection;

    	return true;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-icon-collections-registry.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-icon-collections-registry.php#L50)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-icon-collections-registry.php#L50-L134)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Icon_Collections_Registry::is_registered()](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/is_registered/)`wp-includes/class-wp-icon-collections-registry.php` |

Checks if an icon collection is registered.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_doing_it_wrong()](https://developer.wordpress.org/reference/functions/_doing_it_wrong/)`wp-includes/functions.php` |

Marks something as being incorrectly called.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_icon_collections_registry/register/?output_format=md#changelog)󠁿

| Version | Description | 
| [7.1.0](https://developer.wordpress.org/reference/since/7.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_icon_collections_registry%2Fregister%2F)
before being able to contribute a note or feedback.