Files
m5wp.momentry.ddns.net/plugins/code-snippets/js/components/SnippetForm/page/Notices.tsx
OpenCode 09ef1f000f Initial commit: WordPress wp-content (themes, plugins, languages)
- Theme: momentry (custom theme with REST API routes)
- Plugins: code-snippets (contains all API proxies)
- Languages: zh_TW translations
- Excludes: cache, backups, uploads, logs
2026-05-29 19:07:56 +08:00

35 lines
1.1 KiB
TypeScript

import { createInterpolateElement } from '@wordpress/element'
import React from 'react'
import { __, sprintf } from '@wordpress/i18n'
import { useSnippetForm } from '../../../hooks/useSnippetForm'
import { DismissibleNotice } from '../../common/DismissableNotice'
export const Notices: React.FC = () => {
const { currentNotice, setCurrentNotice, snippet, setSnippet } = useSnippetForm()
return <>
{currentNotice
? <DismissibleNotice className={currentNotice[0]} onDismiss={() => setCurrentNotice(undefined)}>
<p>{createInterpolateElement(currentNotice[1], { strong: <strong /> })}</p>
</DismissibleNotice>
: null}
{snippet.code_error
? <DismissibleNotice
className="notice-error"
onDismiss={() => setSnippet(previous => ({ ...previous, code_error: null }))}
>
<p>
<strong>{sprintf(
// translators: %d: line number.
__('Snippet automatically deactivated due to an error on line %d:', 'code-snippets'),
snippet.code_error[1]
)}</strong>
<blockquote>{snippet.code_error[0]}</blockquote>
</p>
</DismissibleNotice>
: null}
</>
}