WP_Icon_Collections_Registry::unregister( string $collection_slug ): bool

Unregisters an icon collection.

Description

Any icons registered under the given collection are also unregistered.

Parameters

$collection_slugstringrequired
Icon collection slug.

Return

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

Source

public function unregister( $collection_slug ) {
	if ( ! $this->is_registered( $collection_slug ) ) {
		_doing_it_wrong(
			__METHOD__,
			sprintf(
				/* translators: %s: Icon collection slug. */
				__( 'Icon collection "%s" not found.' ),
				$collection_slug
			),
			'7.1.0'
		);
		return false;
	}

	$icons_registry = WP_Icons_Registry::get_instance();
	foreach ( $icons_registry->get_registered_icons() as $icon ) {
		if ( isset( $icon['collection'] ) && $icon['collection'] === $collection_slug ) {
			$icons_registry->unregister( $icon['name'] );
		}
	}

	unset( $this->registered_collections[ $collection_slug ] );

	return true;
}

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.