PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.1.2
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.1.2
2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.2 All 57 releases
easy-invoice / includes / Helpers / ToastHelper.php

ToastHelper.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.1.2, at includes/Helpers/ToastHelper.php

85 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Display a success toast notification
5 *
6 * @since 1.0.0
7 * @param string $message The message to display
8 * @param array $options Additional options
9 */
10 function easy_invoice_toast_success($message, $options = array()) {
11 if (wp_doing_ajax()) {
12 wp_send_json_success(array(
13 'toast' => array(
14 'type' => 'success',
15 'message' => $message,
16 'options' => $options
17 )
18 ));
19 } else {
20 echo "<script>if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.success('" . esc_js($message) . "', " . json_encode($options) . "); }</script>";
21 }
22 }
23
24 /**
25 * Display an error toast notification
26 *
27 * @since 1.0.0
28 * @param string $message The message to display
29 * @param array $options Additional options
30 */
31 function easy_invoice_toast_error($message, $options = array()) {
32 if (wp_doing_ajax()) {
33 wp_send_json_error(array(
34 'toast' => array(
35 'type' => 'error',
36 'message' => $message,
37 'options' => $options
38 )
39 ));
40 } else {
41 echo "<script>if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.error('" . esc_js($message) . "', " . json_encode($options) . "); }</script>";
42 }
43 }
44
45 /**
46 * Display a warning toast notification
47 *
48 * @since 1.0.0
49 * @param string $message The message to display
50 * @param array $options Additional options
51 */
52 function easy_invoice_toast_warning($message, $options = array()) {
53 if (wp_doing_ajax()) {
54 wp_send_json_error(array(
55 'toast' => array(
56 'type' => 'warning',
57 'message' => $message,
58 'options' => $options
59 )
60 ));
61 } else {
62 echo "<script>if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.warning('" . esc_js($message) . "', " . json_encode($options) . "); }</script>";
63 }
64 }
65
66 /**
67 * Display an info toast notification
68 *
69 * @since 1.0.0
70 * @param string $message The message to display
71 * @param array $options Additional options
72 */
73 function easy_invoice_toast_info($message, $options = array()) {
74 if (wp_doing_ajax()) {
75 wp_send_json_success(array(
76 'toast' => array(
77 'type' => 'info',
78 'message' => $message,
79 'options' => $options
80 )
81 ));
82 } else {
83 echo "<script>if (typeof EasyInvoiceToast !== 'undefined') { EasyInvoiceToast.info('" . esc_js($message) . "', " . json_encode($options) . "); }</script>";
84 }
85 }