Skip to content

Commit

Permalink
fix: attribute types for custom author fields (#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoo authored Feb 15, 2023
1 parent 46b4515 commit 483e49c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/blocks/author-list/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
},
"authorRoles": {
"type": "array",
"default": [ "Administrator", "Editor", "Author", "Contributor" ]
"default": [
"Administrator",
"Editor",
"Author",
"Contributor"
]
},
"authorType": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/author-list/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function newspack_blocks_register_author_list() {
$author_custom_fields = \Newspack\Authors_Custom_Fields::get_custom_fields();
foreach ( $author_custom_fields as $field ) {
$block_json['attributes'][ 'show' . $field['name'] ] = [
'type' => 'string',
'type' => 'boolean',
'default' => true,
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/author-profile/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function newspack_blocks_register_author_profile() {
$author_custom_fields = \Newspack\Authors_Custom_Fields::get_custom_fields();
foreach ( $author_custom_fields as $field ) {
$block_json['attributes'][ 'show' . $field['name'] ] = [
'type' => 'string',
'type' => 'boolean',
'default' => true,
];
}
Expand Down
6 changes: 3 additions & 3 deletions src/blocks/shared/author.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export const AuthorDisplaySettings = ( { attributes, setAttributes } ) => {
<>
<p>{ __( 'Display the following fields:', 'newspack-blocks' ) }</p>
{ fields.map( field => {
const attrbuteName = `show${ field.name }`;
const attributeName = `show${ field.name }`;
return (
<ToggleControl
key={ field.name }
label={ field.label }
checked={ Boolean( attributes[ attrbuteName ] ) }
onChange={ () => setAttributes( { [ attrbuteName ]: ! attributes[ attrbuteName ] } ) }
checked={ Boolean( attributes[ attributeName ] ) }
onChange={ () => setAttributes( { [ attributeName ]: ! attributes[ attributeName ] } ) }
/>
);
} ) }
Expand Down

0 comments on commit 483e49c

Please sign in to comment.