Skip to content

Commit

Permalink
Make post type error more specific
Browse files Browse the repository at this point in the history
  • Loading branch information
keesiemeijer committed Dec 5, 2019
1 parent a05fae7 commit a748c94
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions blocks/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ registerBlockType('cptda/calendar', {
keywords: [ __( 'posts', 'custom-post-type-date-archives' ), __( 'archive', 'custom-post-type-date-archives' ) ],
supports: {
align: true,
html: false,
},
edit,
save() {
Expand Down
12 changes: 6 additions & 6 deletions blocks/components/post-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ export default function PostTypeSelect({
let help = '';
let invalidPostType = '';

if (dateArchives && !isDateArchivePostType(postType)) {
if (!isPublicPostType(postType)) {
error = 'cptda-select-error';
help = sprintf(__("The post type %s doesn't exist or doesn't have date archives.", 'custom-post-type-date-archives'), postType);
help += ' ' + __('Please select another post type', 'custom-post-type-date-archives');
help = sprintf(__("The post type %s doesn't exist.", 'custom-post-type-date-archives'), postType);
help += ' ' + __('Please select another post type.', 'custom-post-type-date-archives');
invalidPostType = postType;
} else if (!dateArchives && !isPublicPostType(postType)) {
} else if (dateArchives && !isDateArchivePostType(postType)) {
error = 'cptda-select-error';
help = sprintf(__("The post type %s doesn't exist.", 'custom-post-type-date-archives'), postType);
help += ' ' + __('Please select another post type', 'custom-post-type-date-archives');
help = sprintf(__("The post type %s doesn't have date archives.", 'custom-post-type-date-archives'), postType);
help += ' ' + __('Please select another post type or add date archives to this post type.', 'custom-post-type-date-archives');
invalidPostType = postType;
}

Expand Down
3 changes: 1 addition & 2 deletions blocks/components/query-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ const typeOptions = [
{ value: 'postbypost', label: __('Post By Post') },
{ value: 'weekly', label: __('Weekly') },
{ value: 'yearly', label: __('Yearly') },

];
];
1 change: 1 addition & 0 deletions blocks/components/server-side-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ CPTDA_ServerSideRender.defaultProps = {
if ('Invalid post type' === response.errorMsg) {
let error = getPostTypeError(post_type, dateArchives);
if (error.length) {
error += ' ' + __('See the settings of this block for more information.', 'custom-post-type-date-archives');
errorMessage = (<span>{errorMessage}<br/><br/>{error}</span>);
}
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class LatestPostsEdit extends Component {
dateArchives={false}
/>
<RangeControl
label={ __( 'Number of posts', 'custom-post-type-date-archives' ) }
label={ __( 'Number of items', 'custom-post-type-date-archives' ) }
value={ number }
onChange={ ( value ) => setAttributes( { number: value } ) }
min={ 1 }
Expand Down
2 changes: 1 addition & 1 deletion blocks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "custom-post-type-date-archives-blocks",
"version": "2.6.2-alpha",
"version": "2.7.0-beta1",
"license": "GPL-2.0-or-later",
"devDependencies": {
"@wordpress/components": "^8.4.0",
Expand Down

0 comments on commit a748c94

Please sign in to comment.