diff --git a/CHANGELOG.md b/CHANGELOG.md index b822f814..5ca86dc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ All notable changes to `WP Curate` will be documented in this file. - Enhancement: Subquery block added to allow a separate set of posts within a query block. see https://github.com/alleyinteractive/wp-curate/issues/200 +## 2.3.2 - 2024-09-09 + +- Bug Fix: Prevent block transforms from crashing the Query block. + ## 2.3.1 - 2024-08-28 - Bug Fix: Backfill posts filling out of order in the Editor. diff --git a/blocks/query/block.json b/blocks/query/block.json index 94a577bd..8080ee99 100644 --- a/blocks/query/block.json +++ b/blocks/query/block.json @@ -31,10 +31,6 @@ ], "type": "string" }, - "maxNumberOfPosts": { - "default": 10, - "type": "number" - }, "minNumberOfPosts": { "default": 1, "type": "number" diff --git a/blocks/query/edit.tsx b/blocks/query/edit.tsx index 3939afb0..83c097a8 100644 --- a/blocks/query/edit.tsx +++ b/blocks/query/edit.tsx @@ -37,6 +37,7 @@ interface Window { allowedPostTypes: PostTypeOrTerm[]; allowedTaxonomies: PostTypeOrTerm[]; parselyAvailable: string, + maxPosts: number, }; } @@ -52,7 +53,6 @@ export default function Edit({ attributes: { backfillPosts = [], deduplication = 'inherit', - maxNumberOfPosts = 10, minNumberOfPosts = 1, numberOfPosts = 5, offset = 0, @@ -72,6 +72,7 @@ export default function Edit({ allowedPostTypes = [], allowedTaxonomies = [], parselyAvailable = 'false', + maxPosts = 10, } = {}, } = (window as any as Window); @@ -233,7 +234,7 @@ export default function Edit({ displayTypes={displayTypes} isPostDeduplicating={isPostDeduplicating} manualPosts={manualPosts} - maxNumberOfPosts={maxNumberOfPosts} + maxPosts={maxPosts} minNumberOfPosts={minNumberOfPosts} numberOfPosts={numberOfPosts} offset={offset} diff --git a/blocks/query/index.php b/blocks/query/index.php index d0aab25e..6f5aa15a 100644 --- a/blocks/query/index.php +++ b/blocks/query/index.php @@ -43,6 +43,13 @@ function wp_curate_query_block_init(): void { */ $allowed_taxonomies = apply_filters( 'wp_curate_allowed_taxonomies', [ 'category', 'post_tag' ] ); + /** + * Filter the maximum number of posts that can be displayed in the Query block. + * + * @param integer $max_posts The maximum number of posts to display. + */ + $max_posts = apply_filters( 'wp_curate_max_posts', 10 ); + /** * Filter whether to use Parsely. * @@ -89,6 +96,7 @@ function ( $slug ) { ), ), 'parselyAvailable' => $parsely_available ? 'true' : 'false', + 'maxPosts' => $max_posts, ] ); } diff --git a/blocks/query/types.ts b/blocks/query/types.ts index 0bbe20a8..3c97d8c1 100644 --- a/blocks/query/types.ts +++ b/blocks/query/types.ts @@ -2,7 +2,6 @@ interface EditProps { attributes: { backfillPosts?: number[]; deduplication?: string; - maxNumberOfPosts?: number; minNumberOfPosts?: number; numberOfPosts?: number; offset?: number; diff --git a/components/QueryControls/index.tsx b/components/QueryControls/index.tsx index 844540f2..7a75fbe0 100644 --- a/components/QueryControls/index.tsx +++ b/components/QueryControls/index.tsx @@ -33,7 +33,7 @@ type QueryControlsProps = { displayTypes: Option[]; isPostDeduplicating: boolean; manualPosts: Array; - maxNumberOfPosts: number; + maxPosts: number; minNumberOfPosts: number; numberOfPosts: number; offset: number; @@ -60,7 +60,7 @@ export default function QueryControls({ displayTypes, isPostDeduplicating, manualPosts, - maxNumberOfPosts, + maxPosts, minNumberOfPosts, numberOfPosts, offset, @@ -134,14 +134,14 @@ export default function QueryControls({ title={__('Setup', 'wp-curate')} initialOpen > - {minNumberOfPosts !== undefined && minNumberOfPosts !== maxNumberOfPosts ? ( + {minNumberOfPosts !== undefined && minNumberOfPosts !== maxPosts ? ( ) : null} =4" diff --git a/package.json b/package.json index fe6779bc..fc2a5160 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,6 @@ "ts-jest": "^29.2.5", "typescript": "^5.5.4", "webpack-cli": "^5.1.4", - "wp-types": "^4.66.0" + "wp-types": "^4.66.1" } } diff --git a/services/deduplicate/index.ts b/services/deduplicate/index.ts index 7c1149b0..b33a909d 100644 --- a/services/deduplicate/index.ts +++ b/services/deduplicate/index.ts @@ -87,6 +87,12 @@ export function mainDedupe(blockNames: string[] = ['wp-curate/query']) { redo = true; return; } + + // If the block transforms menu is currently open, skip deduplication. + if (document.querySelector('.block-editor-block-switcher__popover__preview__parent')) { + return; + } + running = true; // Clear the flag for another run. redo = false;