PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.4
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.4
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 -9 2.2.0 → 2.4.4 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,10 +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 - <!-- Load jsPDF for PDF generation -->
42 - <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 + ?>
43 52
44 53 <style>
45 54 * {
46 55 margin: 0;
@@ -238,14 +247,14 @@
238 247 <body>
239 248 <div class="invoice-container">
240 249 <?php
241 250 // Dynamically load the selected template
242 - $template_file = EASY_INVOICE_PLUGIN_DIR . 'templates/invoice-templates/' . $current_template . '.php';
251 + $template_file = easy_invoice_design_template( 'invoice', (string) $current_template );
243 252 if (file_exists($template_file)) {
244 253 include_once $template_file;
245 254 } else {
246 255 // Fallback to standard template if selected template doesn't exist
247 - $template_file = EASY_INVOICE_PLUGIN_DIR . 'templates/invoice-templates/standard.php';
256 + $template_file = easy_invoice_design_template( 'invoice', 'standard' );
248 257 if (file_exists($template_file)) {
249 258 include_once $template_file;
250 259 } else {
251 260 // Show error if no template is available
@@ -257,9 +266,8 @@
257 266 }
258 267 ?>
259 268 </div>
260 269
261 - <!-- Invoice data for PDF generation -->
262 270 <script>
263 271 // Invoice data for PDF generation
264 272 window.invoiceData = <?php
265 273 $invoice_data = $invoice ? \EasyInvoice\Includes\Helpers\PdfHelper::getInvoiceDataForPdf($invoice) : [];
@@ -278,9 +286,9 @@
278 286 pdfGenerator.generatePDF();
279 287
280 288 // Show success message after a short delay
281 289 setTimeout(function() {
282 - alert('<?php _e('PDF generated successfully', 'easy-invoice'); ?>');
290 + alert('<?php echo esc_js(__('PDF generated successfully', 'easy-invoice')); ?>');
283 291 }, 2000);
284 292 } else {
285 293 alert('Error: PDF generator not available');
286 294 }
@@ -285,9 +293,9 @@
285 293 alert('Error: PDF generator not available');
286 294 }
287 295 } catch (error) {
288 296 console.error('PDF generation error:', error);
289 - alert('<?php _e('Error generating PDF', 'easy-invoice'); ?>');
297 + alert('<?php echo esc_js(__('Error generating PDF', 'easy-invoice')); ?>');
290 298 }
291 299 }
292 300 </script>
293 301 </body>