diff --git a/lib/class-wp-rest-icons-controller-gutenberg.php b/lib/class-wp-rest-icons-controller-gutenberg.php index 21b0802de331e5..16fe15786e56c6 100644 --- a/lib/class-wp-rest-icons-controller-gutenberg.php +++ b/lib/class-wp-rest-icons-controller-gutenberg.php @@ -58,7 +58,7 @@ public function register_routes() { register_rest_route( $this->namespace, - '/' . $this->rest_base . '/(?P[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?)', + '/' . $this->rest_base . '/(?P[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?)', array( array( 'methods' => WP_REST_Server::READABLE, @@ -74,15 +74,15 @@ public function register_routes() { /** * Retrieves the query params for the icons collection. * - * Extends the base params with a `namespace` parameter that corresponds + * Extends the base params with a `collection` parameter that corresponds * to an icon collection slug. The same parameter is also captured as a * URL segment by the collection-scoped route. * * @return array Collection parameters. */ public function get_collection_params() { - $query_params = parent::get_collection_params(); - $query_params['namespace'] = array( + $query_params = parent::get_collection_params(); + $query_params['collection'] = array( 'description' => __( 'Limit results to icons belonging to the given collection slug.', 'gutenberg' ), 'type' => 'string', 'pattern' => '^[a-z0-9]([a-z0-9_-]*[a-z0-9])?$', @@ -97,7 +97,7 @@ public function get_collection_params() { * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function get_items( $request ) { - $collection = $request->get_param( 'namespace' ); + $collection = $request->get_param( 'collection' ); if ( null !== $collection && ! WP_Icon_Collections_Registry::get_instance()->is_registered( $collection ) ) { return new WP_Error( diff --git a/lib/compat/wordpress-7.1/class-wp-icon-collections-registry.php b/lib/compat/wordpress-7.1/class-wp-icon-collections-registry.php index a20f3ead60f57a..7213b034829376 100644 --- a/lib/compat/wordpress-7.1/class-wp-icon-collections-registry.php +++ b/lib/compat/wordpress-7.1/class-wp-icon-collections-registry.php @@ -90,6 +90,15 @@ public function register( $collection_slug, $collection_properties ) { return false; } + if ( isset( $collection_properties['description'] ) && ! is_string( $collection_properties['description'] ) ) { + _doing_it_wrong( + __METHOD__, + __( 'Icon collection description must be a string.', 'gutenberg' ), + '7.1.0' + ); + return false; + } + $defaults = array( 'description' => '', ); diff --git a/packages/block-library/src/icon/components/custom-inserter/index.js b/packages/block-library/src/icon/components/custom-inserter/index.js index 3de65c025479a2..13b5882030382f 100644 --- a/packages/block-library/src/icon/components/custom-inserter/index.js +++ b/packages/block-library/src/icon/components/custom-inserter/index.js @@ -46,7 +46,7 @@ export default function CustomInserterModal( { onClose, value, onChange } ) { return { icons: null, hasResolvedIcons: false }; } const query = - collectionSlug === '' ? {} : { namespace: collectionSlug }; + collectionSlug === '' ? {} : { collection: collectionSlug }; const { getEntityRecords, hasFinishedResolution } = select( coreDataStore ); return {