Skip to content

Commit

Permalink
merging in develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mogmarsh committed Sep 12, 2024
2 parents 7d16609 + ce3d00d commit e8b5174
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions blocks/query/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
],
"type": "string"
},
"maxNumberOfPosts": {
"default": 10,
"type": "number"
},
"minNumberOfPosts": {
"default": 1,
"type": "number"
Expand Down
5 changes: 3 additions & 2 deletions blocks/query/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface Window {
allowedPostTypes: PostTypeOrTerm[];
allowedTaxonomies: PostTypeOrTerm[];
parselyAvailable: string,
maxPosts: number,
};
}

Expand All @@ -52,7 +53,6 @@ export default function Edit({
attributes: {
backfillPosts = [],
deduplication = 'inherit',
maxNumberOfPosts = 10,
minNumberOfPosts = 1,
numberOfPosts = 5,
offset = 0,
Expand All @@ -72,6 +72,7 @@ export default function Edit({
allowedPostTypes = [],
allowedTaxonomies = [],
parselyAvailable = 'false',
maxPosts = 10,
} = {},
} = (window as any as Window);

Expand Down Expand Up @@ -233,7 +234,7 @@ export default function Edit({
displayTypes={displayTypes}
isPostDeduplicating={isPostDeduplicating}
manualPosts={manualPosts}
maxNumberOfPosts={maxNumberOfPosts}
maxPosts={maxPosts}
minNumberOfPosts={minNumberOfPosts}
numberOfPosts={numberOfPosts}
offset={offset}
Expand Down
8 changes: 8 additions & 0 deletions blocks/query/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -89,6 +96,7 @@ function ( $slug ) {
),
),
'parselyAvailable' => $parsely_available ? 'true' : 'false',
'maxPosts' => $max_posts,
]
);
}
Expand Down
1 change: 0 additions & 1 deletion blocks/query/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ interface EditProps {
attributes: {
backfillPosts?: number[];
deduplication?: string;
maxNumberOfPosts?: number;
minNumberOfPosts?: number;
numberOfPosts?: number;
offset?: number;
Expand Down
8 changes: 4 additions & 4 deletions components/QueryControls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type QueryControlsProps = {
displayTypes: Option[];
isPostDeduplicating: boolean;
manualPosts: Array<number | null>;
maxNumberOfPosts: number;
maxPosts: number;
minNumberOfPosts: number;
numberOfPosts: number;
offset: number;
Expand All @@ -60,7 +60,7 @@ export default function QueryControls({
displayTypes,
isPostDeduplicating,
manualPosts,
maxNumberOfPosts,
maxPosts,
minNumberOfPosts,
numberOfPosts,
offset,
Expand Down Expand Up @@ -134,14 +134,14 @@ export default function QueryControls({
title={__('Setup', 'wp-curate')}
initialOpen
>
{minNumberOfPosts !== undefined && minNumberOfPosts !== maxNumberOfPosts ? (
{minNumberOfPosts !== undefined && minNumberOfPosts !== maxPosts ? (
<RangeControl
label={__('Number of Posts', 'wp-curate')}
help={__('The maximum number of posts to show.', 'wp-curate')}
value={numberOfPosts}
onChange={setNumberOfPosts}
min={minNumberOfPosts}
max={maxNumberOfPosts}
max={maxPosts}
/>
) : null}
<RangeControl
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 6 additions & 0 deletions services/deduplicate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e8b5174

Please sign in to comment.