# easy-invoice/2.2.0/includes/Helpers/ToastHelper.php

Easy Invoice – Invoice Generator, PDF Quotes &amp; Payments, version 2.2.0. 85 lines.

- Page: https://pluginprobe.com/plugins/easy-invoice/2.2.0/code/includes/Helpers/ToastHelper.php
- Raw: https://pluginprobe.com/plugins/easy-invoice/2.2.0/raw/includes/Helpers/ToastHelper.php
- Modified: 2025-08-14T09:51:16+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.2.0/code/includes/Helpers/ToastHelper.php#L10-L20`.

```php
<?php

/**
 * Display a success toast notification
 *
 * @since 1.0.0
 * @param string $message The message to display
 * @param array $options Additional options
 */
function easy_invoice_toast_success($message, $options = array()) {
    if (wp_doing_ajax()) {
        wp_send_json_success(array(
            'toast' => array(
                'type' => 'success',
                'message' => $message,
                'options' => $options
            )
        ));
    } else {
        echo "<script>if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.success('" . esc_js($message) . "', " . json_encode($options) . "); }</script>";
    }
}

/**
 * Display an error toast notification
 *
 * @since 1.0.0
 * @param string $message The message to display
 * @param array $options Additional options
 */
function easy_invoice_toast_error($message, $options = array()) {
    if (wp_doing_ajax()) {
        wp_send_json_error(array(
            'toast' => array(
                'type' => 'error',
                'message' => $message,
                'options' => $options
            )
        ));
    } else {
        echo "<script>if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.error('" . esc_js($message) . "', " . json_encode($options) . "); }</script>";
    }
}

/**
 * Display a warning toast notification
 *
 * @since 1.0.0
 * @param string $message The message to display
 * @param array $options Additional options
 */
function easy_invoice_toast_warning($message, $options = array()) {
    if (wp_doing_ajax()) {
        wp_send_json_error(array(
            'toast' => array(
                'type' => 'warning',
                'message' => $message,
                'options' => $options
            )
        ));
    } else {
        echo "<script>if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.warning('" . esc_js($message) . "', " . json_encode($options) . "); }</script>";
    }
}

/**
 * Display an info toast notification
 *
 * @since 1.0.0
 * @param string $message The message to display
 * @param array $options Additional options
 */
function easy_invoice_toast_info($message, $options = array()) {
    if (wp_doing_ajax()) {
        wp_send_json_success(array(
            'toast' => array(
                'type' => 'info',
                'message' => $message,
                'options' => $options
            )
        ));
    } else {
        echo "<script>if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.info('" . esc_js($message) . "', " . json_encode($options) . "); }</script>";
    }
}
```
