Skip to content

Commit ee53266

Browse files
committed
Return messages if no section ID is set for the articles block
1 parent a702252 commit ee53266

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-i18n', 'wp-server-side-render'), 'version' => '8dcdb4c49c5937146313');
1+
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-i18n', 'wp-server-side-render'), 'version' => '57b585f3747e128385c5');

includes/blocks/build/sections/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/blocks/class-blocks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ public function render_articles_block( $attributes ) {
155155
$show_excerpt = isset( $attributes['show_excerpt'] ) ? (bool) $attributes['show_excerpt'] : false;
156156

157157
if ( empty( $attributes['term_id'] ) ) {
158-
return '';
158+
return __( 'Enter a section ID.', 'knowledgebase' );
159159
}
160160

161161
$term = get_term( (int) $attributes['term_id'], 'wzkb_category' );
162162

163163
if ( empty( $term ) || is_wp_error( $term ) ) {
164-
return '';
164+
return __( 'Section not found.', 'knowledgebase' );
165165
}
166166

167167
$list_of_posts = Display::get_posts_by_term(

includes/blocks/src/sections/edit.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export default function Edit({ attributes, setAttributes }) {
2222
const blockProps = useBlockProps();
2323

2424
const { terms, hasResolved, error } = useSelect((select) => {
25-
const query = { per_page: -1 };
25+
const query = {
26+
per_page: -1,
27+
hide_empty: 1,
28+
};
2629
const selectorArgs = ['taxonomy', 'wzkb_category', query];
2730

2831
try {

0 commit comments

Comments
 (0)