From c62690fa04d1221a26b78f70af5dd3d66eb7eba3 Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Thu, 22 Feb 2024 17:15:35 +0800 Subject: [PATCH] Remove unneeded pattern overrides translation strings (#59269) Co-authored-by: kevin940726 Co-authored-by: talldan --- .../components/partial-syncing-controls.js | 6 ++--- packages/patterns/src/constants.js | 23 ++++--------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/packages/patterns/src/components/partial-syncing-controls.js b/packages/patterns/src/components/partial-syncing-controls.js index f55ee7bdc26d3..7b3e5cb312e82 100644 --- a/packages/patterns/src/components/partial-syncing-controls.js +++ b/packages/patterns/src/components/partial-syncing-controls.js @@ -17,7 +17,7 @@ import { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../constants'; function PartialSyncingControls( { name, attributes, setAttributes } ) { const syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ]; - const attributeSources = Object.keys( syncedAttributes ).map( + const attributeSources = syncedAttributes.map( ( attributeName ) => attributes.metadata?.bindings?.[ attributeName ]?.source ); @@ -36,7 +36,7 @@ function PartialSyncingControls( { name, attributes, setAttributes } ) { }; if ( ! isChecked ) { - for ( const attributeName of Object.keys( syncedAttributes ) ) { + for ( const attributeName of syncedAttributes ) { if ( updatedBindings[ attributeName ]?.source === 'core/pattern-overrides' @@ -56,7 +56,7 @@ function PartialSyncingControls( { name, attributes, setAttributes } ) { return; } - for ( const attributeName of Object.keys( syncedAttributes ) ) { + for ( const attributeName of syncedAttributes ) { if ( ! updatedBindings[ attributeName ] ) { updatedBindings[ attributeName ] = { source: 'core/pattern-overrides', diff --git a/packages/patterns/src/constants.js b/packages/patterns/src/constants.js index 24401e24fdd3b..99d6a0fa975a8 100644 --- a/packages/patterns/src/constants.js +++ b/packages/patterns/src/constants.js @@ -1,8 +1,3 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; - export const PATTERN_TYPES = { theme: 'pattern', user: 'wp_block', @@ -22,18 +17,8 @@ export const PATTERN_SYNC_TYPES = { // TODO: This should not be hardcoded. Maybe there should be a config and/or an UI. export const PARTIAL_SYNCING_SUPPORTED_BLOCKS = { - 'core/paragraph': { content: __( 'Content' ) }, - 'core/heading': { content: __( 'Content' ) }, - 'core/button': { - text: __( 'Text' ), - url: __( 'URL' ), - linkTarget: __( 'Link Target' ), - rel: __( 'Link Relationship' ), - }, - 'core/image': { - id: __( 'Image ID' ), - url: __( 'URL' ), - title: __( 'Title' ), - alt: __( 'Alt Text' ), - }, + 'core/paragraph': [ 'content' ], + 'core/heading': [ 'content' ], + 'core/button': [ 'text', 'url', 'linkTarget', 'rel' ], + 'core/image': [ 'id', 'url', 'title', 'alt' ], };