HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/confeduphaar/www/wp-content/plugins/essential-blocks/src/templately-installer/index.js
import { createRoot } from "@wordpress/element"
import { subscribe } from '@wordpress/data'

import "./style.scss"
import PatternLibraryButton from "./PatternLibraryButton"

document.addEventListener('DOMContentLoaded', function () {
    const plugin_file = "templately/templately.php";
    const templately = EssentialBlocksLocalize.get_plugins[plugin_file];
    if (templately && templately.active) {
        return;
    }

    // Create Button
    const buttonDiv = document.createElement('div')
    buttonDiv.classList.add('eb-pattern-library-button-wrapper')
    const root = createRoot(buttonDiv);
    root.render(<PatternLibraryButton />);

    subscribe(() => {
        const toplbar = document.querySelector('.edit-post-header-toolbar')
        if (toplbar) {
            const templately = EssentialBlocksLocalize.get_plugins[plugin_file];
            if (templately && templately.active) {
                if (toplbar.querySelector('.eb-pattern-library-button-wrapper')) {
                    toplbar.removeChild(buttonDiv)
                }
            }
            else if (!toplbar.querySelector('.eb-pattern-library-button-wrapper')) {
                toplbar.appendChild(buttonDiv)
            }
        }
    })
});