import { useLayoutEffect, useRef } from 'react'; const NOTICE_SELECTOR = ':scope > .notice, :scope > div.updated, :scope > div.error'; /** * Moves the admin notices WordPress printed above the app into the content * area, below the header. Only this plugin's notices reach this screen (see * WTOFE_Settings_App::remove_foreign_notices()). The nodes are moved, not * re-rendered, so their own scripts (dismiss buttons) keep working. */ export default function WpNotices() { const slot = useRef( null ); useLayoutEffect( () => { const container = document.getElementById( 'wpbody-content' ); if ( container && slot.current ) { container.querySelectorAll( NOTICE_SELECTOR ).forEach( ( notice ) => slot.current?.appendChild( notice ) ); } }, [] ); return
; }