PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.0
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.0
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
← All changes | includes/Helpers/ToastHelper.php +7 -1 2.3.62.4.0 View file →
@@ -7,8 +7,11 @@
7 7 * mid-body (e.g. during a settings page render) must wait for the global to
8 8 * appear. We poll for up to ~3s, then fall back to a hidden DOM queue that
9 9 * the toast script flushes when it boots.
10 10 */
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
11 14 function _easy_invoice_emit_toast_script($type, $message, $options) {
12 15 $type = in_array($type, array('success', 'error', 'warning', 'info'), true) ? $type : 'info';
13 16 $message = (string) $message;
14 17 $payload = wp_json_encode(
@@ -28,9 +31,12 @@
28 31 // appended to <body> by its jQuery-ready init() — calling show() before
29 32 // the container exists crashes on `toastContainer.append(...)`.
30 33 // The `fired` latch guarantees we fire exactly once across the interval,
31 34 // DOMContentLoaded, and load triggers.
32 - echo "<script>(function(){var p=" . $payload . ";var fired=false;"
35 + // The payload is JSON built with JSON_HEX_* above, which is what makes it
36 + // safe inside <script>; esc_html() would turn its quotes into &quot; and
37 + // the script would not parse.
38 + echo "<script>(function(){var p=" . $payload . ";var fired=false;" // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
33 39 . "function ready(){return !!(window.EasyInvoiceToast"
34 40 . "&&typeof window.EasyInvoiceToast[p.type]==='function'"
35 41 . "&&document.getElementById('easy-invoice-toast-container'));}"
36 42 . "function fire(){if(fired)return true;if(!ready())return false;"