PluginProbe
Code Snippets / 3.9.6
Code Snippets v3.9.6
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / SnippetForm / page / Notices.tsx

Notices.tsx in Code Snippets 3.9.6, at js/components/SnippetForm/page/Notices.tsx

35 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { createInterpolateElement } from '@wordpress/element'
2 import React from 'react'
3 import { __, sprintf } from '@wordpress/i18n'
4 import { useSnippetForm } from '../../../hooks/useSnippetForm'
5 import { DismissibleNotice } from '../../common/DismissableNotice'
6
7 export const Notices: React.FC = () => {
8 const { currentNotice, setCurrentNotice, snippet, setSnippet } = useSnippetForm()
9
10 return <>
11 {currentNotice
12 ? <DismissibleNotice className={currentNotice[0]} onDismiss={() => setCurrentNotice(undefined)}>
13 <p>{createInterpolateElement(currentNotice[1], { strong: <strong /> })}</p>
14 </DismissibleNotice>
15 : null}
16
17 {snippet.code_error
18 ? <DismissibleNotice
19 className="notice-error"
20 onDismiss={() => setSnippet(previous => ({ ...previous, code_error: null }))}
21 >
22 <p>
23 <strong>{sprintf(
24 // translators: %d: line number.
25 __('Snippet automatically deactivated due to an error on line %d:', 'code-snippets'),
26 snippet.code_error[1]
27 )}</strong>
28
29 <blockquote>{snippet.code_error[0]}</blockquote>
30 </p>
31 </DismissibleNotice>
32 : null}
33 </>
34 }
35