| Server IP : 52.25.153.185 / Your IP : 216.73.216.194 Web Server : Apache System : Linux ip-172-26-6-158 5.10.0-45-cloud-amd64 #1 SMP Debian 5.10.259-1 (2026-07-02) x86_64 User : daemon ( 1) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/code-snippets/js/components/common/ |
Upload File : |
import React, { useEffect } from 'react'
const SLOT_ID = 'snippets-screen-meta-slot'
export interface ScreenMetaSlotProps {
hidden?: boolean
}
/**
* Relocates the WordPress Screen Options and Help tabs (and their panels)
* from above the page content into this slot, so they appear directly below
* the page's subnavigation bar. The slot div is rendered empty by React and
* never reconciled with children, so adopting the foreign nodes is safe.
* The nodes are returned to the top of the page when the slot unmounts.
*
* Stays mounted (with `hidden`) rather than being conditionally rendered by
* the caller: unmounting hands the adopted nodes back to their native,
* visible position at the top of the page instead of hiding them.
*/
export const ScreenMetaSlot: React.FC<ScreenMetaSlotProps> = ({ hidden = false }) => {
useEffect(() => {
const slot = document.getElementById(SLOT_ID)
const meta = document.getElementById('screen-meta')
const links = document.getElementById('screen-meta-links')
if (!slot || !meta || !links) {
return undefined
}
const parent = meta.parentElement
slot.append(meta, links)
return () => {
parent?.prepend(meta, links)
}
}, [])
return <div id={SLOT_ID} className="snippets-screen-meta-slot" hidden={hidden} />
}