From 9e29a3ab49bc995f3daf0a7b9fb14223da09e788 Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Fri, 6 Mar 2026 10:49:59 +0600 Subject: [PATCH 01/46] Add block guidelines management --- .../components/block-guideline-modal.scss | 4 +- .../components/block-guideline-modal.tsx | 131 +++++--------- .../components/block-guidelines.scss | 24 +-- .../components/block-guidelines.tsx | 169 +++--------------- routes/content-guidelines/stage.tsx | 3 + 5 files changed, 77 insertions(+), 254 deletions(-) diff --git a/routes/content-guidelines/components/block-guideline-modal.scss b/routes/content-guidelines/components/block-guideline-modal.scss index 904b3427cdd2e8..2d8404c9043df2 100644 --- a/routes/content-guidelines/components/block-guideline-modal.scss +++ b/routes/content-guidelines/components/block-guideline-modal.scss @@ -1,5 +1,3 @@ -@use "@wordpress/base-styles/variables" as *; - .block-guideline-modal { width: min(100%, 660px); @@ -8,6 +6,6 @@ } &__actions { - margin-top: $grid-unit-10; + margin-top: 8px; } } diff --git a/routes/content-guidelines/components/block-guideline-modal.tsx b/routes/content-guidelines/components/block-guideline-modal.tsx index d3f649695dc34f..4451f74cc39524 100644 --- a/routes/content-guidelines/components/block-guideline-modal.tsx +++ b/routes/content-guidelines/components/block-guideline-modal.tsx @@ -1,5 +1,3 @@ -/* @jsx createElement */ - /** * WordPress dependencies */ @@ -7,31 +5,23 @@ import { Button, ComboboxControl, Modal, - TextControl, TextareaControl, __experimentalHStack as HStack, __experimentalVStack as VStack, } from '@wordpress/components'; import { __, sprintf } from '@wordpress/i18n'; import { Notice } from '@wordpress/ui'; -import { createElement, useMemo, useState } from '@wordpress/element'; +import { useState, useEffect } from '@wordpress/element'; import { useDispatch, useSelect } from '@wordpress/data'; -import { - privateApis as blocksPrivateApis, - store as blocksStore, -} from '@wordpress/blocks'; -import { store as noticesStore } from '@wordpress/notices'; +import { store as blocksStore } from '@wordpress/blocks'; /** * Internal dependencies */ import { saveContentGuidelines } from '../api'; import { STORE_NAME } from '../store'; -import { unlock } from '../../lock-unlock'; import './block-guideline-modal.scss'; -const { isContentBlock } = unlock( blocksPrivateApis ); - interface BlockGuidelineModalProps { closeModal: () => void; initialBlock?: string; @@ -41,6 +31,7 @@ export default function BlockGuidelineModal( { closeModal, initialBlock, }: BlockGuidelineModalProps ) { + const [ guidelineText, setGuidelineText ] = useState( '' ); const [ selectedBlock, setSelectedBlock ] = useState< string | undefined >( initialBlock ); @@ -48,16 +39,21 @@ export default function BlockGuidelineModal( { const [ isSaving, setIsSaving ] = useState( false ); const [ error, setError ] = useState< string | null >( null ); - const blockGuidelines = useSelect( + const currentGuideline = useSelect( // @ts-ignore - ( select ) => select( STORE_NAME ).getBlockGuidelines(), - [] + ( select ) => select( STORE_NAME ).getBlockGuideline( selectedBlock ), + [ selectedBlock ] ); - const isEditing = !! initialBlock; + const isEditing = !! currentGuideline; - const currentGuideline = blockGuidelines[ selectedBlock ] ?? ''; - const [ guidelineText, setGuidelineText ] = useState( currentGuideline ); + useEffect( () => { + setSelectedBlock( initialBlock ); + }, [ initialBlock ] ); + + useEffect( () => { + setGuidelineText( currentGuideline ?? '' ); + }, [ currentGuideline ] ); const blockOptions = useSelect( // @ts-ignore @@ -65,59 +61,37 @@ export default function BlockGuidelineModal( { [] ); - const availableBlockOptions = useMemo( () => { - const set = new Set( Object.keys( blockGuidelines ) ); - if ( initialBlock ) { - set.delete( initialBlock ); - } - if ( selectedBlock ) { - set.delete( selectedBlock ); - } - - return blockOptions - .filter( - ( block ) => - isContentBlock( block.name ) && ! set.has( block.name ) - ) - .map( ( block ) => ( { - value: block.name, - label: block.title, - } ) ); - }, [ blockGuidelines, blockOptions, initialBlock, selectedBlock ] ); - - const selectedBlockLabel = useMemo( - () => - blockOptions.find( ( block ) => block.name === selectedBlock ) - ?.title || '', - [ blockOptions, selectedBlock ] - ); - const { setBlockGuideline } = useDispatch( STORE_NAME ); - const { createSuccessNotice } = useDispatch( noticesStore ); - const handleSave = ( value: string ) => { - value = value.trim(); - if ( ! selectedBlock ) { + const handleAddGuideline = () => { + if ( ! selectedBlock || ! guidelineText.trim() ) { return; } + setIsSaving( true ); + setBlockGuideline( selectedBlock, guidelineText.trim() ); + saveContentGuidelines() + .then( () => { + setError( null ); + closeModal(); + } ) + .catch( ( e: Error ) => setError( e.message ) ) + .finally( () => setIsSaving( false ) ); + }; + const handleRemoveGuideline = () => { + if ( ! selectedBlock ) { + return; + } setIsSaving( true ); - const oldValue = blockGuidelines[ selectedBlock ]; - setBlockGuideline( selectedBlock, value ); + setBlockGuideline( selectedBlock, '' ); saveContentGuidelines() .then( () => { setError( null ); - createSuccessNotice( - value - ? __( 'Block guideline saved.' ) - : __( 'Block guideline removed.' ), - { type: 'snackbar' } - ); closeModal(); } ) .catch( ( e: Error ) => { setError( e.message ); - setBlockGuideline( selectedBlock, oldValue ); + setBlockGuideline( selectedBlock, currentGuideline ); } ) .finally( () => setIsSaving( false ) ); }; @@ -142,26 +116,19 @@ export default function BlockGuidelineModal( { onRequestClose={ closeModal } > - { isEditing ? ( - {} } - disabled - /> - ) : ( - - setSelectedBlock( value ?? undefined ) - } - placeholder={ __( 'Search for a block…' ) } - /> - ) } + ( { + value: block.name, + label: block.title, + } ) ) } + value={ selectedBlock } + onChange={ ( value ) => + setSelectedBlock( value ?? undefined ) + } + placeholder={ __( 'Search for a block…' ) } + /> handleSave( '' ) } + onClick={ handleRemoveGuideline } disabled={ isSaving } - accessibleWhenDisabled > { __( 'Remove' ) } ) } diff --git a/routes/content-guidelines/components/block-guidelines.scss b/routes/content-guidelines/components/block-guidelines.scss index e20416f90c5a58..3249ab7d37c6c5 100644 --- a/routes/content-guidelines/components/block-guidelines.scss +++ b/routes/content-guidelines/components/block-guidelines.scss @@ -3,32 +3,18 @@ .block-guidelines { margin-top: $grid-unit-30; - .block-guidelines__icon { + &__add-button { + width: 155px; + } + + .dataviews-view-list__media-wrapper { display: flex; align-items: center; justify-content: center; - height: 100%; - width: 100%; } .dataviews-view-list__field-wrapper { display: flex; justify-content: center; } - - .dataviews-wrapper { - margin-right: -$grid-unit-30; - margin-left: -$grid-unit-30; - } - - .dataviews-search { - margin-right: $grid-unit-30; - margin-left: $grid-unit-30; - } -} - -.block-guidelines__remove-modal { - .components-modal__header-heading { - font-weight: 500; - } } diff --git a/routes/content-guidelines/components/block-guidelines.tsx b/routes/content-guidelines/components/block-guidelines.tsx index 4416ac5e1429cd..5b8aae99ce1046 100644 --- a/routes/content-guidelines/components/block-guidelines.tsx +++ b/routes/content-guidelines/components/block-guidelines.tsx @@ -1,15 +1,10 @@ -/* @jsx createElement */ - /** * WordPress dependencies */ import { Button, Icon, - Modal, __experimentalVStack as VStack, - __experimentalHStack as HStack, - __experimentalText as Text, } from '@wordpress/components'; import { Notice } from '@wordpress/ui'; import { @@ -18,16 +13,10 @@ import { type View, } from '@wordpress/dataviews'; import { __, sprintf } from '@wordpress/i18n'; -import { - createElement, - useEffect, - useMemo, - useState, -} from '@wordpress/element'; +import { useMemo, useState } from '@wordpress/element'; import { useSelect, useDispatch } from '@wordpress/data'; import { blockDefault } from '@wordpress/icons'; import { store as blocksStore } from '@wordpress/blocks'; -import { store as noticesStore } from '@wordpress/notices'; /** * Internal dependencies @@ -37,13 +26,11 @@ import { saveContentGuidelines } from '../api'; import { STORE_NAME } from '../store'; import './block-guidelines.scss'; -const PER_PAGE = 5; - const initialView: View = { type: 'list', search: '', page: 1, - perPage: PER_PAGE, + perPage: 5, filters: [], mediaField: 'icon', showMedia: true, @@ -53,20 +40,13 @@ const initialView: View = { }, }; -interface DataRow { - id: string; - label: string; -} - const fields = [ { id: 'icon', label: __( 'Icon' ), type: 'media' as const, render: ( { item } ) => ( -
- -
+ ), }, { @@ -84,11 +64,6 @@ export default function BlockGuidelines() { const [ view, setView ] = useState< View >( initialView ); const [ selectedItem, setSelectedItem ] = useState< string >(); const [ error, setError ] = useState< string | null >( null ); - const [ busy, setBusy ] = useState( false ); - const [ itemToDelete, setItemToDelete ] = useState< DataRow | null >( - null - ); - const { createSuccessNotice } = useDispatch( noticesStore ); const blockGuidelines = useSelect( // @ts-ignore @@ -117,79 +92,37 @@ export default function BlockGuidelines() { const { setBlockGuideline } = useDispatch( STORE_NAME ); - const handleRowClick = ( id: string ) => { - setSelectedItem( id ); - setIsOpen( true ); - }; - const actions = useMemo( () => [ { id: 'edit', label: __( 'Edit' ), - callback: ( items: DataRow[] ) => { + callback: ( items ) => { const item = items[ 0 ]; - handleRowClick( item.id ); + setSelectedItem( item.id ); + setIsOpen( true ); }, }, { id: 'remove', label: __( 'Remove' ), - callback: ( items: DataRow[] ) => { + callback: ( items ) => { const item = items[ 0 ]; - setItemToDelete( item ); + setBlockGuideline( item.id, '' ); + saveContentGuidelines() + .then( () => setError( null ) ) + .catch( ( e: Error ) => setError( e.message ) ); }, }, ], - [ setItemToDelete ] + [ setBlockGuideline ] ); - const handleDelete = () => { - if ( ! itemToDelete ) { - return; - } - const oldValue = blockGuidelines[ itemToDelete.id ]; - // We need to pass an empty string to remove the guideline. - // This is because the API will only remove the guideline if the value is an empty string. - setBlockGuideline( itemToDelete.id, '' ); - setBusy( true ); - saveContentGuidelines() - .then( () => { - setError( null ); - createSuccessNotice( __( 'Block guidelines removed.' ), { - type: 'snackbar', - } ); - } ) - .catch( ( e: Error ) => { - setError( e.message ); - setBlockGuideline( itemToDelete.id, oldValue ); - } ) - .finally( () => { - setBusy( false ); - setItemToDelete( null ); - } ); - }; - const { data: processedData, paginationInfo } = useMemo( () => filterSortAndPaginate( rows, view, fields ), [ rows, view ] ); - useEffect( () => { - const lastPage = Math.max( paginationInfo.totalPages, 1 ); - - if ( view.page && view.page > lastPage ) { - setView( ( currentView ) => - currentView.page && currentView.page > lastPage - ? { - ...currentView, - page: lastPage, - } - : currentView - ); - } - }, [ paginationInfo.totalPages, view.page ] ); - const closeModal = () => { setIsOpen( false ); setSelectedItem( undefined ); @@ -200,8 +133,6 @@ export default function BlockGuidelines() { setIsOpen( true ); }; - const shouldShowDataViewControls = rows.length > PER_PAGE; - return ( { error && ( @@ -223,29 +154,19 @@ export default function BlockGuidelines() { onChangeView={ setView } fields={ fields } actions={ actions } - config={ { perPageSizes: [ PER_PAGE ] } } - onChangeSelection={ ( items ) => { - const id = items[ 0 ]; - handleRowClick( id ); - } } + config={ { perPageSizes: [ 5, 10, 20, 50 ] } } defaultLayouts={ { list: {}, } } - > - - { shouldShowDataViewControls && ( - - ) } - - { shouldShowDataViewControls && } - - + > ) } - - - + { isOpen && ( ) } - { itemToDelete && ( - setItemToDelete( null ) } - size="small" - > - - - - { sprintf( - /* translators: %s: Block name. */ - __( - 'You are about to remove the block guidelines for the %s block.' - ), - itemToDelete.label - ) } - - - { __( - 'This can be undone from revision history.' - ) } - - - - - - - - - ) } ); } diff --git a/routes/content-guidelines/stage.tsx b/routes/content-guidelines/stage.tsx index e418423cfe62a4..dbabf12dacb06e 100644 --- a/routes/content-guidelines/stage.tsx +++ b/routes/content-guidelines/stage.tsx @@ -17,6 +17,7 @@ import GuidelineAccordion from './components/guideline-accordion'; import GuidelineAccordionForm from './components/guideline-accordion-form'; import { fetchContentGuidelines } from './api'; import BlockGuidelines from './components/block-guidelines'; +import { bootstrapBlockRegistry } from './bootstrap-block-registry'; const GUIDELINE_ITEMS = [ { @@ -63,6 +64,8 @@ function ContentGuidelinesPage() { const [ error, setError ] = useState< string | null >( null ); useEffect( () => { + // Bootstrap Core blocks so block icons are available (e.g. in Block Guidelines). + bootstrapBlockRegistry(); // Populate the store with the content guidelines. fetchContentGuidelines() .then( () => setError( null ) ) From 2c86cd670286f4c7ee9aefa607580ebe7032d302 Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Mon, 9 Mar 2026 11:02:06 +0600 Subject: [PATCH 02/46] Fix spacing of the dataviews --- routes/content-guidelines/components/block-guidelines.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routes/content-guidelines/components/block-guidelines.scss b/routes/content-guidelines/components/block-guidelines.scss index 3249ab7d37c6c5..dc069c1c025f99 100644 --- a/routes/content-guidelines/components/block-guidelines.scss +++ b/routes/content-guidelines/components/block-guidelines.scss @@ -17,4 +17,9 @@ display: flex; justify-content: center; } + + .dataviews-wrapper { + margin-right: -$grid-unit-30; + margin-left: -$grid-unit-30; + } } From 90830ba04fdbc9239f3b931a1fa2358691282241 Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Mon, 9 Mar 2026 11:19:04 +0600 Subject: [PATCH 03/46] Remove dataviews sort and filter And omit dataviews search too when there are less than 6 items --- .../components/block-guidelines.scss | 5 +++++ .../components/block-guidelines.tsx | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/routes/content-guidelines/components/block-guidelines.scss b/routes/content-guidelines/components/block-guidelines.scss index dc069c1c025f99..49024d011bbdc7 100644 --- a/routes/content-guidelines/components/block-guidelines.scss +++ b/routes/content-guidelines/components/block-guidelines.scss @@ -22,4 +22,9 @@ margin-right: -$grid-unit-30; margin-left: -$grid-unit-30; } + + .dataviews-search { + margin-right: $grid-unit-30; + margin-left: $grid-unit-30; + } } diff --git a/routes/content-guidelines/components/block-guidelines.tsx b/routes/content-guidelines/components/block-guidelines.tsx index 5b8aae99ce1046..349e1c67745eed 100644 --- a/routes/content-guidelines/components/block-guidelines.tsx +++ b/routes/content-guidelines/components/block-guidelines.tsx @@ -1,3 +1,5 @@ +/* @jsx createElement */ + /** * WordPress dependencies */ @@ -13,7 +15,7 @@ import { type View, } from '@wordpress/dataviews'; import { __, sprintf } from '@wordpress/i18n'; -import { useMemo, useState } from '@wordpress/element'; +import { createElement, useMemo, useState } from '@wordpress/element'; import { useSelect, useDispatch } from '@wordpress/data'; import { blockDefault } from '@wordpress/icons'; import { store as blocksStore } from '@wordpress/blocks'; @@ -133,6 +135,8 @@ export default function BlockGuidelines() { setIsOpen( true ); }; + const shouldShowDataViewControls = rows.length > 5; + return ( { error && ( @@ -158,7 +162,15 @@ export default function BlockGuidelines() { defaultLayouts={ { list: {}, } } - > + > + + { shouldShowDataViewControls && ( + + ) } + + { shouldShowDataViewControls && } + + ) } + + + + + ) }
); } From 7dc2deede54033745a571a28b38ca31182434b8e Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Mon, 9 Mar 2026 13:00:45 +0600 Subject: [PATCH 06/46] Improve save/delete logic --- .../components/block-guideline-modal.tsx | 47 ++++++++----------- .../components/block-guidelines.tsx | 12 +++-- routes/content-guidelines/store.ts | 4 ++ 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/routes/content-guidelines/components/block-guideline-modal.tsx b/routes/content-guidelines/components/block-guideline-modal.tsx index 5edc9d6d4157a8..461a06ea0fab0d 100644 --- a/routes/content-guidelines/components/block-guideline-modal.tsx +++ b/routes/content-guidelines/components/block-guideline-modal.tsx @@ -64,6 +64,9 @@ export default function BlockGuidelineModal( { if ( initialBlock ) { set.delete( initialBlock ); } + if ( selectedBlock ) { + set.delete( selectedBlock ); + } return blockOptions .filter( ( block ) => ! set.has( block.name ) ) @@ -71,7 +74,7 @@ export default function BlockGuidelineModal( { value: block.name, label: block.title, } ) ); - }, [ blockGuidelines, blockOptions, initialBlock ] ); + }, [ blockGuidelines, blockOptions, initialBlock, selectedBlock ] ); const selectedBlockLabel = useMemo( () => @@ -83,41 +86,31 @@ export default function BlockGuidelineModal( { const { setBlockGuideline } = useDispatch( STORE_NAME ); const { createSuccessNotice } = useDispatch( noticesStore ); - const handleAddGuideline = () => { - if ( ! selectedBlock || ! guidelineText.trim() ) { - return; - } - setIsSaving( true ); - setBlockGuideline( selectedBlock, guidelineText.trim() ); - saveContentGuidelines() - .then( () => { - setError( null ); - closeModal(); - createSuccessNotice( __( 'Block guideline saved.' ), { - type: 'snackbar', - } ); - } ) - .catch( ( e: Error ) => setError( e.message ) ) - .finally( () => setIsSaving( false ) ); - }; - - const handleRemoveGuideline = () => { + const handleSave = ( value: string ) => { + value = value.trim(); if ( ! selectedBlock ) { return; } + setIsSaving( true ); - setBlockGuideline( selectedBlock, '' ); + const oldValue = blockGuidelines[ selectedBlock ]; + setBlockGuideline( selectedBlock, value ); saveContentGuidelines() .then( () => { setError( null ); - createSuccessNotice( __( 'Block guideline removed.' ), { - type: 'snackbar', - } ); + createSuccessNotice( + sprintf( + /* translators: %s: Block label. */ + __( 'Block guideline "%s"' ), + value ? 'saved' : 'removed' + ), + { type: 'snackbar' } + ); closeModal(); } ) .catch( ( e: Error ) => { setError( e.message ); - setBlockGuideline( selectedBlock, currentGuideline ); + setBlockGuideline( selectedBlock, oldValue ); } ) .finally( () => setIsSaving( false ) ); }; @@ -191,7 +184,7 @@ export default function BlockGuidelineModal( { + + + { isOpen && ( Date: Mon, 9 Mar 2026 13:43:55 +0600 Subject: [PATCH 11/46] Do not remove block-key when removing block guideline This is because the backend expects empty string in order to delete a block --- routes/content-guidelines/store.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/routes/content-guidelines/store.ts b/routes/content-guidelines/store.ts index c7f8dcaf0850d7..9287f066d766ff 100644 --- a/routes/content-guidelines/store.ts +++ b/routes/content-guidelines/store.ts @@ -114,14 +114,6 @@ function reducer( [ action.blockName ]: action.value, }; -<<<<<<< HEAD - if ( action.value === undefined ) { -======= - if ( ! action.value ) { ->>>>>>> f229dee50d (Improve save/delete logic) - delete blocks[ action.blockName ]; - } - return { ...state, categories: { From 61da70be29e5b256b222b601432c8c19e56b9a34 Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Mon, 9 Mar 2026 14:05:58 +0600 Subject: [PATCH 12/46] Fix issue with empty page after deleting rows --- .../components/block-guidelines.tsx | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/routes/content-guidelines/components/block-guidelines.tsx b/routes/content-guidelines/components/block-guidelines.tsx index 1f491d811ec6a4..db03307483d5ad 100644 --- a/routes/content-guidelines/components/block-guidelines.tsx +++ b/routes/content-guidelines/components/block-guidelines.tsx @@ -18,7 +18,12 @@ import { type View, } from '@wordpress/dataviews'; import { __, sprintf } from '@wordpress/i18n'; -import { createElement, useMemo, useState } from '@wordpress/element'; +import { + createElement, + useEffect, + useMemo, + useState, +} from '@wordpress/element'; import { useSelect, useDispatch } from '@wordpress/data'; import { blockDefault } from '@wordpress/icons'; import { store as blocksStore } from '@wordpress/blocks'; @@ -32,11 +37,13 @@ import { saveContentGuidelines } from '../api'; import { STORE_NAME } from '../store'; import './block-guidelines.scss'; +const PER_PAGE = 5; + const initialView: View = { type: 'list', search: '', page: 1, - perPage: 5, + perPage: PER_PAGE, filters: [], mediaField: 'icon', showMedia: true, @@ -160,6 +167,21 @@ export default function BlockGuidelines() { [ rows, view ] ); + useEffect( () => { + const lastPage = Math.max( paginationInfo.totalPages, 1 ); + + if ( view.page && view.page > lastPage ) { + setView( ( currentView ) => + currentView.page && currentView.page > lastPage + ? { + ...currentView, + page: lastPage, + } + : currentView + ); + } + }, [ paginationInfo.totalPages, view.page ] ); + const closeModal = () => { setIsOpen( false ); setSelectedItem( undefined ); @@ -170,7 +192,7 @@ export default function BlockGuidelines() { setIsOpen( true ); }; - const shouldShowDataViewControls = rows.length > 5; + const shouldShowDataViewControls = rows.length > PER_PAGE; return ( @@ -193,7 +215,7 @@ export default function BlockGuidelines() { onChangeView={ setView } fields={ fields } actions={ actions } - config={ { perPageSizes: [ 5, 10, 20, 50 ] } } + config={ { perPageSizes: [ PER_PAGE ] } } defaultLayouts={ { list: {}, } } From 15ac51521d77f31f50e1e2d9ac33c3a219eb3f45 Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Mon, 9 Mar 2026 14:07:58 +0600 Subject: [PATCH 13/46] Fix mistake with wrapping up action-text in double quote --- routes/content-guidelines/components/block-guideline-modal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/content-guidelines/components/block-guideline-modal.tsx b/routes/content-guidelines/components/block-guideline-modal.tsx index 461a06ea0fab0d..729b0a4e2088d5 100644 --- a/routes/content-guidelines/components/block-guideline-modal.tsx +++ b/routes/content-guidelines/components/block-guideline-modal.tsx @@ -101,7 +101,7 @@ export default function BlockGuidelineModal( { createSuccessNotice( sprintf( /* translators: %s: Block label. */ - __( 'Block guideline "%s"' ), + __( 'Block guideline %s' ), value ? 'saved' : 'removed' ), { type: 'snackbar' } From b2f42639763e08335f026ddf9ef7b8a5dd65aa8b Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Mon, 9 Mar 2026 14:40:14 +0600 Subject: [PATCH 14/46] Add . after success notice text --- routes/content-guidelines/components/block-guideline-modal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/content-guidelines/components/block-guideline-modal.tsx b/routes/content-guidelines/components/block-guideline-modal.tsx index 729b0a4e2088d5..baec29c79ff8c0 100644 --- a/routes/content-guidelines/components/block-guideline-modal.tsx +++ b/routes/content-guidelines/components/block-guideline-modal.tsx @@ -101,7 +101,7 @@ export default function BlockGuidelineModal( { createSuccessNotice( sprintf( /* translators: %s: Block label. */ - __( 'Block guideline %s' ), + __( 'Block guideline %s.' ), value ? 'saved' : 'removed' ), { type: 'snackbar' } From a0b531d96b734a715b1c7630f3e4cd7c6655c66c Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Mon, 9 Mar 2026 14:42:03 +0600 Subject: [PATCH 15/46] Remove undefined keys from block entries --- routes/content-guidelines/store.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routes/content-guidelines/store.ts b/routes/content-guidelines/store.ts index 9287f066d766ff..963c9d956b7e46 100644 --- a/routes/content-guidelines/store.ts +++ b/routes/content-guidelines/store.ts @@ -114,6 +114,10 @@ function reducer( [ action.blockName ]: action.value, }; + if ( action.value === undefined ) { + delete blocks[ action.blockName ]; + } + return { ...state, categories: { From ecc1312dadc804fdd17f5f8d59b83e41e0ccc72b Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Mon, 9 Mar 2026 14:46:15 +0600 Subject: [PATCH 16/46] Add clarifying comment for setting empty string to delete a block guideline --- routes/content-guidelines/components/block-guideline-modal.tsx | 2 ++ routes/content-guidelines/components/block-guidelines.tsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/routes/content-guidelines/components/block-guideline-modal.tsx b/routes/content-guidelines/components/block-guideline-modal.tsx index baec29c79ff8c0..7111b24b0986e8 100644 --- a/routes/content-guidelines/components/block-guideline-modal.tsx +++ b/routes/content-guidelines/components/block-guideline-modal.tsx @@ -184,6 +184,8 @@ export default function BlockGuidelineModal( { + + + ); + } ) } + + { /* eslint-enable jsx-a11y/no-redundant-roles */ } + + + ); +} diff --git a/routes/content-guidelines/stage.tsx b/routes/content-guidelines/stage.tsx index ba43312a95e2b5..209875f17d63c1 100644 --- a/routes/content-guidelines/stage.tsx +++ b/routes/content-guidelines/stage.tsx @@ -18,6 +18,7 @@ import GuidelineAccordionForm from './components/guideline-accordion-form'; import { fetchContentGuidelines } from './api'; import BlockGuidelines from './components/block-guidelines'; import { bootstrapBlockRegistry } from './bootstrap-block-registry'; +import ActionsSection from './components/actions-section'; // Bootstrap Core blocks so block icons are available (e.g. in Block Guidelines). bootstrapBlockRegistry(); @@ -149,6 +150,7 @@ function ContentGuidelinesPage() { } ) } { /* eslint-enable jsx-a11y/no-redundant-roles */ } + ) ) } diff --git a/routes/content-guidelines/style.scss b/routes/content-guidelines/style.scss index 5fbd80103f250d..b005e9962b7fab 100644 --- a/routes/content-guidelines/style.scss +++ b/routes/content-guidelines/style.scss @@ -27,3 +27,50 @@ align-items: center; margin-top: $grid-unit-20; } + +.content-guidelines__actions { + width: min(680px, 100%); + margin: $grid-unit-20 auto 0; +} + +.content-guidelines__actions-card { + padding: 0; + overflow: hidden; +} + +.content-guidelines__actions-list { + list-style: none; + padding: 0; + margin: 0; +} + +.content-guidelines__action-row { + padding: $grid-unit-20 $grid-unit-30; + align-items: center; + width: 100%; + box-sizing: border-box; + + > :first-child { + flex: 1; + min-width: 0; + } +} + +.content-guidelines__action-row--bordered { + border-bottom: 1px solid $gray-200; +} + +.content-guidelines__actions-card .components-button { + min-width: 130px; + justify-content: center; + font-size: 13px; + font-weight: 400; +} + +.content-guidelines__action-title { + color: $gray-900; +} + +.content-guidelines__action-description { + color: $gray-700; +} From 3eac082f6bc792e2e7614d2ff46a8c1af3b62e8f Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Wed, 4 Mar 2026 19:15:28 +0000 Subject: [PATCH 18/46] Adds simple import and export function --- routes/content-guidelines/api.ts | 118 +++++++++++++++++- .../components/actions-section.tsx | 56 +++++++++ routes/content-guidelines/store.ts | 2 +- routes/content-guidelines/types.ts | 4 + 4 files changed, 178 insertions(+), 2 deletions(-) diff --git a/routes/content-guidelines/api.ts b/routes/content-guidelines/api.ts index 32f38a5a010030..bb862f6100f8c2 100644 --- a/routes/content-guidelines/api.ts +++ b/routes/content-guidelines/api.ts @@ -3,12 +3,37 @@ */ import apiFetch from '@wordpress/api-fetch'; import { dispatch, select } from '@wordpress/data'; +import { __, sprintf } from '@wordpress/i18n'; +import { store as noticesStore } from '@wordpress/notices'; /** * Internal dependencies */ import { STORE_NAME } from './store'; -import type { Categories, RestGuidelinesResponse } from './types'; +import type { + Categories, + RestGuidelinesResponse, + GuidelinesImportData, +} from './types'; + +const FLAT_CATEGORIES = [ 'site', 'copy', 'images', 'additional' ] as const; + +function getErrorMessage( error: unknown ): string { + return error instanceof Error ? error.message : __( 'Unknown error.' ); +} + +function isValidGuidelinesImport( + data: unknown +): data is GuidelinesImportData { + return ( + !! data && + typeof data === 'object' && + 'guideline_categories' in data && + typeof ( data as Record< string, unknown > ).guideline_categories === + 'object' && + ( data as Record< string, unknown > ).guideline_categories !== null + ); +} export async function fetchContentGuidelines(): Promise< RestGuidelinesResponse > { const { setFromResponse } = dispatch( STORE_NAME ) as { @@ -83,3 +108,94 @@ export async function saveContentGuidelines(): Promise< RestGuidelinesResponse > return response; } + +/** + * Opens file selector, reads the selected file and imports the content guidelines. + * @param file Content Guidelines JSON file + */ +export async function importContentGuidelines( file: File ): Promise< void > { + const { createErrorNotice } = dispatch( noticesStore ); + // @ts-ignore + const { setGuideline } = dispatch( STORE_NAME ); + + try { + const parsed: unknown = JSON.parse( await file.text() ); + + if ( ! isValidGuidelinesImport( parsed ) ) { + throw new Error( __( 'Invalid file format.' ) ); + } + + const { guideline_categories: contentGuidelinesCategories } = parsed; + + FLAT_CATEGORIES.forEach( ( guidelineCategory ) => { + const guidelines = + contentGuidelinesCategories[ guidelineCategory ]?.guidelines; + if ( typeof guidelines === 'string' ) { + setGuideline( guidelineCategory, guidelines ); + } + } ); + + await saveContentGuidelines(); + } catch ( e: unknown ) { + createErrorNotice( + sprintf( + /* translators: %s: Error message. */ + __( 'Failed to import content guidelines: %s' ), + getErrorMessage( e ) + ), + { type: 'snackbar' } + ); + } +} + +/** + * Exports the content guidelines as a JSON file. + */ +export function exportContentGuidelines(): void { + const { createSuccessNotice, createErrorNotice } = dispatch( noticesStore ); + + try { + const contentGuidelinesCategories = ( + select( STORE_NAME ) as { + getAllGuidelines: () => Categories; + } + ).getAllGuidelines(); + + const data = { + guideline_categories: Object.fromEntries( + FLAT_CATEGORIES.map( ( guidelineCategory ) => [ + guidelineCategory, + { + guidelines: + contentGuidelinesCategories[ guidelineCategory ], + }, + ] ) + ), + }; + + const blob = new Blob( [ JSON.stringify( data, null, 2 ) ], { + type: 'application/json', + } ); + const url = URL.createObjectURL( blob ); + const anchor = document.createElement( 'a' ); + anchor.href = url; + anchor.download = 'content-guidelines.json'; + document.body.appendChild( anchor ); + anchor.click(); + document.body.removeChild( anchor ); + URL.revokeObjectURL( url ); + + createSuccessNotice( __( 'Content guidelines exported.' ), { + type: 'snackbar', + } ); + } catch ( e: unknown ) { + createErrorNotice( + sprintf( + /* translators: %s: Error message. */ + __( 'Failed to export content guidelines: %s' ), + getErrorMessage( e ) + ), + { type: 'snackbar' } + ); + } +} diff --git a/routes/content-guidelines/components/actions-section.tsx b/routes/content-guidelines/components/actions-section.tsx index 559ebd21ffdc55..d9808d218c4800 100644 --- a/routes/content-guidelines/components/actions-section.tsx +++ b/routes/content-guidelines/components/actions-section.tsx @@ -10,6 +10,12 @@ import { __experimentalHStack as HStack, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; +import { useRef, useState } from '@wordpress/element'; + +/** + * Internal dependencies + */ +import { importContentGuidelines, exportContentGuidelines } from '../api'; const ACTIONS = [ { @@ -45,11 +51,59 @@ const ACTIONS = [ ]; export default function ActionsSection() { + const fileInputRef = useRef< HTMLInputElement >( null ); + const [ isImporting, setIsImporting ] = useState( false ); + + function handleImportClick() { + fileInputRef.current?.click(); + } + + async function handleFileChange( + event: React.ChangeEvent< HTMLInputElement > + ) { + const file = event.target.files?.[ 0 ]; + if ( ! file ) { + return; + } + event.target.value = ''; // allow re-importing the same file + setIsImporting( true ); + try { + await importContentGuidelines( file ); + } finally { + setIsImporting( false ); + } + } + + function handleExportClick() { + exportContentGuidelines(); + } + + const buttonProps: Partial< + Record< + string, + { onClick: () => void; isBusy?: boolean; disabled?: boolean } + > + > = { + import: { + onClick: handleImportClick, + isBusy: isImporting, + disabled: isImporting, + }, + export: { onClick: handleExportClick }, + }; + return ( { __( 'Actions' ) } + { /* * Disable reason: The `list` ARIA role is redundant but @@ -94,6 +148,8 @@ export default function ActionsSection() { __next40pxDefaultSize aria-label={ action.ariaLabel } aria-describedby={ descriptionId } + { ...( buttonProps[ action.slug ] ?? + {} ) } > { action.buttonLabel } diff --git a/routes/content-guidelines/store.ts b/routes/content-guidelines/store.ts index 963c9d956b7e46..c98d0ff9f74ec7 100644 --- a/routes/content-guidelines/store.ts +++ b/routes/content-guidelines/store.ts @@ -75,7 +75,7 @@ function parseResponse( }, }; - CATEGORIES.forEach( ( category ) => { + FLAT_CATEGORIES.forEach( ( category ) => { const guidelines = categoriesFromResponse?.[ category ]?.guidelines; if ( typeof guidelines === 'string' ) { result.categories[ category ] = guidelines; diff --git a/routes/content-guidelines/types.ts b/routes/content-guidelines/types.ts index cca251c8b1b34f..47be4a70870d74 100644 --- a/routes/content-guidelines/types.ts +++ b/routes/content-guidelines/types.ts @@ -28,6 +28,10 @@ export interface RestGuidelinesResponse { guideline_categories?: Record< string, BlockGuideline >; } +export interface GuidelinesImportData { + guideline_categories: Record< string, { guidelines?: string } >; +} + export interface GuidelineAccordionProps { title: string; description: string; From 110eec024404aaa23babec1d6eeb3edd63e99962 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Thu, 5 Mar 2026 12:19:50 +0000 Subject: [PATCH 19/46] Content Guidelines: Add manage access and revision screens --- routes/content-guidelines/api.ts | 50 ++++- .../components/actions-section.tsx | 4 + .../components/manage-access.tsx | 60 +++++ .../components/revision-history.tsx | 211 ++++++++++++++++++ routes/content-guidelines/stage.tsx | 106 +++++---- routes/content-guidelines/style.scss | 53 +++++ routes/content-guidelines/types.ts | 9 + 7 files changed, 452 insertions(+), 41 deletions(-) create mode 100644 routes/content-guidelines/components/manage-access.tsx create mode 100644 routes/content-guidelines/components/revision-history.tsx diff --git a/routes/content-guidelines/api.ts b/routes/content-guidelines/api.ts index bb862f6100f8c2..2a983ab914cad4 100644 --- a/routes/content-guidelines/api.ts +++ b/routes/content-guidelines/api.ts @@ -14,6 +14,7 @@ import type { Categories, RestGuidelinesResponse, GuidelinesImportData, + ContentGuidelinesRevision, } from './types'; const FLAT_CATEGORIES = [ 'site', 'copy', 'images', 'additional' ] as const; @@ -179,7 +180,7 @@ export function exportContentGuidelines(): void { const url = URL.createObjectURL( blob ); const anchor = document.createElement( 'a' ); anchor.href = url; - anchor.download = 'content-guidelines.json'; + anchor.download = 'guidelines.json'; document.body.appendChild( anchor ); anchor.click(); document.body.removeChild( anchor ); @@ -199,3 +200,50 @@ export function exportContentGuidelines(): void { ); } } + +export async function fetchContentGuidelinesRevisions( { + guidelinesId, + page = 1, + perPage = 10, + search, +}: { + guidelinesId: number; + page?: number; + perPage?: number; + search?: string; +} ): Promise< { + revisions: ContentGuidelinesRevision[]; + total: number; + totalPages: number; +} > { + const params = new URLSearchParams( { + page: String( page ), + per_page: String( perPage ), + _embed: 'author', + ...( search ? { search } : {} ), + } ); + + const response = ( await apiFetch( { + path: `/wp/v2/content-guidelines/${ guidelinesId }/revisions?${ params }`, + parse: false, + } ) ) as Response; + + const revisions = ( await response.json() ) as ContentGuidelinesRevision[]; + const total = parseInt( response.headers.get( 'X-WP-Total' ) ?? '0', 10 ); + const totalPages = parseInt( + response.headers.get( 'X-WP-TotalPages' ) ?? '0', + 10 + ); + + return { revisions, total, totalPages }; +} + +export async function restoreContentGuidelinesRevision( + guidelinesId: number, + revisionId: number +): Promise< RestGuidelinesResponse > { + return ( await apiFetch( { + path: `/wp/v2/content-guidelines/${ guidelinesId }/revisions/${ revisionId }/restore`, + method: 'POST', + } ) ) as RestGuidelinesResponse; +} diff --git a/routes/content-guidelines/components/actions-section.tsx b/routes/content-guidelines/components/actions-section.tsx index d9808d218c4800..c73f762ba600eb 100644 --- a/routes/content-guidelines/components/actions-section.tsx +++ b/routes/content-guidelines/components/actions-section.tsx @@ -4,6 +4,7 @@ import { Button, Card, + useNavigator, __experimentalText as Text, __experimentalHeading as Heading, __experimentalVStack as VStack, @@ -51,6 +52,7 @@ const ACTIONS = [ ]; export default function ActionsSection() { + const { goTo } = useNavigator(); const fileInputRef = useRef< HTMLInputElement >( null ); const [ isImporting, setIsImporting ] = useState( false ); @@ -90,6 +92,8 @@ export default function ActionsSection() { disabled: isImporting, }, export: { onClick: handleExportClick }, + 'manage-access': { onClick: () => goTo( '/manage-access' ) }, + revert: { onClick: () => goTo( '/revision-history' ) }, }; return ( diff --git a/routes/content-guidelines/components/manage-access.tsx b/routes/content-guidelines/components/manage-access.tsx new file mode 100644 index 00000000000000..d8fd04bee09071 --- /dev/null +++ b/routes/content-guidelines/components/manage-access.tsx @@ -0,0 +1,60 @@ +/** + * WordPress dependencies + */ +import { + Card, + ToggleControl, + __experimentalText as Text, + __experimentalHeading as Heading, + __experimentalVStack as VStack, + Navigator, +} from '@wordpress/components'; +import { __, sprintf } from '@wordpress/i18n'; +import { useState } from '@wordpress/element'; +import { arrowLeft } from '@wordpress/icons'; + +export default function ManageAccess() { + const [ allowExternalAccess, setAllowExternalAccess ] = useState( true ); + + return ( +
+ + { __( 'Manage access' ) } + + + + { __( 'Control who can access your content guidelines.' ) } + + + + + + { __( 'External AI agents…' ) } + + + { sprintf( + /* translators: %s is a URL path — do not translate */ + __( + 'Share your guidelines with outside AI tools by publishing them to %s. This helps them understand your site and create content that fits.' + ), + '/.well-known/content-guidelines' + ) } + + + + +
+ ); +} diff --git a/routes/content-guidelines/components/revision-history.tsx b/routes/content-guidelines/components/revision-history.tsx new file mode 100644 index 00000000000000..2905f8fa1e41e1 --- /dev/null +++ b/routes/content-guidelines/components/revision-history.tsx @@ -0,0 +1,211 @@ +/** + * WordPress dependencies + */ +import { + Button, + Modal, + Navigator, + __experimentalText as Text, + __experimentalVStack as VStack, + __experimentalHStack as HStack, +} from '@wordpress/components'; +import { DataViews } from '@wordpress/dataviews'; +import { __, sprintf } from '@wordpress/i18n'; +import { useEffect, useState } from '@wordpress/element'; +import { useSelect } from '@wordpress/data'; +import { arrowLeft } from '@wordpress/icons'; +import type { View, Field, Action } from '@wordpress/dataviews'; + +/** + * Internal dependencies + */ +import { STORE_NAME } from '../store'; +import { + fetchContentGuidelinesRevisions, + restoreContentGuidelinesRevision, +} from '../api'; +import type { ContentGuidelinesRevision } from '../types'; + +const DEFAULT_VIEW: View = { + type: 'table' as const, + fields: [ 'date', 'author' ], + page: 1, + perPage: 10, +}; + +function formatDate( dateString: string ): string { + return new Intl.DateTimeFormat( undefined, { + year: 'numeric', + month: 'short', + day: 'numeric', + hour: 'numeric', + minute: '2-digit', + hour12: true, + } ).format( new Date( dateString ) ); +} + +const FIELDS: Field< ContentGuidelinesRevision >[] = [ + { + id: 'date', + label: __( 'Date' ), + getValue: ( { item } ) => item.date, + render: ( { item } ) => ( + + ), + enableSorting: false, + enableHiding: false, + enableGlobalSearch: false, + }, + { + id: 'author', + label: __( 'User' ), + getValue: ( { item } ) => + item._embedded?.author?.[ 0 ]?.name ?? __( 'Unknown' ), + render: ( { item } ) => ( + + { item._embedded?.author?.[ 0 ]?.name ?? __( 'Unknown' ) } + + ), + enableSorting: false, + enableHiding: false, + enableGlobalSearch: true, + }, +]; + +export default function RevisionHistory() { + const [ view, setView ] = useState< View >( DEFAULT_VIEW ); + const [ revisions, setRevisions ] = useState< ContentGuidelinesRevision[] >( + [] + ); + const [ total, setTotal ] = useState( 0 ); + const [ totalPages, setTotalPages ] = useState( 0 ); + const [ isLoading, setIsLoading ] = useState( false ); + const [ revisionToRestore, setRevisionToRestore ] = + useState< ContentGuidelinesRevision | null >( null ); + const [ isRestoring, setIsRestoring ] = useState( false ); + + // @ts-ignore + const guidelinesId = useSelect( + // @ts-ignore + ( select ) => select( STORE_NAME ).getId(), + [] + ) as number | null; + + useEffect( () => { + if ( ! guidelinesId ) { + return; + } + setIsLoading( true ); + fetchContentGuidelinesRevisions( { + guidelinesId, + page: view.page, + perPage: view.perPage, + search: view.search, + } ) + .then( ( result ) => { + setRevisions( result.revisions ); + setTotal( result.total ); + setTotalPages( result.totalPages ); + } ) + .finally( () => setIsLoading( false ) ); + }, [ guidelinesId, view.page, view.perPage, view.search ] ); + + const actions: Action< ContentGuidelinesRevision >[] = [ + { + id: 'restore-revision', + label: __( 'Restore' ), + callback: ( items ) => setRevisionToRestore( items[ 0 ] ), + }, + ]; + + async function handleRestore() { + if ( ! guidelinesId || ! revisionToRestore ) { + return; + } + setIsRestoring( true ); + try { + await restoreContentGuidelinesRevision( + guidelinesId, + revisionToRestore.id + ); + setRevisionToRestore( null ); + setView( ( v ) => ( { ...v, page: 1 } ) ); + } finally { + setIsRestoring( false ); + } + } + + return ( +
+ + { __( 'Revision history' ) } + + + + { __( 'Use a previous version of your content guidelines.' ) } + + + String( item.id ) } + /> + + { revisionToRestore && ( + setRevisionToRestore( null ) } + size="medium" + > + + + { sprintf( + /* translators: %s: formatted revision date */ + __( + 'You are about to restore the content guidelines from %s.' + ), + formatDate( revisionToRestore.date ) + ) } + + + { __( 'This action cannot be undone.' ) } + + + + + + + + ) } +
+ ); +} diff --git a/routes/content-guidelines/stage.tsx b/routes/content-guidelines/stage.tsx index 209875f17d63c1..d9f43d132d7030 100644 --- a/routes/content-guidelines/stage.tsx +++ b/routes/content-guidelines/stage.tsx @@ -6,7 +6,7 @@ import { Page } from '@wordpress/admin-ui'; import { __, sprintf } from '@wordpress/i18n'; import { createElement, useEffect, useState } from '@wordpress/element'; -import { Spinner } from '@wordpress/components'; +import { Spinner, Navigator } from '@wordpress/components'; import { Notice } from '@wordpress/ui'; /** @@ -19,6 +19,8 @@ import { fetchContentGuidelines } from './api'; import BlockGuidelines from './components/block-guidelines'; import { bootstrapBlockRegistry } from './bootstrap-block-registry'; import ActionsSection from './components/actions-section'; +import ManageAccess from './components/manage-access'; +import RevisionHistory from './components/revision-history'; // Bootstrap Core blocks so block icons are available (e.g. in Block Guidelines). bootstrapBlockRegistry(); @@ -106,52 +108,76 @@ function ContentGuidelinesPage() { ) : ( ! error && ( -
- { /* - * Disable reason: The `list` ARIA role is redundant but - * Safari+VoiceOver won't announce the list otherwise. - */ - /* eslint-disable jsx-a11y/no-redundant-roles */ } -
    - { GUIDELINE_ITEMS.map( ( item ) => { - const contentId = `content-guidelines-${ item.slug }`; - const headingId = `content-guidelines-${ item.slug }-heading`; - const descriptionId = `content-guidelines-${ item.slug }-description`; + + +
    + { /* + * Disable reason: The `list` ARIA role is redundant but + * Safari+VoiceOver won't announce the list otherwise. + */ + /* eslint-disable jsx-a11y/no-redundant-roles */ } +
      + { GUIDELINE_ITEMS.map( ( item ) => { + const contentId = `content-guidelines-${ item.slug }`; + const headingId = `content-guidelines-${ item.slug }-heading`; + const descriptionId = `content-guidelines-${ item.slug }-description`; - return ( -
    • -
      - - { item.slug === 'blocks' ? ( - - ) : ( - + - ) } - -
      -
    • - ); - } ) } -
    - { /* eslint-enable jsx-a11y/no-redundant-roles */ } - -
    + > + { item.slug === + 'blocks' ? ( + + ) : ( + + ) } + +
+ + ); + } ) } + + { /* eslint-enable jsx-a11y/no-redundant-roles */ } + + + + + + + + + + ) ) } diff --git a/routes/content-guidelines/style.scss b/routes/content-guidelines/style.scss index b005e9962b7fab..f589e79ae1939b 100644 --- a/routes/content-guidelines/style.scss +++ b/routes/content-guidelines/style.scss @@ -74,3 +74,56 @@ .content-guidelines__action-description { color: $gray-700; } + +.content-guidelines__manage-access { + padding: $grid-unit-30; + display: flex; + flex-direction: column; + gap: $grid-unit-20; +} + +.content-guidelines__manage-access-back { + align-self: flex-start; + margin-left: -$grid-unit-15; +} + +.content-guidelines__manage-access-card { + padding: $grid-unit-20 $grid-unit-30; +} + +.content-guidelines__revision-history { + padding: $grid-unit-30; + display: flex; + flex-direction: column; + gap: $grid-unit-20; + + // DataViews adds its own horizontal padding ($grid-unit-30) on the toolbar + // and first/last table columns, which would double up on our container padding. + // Override to zero so everything aligns with our container's padding. + .dataviews__view-actions, + .dataviews-filters__container { + padding-left: 0; + padding-right: 0; + } + + .dataviews-view-table { + td:first-child, + th:first-child { + padding-left: 0; + } + + td:last-child, + th:last-child { + padding-right: 0; + } + } +} + +.content-guidelines__revision-history-back { + align-self: flex-start; + margin-left: -$grid-unit-15; +} + +.content-guidelines__restore-modal-actions { + margin-top: $grid-unit-30; +} diff --git a/routes/content-guidelines/types.ts b/routes/content-guidelines/types.ts index 47be4a70870d74..9035f365cfa85a 100644 --- a/routes/content-guidelines/types.ts +++ b/routes/content-guidelines/types.ts @@ -41,6 +41,15 @@ export interface GuidelineAccordionProps { descriptionId?: string; } +export interface ContentGuidelinesRevision { + id: number; + date: string; + author: number; + _embedded?: { + author: Array< { name: string } >; + }; +} + export interface GuidelineAccordionFormProps { slug: string; contentId?: string; // Used for a11y. From 2db272d0029b3b9da447e026edd2231132622e98 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Thu, 5 Mar 2026 13:58:00 +0000 Subject: [PATCH 20/46] Content Guidelines: Search in revision history screen --- ...ontent-guidelines-revisions-controller.php | 9 +++++ .../components/revision-history.tsx | 39 ++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php index a77e0bfcb2120f..4592e801394b9c 100644 --- a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php +++ b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php @@ -103,6 +103,15 @@ public function prepare_item_for_response( $item, $request ) { $response->set_data( $data ); } + // Add embeddable author link to get author name in revision history screen + if ( ! empty( $item->post_author ) ) { + $response->add_link( + 'author', + rest_url( 'wp/v2/users/' . $item->post_author ), + array( 'embeddable' => true ) + ); + } + return $response; } diff --git a/routes/content-guidelines/components/revision-history.tsx b/routes/content-guidelines/components/revision-history.tsx index 2905f8fa1e41e1..e49f6c7949db37 100644 --- a/routes/content-guidelines/components/revision-history.tsx +++ b/routes/content-guidelines/components/revision-history.tsx @@ -11,7 +11,7 @@ import { } from '@wordpress/components'; import { DataViews } from '@wordpress/dataviews'; import { __, sprintf } from '@wordpress/i18n'; -import { useEffect, useState } from '@wordpress/element'; +import { useEffect, useMemo, useState } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { arrowLeft } from '@wordpress/icons'; import type { View, Field, Action } from '@wordpress/dataviews'; @@ -54,7 +54,7 @@ const FIELDS: Field< ContentGuidelinesRevision >[] = [ ), enableSorting: false, enableHiding: false, - enableGlobalSearch: false, + enableGlobalSearch: true, }, { id: 'author', @@ -100,7 +100,6 @@ export default function RevisionHistory() { guidelinesId, page: view.page, perPage: view.perPage, - search: view.search, } ) .then( ( result ) => { setRevisions( result.revisions ); @@ -108,7 +107,22 @@ export default function RevisionHistory() { setTotalPages( result.totalPages ); } ) .finally( () => setIsLoading( false ) ); - }, [ guidelinesId, view.page, view.perPage, view.search ] ); + }, [ guidelinesId, view.page, view.perPage ] ); + + // Filter revisions based on search term in the view. This is done client-side + const displayedRevisions = useMemo( () => { + const term = view.search?.trim().toLowerCase(); + if ( ! term ) { + return revisions; + } + return revisions.filter( ( revision ) => { + const author = ( + revision._embedded?.author?.[ 0 ]?.name ?? '' + ).toLowerCase(); + const date = formatDate( revision.date ).toLowerCase(); + return author.includes( term ) || date.includes( term ); + } ); + }, [ revisions, view.search ] ); const actions: Action< ContentGuidelinesRevision >[] = [ { @@ -153,13 +167,26 @@ export default function RevisionHistory() { String( item.id ) } /> From 92bcadcc704de090677692ceb303ea1bbafb2e87 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Fri, 6 Mar 2026 10:23:17 +0000 Subject: [PATCH 21/46] Content guidelines: Use filterSortAndPaginate from DataViews to implement search in guidelines revision history screen --- .../components/revision-history.tsx | 52 +++++-------------- 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/routes/content-guidelines/components/revision-history.tsx b/routes/content-guidelines/components/revision-history.tsx index e49f6c7949db37..5c9c75fbde6c51 100644 --- a/routes/content-guidelines/components/revision-history.tsx +++ b/routes/content-guidelines/components/revision-history.tsx @@ -9,9 +9,9 @@ import { __experimentalVStack as VStack, __experimentalHStack as HStack, } from '@wordpress/components'; -import { DataViews } from '@wordpress/dataviews'; +import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews'; import { __, sprintf } from '@wordpress/i18n'; -import { useEffect, useMemo, useState } from '@wordpress/element'; +import { useEffect, useState } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { arrowLeft } from '@wordpress/icons'; import type { View, Field, Action } from '@wordpress/dataviews'; @@ -48,7 +48,7 @@ const FIELDS: Field< ContentGuidelinesRevision >[] = [ { id: 'date', label: __( 'Date' ), - getValue: ( { item } ) => item.date, + getValue: ( { item } ) => formatDate( item.date ), render: ( { item } ) => ( ), @@ -77,12 +77,11 @@ export default function RevisionHistory() { const [ revisions, setRevisions ] = useState< ContentGuidelinesRevision[] >( [] ); - const [ total, setTotal ] = useState( 0 ); - const [ totalPages, setTotalPages ] = useState( 0 ); const [ isLoading, setIsLoading ] = useState( false ); const [ revisionToRestore, setRevisionToRestore ] = useState< ContentGuidelinesRevision | null >( null ); const [ isRestoring, setIsRestoring ] = useState( false ); + const [ refetchKey, setRefetchKey ] = useState( 0 ); // @ts-ignore const guidelinesId = useSelect( @@ -98,31 +97,19 @@ export default function RevisionHistory() { setIsLoading( true ); fetchContentGuidelinesRevisions( { guidelinesId, - page: view.page, - perPage: view.perPage, + perPage: 100, } ) .then( ( result ) => { setRevisions( result.revisions ); - setTotal( result.total ); - setTotalPages( result.totalPages ); } ) .finally( () => setIsLoading( false ) ); - }, [ guidelinesId, view.page, view.perPage ] ); + }, [ guidelinesId, refetchKey ] ); - // Filter revisions based on search term in the view. This is done client-side - const displayedRevisions = useMemo( () => { - const term = view.search?.trim().toLowerCase(); - if ( ! term ) { - return revisions; - } - return revisions.filter( ( revision ) => { - const author = ( - revision._embedded?.author?.[ 0 ]?.name ?? '' - ).toLowerCase(); - const date = formatDate( revision.date ).toLowerCase(); - return author.includes( term ) || date.includes( term ); - } ); - }, [ revisions, view.search ] ); + const { data: displayedRevisions, paginationInfo } = filterSortAndPaginate( + revisions, + view, + FIELDS + ); const actions: Action< ContentGuidelinesRevision >[] = [ { @@ -143,7 +130,7 @@ export default function RevisionHistory() { revisionToRestore.id ); setRevisionToRestore( null ); - setView( ( v ) => ( { ...v, page: 1 } ) ); + setRefetchKey( ( k ) => k + 1 ); } finally { setIsRestoring( false ); } @@ -173,20 +160,7 @@ export default function RevisionHistory() { onChangeView={ setView } actions={ actions } isLoading={ isLoading } - paginationInfo={ - view.search - ? { - totalItems: displayedRevisions.length, - totalPages: Math.max( - 1, - Math.ceil( - displayedRevisions.length / - ( view.perPage ?? 10 ) - ) - ), - } - : { totalItems: total, totalPages } - } + paginationInfo={ paginationInfo } defaultLayouts={ { table: {} } } getItemId={ ( item ) => String( item.id ) } /> From e5fee18c40ed41ed9de0d9d430e535b676c3065c Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Fri, 6 Mar 2026 10:26:54 +0000 Subject: [PATCH 22/46] Content guidelines: Hide Manage Access action button for MVP --- routes/content-guidelines/components/actions-section.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/routes/content-guidelines/components/actions-section.tsx b/routes/content-guidelines/components/actions-section.tsx index c73f762ba600eb..2062523c6e251f 100644 --- a/routes/content-guidelines/components/actions-section.tsx +++ b/routes/content-guidelines/components/actions-section.tsx @@ -35,13 +35,6 @@ const ACTIONS = [ buttonLabel: __( 'Download' ), ariaLabel: __( 'Export content guidelines' ), }, - { - slug: 'manage-access', - title: __( 'Manage access' ), - description: __( 'Control who can access your content guidelines.' ), - buttonLabel: __( 'Manage' ), - ariaLabel: __( 'Manage access to content guidelines' ), - }, { slug: 'revert', title: __( 'Revert' ), @@ -92,6 +85,8 @@ export default function ActionsSection() { disabled: isImporting, }, export: { onClick: handleExportClick }, + // TODO: Manage access ACTTION is removed but the route exists for future implementation + // without duplicating the work. 'manage-access': { onClick: () => goTo( '/manage-access' ) }, revert: { onClick: () => goTo( '/revision-history' ) }, }; From 056cb568156aa6d3f1966377a477ffbc8858fc03 Mon Sep 17 00:00:00 2001 From: Ahmed Sayeed Wasif Date: Fri, 6 Mar 2026 12:40:23 +0600 Subject: [PATCH 23/46] Improve spacing --- .../components/actions-section.tsx | 22 +++++++------- .../components/manage-access.tsx | 15 ++++++---- routes/content-guidelines/stage.tsx | 10 +++++-- routes/content-guidelines/style.scss | 30 ++++++++++++------- 4 files changed, 46 insertions(+), 31 deletions(-) diff --git a/routes/content-guidelines/components/actions-section.tsx b/routes/content-guidelines/components/actions-section.tsx index 2062523c6e251f..0c349261703a55 100644 --- a/routes/content-guidelines/components/actions-section.tsx +++ b/routes/content-guidelines/components/actions-section.tsx @@ -92,8 +92,8 @@ export default function ActionsSection() { }; return ( - - + + { __( 'Actions' ) } - { ACTIONS.map( ( action, index ) => { + { ACTIONS.map( ( action ) => { const descriptionId = `content-guidelines-action-${ action.slug }-description`; return ( -
  • +
  • { action.title } @@ -143,8 +141,8 @@ export default function ActionsSection() { + + + + ) } ); } diff --git a/routes/content-guidelines/style.scss b/routes/content-guidelines/style.scss index 0b2b9760294480..587f750fe6338d 100644 --- a/routes/content-guidelines/style.scss +++ b/routes/content-guidelines/style.scss @@ -137,6 +137,7 @@ padding-left: $grid-unit-10; } -.content-guidelines__restore-modal-actions { +.content-guidelines__restore-modal-actions, +.content-guidelines__import-modal-actions { margin-top: $grid-unit-30; } From f75d9f458147b34990a4105a13398906f869f788 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Mon, 9 Mar 2026 17:48:28 +0000 Subject: [PATCH 33/46] Content guidelines: Updates modal sequence and copy --- .../components/actions-section.tsx | 30 ++++++++++--------- .../components/revision-history.tsx | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/routes/content-guidelines/components/actions-section.tsx b/routes/content-guidelines/components/actions-section.tsx index 882b756d63764a..3162d6fc767019 100644 --- a/routes/content-guidelines/components/actions-section.tsx +++ b/routes/content-guidelines/components/actions-section.tsx @@ -61,25 +61,27 @@ export default function ActionsSection() { const fileInputRef = useRef< HTMLInputElement >( null ); const [ isImporting, setIsImporting ] = useState( false ); const [ error, setError ] = useState< string | null >( null ); - const [ isImportModalOpen, setIsImportModalOpen ] = useState( false ); + const [ pendingImport, setPendingImport ] = useState< File | null >( null ); function handleImportClick() { - setIsImportModalOpen( true ); - } - - function handleModalContinue() { - setIsImportModalOpen( false ); fileInputRef.current?.click(); } - async function handleFileChange( - event: React.ChangeEvent< HTMLInputElement > - ) { + function handleFileChange( event: React.ChangeEvent< HTMLInputElement > ) { const file = event.target.files?.[ 0 ]; + event.target.value = ''; // allow re-selecting the same file if ( ! file ) { return; } - event.target.value = ''; // allow re-importing the same file + setPendingImport( file ); + } + + async function handleModalContinue() { + if ( ! pendingImport ) { + return; + } + const file = pendingImport; + setPendingImport( null ); setIsImporting( true ); try { await importContentGuidelines( file ); @@ -125,7 +127,7 @@ export default function ActionsSection() { import: { onClick: handleImportClick, isBusy: isImporting, - disabled: isImporting, + disabled: isImporting || !! pendingImport, }, export: { onClick: handleExportClick }, revert: { onClick: () => goTo( '/revision-history' ) }, @@ -208,10 +210,10 @@ export default function ActionsSection() { { /* eslint-enable jsx-a11y/no-redundant-roles */ } - { isImportModalOpen && ( + { pendingImport && ( setIsImportModalOpen( false ) } + onRequestClose={ () => setPendingImport( null ) } size="medium" > @@ -232,7 +234,7 @@ export default function ActionsSection() { > diff --git a/routes/content-guidelines/components/revision-history.tsx b/routes/content-guidelines/components/revision-history.tsx index d6f813ce3d918d..f64d070dc615a2 100644 --- a/routes/content-guidelines/components/revision-history.tsx +++ b/routes/content-guidelines/components/revision-history.tsx @@ -233,7 +233,7 @@ export default function RevisionHistory() { { __( - 'A new version will be saved so you can always come back.' + 'You can undo this anytime from revision history.' ) } From cc31eeb114e922f5e22cf56f97d4f1355493b444 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Tue, 10 Mar 2026 10:37:36 +0000 Subject: [PATCH 34/46] Content guidelines: Addresses PR feedback to:1. Fix unnecessary try/catch 2. Remov unnecessary lint escapes 3. Use memoisation to avoid rerenders --- routes/content-guidelines/api.ts | 53 ++++++++----------- .../components/revision-history.tsx | 32 ++++++----- 2 files changed, 41 insertions(+), 44 deletions(-) diff --git a/routes/content-guidelines/api.ts b/routes/content-guidelines/api.ts index 1308fa6db65818..fc8d579da74b8c 100644 --- a/routes/content-guidelines/api.ts +++ b/routes/content-guidelines/api.ts @@ -116,44 +116,35 @@ export async function importContentGuidelines( file: File ): Promise< void > { const { setGuideline, setBlockGuideline } = dispatch( STORE_NAME ); const { createSuccessNotice } = dispatch( noticesStore ); - try { - const parsed: unknown = JSON.parse( await file.text() ); + const parsed: unknown = JSON.parse( await file.text() ); - if ( ! isValidGuidelinesImport( parsed ) ) { - throw new Error( __( 'Invalid file format.' ) ); - } - - const { guideline_categories: contentGuidelinesCategories } = parsed; + if ( ! isValidGuidelinesImport( parsed ) ) { + throw new Error( __( 'Invalid file format.' ) ); + } - FLAT_CATEGORIES.forEach( ( guidelineCategory ) => { - const guidelines = - contentGuidelinesCategories[ guidelineCategory ]?.guidelines; - if ( typeof guidelines === 'string' ) { - setGuideline( guidelineCategory, guidelines ); - } - } ); + const { guideline_categories: contentGuidelinesCategories } = parsed; - const blocksData = contentGuidelinesCategories.blocks; - if ( blocksData && typeof blocksData === 'object' ) { - Object.entries( blocksData ).forEach( - ( [ blockName, blockData ] ) => { - if ( - blockData && - typeof blockData.guidelines === 'string' - ) { - setBlockGuideline( blockName, blockData.guidelines ); - } - } - ); + FLAT_CATEGORIES.forEach( ( guidelineCategory ) => { + const guidelines = + contentGuidelinesCategories[ guidelineCategory ]?.guidelines; + if ( typeof guidelines === 'string' ) { + setGuideline( guidelineCategory, guidelines ); } + } ); - await saveContentGuidelines(); - createSuccessNotice( __( 'Content guidelines imported.' ), { - type: 'snackbar', + const blocksData = contentGuidelinesCategories.blocks; + if ( blocksData && typeof blocksData === 'object' ) { + Object.entries( blocksData ).forEach( ( [ blockName, blockData ] ) => { + if ( blockData && typeof blockData.guidelines === 'string' ) { + setBlockGuideline( blockName, blockData.guidelines ); + } } ); - } catch ( e: unknown ) { - throw e; } + + await saveContentGuidelines(); + createSuccessNotice( __( 'Content guidelines imported.' ), { + type: 'snackbar', + } ); } /** diff --git a/routes/content-guidelines/components/revision-history.tsx b/routes/content-guidelines/components/revision-history.tsx index f64d070dc615a2..b62bc849e87ade 100644 --- a/routes/content-guidelines/components/revision-history.tsx +++ b/routes/content-guidelines/components/revision-history.tsx @@ -55,12 +55,15 @@ export default function RevisionHistory() { const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore ); - // @ts-ignore const guidelinesId = useSelect( - // @ts-ignore - ( select ) => select( STORE_NAME ).getId(), + ( select ) => + ( + select( STORE_NAME ) as unknown as { + getId: () => number | null; + } + ).getId(), [] - ) as number | null; + ); useEffect( () => { if ( ! guidelinesId ) { @@ -86,7 +89,7 @@ export default function RevisionHistory() { } loadRevisions(); - }, [ guidelinesId, refetchKey ] ); + }, [ guidelinesId, refetchKey, createErrorNotice ] ); const authorElements = useMemo( () => { return [ @@ -148,13 +151,16 @@ export default function RevisionHistory() { fields ); - const actions: Action< ContentGuidelinesRevision >[] = [ - { - id: 'restore-revision', - label: __( 'Restore' ), - callback: ( items ) => setRevisionToRestore( items[ 0 ] ), - }, - ]; + const actions = useMemo< Action< ContentGuidelinesRevision >[] >( + () => [ + { + id: 'restore-revision', + label: __( 'Restore' ), + callback: ( items ) => setRevisionToRestore( items[ 0 ] ), + }, + ], + [ setRevisionToRestore ] + ); async function handleRestore() { if ( ! guidelinesId || ! revisionToRestore ) { @@ -194,7 +200,7 @@ export default function RevisionHistory() { { __( 'Use a previous version of your content guidelines.' ) } From 8f0815a1624283d9bff87d888d0d309806c7c892 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Tue, 10 Mar 2026 11:00:58 +0000 Subject: [PATCH 35/46] Content guidelines: Remove unnecessary overrides in CSS, where possible --- routes/content-guidelines/components/actions-section.tsx | 1 + routes/content-guidelines/style.scss | 9 +-------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/routes/content-guidelines/components/actions-section.tsx b/routes/content-guidelines/components/actions-section.tsx index 3162d6fc767019..75c05b4e735005 100644 --- a/routes/content-guidelines/components/actions-section.tsx +++ b/routes/content-guidelines/components/actions-section.tsx @@ -196,6 +196,7 @@ export default function ActionsSection() { @@ -197,6 +205,7 @@ export default function BlockGuidelineModal( { onClick={ () => handleSave( guidelineText ) } disabled={ ! canSubmit || isSaving } isBusy={ isSaving } + accessibleWhenDisabled > { submitButtonLabel } diff --git a/routes/content-guidelines/components/block-guidelines.tsx b/routes/content-guidelines/components/block-guidelines.tsx index 2616d2f279c587..4416ac5e1429cd 100644 --- a/routes/content-guidelines/components/block-guidelines.tsx +++ b/routes/content-guidelines/components/block-guidelines.tsx @@ -64,7 +64,9 @@ const fields = [ label: __( 'Icon' ), type: 'media' as const, render: ( { item } ) => ( - +
    + +
    ), }, { @@ -115,6 +117,11 @@ export default function BlockGuidelines() { const { setBlockGuideline } = useDispatch( STORE_NAME ); + const handleRowClick = ( id: string ) => { + setSelectedItem( id ); + setIsOpen( true ); + }; + const actions = useMemo( () => [ { @@ -122,8 +129,7 @@ export default function BlockGuidelines() { label: __( 'Edit' ), callback: ( items: DataRow[] ) => { const item = items[ 0 ]; - setSelectedItem( item.id ); - setIsOpen( true ); + handleRowClick( item.id ); }, }, { @@ -218,6 +224,10 @@ export default function BlockGuidelines() { fields={ fields } actions={ actions } config={ { perPageSizes: [ PER_PAGE ] } } + onChangeSelection={ ( items ) => { + const id = items[ 0 ]; + handleRowClick( id ); + } } defaultLayouts={ { list: {}, } } diff --git a/routes/content-guidelines/stage.tsx b/routes/content-guidelines/stage.tsx index 0fc1cd5e135acf..66a3766c66b012 100644 --- a/routes/content-guidelines/stage.tsx +++ b/routes/content-guidelines/stage.tsx @@ -21,13 +21,9 @@ import GuidelineAccordion from './components/guideline-accordion'; import GuidelineAccordionForm from './components/guideline-accordion-form'; import { fetchContentGuidelines } from './api'; import BlockGuidelines from './components/block-guidelines'; -import { bootstrapBlockRegistry } from './bootstrap-block-registry'; import ActionsSection from './components/actions-section'; import RevisionHistory from './components/revision-history'; -// Bootstrap Core blocks so block icons are available (e.g. in Block Guidelines). -bootstrapBlockRegistry(); - const GUIDELINE_ITEMS = [ { title: __( 'Site' ), From 150eb32c24f945c9321b4f75435262b8b300b414 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Tue, 10 Mar 2026 12:46:16 +0000 Subject: [PATCH 38/46] Content guidelines: Revert unnecessary changes brought in incorrect rebase --- .../components/block-guidelines.scss | 4 ++- routes/content-guidelines/store.ts | 30 +++++-------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/routes/content-guidelines/components/block-guidelines.scss b/routes/content-guidelines/components/block-guidelines.scss index 5acc3e46984b6b..e20416f90c5a58 100644 --- a/routes/content-guidelines/components/block-guidelines.scss +++ b/routes/content-guidelines/components/block-guidelines.scss @@ -3,10 +3,12 @@ .block-guidelines { margin-top: $grid-unit-30; - .dataviews-view-list__media-wrapper { + .block-guidelines__icon { display: flex; align-items: center; justify-content: center; + height: 100%; + width: 100%; } .dataviews-view-list__field-wrapper { diff --git a/routes/content-guidelines/store.ts b/routes/content-guidelines/store.ts index 1f298d96fff0d4..963c9d956b7e46 100644 --- a/routes/content-guidelines/store.ts +++ b/routes/content-guidelines/store.ts @@ -76,24 +76,13 @@ function parseResponse( }; CATEGORIES.forEach( ( category ) => { - const guidelines = ( - categoriesFromResponse as Record< - string, - { guidelines?: string } | undefined - > - )[ category ]?.guidelines; - + const guidelines = categoriesFromResponse?.[ category ]?.guidelines; if ( typeof guidelines === 'string' ) { - result.categories[ category as keyof typeof result.categories ] = - guidelines; + result.categories[ category ] = guidelines; } else if ( category === 'blocks' ) { - const blocks = ( categoriesFromResponse?.blocks ?? - {} ) as unknown as Record< string, { guidelines?: string } >; - - for ( const blockName in blocks ) { - ( result.categories.blocks as Record< string, string > )[ - blockName - ] = blocks[ blockName ]?.guidelines ?? ''; + const blocks = categoriesFromResponse?.blocks ?? {}; + for ( const [ blockName, blockData ] of Object.entries( blocks ) ) { + result.categories.blocks[ blockName ] = blockData?.guidelines; } } } ); @@ -116,7 +105,7 @@ function reducer( ...state, categories: { ...state.categories, - [ action.category as keyof Categories ]: action.value, + [ action.category ]: action.value, }, }; case 'SET_BLOCK_GUIDELINE': { @@ -147,12 +136,7 @@ const selectors = { state: ContentGuidelinesState, category: string ): string | Record< string, string > { - return ( - state.categories as unknown as Record< - string, - string | Record< string, string > - > - )[ category ]; + return state.categories[ category ]; }, getAllGuidelines( state: ContentGuidelinesState ): Categories { return state.categories; From e834df6f3b0a8d530a7764d82a14b4b01be82c46 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Tue, 10 Mar 2026 14:00:36 +0000 Subject: [PATCH 39/46] Content guidelines: Handle guidelines import error correctly by restoring previous version --- routes/content-guidelines/api.ts | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/routes/content-guidelines/api.ts b/routes/content-guidelines/api.ts index fc8d579da74b8c..3e1fc8dc3a1332 100644 --- a/routes/content-guidelines/api.ts +++ b/routes/content-guidelines/api.ts @@ -122,6 +122,13 @@ export async function importContentGuidelines( file: File ): Promise< void > { throw new Error( __( 'Invalid file format.' ) ); } + const guidelinesStore = select( STORE_NAME ) as unknown as { + getAllGuidelines: () => Categories; + getBlockGuidelines: () => Record< string, string >; + }; + const previousCategories = guidelinesStore.getAllGuidelines(); + const previousBlocks = { ...guidelinesStore.getBlockGuidelines() }; + const { guideline_categories: contentGuidelinesCategories } = parsed; FLAT_CATEGORIES.forEach( ( guidelineCategory ) => { @@ -141,10 +148,26 @@ export async function importContentGuidelines( file: File ): Promise< void > { } ); } - await saveContentGuidelines(); - createSuccessNotice( __( 'Content guidelines imported.' ), { - type: 'snackbar', - } ); + try { + await saveContentGuidelines(); + createSuccessNotice( __( 'Content guidelines imported.' ), { + type: 'snackbar', + } ); + } catch ( error ) { + FLAT_CATEGORIES.forEach( ( cat ) => { + setGuideline( cat, previousCategories[ cat ] ?? '' ); + } ); + + const currentBlocks = guidelinesStore.getBlockGuidelines(); + Object.keys( currentBlocks ).forEach( ( blockName ) => + setBlockGuideline( blockName, '' ) + ); + Object.entries( previousBlocks ).forEach( ( [ blockName, value ] ) => + setBlockGuideline( blockName, value ) + ); + + throw error; + } } /** From 9c89dd71971d60246e53d4f3bb39616ff56b1852 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Tue, 10 Mar 2026 14:15:18 +0000 Subject: [PATCH 40/46] Content guidelines: Pre-emptively add override for wordpress/ui Notice component --- .eslintrc.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 149d230349c77c..8d4aafcef7b1c9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -197,6 +197,12 @@ module.exports = { ], }, overrides: [ + { + files: [ 'routes/content-guidelines/**' ], + rules: { + '@wordpress/use-recommended-components': 'off', + }, + }, { files: [ '**/*.@(android|ios|native).js', From 44271e9509f0c5d6eedd496a0a9fd3b841bb5cad Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Tue, 10 Mar 2026 16:05:36 +0000 Subject: [PATCH 41/46] Content guidelines: Update copy for content guidelines import error --- routes/content-guidelines/api.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routes/content-guidelines/api.ts b/routes/content-guidelines/api.ts index 3e1fc8dc3a1332..4fd0bd56c04306 100644 --- a/routes/content-guidelines/api.ts +++ b/routes/content-guidelines/api.ts @@ -119,7 +119,11 @@ export async function importContentGuidelines( file: File ): Promise< void > { const parsed: unknown = JSON.parse( await file.text() ); if ( ! isValidGuidelinesImport( parsed ) ) { - throw new Error( __( 'Invalid file format.' ) ); + throw new Error( + __( + 'Check that your file contains valid JSON markup and try again.' + ) + ); } const guidelinesStore = select( STORE_NAME ) as unknown as { From b4b3cd3f9f51f5b8ac51a623506c2e332a64e5ca Mon Sep 17 00:00:00 2001 From: Aagam Shah Date: Tue, 10 Mar 2026 22:56:13 +0530 Subject: [PATCH 42/46] Guidelines: Rename "Content Guidelines" to "Guidelines" in all user-facing strings Rename the feature from "Content Guidelines" to "Guidelines" across all user-facing strings (page title, menu item, experiments toggle, notices, modals, aria labels, error messages) while keeping variable and file names unchanged. This aligns with the decision to use the shorter name while the feature remains experimental. Co-Authored-By: Claude Opus 4.6 --- ...ss-gutenberg-content-guidelines-post-type.php | 4 ++-- ...enberg-content-guidelines-rest-controller.php | 6 +++--- ...g-content-guidelines-revisions-controller.php | 4 ++-- lib/experimental/content-guidelines/load.php | 4 ++-- lib/experiments-page.php | 4 ++-- routes/content-guidelines/api.ts | 4 ++-- .../components/actions-section.tsx | 16 +++++++--------- .../components/revision-history.tsx | 6 +++--- routes/content-guidelines/route.ts | 2 +- routes/content-guidelines/stage.tsx | 4 ++-- 10 files changed, 26 insertions(+), 28 deletions(-) diff --git a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-post-type.php b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-post-type.php index 4b281db11bbce6..6758498bee6071 100644 --- a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-post-type.php +++ b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-post-type.php @@ -71,8 +71,8 @@ class Gutenberg_Content_Guidelines_Post_Type { public static function register() { $args = array( 'labels' => array( - 'name' => __( 'Content Guidelines', 'gutenberg' ), - 'singular_name' => __( 'Content Guidelines', 'gutenberg' ), + 'name' => __( 'Guidelines', 'gutenberg' ), + 'singular_name' => __( 'Guidelines', 'gutenberg' ), ), 'public' => false, 'publicly_queryable' => false, diff --git a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-rest-controller.php b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-rest-controller.php index f1d65ba4cf40fc..f2fe15e8dce268 100644 --- a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-rest-controller.php +++ b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-rest-controller.php @@ -111,7 +111,7 @@ public function get_guidelines_permissions_check( $request ) { // phpcs:ignore V if ( ! current_user_can( $post_type->cap->read ) ) { return new WP_Error( 'rest_forbidden', - __( 'Sorry, you are not allowed to view content guidelines.', 'gutenberg' ), + __( 'Sorry, you are not allowed to view guidelines.', 'gutenberg' ), array( 'status' => rest_authorization_required_code() ) ); } @@ -161,14 +161,14 @@ public function create_item( $request ) { if ( $existing ) { return new WP_Error( 'rest_guidelines_exists', - __( 'Content guidelines already exist. Use PATCH to update.', 'gutenberg' ), + __( 'Guidelines already exist. Use PATCH to update.', 'gutenberg' ), array( 'status' => 400 ) ); } $prepared = $this->prepare_item_for_database( $request ); $prepared->post_type = $this->post_type; - $prepared->post_title = __( 'Content Guidelines', 'gutenberg' ); + $prepared->post_title = __( 'Guidelines', 'gutenberg' ); if ( ! isset( $prepared->post_status ) ) { $prepared->post_status = 'draft'; diff --git a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php index 4592e801394b9c..4045f77eefe7e2 100644 --- a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php +++ b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php @@ -146,7 +146,7 @@ public function restore_revision_permissions_check( $request ) { if ( ! $parent || $this->parent_post_type !== $parent->post_type ) { return new WP_Error( 'rest_post_not_found', - __( 'Content guidelines not found.', 'gutenberg' ), + __( 'Guidelines not found.', 'gutenberg' ), array( 'status' => 404 ) ); } @@ -178,7 +178,7 @@ public function restore_revision( $request ) { if ( ! $parent || $this->parent_post_type !== $parent->post_type ) { return new WP_Error( 'rest_post_not_found', - __( 'Content guidelines not found.', 'gutenberg' ), + __( 'Guidelines not found.', 'gutenberg' ), array( 'status' => 404 ) ); } diff --git a/lib/experimental/content-guidelines/load.php b/lib/experimental/content-guidelines/load.php index e72f17eb4e42da..10447caf00c1a4 100644 --- a/lib/experimental/content-guidelines/load.php +++ b/lib/experimental/content-guidelines/load.php @@ -15,8 +15,8 @@ function gutenberg_register_content_guidelines_settings_submenu() { add_submenu_page( 'options-general.php', - __( 'Content Guidelines', 'gutenberg' ), - __( 'Content Guidelines', 'gutenberg' ), + __( 'Guidelines', 'gutenberg' ), + __( 'Guidelines', 'gutenberg' ), 'manage_options', 'content-guidelines-wp-admin', 'gutenberg_content_guidelines_wp_admin_render_page' diff --git a/lib/experiments-page.php b/lib/experiments-page.php index 99baa773955adf..158c5b39f7301e 100644 --- a/lib/experiments-page.php +++ b/lib/experiments-page.php @@ -211,12 +211,12 @@ function gutenberg_initialize_experiments_settings() { add_settings_field( 'gutenberg-content-guidelines', - __( 'Content Guidelines', 'gutenberg' ), + __( 'Guidelines', 'gutenberg' ), 'gutenberg_display_experiment_field', 'gutenberg-experiments', 'gutenberg_experiments_section', array( - 'label' => __( 'Enables Content Guidelines feature for managing editorial voice and tone guidelines under Settings.', 'gutenberg' ), + 'label' => __( 'Enables Guidelines feature for managing editorial voice and tone guidelines under Settings.', 'gutenberg' ), 'id' => 'gutenberg-content-guidelines', ) ); diff --git a/routes/content-guidelines/api.ts b/routes/content-guidelines/api.ts index 4fd0bd56c04306..6e2b97af99b27c 100644 --- a/routes/content-guidelines/api.ts +++ b/routes/content-guidelines/api.ts @@ -154,7 +154,7 @@ export async function importContentGuidelines( file: File ): Promise< void > { try { await saveContentGuidelines(); - createSuccessNotice( __( 'Content guidelines imported.' ), { + createSuccessNotice( __( 'Guidelines imported.' ), { type: 'snackbar', } ); } catch ( error ) { @@ -216,7 +216,7 @@ export function exportContentGuidelines(): void { 'application/json' ); - createSuccessNotice( __( 'Content guidelines exported.' ), { + createSuccessNotice( __( 'Guidelines exported.' ), { type: 'snackbar', } ); } diff --git a/routes/content-guidelines/components/actions-section.tsx b/routes/content-guidelines/components/actions-section.tsx index 75c05b4e735005..213abd3f81655e 100644 --- a/routes/content-guidelines/components/actions-section.tsx +++ b/routes/content-guidelines/components/actions-section.tsx @@ -34,25 +34,23 @@ const ACTIONS = [ { slug: 'import', title: __( 'Import' ), - description: __( - 'Upload a JSON file to import your content guidelines.' - ), + description: __( 'Upload a JSON file to import your guidelines.' ), buttonLabel: __( 'Upload' ), - ariaLabel: __( 'Import content guidelines' ), + ariaLabel: __( 'Import guidelines' ), }, { slug: 'export', title: __( 'Export' ), - description: __( 'Export your content guidelines to a JSON file.' ), + description: __( 'Export your guidelines to a JSON file.' ), buttonLabel: __( 'Download' ), - ariaLabel: __( 'Export content guidelines' ), + ariaLabel: __( 'Export guidelines' ), }, { slug: 'revert', title: __( 'Revert' ), - description: __( 'Use a previous version of your content guidelines.' ), + description: __( 'Use a previous version of your guidelines.' ), buttonLabel: __( 'View history' ), - ariaLabel: __( 'View history of content guidelines' ), + ariaLabel: __( 'View history of guidelines' ), }, ]; @@ -220,7 +218,7 @@ export default function ActionsSection() { { __( - 'Importing new guidelines will replace your current content guidelines.' + 'Importing new guidelines will replace your current one.' ) } diff --git a/routes/content-guidelines/components/revision-history.tsx b/routes/content-guidelines/components/revision-history.tsx index 6b375b822915af..0fca101474ff93 100644 --- a/routes/content-guidelines/components/revision-history.tsx +++ b/routes/content-guidelines/components/revision-history.tsx @@ -202,7 +202,7 @@ export default function RevisionHistory() { variant="muted" className="content-guidelines__revision-description" > - { __( 'Use a previous version of your content guidelines.' ) } + { __( 'Use a previous version of your guidelines.' ) } setRevisionToRestore( null ) } size="medium" > @@ -228,7 +228,7 @@ export default function RevisionHistory() { { sprintf( /* translators: %s: formatted revision date */ __( - 'You are about to restore the content guidelines from %s.' + 'You are about to restore the guidelines from %s.' ), dateI18n( getSettings().formats.datetimeAbbreviated, diff --git a/routes/content-guidelines/route.ts b/routes/content-guidelines/route.ts index 9c005bb96f646b..d901ef978291a4 100644 --- a/routes/content-guidelines/route.ts +++ b/routes/content-guidelines/route.ts @@ -10,5 +10,5 @@ import { bootstrapBlockRegistry } from './bootstrap-block-registry'; export const route = { beforeLoad: bootstrapBlockRegistry, - title: () => __( 'Content Guidelines' ), + title: () => __( 'Guidelines' ), }; diff --git a/routes/content-guidelines/stage.tsx b/routes/content-guidelines/stage.tsx index 66a3766c66b012..cca018a139f191 100644 --- a/routes/content-guidelines/stage.tsx +++ b/routes/content-guidelines/stage.tsx @@ -78,7 +78,7 @@ function ContentGuidelinesPage() { return ( { sprintf( /* translators: %s: Error message. */ - __( 'Error loading content guidelines: %s' ), + __( 'Error loading guidelines: %s' ), error ) } From 1241059f770481318973e14abfebe7e04d41900d Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Tue, 10 Mar 2026 17:31:22 +0000 Subject: [PATCH 43/46] Content guidelines: Change the text 'content guidelines' to 'guidelines' in user facing interfaces --- ...ss-gutenberg-content-guidelines-post-type.php | 4 ++-- ...enberg-content-guidelines-rest-controller.php | 6 +++--- ...g-content-guidelines-revisions-controller.php | 4 ++-- lib/experiments-page.php | 4 ++-- routes/content-guidelines/api.ts | 4 ++-- .../components/actions-section.tsx | 16 +++++++--------- .../components/revision-history.tsx | 6 +++--- routes/content-guidelines/route.ts | 2 +- routes/content-guidelines/stage.tsx | 4 ++-- 9 files changed, 24 insertions(+), 26 deletions(-) diff --git a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-post-type.php b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-post-type.php index 4b281db11bbce6..6758498bee6071 100644 --- a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-post-type.php +++ b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-post-type.php @@ -71,8 +71,8 @@ class Gutenberg_Content_Guidelines_Post_Type { public static function register() { $args = array( 'labels' => array( - 'name' => __( 'Content Guidelines', 'gutenberg' ), - 'singular_name' => __( 'Content Guidelines', 'gutenberg' ), + 'name' => __( 'Guidelines', 'gutenberg' ), + 'singular_name' => __( 'Guidelines', 'gutenberg' ), ), 'public' => false, 'publicly_queryable' => false, diff --git a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-rest-controller.php b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-rest-controller.php index f1d65ba4cf40fc..03d502f4001c21 100644 --- a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-rest-controller.php +++ b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-rest-controller.php @@ -111,7 +111,7 @@ public function get_guidelines_permissions_check( $request ) { // phpcs:ignore V if ( ! current_user_can( $post_type->cap->read ) ) { return new WP_Error( 'rest_forbidden', - __( 'Sorry, you are not allowed to view content guidelines.', 'gutenberg' ), + __( 'Sorry, you are not allowed to view the guidelines.', 'gutenberg' ), array( 'status' => rest_authorization_required_code() ) ); } @@ -161,14 +161,14 @@ public function create_item( $request ) { if ( $existing ) { return new WP_Error( 'rest_guidelines_exists', - __( 'Content guidelines already exist. Use PATCH to update.', 'gutenberg' ), + __( 'Guidelines already exist. Use PATCH to update.', 'gutenberg' ), array( 'status' => 400 ) ); } $prepared = $this->prepare_item_for_database( $request ); $prepared->post_type = $this->post_type; - $prepared->post_title = __( 'Content Guidelines', 'gutenberg' ); + $prepared->post_title = __( 'Guidelines', 'gutenberg' ); if ( ! isset( $prepared->post_status ) ) { $prepared->post_status = 'draft'; diff --git a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php index 4592e801394b9c..4045f77eefe7e2 100644 --- a/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php +++ b/lib/experimental/content-guidelines/class-gutenberg-content-guidelines-revisions-controller.php @@ -146,7 +146,7 @@ public function restore_revision_permissions_check( $request ) { if ( ! $parent || $this->parent_post_type !== $parent->post_type ) { return new WP_Error( 'rest_post_not_found', - __( 'Content guidelines not found.', 'gutenberg' ), + __( 'Guidelines not found.', 'gutenberg' ), array( 'status' => 404 ) ); } @@ -178,7 +178,7 @@ public function restore_revision( $request ) { if ( ! $parent || $this->parent_post_type !== $parent->post_type ) { return new WP_Error( 'rest_post_not_found', - __( 'Content guidelines not found.', 'gutenberg' ), + __( 'Guidelines not found.', 'gutenberg' ), array( 'status' => 404 ) ); } diff --git a/lib/experiments-page.php b/lib/experiments-page.php index 99baa773955adf..c42e758ca02713 100644 --- a/lib/experiments-page.php +++ b/lib/experiments-page.php @@ -211,12 +211,12 @@ function gutenberg_initialize_experiments_settings() { add_settings_field( 'gutenberg-content-guidelines', - __( 'Content Guidelines', 'gutenberg' ), + __( 'Guidelines', 'gutenberg' ), 'gutenberg_display_experiment_field', 'gutenberg-experiments', 'gutenberg_experiments_section', array( - 'label' => __( 'Enables Content Guidelines feature for managing editorial voice and tone guidelines under Settings.', 'gutenberg' ), + 'label' => __( 'Enables guidelines feature for managing editorial voice and tone guidelines under Settings.', 'gutenberg' ), 'id' => 'gutenberg-content-guidelines', ) ); diff --git a/routes/content-guidelines/api.ts b/routes/content-guidelines/api.ts index 4fd0bd56c04306..6e2b97af99b27c 100644 --- a/routes/content-guidelines/api.ts +++ b/routes/content-guidelines/api.ts @@ -154,7 +154,7 @@ export async function importContentGuidelines( file: File ): Promise< void > { try { await saveContentGuidelines(); - createSuccessNotice( __( 'Content guidelines imported.' ), { + createSuccessNotice( __( 'Guidelines imported.' ), { type: 'snackbar', } ); } catch ( error ) { @@ -216,7 +216,7 @@ export function exportContentGuidelines(): void { 'application/json' ); - createSuccessNotice( __( 'Content guidelines exported.' ), { + createSuccessNotice( __( 'Guidelines exported.' ), { type: 'snackbar', } ); } diff --git a/routes/content-guidelines/components/actions-section.tsx b/routes/content-guidelines/components/actions-section.tsx index 75c05b4e735005..501147c3bba438 100644 --- a/routes/content-guidelines/components/actions-section.tsx +++ b/routes/content-guidelines/components/actions-section.tsx @@ -34,25 +34,23 @@ const ACTIONS = [ { slug: 'import', title: __( 'Import' ), - description: __( - 'Upload a JSON file to import your content guidelines.' - ), + description: __( 'Upload a JSON file to import your guidelines.' ), buttonLabel: __( 'Upload' ), - ariaLabel: __( 'Import content guidelines' ), + ariaLabel: __( 'Import guidelines' ), }, { slug: 'export', title: __( 'Export' ), - description: __( 'Export your content guidelines to a JSON file.' ), + description: __( 'Export your guidelines to a JSON file.' ), buttonLabel: __( 'Download' ), - ariaLabel: __( 'Export content guidelines' ), + ariaLabel: __( 'Export guidelines' ), }, { slug: 'revert', title: __( 'Revert' ), - description: __( 'Use a previous version of your content guidelines.' ), + description: __( 'Use a previous version of your guidelines.' ), buttonLabel: __( 'View history' ), - ariaLabel: __( 'View history of content guidelines' ), + ariaLabel: __( 'View history of guidelines' ), }, ]; @@ -220,7 +218,7 @@ export default function ActionsSection() { { __( - 'Importing new guidelines will replace your current content guidelines.' + 'Importing new guidelines will replace your current guidelines.' ) } diff --git a/routes/content-guidelines/components/revision-history.tsx b/routes/content-guidelines/components/revision-history.tsx index 6b375b822915af..0fca101474ff93 100644 --- a/routes/content-guidelines/components/revision-history.tsx +++ b/routes/content-guidelines/components/revision-history.tsx @@ -202,7 +202,7 @@ export default function RevisionHistory() { variant="muted" className="content-guidelines__revision-description" > - { __( 'Use a previous version of your content guidelines.' ) } + { __( 'Use a previous version of your guidelines.' ) } setRevisionToRestore( null ) } size="medium" > @@ -228,7 +228,7 @@ export default function RevisionHistory() { { sprintf( /* translators: %s: formatted revision date */ __( - 'You are about to restore the content guidelines from %s.' + 'You are about to restore the guidelines from %s.' ), dateI18n( getSettings().formats.datetimeAbbreviated, diff --git a/routes/content-guidelines/route.ts b/routes/content-guidelines/route.ts index 9c005bb96f646b..d901ef978291a4 100644 --- a/routes/content-guidelines/route.ts +++ b/routes/content-guidelines/route.ts @@ -10,5 +10,5 @@ import { bootstrapBlockRegistry } from './bootstrap-block-registry'; export const route = { beforeLoad: bootstrapBlockRegistry, - title: () => __( 'Content Guidelines' ), + title: () => __( 'Guidelines' ), }; diff --git a/routes/content-guidelines/stage.tsx b/routes/content-guidelines/stage.tsx index 66a3766c66b012..cca018a139f191 100644 --- a/routes/content-guidelines/stage.tsx +++ b/routes/content-guidelines/stage.tsx @@ -78,7 +78,7 @@ function ContentGuidelinesPage() { return ( { sprintf( /* translators: %s: Error message. */ - __( 'Error loading content guidelines: %s' ), + __( 'Error loading guidelines: %s' ), error ) } From 58d7408f3009ba3c09f66303393964340f6bd8cb Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Tue, 10 Mar 2026 17:38:42 +0000 Subject: [PATCH 44/46] Content Guidelines: Remove lint override which is not live yet --- .eslintrc.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8d4aafcef7b1c9..149d230349c77c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -197,12 +197,6 @@ module.exports = { ], }, overrides: [ - { - files: [ 'routes/content-guidelines/**' ], - rules: { - '@wordpress/use-recommended-components': 'off', - }, - }, { files: [ '**/*.@(android|ios|native).js', From f88ac9e5cd565161fcdfec10e9164ec446aba397 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Tue, 10 Mar 2026 18:54:49 +0000 Subject: [PATCH 45/46] Content guidelines: Updates copy of import error notice and removes moving revision history columns feature --- routes/content-guidelines/components/actions-section.tsx | 2 +- routes/content-guidelines/components/revision-history.tsx | 1 + routes/content-guidelines/style.scss | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/routes/content-guidelines/components/actions-section.tsx b/routes/content-guidelines/components/actions-section.tsx index 501147c3bba438..c2c681e48d1796 100644 --- a/routes/content-guidelines/components/actions-section.tsx +++ b/routes/content-guidelines/components/actions-section.tsx @@ -88,7 +88,7 @@ export default function ActionsSection() { setError( sprintf( /* translators: %s: Error message. */ - __( 'We ran into a problem importing your guidelines: %s' ), + __( 'We ran into a problem importing your guidelines. %s' ), getErrorMessage( importError ) ) ); diff --git a/routes/content-guidelines/components/revision-history.tsx b/routes/content-guidelines/components/revision-history.tsx index 0fca101474ff93..8c917b61f3b44b 100644 --- a/routes/content-guidelines/components/revision-history.tsx +++ b/routes/content-guidelines/components/revision-history.tsx @@ -35,6 +35,7 @@ const DEFAULT_VIEW: View = { page: 1, perPage: 10, layout: { + enableMoving: false, styles: { author: { align: 'end' }, }, diff --git a/routes/content-guidelines/style.scss b/routes/content-guidelines/style.scss index 3c26054b0b2a6f..b21a97539ad3b6 100644 --- a/routes/content-guidelines/style.scss +++ b/routes/content-guidelines/style.scss @@ -113,6 +113,11 @@ td { padding: $grid-unit-20 $grid-unit-10; } + + thead th:has(.dataviews-view-table-header-button):first-child { + padding-left: 0; + } + .dataviews-view-table__cell-content-wrapper { max-width: 100%; } From dfd8932df809d6a01e3afe1cb50aeaee50b000b4 Mon Sep 17 00:00:00 2001 From: Mayank Chugh Date: Tue, 10 Mar 2026 19:58:29 +0000 Subject: [PATCH 46/46] Content guidelines: Updates snackbar/toast message copy --- .../content-guidelines/components/block-guideline-modal.tsx | 4 ++-- routes/content-guidelines/components/block-guidelines.tsx | 2 +- .../components/guideline-accordion-form.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/content-guidelines/components/block-guideline-modal.tsx b/routes/content-guidelines/components/block-guideline-modal.tsx index d3f649695dc34f..66897d0a55fdde 100644 --- a/routes/content-guidelines/components/block-guideline-modal.tsx +++ b/routes/content-guidelines/components/block-guideline-modal.tsx @@ -109,8 +109,8 @@ export default function BlockGuidelineModal( { setError( null ); createSuccessNotice( value - ? __( 'Block guideline saved.' ) - : __( 'Block guideline removed.' ), + ? __( 'Guidelines saved.' ) + : __( 'Guidelines removed.' ), { type: 'snackbar' } ); closeModal(); diff --git a/routes/content-guidelines/components/block-guidelines.tsx b/routes/content-guidelines/components/block-guidelines.tsx index 4416ac5e1429cd..c69ad8d5dda399 100644 --- a/routes/content-guidelines/components/block-guidelines.tsx +++ b/routes/content-guidelines/components/block-guidelines.tsx @@ -156,7 +156,7 @@ export default function BlockGuidelines() { saveContentGuidelines() .then( () => { setError( null ); - createSuccessNotice( __( 'Block guidelines removed.' ), { + createSuccessNotice( __( 'Guidelines removed.' ), { type: 'snackbar', } ); } ) diff --git a/routes/content-guidelines/components/guideline-accordion-form.tsx b/routes/content-guidelines/components/guideline-accordion-form.tsx index bf28046751a40e..0d64529d0c6c2d 100644 --- a/routes/content-guidelines/components/guideline-accordion-form.tsx +++ b/routes/content-guidelines/components/guideline-accordion-form.tsx @@ -80,7 +80,7 @@ export default function GuidelineAccordionForm( { saveContentGuidelines() .then( () => { setError( null ); - createSuccessNotice( __( 'Guideline category saved.' ), { + createSuccessNotice( __( 'Guidelines saved.' ), { type: 'snackbar', } ); } )