diff --git a/assets/js/src/components/DesignPackNotice.js b/assets/js/src/components/DesignPackNotice.js index d9afc33..4597522 100644 --- a/assets/js/src/components/DesignPackNotice.js +++ b/assets/js/src/components/DesignPackNotice.js @@ -2,6 +2,7 @@ import { useSelect } from '@wordpress/data'; import { Icon, closeSmall } from '@wordpress/icons'; import { useEffect, useState } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; const logo = ( ); +// WP < 6.8 id; 6.8+ shares 'inserter-notice' with other inserter snackbars. const BLOCK_PATTERN_INSERTED_NOTICE = 'block-pattern-inserted-notice'; +const INSERTER_NOTICE = 'inserter-notice'; + +const isPatternInsertedNotice = ( notice ) => { + if ( notice.id === BLOCK_PATTERN_INSERTED_NOTICE ) { + return true; + } + + if ( notice.id !== INSERTER_NOTICE || typeof notice.content !== 'string' ) { + return false; + } + + // Core's wording before and after its rename (6.9 → 7.1). + return [ + /* translators: %s: block pattern title. */ + __( 'Block pattern "%s" inserted.' ), + /* translators: %s: block pattern title. */ + __( 'Pattern "%s" inserted.' ), + ].some( ( template ) => { + const [ before, after = '' ] = template.split( /%(?:\d+\$)?s/ ); + + return ( + notice.content.startsWith( before ) && + notice.content.endsWith( after ) + ); + } ); +}; + export default () => { const [ dismissed, setDismissed ] = useState( false ); const [ noticeTriggered, setNoticeTriggered ] = useState( false ); - const patternInserted = useSelect( - ( select ) => - select( 'core/notices' ) - .getNotices() - .filter( ( n ) => n.id === BLOCK_PATTERN_INSERTED_NOTICE ) - .length > 0 + const patternInserted = useSelect( ( select ) => + select( 'core/notices' ).getNotices().some( isPatternInsertedNotice ) ); useEffect( () => { diff --git a/composer.lock b/composer.lock index 584f714..a6f751a 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "codeinwp/themeisle-sdk", - "version": "3.3.71", + "version": "3.3.74", "source": { "type": "git", "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "cd7acfc0b01b8d5712736aa3721d689591ced991" + "reference": "3131818293a5c08105d443fa7c476cfe339b0299" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/cd7acfc0b01b8d5712736aa3721d689591ced991", - "reference": "cd7acfc0b01b8d5712736aa3721d689591ced991", + "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/3131818293a5c08105d443fa7c476cfe339b0299", + "reference": "3131818293a5c08105d443fa7c476cfe339b0299", "shasum": "" }, "require-dev": { @@ -43,9 +43,9 @@ ], "support": { "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", - "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.71" + "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.74" }, - "time": "2026-11-04T20:22:53+00:00" + "time": "2026-11-27T08:23:44+00:00" } ], "packages-dev": [