From 7d8d4c92686af0efb1315c10dc4b333005fda7b7 Mon Sep 17 00:00:00 2001 From: Matthew Ell Date: Wed, 21 Aug 2024 15:08:25 -0600 Subject: [PATCH 1/5] Add attribute for level support Provide a way to filter the ability to select heading levels from the block settings --- blocks/post-title/block.json | 6 +++++- blocks/post-title/edit.tsx | 39 +++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/blocks/post-title/block.json b/blocks/post-title/block.json index 9cb901fe..4c18c7ea 100644 --- a/blocks/post-title/block.json +++ b/blocks/post-title/block.json @@ -15,7 +15,11 @@ "level": { "type": "number", "default": 3 - } + }, + "supportsLevel": { + "type": "boolean", + "default": true + }, }, "render": "file:render.php", "supports": { diff --git a/blocks/post-title/edit.tsx b/blocks/post-title/edit.tsx index beb20db4..595484ec 100644 --- a/blocks/post-title/edit.tsx +++ b/blocks/post-title/edit.tsx @@ -9,6 +9,7 @@ interface PostTitleEditProps { clientId?: string; attributes: { level?: number; + supportsLevel?: boolean; }; context: { postId: number; @@ -48,11 +49,11 @@ export default function Edit({ query: { postType = 'post' }, customPostTitles = [], } = context; - const { level = 3 } = attributes; + const { level = 3, supportsLevel } = attributes; const [rawTitle = '', , fullTitle] = useEntityProp('postType', postType, 'title', postId.toString()); const isPinned = pinnedPosts.includes(postId); const currentCustomPostTitle = customPostTitles.find((item) => item?.postId === postId); - const TagName = level === 0 ? 'p' : `h${level}`; + const TagName = !supportsLevel || level === 0 ? 'p' : `h${level}`; const blockProps = useBlockProps(); useEffect(() => { @@ -151,23 +152,25 @@ export default function Edit({ title={__('Setup', 'wp-curate')} initialOpen > - { - setAttributes({ level: parseInt(newLevel, 10) }); - }} - /> + value={level.toString()} + options={[ + { label: 'p', value: '0' }, + { label: 'h1', value: '1' }, + { label: 'h2', value: '2' }, + { label: 'h3', value: '3' }, + { label: 'h4', value: '4' }, + { label: 'h5', value: '5' }, + { label: 'h6', value: '6' }, + ]} + onChange={(newLevel) => { + setAttributes({ level: parseInt(newLevel, 10) }); + }} + /> + ) : null } From d331e5734e79a27bc2c168c0dd4f95d51ba8cf81 Mon Sep 17 00:00:00 2001 From: Matthew Ell Date: Wed, 21 Aug 2024 15:23:31 -0600 Subject: [PATCH 2/5] Remove trailing comma --- blocks/post-title/block.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks/post-title/block.json b/blocks/post-title/block.json index 4c18c7ea..80d0ae07 100644 --- a/blocks/post-title/block.json +++ b/blocks/post-title/block.json @@ -19,7 +19,7 @@ "supportsLevel": { "type": "boolean", "default": true - }, + } }, "render": "file:render.php", "supports": { From bfa0a08c59f91eb17f41a91bbe3adf9b59592410 Mon Sep 17 00:00:00 2001 From: Matthew Ell Date: Thu, 22 Aug 2024 09:07:54 -0600 Subject: [PATCH 3/5] Hide setting panel if no heading level support --- blocks/post-title/edit.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/blocks/post-title/edit.tsx b/blocks/post-title/edit.tsx index 595484ec..e6b1060b 100644 --- a/blocks/post-title/edit.tsx +++ b/blocks/post-title/edit.tsx @@ -147,15 +147,15 @@ export default function Edit({ return ( <> { titleElement } - - - {supportsLevel ? ( + {supportsLevel ? ( + + - ) : null } - - + + + ) : null} ); } From a70b2f1ff31037e3cc5e091ead3a10d3a0adea1b Mon Sep 17 00:00:00 2001 From: Matthew Ell Date: Thu, 22 Aug 2024 09:40:50 -0600 Subject: [PATCH 4/5] Version bump; Update changelog --- CHANGELOG.md | 6 +++++- wp-curate.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe96b12b..b7f76ae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,17 @@ All notable changes to `WP Curate` will be documented in this file. +## 2.2.3 - 2024-08-22 + +- Enhancement: Enable block filter support for Post Title block setting Heading Level select. + ## 2.2.2 - 2024-08-21 - Enhancement: Introduce `SWR` for caching API requests in the Query block. ## 2.2.1 - 2024-08-15 - - Bug Fix: Handle cases where a pinned post has been deleted or unpublished. +- Bug Fix: Handle cases where a pinned post has been deleted or unpublished. ## 2.2.0 - 2024-08-05 diff --git a/wp-curate.php b/wp-curate.php index 3afc4502..ab0676c5 100644 --- a/wp-curate.php +++ b/wp-curate.php @@ -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.2.2 + * Version: 2.2.3 * Author: Alley Interactive * Author URI: https://github.com/alleyinteractive/wp-curate * Requires at least: 6.4 From 15a139de54941c338a1fd95214aa2c0efd5e624c Mon Sep 17 00:00:00 2001 From: Matthew Ell Date: Wed, 28 Aug 2024 05:41:08 -0600 Subject: [PATCH 5/5] Version bump as minor --- wp-curate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-curate.php b/wp-curate.php index ab0676c5..d9fff85d 100644 --- a/wp-curate.php +++ b/wp-curate.php @@ -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.2.3 + * Version: 2.3.0 * Author: Alley Interactive * Author URI: https://github.com/alleyinteractive/wp-curate * Requires at least: 6.4