| @@ -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 quote data |
| 10 | 13 | $quote_id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
| 11 | 14 | $quote = $quote ?? null; |
| 12 | 15 | |
| 13 | 16 | if ($quote_id <= 0 || !$quote) { |
| 14 | - wp_die(__('Quote not found.', 'easy-invoice')); | |
| 17 | + wp_die(esc_html__('Quote not found.', 'easy-invoice')); | |
| 15 | 18 | } |
| 16 | 19 | |
| 17 | 20 | // Initialize formatter for currency formatting |
| 18 | 21 | $formatter = $quote ? new \EasyInvoice\Helpers\QuoteFormatter($quote) : 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>Quote <?php echo $quote ? esc_html($quote->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; |
| @@ -239,16 +248,14 @@ | ||
| 239 | 248 | <body> |
| 240 | 249 | <div class="quote-container"> |
| 241 | 250 | <?php |
| 242 | 251 | // Dynamically load the selected template |
| 243 | - $template_file = EASY_INVOICE_PLUGIN_DIR . 'templates/quote-templates/' . $current_template . '.php'; | |
| 244 | - | |
| 245 | - $template_file = file_exists($template_file) ? $template_file : EASY_INVOICE_PLUGIN_DIR . 'templates/quote-templates/default.php'; | |
| 252 | + $template_file = easy_invoice_design_template( 'quote', (string) $current_template ); | |
| 246 | 253 | if (file_exists($template_file)) { |
| 247 | 254 | include_once $template_file; |
| 248 | 255 | } else { |
| 249 | 256 | // Fallback to standard template if selected template doesn't exist |
| 250 | - $template_file = EASY_INVOICE_PLUGIN_DIR . 'templates/quote-templates/standard.php'; | |
| 257 | + $template_file = easy_invoice_design_template( 'quote', 'standard' ); | |
| 251 | 258 | if (file_exists($template_file)) { |
| 252 | 259 | include_once $template_file; |
| 253 | 260 | } else { |
| 254 | 261 | // Show error if no template is available |
| @@ -260,9 +267,8 @@ | ||
| 260 | 267 | } |
| 261 | 268 | ?> |
| 262 | 269 | </div> |
| 263 | 270 | |
| 264 | - <!-- Quote data for PDF generation --> | |
| 265 | 271 | <script> |
| 266 | 272 | // Quote data for PDF generation |
| 267 | 273 | window.quoteData = <?php |
| 268 | 274 | $quote_data = $quote ? \EasyInvoice\Includes\Helpers\PdfHelper::getInvoiceDataForPdf($quote) : []; |