PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.2
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.2
2.4.3 2.4.4 2.4.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 All 60 releases
← All changes | templates/invoices/preview.php +17 -7 2.3.4 → 2.4.2 View file →
@@ -5,14 +5,17 @@
5 5 * @package EasyInvoice
6 6 * @since 1.0.0
7 7 */
8 8
9 +if ( ! defined( 'ABSPATH' ) ) {
10 + exit;
11 +}
9 12 // Get invoice data
10 -$invoice_id = isset($_GET['invoice_id']) ? (int) $_GET['invoice_id'] : 0;
13 +$invoice_id = isset($_GET['invoice_id']) ? (int) $_GET['invoice_id'] : (isset($_GET['id']) ? (int) $_GET['id'] : 0); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
11 14 $invoice = $invoice ?? null;
12 15
13 16 if ($invoice_id <= 0 || !$invoice) {
14 - wp_die(__('Invoice not found.', 'easy-invoice'));
17 + wp_die(esc_html__('Invoice not found.', 'easy-invoice'));
15 18 }
16 19
17 20 // Initialize formatter for currency formatting
18 21 $formatter = $invoice ? new \EasyInvoice\Helpers\InvoiceFormatter($invoice) : null;
@@ -37,9 +40,16 @@
37 40 <meta charset="UTF-8">
38 41 <meta name="viewport" content="width=device-width, initial-scale=1.0">
39 42 <title>Invoice <?php echo $invoice ? esc_html($invoice->getNumber()) : 'Unknown'; ?></title>
40 43
41 - <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
44 + <?php
45 + // Bundled locally (wp.org requires all assets to ship inside the plugin)
46 + // and printed through the script registry so filters and dependencies apply.
47 + if ( ! wp_script_is( 'jspdf', 'registered' ) ) {
48 + wp_register_script( 'jspdf', EASY_INVOICE_PLUGIN_URL . 'assets/js/vendors/jspdf.umd.min.js', [], '2.5.1', false );
49 + }
50 + wp_print_scripts( [ 'jspdf' ] );
51 + ?>
42 52
43 53 <style>
44 54 * {
45 55 margin: 0;
@@ -237,14 +247,14 @@
237 247 <body>
238 248 <div class="invoice-container">
239 249 <?php
240 250 // Dynamically load the selected template
241 - $template_file = EASY_INVOICE_PLUGIN_DIR . 'templates/invoice-templates/' . $current_template . '.php';
251 + $template_file = easy_invoice_design_template( 'invoice', (string) $current_template );
242 252 if (file_exists($template_file)) {
243 253 include_once $template_file;
244 254 } else {
245 255 // Fallback to standard template if selected template doesn't exist
246 - $template_file = EASY_INVOICE_PLUGIN_DIR . 'templates/invoice-templates/standard.php';
256 + $template_file = easy_invoice_design_template( 'invoice', 'standard' );
247 257 if (file_exists($template_file)) {
248 258 include_once $template_file;
249 259 } else {
250 260 // Show error if no template is available
@@ -276,9 +286,9 @@
276 286 pdfGenerator.generatePDF();
277 287
278 288 // Show success message after a short delay
279 289 setTimeout(function() {
280 - alert('<?php _e('PDF generated successfully', 'easy-invoice'); ?>');
290 + alert('<?php echo esc_js(__('PDF generated successfully', 'easy-invoice')); ?>');
281 291 }, 2000);
282 292 } else {
283 293 alert('Error: PDF generator not available');
284 294 }
@@ -283,9 +293,9 @@
283 293 alert('Error: PDF generator not available');
284 294 }
285 295 } catch (error) {
286 296 console.error('PDF generation error:', error);
287 - alert('<?php _e('Error generating PDF', 'easy-invoice'); ?>');
297 + alert('<?php echo esc_js(__('Error generating PDF', 'easy-invoice')); ?>');
288 298 }
289 299 }
290 300 </script>
291 301 </body>