This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * WordPress dependencies | |
| */ | |
| import { PanelBody, ToggleControl } from '@wordpress/components'; | |
| import { useSelect, useDispatch } from '@wordpress/data'; | |
| import { __ } from '@wordpress/i18n'; | |
| /** | |
| * Renders the Advanced Features sidebar panel and toggle for the alley feature flag. | |
| * Reads and updates post meta via core/editor; does not persist to server (editor save does). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Registers a REST API endpoint that returns post counts by status, | |
| * cached per capability (editor vs non-editor) to avoid repeated database queries. | |
| */ | |
| add_action( 'rest_api_init', function () { | |
| register_rest_route( | |
| 'alley/v1', | |
| '/post-metrics', | |
| [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useEffect, useRef } from 'react'; | |
| const useClickOutside = (callback: () => void) => { | |
| const ref = useRef<HTMLElement>(null); | |
| useEffect(() => { | |
| const handleClickOutside = (event: MouseEvent) => { | |
| // If the ref exists and the clicked element is not inside the ref's element | |
| if (ref.current && !ref.current.contains(event.target as Node)) { | |
| callback(); // Execute the provided callback function |