# easy-invoice/2.4.3/templates/admin/partials/confirm-helper.php

Easy Invoice – Invoice Generator, PDF Quotes &amp; Payments, version 2.4.3. 76 lines.

- Page: https://pluginprobe.com/plugins/easy-invoice/2.4.3/code/templates/admin/partials/confirm-helper.php
- Raw: https://pluginprobe.com/plugins/easy-invoice/2.4.3/raw/templates/admin/partials/confirm-helper.php
- Modified: 2026-09-15T12:31:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-invoice/2.4.3/code/templates/admin/partials/confirm-helper.php#L10-L20`.

```php
<?php
/**
 * Inline confirmation handler shared by addon pages.
 *
 * Hooks any element bearing [data-ei-confirm] (e.g. a delete-button inside a
 * form) and replaces native window.confirm() with the project's custom
 * EasyInvoiceConfirmation modal. Falls back to window.confirm() if the
 * confirmation script is unavailable.
 *
 * Supported attributes:
 *   data-ei-confirm        — message (required)
 *   data-ei-confirm-title  — modal title (optional)
 *   data-ei-confirm-text   — confirm button label (optional)
 *   data-ei-confirm-class  — Tailwind classes for confirm button (optional)
 */
if (!defined('ABSPATH')) {
    exit;
}
?>
<script>
(function () {
    if (window.__eiConfirmHelperLoaded) return;
    window.__eiConfirmHelperLoaded = true;

    document.addEventListener('click', function (e) {
        var btn = e.target && e.target.closest ? e.target.closest('[data-ei-confirm]') : null;
        if (!btn) return;
        if (btn.dataset.eiConfirmed === '1') {
            // Re-entry after user confirmed — let the native action proceed.
            btn.removeAttribute('data-ei-confirmed');
            return;
        }
        e.preventDefault();
        e.stopPropagation();

        var message      = btn.getAttribute('data-ei-confirm') || 'Are you sure?';
        var title        = btn.getAttribute('data-ei-confirm-title') || 'Confirm action';
        var confirmText  = btn.getAttribute('data-ei-confirm-text') || 'Confirm';
        var confirmClass = btn.getAttribute('data-ei-confirm-class') || 'bg-red-600 hover:bg-red-700';

        function proceed() {
            btn.dataset.eiConfirmed = '1';
            var form = btn.closest ? btn.closest('form') : null;
            var isSubmit = btn.tagName === 'BUTTON' ? (btn.type || 'submit') === 'submit' : (btn.tagName === 'INPUT' && btn.type === 'submit');
            if (btn.tagName === 'A' && btn.href) {
                // A link inside a form (a row action in a bulk-action table)
                // still just follows its href.
                window.location.href = btn.href;
            } else if (form && isSubmit) {
                if (typeof form.requestSubmit === 'function') {
                    form.requestSubmit(btn);
                } else {
                    form.submit();
                }
            } else {
                // type="button" and similar: re-fire the click; the marker
                // above lets the element's own handler run this time.
                btn.click();
            }
        }

        if (window.EasyInvoiceConfirmation && typeof window.EasyInvoiceConfirmation.show === 'function') {
            window.EasyInvoiceConfirmation.show({
                title:        title,
                message:      message,
                confirmText:  confirmText,
                confirmClass: confirmClass,
                onConfirm:    proceed
            });
        } else if (window.confirm(message)) {
            proceed();
        }
    }, true);
})();
</script>

```
