Skip to content

Commit

Permalink
fixed linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pbking committed Oct 18, 2023
1 parent 71e3f40 commit 0a60636
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 42 deletions.
3 changes: 1 addition & 2 deletions lib/experimental/fonts/font-library/class-wp-font-family.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,14 @@ public function get_font_post() {
* @since 6.5.0
*
* @return WP_Post|WP_Error The post for this font family object if it exists and has valid JSON content.
*
*/
public function get_data_from_post() {
$post = $this->get_font_post();

if ( ! $post ) {
return new WP_Error(
'font_family_slug_not_found',
__('Font Family with that slug was not found.'),
__( 'Font Family with that slug was not found.' ),

Check warning on line 466 in lib/experimental/fonts/font-library/class-wp-font-family.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Missing $domain parameter in function call to __(). If this text string is supposed to use a WP Core translation, use the "default" text domain.
array(
'status' => 404,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ public function get_item( $request ) {
*
* @since 6.4.0
*
* @param WP_REST_Request $request Full details about the request. *
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response Response object.
*
*/
public function get_items( $request ) {

Check warning on line 103 in lib/experimental/fonts/font-library/class-wp-rest-font-collections-controller.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Unused function parameter $request.
$collections = array();
Expand Down Expand Up @@ -143,10 +142,10 @@ public function get_items_schema() {
}

$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'font-collections',
'type' => 'array',
'items' => array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'font-collections',
'type' => 'array',
'items' => array(
'type' => 'object',
'properties' => array(
'id' => array(
Expand Down Expand Up @@ -222,19 +221,19 @@ public function get_item_schema() {
'items' => array(
'type' => 'object',
'properties' => array(
'name' => array(
'name' => array(
'description' => __( 'Name of the font family.' ),
'type' => 'string',
),
'font_family' => array(
'description' => __( 'Font family string.' ),
'type' => 'string',
),
'slug' => array(
'slug' => array(
'description' => __( 'Slug of the font family.' ),
'type' => 'string',
),
'category' => array(
'category' => array(
'description' => __( 'Category of the font family.' ),
'type' => 'string',
),
Expand Down Expand Up @@ -267,7 +266,7 @@ public function get_item_schema() {
),
),
),
'preview' => array(
'preview' => array(
'description' => __( 'URL for font family preview.' ),
'type' => 'string',
),
Expand All @@ -282,5 +281,4 @@ public function get_item_schema() {
$this->schema = $schema;
return $this->add_additional_fields_schema( $this->schema );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function register_routes() {
* @return WP_REST_Response|WP_Error
*/
public function get_item( $request ) {
$font_family = new WP_Font_Family( array( 'slug' => $request['slug'] ) );
$font_family = new WP_Font_Family( array( 'slug' => $request['slug'] ) );
$font_family_data = $font_family->get_data_from_post();

if ( is_wp_error( $font_family_data ) ) {
Expand Down Expand Up @@ -412,23 +412,23 @@ public function get_item_schema() {
if ( $this->schema ) {
return $this->add_additional_fields_schema( $this->schema );
}
$family_schema = array (
$family_schema = array(
'title' => 'Font family',
'type' => 'object',
'properties' => $this->font_family_schema(),
);
$delete_success_schema = array(
'title' => 'Font family delete success',
'type' => 'boolean',
'title' => 'Font family delete success',
'type' => 'boolean',
'description' => 'Indicates a successful response.',
'enum' => array( true),
'enum' => array( true ),
);
$schema = array(
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'Font family item endpoint reponse',
'oneOf' => array( $family_schema, $delete_success_schema, $this->error_schema() ),
'title' => 'Font family item endpoint reponse',
'oneOf' => array( $family_schema, $delete_success_schema, $this->error_schema() ),
);
$this->schema = $schema;
$this->schema = $schema;
return $this->add_additional_fields_schema( $this->schema );
}

Expand All @@ -444,21 +444,21 @@ public function get_items_schema() {
return $this->add_additional_fields_schema( $this->schema );
}
$families_schema = array(
'title' => 'Font families',
'type' => 'array',
'items' => (
'title' => 'Font families',
'type' => 'array',
'items' => (
array(
'type' => 'object',
'properties' => $this->font_family_schema(),
)
)
),
);
$schema = array(
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'Font families items endpoint reponse',
'oneOf' => array( $families_schema, $this->error_schema() ),
'title' => 'Font families items endpoint reponse',
'oneOf' => array( $families_schema, $this->error_schema() ),
);
$this->schema = $schema;
$this->schema = $schema;
return $this->add_additional_fields_schema( $this->schema );
}

Expand All @@ -469,28 +469,28 @@ public function get_items_schema() {
*
* @return array Error schema data.
*/
private function error_schema () {
private function error_schema() {
return array(
'title' => 'Error response',
'type' => 'object',
'title' => 'Error response',
'type' => 'object',
'properties' => array(
'errors' => array(
'type' => 'object',
'description' => 'An associative array of error codes to error messages.',
'propertyNames' => array(
'errors' => array(
'type' => 'object',
'description' => 'An associative array of error codes to error messages.',
'propertyNames' => array(
'type' => 'string',
),
'additionalProperties' => array(
'type' => 'array',
'type' => 'array',
'items' => array(
'type' => 'string',
),
),
),
'error_data' => array(
'type' => 'object',
'description' => 'An associative array of error codes to mixed error data.',
'propertyNames' => array(
'type' => 'object',
'description' => 'An associative array of error codes to mixed error data.',
'propertyNames' => array(
'type' => 'string',
),
'additionalProperties' => array(
Expand Down
1 change: 0 additions & 1 deletion lib/experimental/fonts/font-library/font-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function gutenberg_init_font_library_routes() {
$font_families_controller->register_routes();
$font_collections_controller = new WP_REST_Font_Collections_Controller();
$font_collections_controller->register_routes();

}

add_action( 'rest_api_init', 'gutenberg_init_font_library_routes' );
Expand Down

0 comments on commit 0a60636

Please sign in to comment.