HEX
Server: LiteSpeed
System: Linux server240.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: creaqbdc (8964)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /home/creaqbdc/public_html/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)
            }
        }
    })
});