Skip to content

Commit

Permalink
Merge pull request #269 from alleyinteractive/hotfix/zero-posts-handling
Browse files Browse the repository at this point in the history
Display a message if number of posts on subquery block is set to 0.
  • Loading branch information
mogmarsh authored Dec 17, 2024
2 parents 970151d + 2bc79da commit f9d1b48
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `WP Curate` will be documented in this file.

## 2.4.7 - 2024-12-17

- Enhancement: Display a message if number of posts on subquery block is set to 0.

## 2.4.6 - 2024-12-11

- Bug Fix: Roll back to React 18.
Expand Down
7 changes: 6 additions & 1 deletion blocks/subquery/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useDebounce } from '@uidotdev/usehooks';
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
import { addQueryArgs } from '@wordpress/url';
import { __ } from '@wordpress/i18n';

import { Template } from '@wordpress/blocks';
import type { WP_REST_API_Posts as WpRestApiPosts } from 'wp-types'; // eslint-disable-line camelcase
Expand Down Expand Up @@ -249,7 +250,11 @@ export default function Edit({
index === 0 ? (
<>
<div {...blockProps}>
<InnerBlocks template={TEMPLATE} />
{numberOfPosts > 0 ? (
<InnerBlocks template={TEMPLATE} />
) : (
<p className="zero-posts">{__('Subquery Block: Number of Posts is set to 0', 'wp-curate')}</p>
)}
</div>
<QueryControls
allowedPostTypes={allowedPostTypes}
Expand Down
6 changes: 6 additions & 0 deletions blocks/subquery/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
.wp-block-wp-curate-subquery {
border: 1px dotted #ccc;
opacity: 1;

p.zero-posts {
font-size: 0.8em;
font-style: italic;
margin: 1em 0;
}
}
2 changes: 1 addition & 1 deletion wp-curate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Curate
* Plugin URI: https://github.com/alleyinteractive/wp-curate
* Description: Plugin to curate homepages and other landing pages
* Version: 2.4.6
* Version: 2.4.7
* Author: Alley Interactive
* Author URI: https://github.com/alleyinteractive/wp-curate
* Requires at least: 6.4
Expand Down

0 comments on commit f9d1b48

Please sign in to comment.