Title: WP_Icons_Registry::register
Published: May 20, 2026

---

# WP_Icons_Registry::register( string $icon_name, array $icon_properties ): bool

## In this article

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

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

Registers an icon.

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

 `$icon_name`stringrequired

Icon name including namespace.

`$icon_properties`arrayrequired

List of properties for the icon.

 * `label` string
 * Required. A human-readable label for the icon.
 * `content` string
 * Optional. SVG markup for the icon.
    If not provided, the content will be retrieved
   from the `filePath` if set. If both `content` and `filePath` are not set, the
   icon will not be registered.
 * `filePath` string
 * Optional. The full path to the file containing the icon content.

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

 bool True if the icon was registered with success and false otherwise.

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

    ```php
    protected 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;
    	}

    	$allowed_keys = array_fill_keys( array( 'label', 'content', 'filePath' ), 1 );
    	foreach ( array_keys( $icon_properties ) as $key ) {
    		if ( ! array_key_exists( $key, $allowed_keys ) ) {
    			_doing_it_wrong(
    				__METHOD__,
    				sprintf(
    					// translators: %s is the name of any user-provided key
    					__( 'Invalid icon property: "%s".' ),
    					$key
    				),
    				'7.0.0'
    			);
    			return false;
    		}
    	}

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

    	if (
    		( ! isset( $icon_properties['content'] ) && ! isset( $icon_properties['filePath'] ) ) ||
    		( isset( $icon_properties['content'] ) && isset( $icon_properties['filePath'] ) )
    	) {
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'Icons must provide either `content` or `filePath`.' ),
    			'7.0.0'
    		);
    		return false;
    	}

    	if ( isset( $icon_properties['content'] ) ) {
    		if ( ! is_string( $icon_properties['content'] ) ) {
    			_doing_it_wrong(
    				__METHOD__,
    				__( 'Icon content must be a string.' ),
    				'7.0.0'
    			);
    			return false;
    		}

    		$sanitized_icon_content = $this->sanitize_icon_content( $icon_properties['content'] );
    		if ( empty( $sanitized_icon_content ) ) {
    			_doing_it_wrong(
    				__METHOD__,
    				__( 'Icon content does not contain valid SVG markup.' ),
    				'7.0.0'
    			);
    			return false;
    		}
    	}

    	$icon = array_merge(
    		$icon_properties,
    		array( 'name' => $icon_name )
    	);

    	$this->registered_icons[ $icon_name ] = $icon;

    	return true;
    }
    ```

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

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

| Uses | Description | 
| [WP_Icons_Registry::sanitize_icon_content()](https://developer.wordpress.org/reference/classes/wp_icons_registry/sanitize_icon_content/)`wp-includes/class-wp-icons-registry.php` |

Sanitizes the icon SVG content.

  | 
| [__()](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_icons_registry/register/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_icons_registry/register/?output_format=md#)

| Used by | Description | 
| [WP_Icons_Registry::__construct()](https://developer.wordpress.org/reference/classes/wp_icons_registry/__construct/)`wp-includes/class-wp-icons-registry.php` |

Constructor.

  |

## User Contributed Notes

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