Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/class-wp-rest-icons-controller-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function register_routes() {

register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<namespace>[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?)',
'/' . $this->rest_base . '/(?P<collection>[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?)',
array(
array(
'methods' => WP_REST_Server::READABLE,
Expand All @@ -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])?$',
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading