diff --git a/packages/block-library/src/editor.scss b/packages/block-library/src/editor.scss
index 49d89ff9e7c3f9..b813152d2f1900 100644
--- a/packages/block-library/src/editor.scss
+++ b/packages/block-library/src/editor.scss
@@ -36,6 +36,8 @@
@import "./separator/editor.scss";
@import "./shortcode/editor.scss";
@import "./site-logo/editor.scss";
+@import "./site-tagline/editor.scss";
+@import "./site-title/editor.scss";
@import "./social-link/editor.scss";
@import "./social-links/editor.scss";
@import "./spacer/editor.scss";
diff --git a/packages/block-library/src/site-tagline/block.json b/packages/block-library/src/site-tagline/block.json
index d18b9517241349..13ba84c9688c89 100644
--- a/packages/block-library/src/site-tagline/block.json
+++ b/packages/block-library/src/site-tagline/block.json
@@ -26,5 +26,6 @@
"__experimentalFontFamily": true,
"__experimentalTextTransform": true
}
- }
+ },
+ "editorStyle": "wp-block-site-tagline-editor"
}
diff --git a/packages/block-library/src/site-tagline/edit.js b/packages/block-library/src/site-tagline/edit.js
index 33c4c72aad9e98..209f110311bc0f 100644
--- a/packages/block-library/src/site-tagline/edit.js
+++ b/packages/block-library/src/site-tagline/edit.js
@@ -6,7 +6,8 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
-import { useEntityProp } from '@wordpress/core-data';
+import { useSelect } from '@wordpress/data';
+import { useEntityProp, store as coreStore } from '@wordpress/core-data';
import {
AlignmentControl,
useBlockProps,
@@ -22,11 +23,36 @@ export default function SiteTaglineEdit( { attributes, setAttributes } ) {
'site',
'description'
);
+ const { canUserEdit, readOnlySiteTagLine } = useSelect( ( select ) => {
+ const { canUser, getEntityRecord } = select( coreStore );
+ const siteData = getEntityRecord( 'root', '__unstableBase' );
+ return {
+ canUserEdit: canUser( 'update', 'settings' ),
+ readOnlySiteTagLine: siteData?.description,
+ };
+ }, [] );
const blockProps = useBlockProps( {
className: classnames( {
[ `has-text-align-${ textAlign }` ]: textAlign,
+ 'wp-block-site-tagline__placeholder':
+ ! canUserEdit && ! readOnlySiteTagLine,
} ),
} );
+ const siteTaglineContent = canUserEdit ? (
+
+ { readOnlySiteTagLine || __( 'Site Tagline placeholder' ) } +
+ ); return ( <>%2$s
', $wrapper_attributes, - get_bloginfo( 'description' ) + $site_tagline ); } diff --git a/packages/block-library/src/site-title/block.json b/packages/block-library/src/site-title/block.json index 3e16e62071a32e..c43f078daca445 100644 --- a/packages/block-library/src/site-title/block.json +++ b/packages/block-library/src/site-title/block.json @@ -34,5 +34,6 @@ "__experimentalFontStyle": true, "__experimentalFontWeight": true } - } + }, + "editorStyle": "wp-block-site-title-editor" } diff --git a/packages/block-library/src/site-title/edit/index.js b/packages/block-library/src/site-title/edit/index.js index c93b4287cdbf27..f666166da87886 100644 --- a/packages/block-library/src/site-title/edit/index.js +++ b/packages/block-library/src/site-title/edit/index.js @@ -6,7 +6,8 @@ import classnames from 'classnames'; /** * WordPress dependencies */ -import { useEntityProp } from '@wordpress/core-data'; +import { useSelect } from '@wordpress/data'; +import { useEntityProp, store as coreStore } from '@wordpress/core-data'; import { __ } from '@wordpress/i18n'; import { RichText, @@ -28,12 +29,48 @@ export default function SiteTitleEdit( { } ) { const { level, textAlign } = attributes; const [ title, setTitle ] = useEntityProp( 'root', 'site', 'title' ); + const { canUserEdit, readOnlyTitle } = useSelect( ( select ) => { + const { canUser, getEntityRecord } = select( coreStore ); + const siteData = getEntityRecord( 'root', '__unstableBase' ); + return { + canUserEdit: canUser( 'update', 'settings' ), + readOnlyTitle: siteData?.name, + }; + }, [] ); const TagName = level === 0 ? 'p' : `h${ level }`; const blockProps = useBlockProps( { className: classnames( { [ `has-text-align-${ textAlign }` ]: textAlign, + 'wp-block-site-title__placeholder': + ! canUserEdit && ! readOnlyTitle, } ), } ); + const siteTitleContent = canUserEdit ? ( +