Server IP : 172.67.214.6 / Your IP : 216.73.216.73 Web Server : LiteSpeed System : Linux premium900.web-hosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : redwjova ( 1790) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/redwjova/near.llc/wp-content/plugins/extendify/src/PageCreator/components/ |
Upload File : |
import { useSelect } from '@wordpress/data'; import { store as editorStore } from '@wordpress/editor'; import { useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { Icon } from '@wordpress/icons'; import { ConfirmationModal } from '@page-creator/components/ConfirmationModal'; import { PageGen } from '@page-creator/icons/ai-gen'; import { useGlobalsStore } from '@page-creator/state/global'; import { useActivityStore } from '@shared/state/activity'; export const MainButton = () => { const { setOpen } = useGlobalsStore(); const { incrementActivity } = useActivityStore(); const [confirmationOpen, setConfirmationOpen] = useState(false); // Get post attributes using WordPress's useSelect hook const isEmptyPage = useSelect( (select) => select(editorStore).isEditedPostEmpty(), [], ); const handleClick = () => { // Minimize HC if its open window.dispatchEvent(new CustomEvent('extendify-hc:minimize')); if (!isEmptyPage) return setConfirmationOpen(true); setOpen(true); incrementActivity('page-creator-button-click'); }; return ( <> {confirmationOpen && ( <ConfirmationModal setConfirmationOpen={setConfirmationOpen} setModalOpen={setOpen} confirmationOpen={confirmationOpen} /> )} <div role="button" onClick={handleClick} className="components-button has-icon is-primary ml-3 h-8 min-w-0 cursor-pointer px-2 xs:h-9 sm:ml-2 xl:pr-3"> <Icon icon={PageGen} size={24} className="fill-none" /> <span className="ml-1 hidden xl:inline"> {__('AI Page Generator', 'extendify-local')} </span> </div> </> ); };