| @@ -6,13 +6,17 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace EasyInvoice\Templates\Payments; |
| 9 | 9 | |
| 10 | + | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit; | |
| 13 | +} | |
| 10 | 14 | use EasyInvoice\Models\Payment; |
| 11 | 15 | use EasyInvoice\Models\Invoice; |
| 12 | 16 | |
| 13 | 17 | if (!isset($payment) || !($payment instanceof Payment)) { |
| 14 | - wp_die(__('Invalid payment', 'easy-invoice')); | |
| 18 | + wp_die(esc_html__('Invalid payment', 'easy-invoice')); | |
| 15 | 19 | } |
| 16 | 20 | |
| 17 | 21 | $invoice_post = get_post($payment->getInvoiceId()); |
| 18 | 22 | $invoice = $invoice_post ? new Invoice($invoice_post) : null; |
| @@ -22,48 +26,47 @@ | ||
| 22 | 26 | |
| 23 | 27 | <div class="p-8"> |
| 24 | 28 | <div class="flex justify-between items-center mb-6"> |
| 25 | 29 | <h1 class="text-2xl font-bold text-gray-900"> |
| 26 | - <?php printf(__('Payment #%s', 'easy-invoice'), $payment->getId()); ?> | |
| 30 | + <?php /* translators: %s: payment id. */ printf(esc_html__('Payment #%s', 'easy-invoice'), (int) $payment->getId()); ?> | |
| 27 | 31 | </h1> |
| 28 | - <a href="<?php echo admin_url('admin.php?page=easy-invoice-payments'); ?>" | |
| 32 | + <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice-payments')); ?>" | |
| 29 | 33 | class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"> |
| 30 | - <?php _e('Back to Payments', 'easy-invoice'); ?> | |
| 34 | + <?php esc_html_e('Back to Payments', 'easy-invoice'); ?> | |
| 31 | 35 | </a> |
| 32 | 36 | </div> |
| 33 | 37 | |
| 34 | 38 | <div class="bg-white shadow overflow-hidden sm:rounded-lg"> |
| 35 | - <!-- Payment Information --> | |
| 36 | 39 | <div class="px-4 py-5 sm:px-6 border-b border-gray-200"> |
| 37 | - <h2 class="text-lg font-medium text-gray-900"><?php _e('Payment Information', 'easy-invoice'); ?></h2> | |
| 40 | + <h2 class="text-lg font-medium text-gray-900"><?php esc_html_e('Payment Information', 'easy-invoice'); ?></h2> | |
| 38 | 41 | </div> |
| 39 | 42 | <div class="border-t border-gray-200"> |
| 40 | 43 | <dl> |
| 41 | 44 | <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 42 | - <dt class="text-sm font-medium text-gray-500"><?php _e('Payment ID', 'easy-invoice'); ?></dt> | |
| 43 | - <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">#<?php echo $payment->getId(); ?></dd> | |
| 45 | + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Payment ID', 'easy-invoice'); ?></dt> | |
| 46 | + <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">#<?php echo (int) $payment->getId(); ?></dd> | |
| 44 | 47 | </div> |
| 45 | 48 | <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 46 | - <dt class="text-sm font-medium text-gray-500"><?php _e('Invoice', 'easy-invoice'); ?></dt> | |
| 49 | + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Invoice', 'easy-invoice'); ?></dt> | |
| 47 | 50 | <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"> |
| 48 | 51 | <?php if ($invoice): ?> |
| 49 | - <a href="<?php echo admin_url('admin.php?page=easy-invoice&action=edit&id=' . $invoice->getId()); ?>" | |
| 52 | + <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice&action=edit&id=' . $invoice->getId())); ?>" | |
| 50 | 53 | class="text-indigo-600 hover:text-indigo-900"> |
| 51 | - <?php echo $invoice->getNumber(); ?> | |
| 54 | + <?php echo esc_html($invoice->getNumber()); ?> | |
| 52 | 55 | </a> |
| 53 | 56 | <?php else: ?> |
| 54 | - <span class="text-gray-400"><?php _e('Invoice not found', 'easy-invoice'); ?></span> | |
| 57 | + <span class="text-gray-400"><?php esc_html_e('Invoice not found', 'easy-invoice'); ?></span> | |
| 55 | 58 | <?php endif; ?> |
| 56 | 59 | </dd> |
| 57 | 60 | </div> |
| 58 | 61 | <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 59 | - <dt class="text-sm font-medium text-gray-500"><?php _e('Amount', 'easy-invoice'); ?></dt> | |
| 62 | + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Amount', 'easy-invoice'); ?></dt> | |
| 60 | 63 | <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"> |
| 61 | - <?php echo $payment->getCurrencySymbol() . number_format($payment->getAmount(), 2); ?> | |
| 64 | + <?php echo esc_html($payment->getCurrencySymbol() . number_format((float) $payment->getAmount(), 2)); ?> | |
| 62 | 65 | </dd> |
| 63 | 66 | </div> |
| 64 | 67 | <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 65 | - <dt class="text-sm font-medium text-gray-500"><?php _e('Payment Method', 'easy-invoice'); ?></dt> | |
| 68 | + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Payment Method', 'easy-invoice'); ?></dt> | |
| 66 | 69 | <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"> |
| 67 | 70 | <?php |
| 68 | 71 | $payment_method = $payment->getPaymentMethod(); |
| 69 | 72 | if (empty($payment_method)) { |
| @@ -76,14 +79,14 @@ | ||
| 76 | 79 | } |
| 77 | 80 | |
| 78 | 81 | |
| 79 | 82 | |
| 80 | - echo ucfirst($payment_method ?: __('Not specified', 'easy-invoice')); | |
| 83 | + echo esc_html(ucfirst($payment_method ?: __('Not specified', 'easy-invoice'))); | |
| 81 | 84 | ?> |
| 82 | 85 | </dd> |
| 83 | 86 | </div> |
| 84 | 87 | <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 85 | - <dt class="text-sm font-medium text-gray-500"><?php _e('Status', 'easy-invoice'); ?></dt> | |
| 88 | + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Status', 'easy-invoice'); ?></dt> | |
| 86 | 89 | <dd class="mt-1 text-sm sm:mt-0 sm:col-span-2"> |
| 87 | 90 | <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full |
| 88 | 91 | <?php |
| 89 | 92 | switch ($payment->getStatus()) { |
| @@ -99,39 +102,39 @@ | ||
| 99 | 102 | default: |
| 100 | 103 | echo 'bg-gray-100 text-gray-800'; |
| 101 | 104 | } |
| 102 | 105 | ?>"> |
| 103 | - <?php echo ucfirst($payment->getStatus()); ?> | |
| 106 | + <?php echo esc_html(ucfirst($payment->getStatus())); ?> | |
| 104 | 107 | </span> |
| 105 | 108 | </dd> |
| 106 | 109 | </div> |
| 107 | 110 | <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 108 | - <dt class="text-sm font-medium text-gray-500"><?php _e('Date', 'easy-invoice'); ?></dt> | |
| 111 | + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Date', 'easy-invoice'); ?></dt> | |
| 109 | 112 | <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"> |
| 110 | - <?php echo date_i18n(get_option('date_format'), strtotime($payment->getPaymentDate())); ?> | |
| 113 | + <?php echo esc_html(date_i18n(get_option('date_format'), strtotime($payment->getPaymentDate()))); ?> | |
| 111 | 114 | </dd> |
| 112 | 115 | </div> |
| 113 | 116 | <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 114 | - <dt class="text-sm font-medium text-gray-500"><?php _e('Type', 'easy-invoice'); ?></dt> | |
| 117 | + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Type', 'easy-invoice'); ?></dt> | |
| 115 | 118 | <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"> |
| 116 | - <?php echo ucfirst($payment->getPaymentType()); ?> | |
| 119 | + <?php echo esc_html(ucfirst($payment->getPaymentType())); ?> | |
| 117 | 120 | </dd> |
| 118 | 121 | </div> |
| 119 | 122 | <?php if ($payment->getRecurringId()) : ?> |
| 120 | 123 | <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 121 | - <dt class="text-sm font-medium text-gray-500"><?php _e('Recurring ID', 'easy-invoice'); ?></dt> | |
| 124 | + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Recurring ID', 'easy-invoice'); ?></dt> | |
| 122 | 125 | <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"> |
| 123 | - <?php echo $payment->getRecurringId(); ?> | |
| 126 | + <?php echo esc_html($payment->getRecurringId()); ?> | |
| 124 | 127 | </dd> |
| 125 | 128 | </div> |
| 126 | 129 | <?php endif; ?> |
| 127 | 130 | <?php if ($payment->getParentPaymentId()) : ?> |
| 128 | 131 | <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 129 | - <dt class="text-sm font-medium text-gray-500"><?php _e('Parent Payment', 'easy-invoice'); ?></dt> | |
| 132 | + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Parent Payment', 'easy-invoice'); ?></dt> | |
| 130 | 133 | <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"> |
| 131 | - <a href="<?php echo admin_url('admin.php?page=easy-invoice-payments&action=view&id=' . $payment->getParentPaymentId()); ?>" | |
| 134 | + <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice-payments&action=view&id=' . $payment->getParentPaymentId())); ?>" | |
| 132 | 135 | class="text-indigo-600 hover:text-indigo-900"> |
| 133 | - #<?php echo $payment->getParentPaymentId(); ?> | |
| 136 | + #<?php echo (int) $payment->getParentPaymentId(); ?> | |
| 134 | 137 | </a> |
| 135 | 138 | </dd> |
| 136 | 139 | </div> |
| 137 | 140 | <?php endif; ?> |
| @@ -136,9 +139,9 @@ | ||
| 136 | 139 | </div> |
| 137 | 140 | <?php endif; ?> |
| 138 | 141 | <?php if ($payment->getNotes()) : ?> |
| 139 | 142 | <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 140 | - <dt class="text-sm font-medium text-gray-500"><?php _e('Notes', 'easy-invoice'); ?></dt> | |
| 143 | + <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Notes', 'easy-invoice'); ?></dt> | |
| 141 | 144 | <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"> |
| 142 | 145 | <?php echo nl2br(esc_html($payment->getNotes())); ?> |
| 143 | 146 | </dd> |
| 144 | 147 | </div> |
| @@ -160,11 +163,10 @@ | ||
| 160 | 163 | } |
| 161 | 164 | |
| 162 | 165 | if ($gateway_response && is_array($gateway_response)) : |
| 163 | 166 | ?> |
| 164 | - <!-- Gateway Response --> | |
| 165 | 167 | <div class="px-4 py-5 sm:px-6 border-t border-gray-200"> |
| 166 | - <h2 class="text-lg font-medium text-gray-900"><?php _e('Gateway Response', 'easy-invoice'); ?></h2> | |
| 168 | + <h2 class="text-lg font-medium text-gray-900"><?php esc_html_e('Gateway Response', 'easy-invoice'); ?></h2> | |
| 167 | 169 | </div> |
| 168 | 170 | <div class="border-t border-gray-200"> |
| 169 | 171 | <dl> |
| 170 | 172 | <?php |
| @@ -172,9 +174,9 @@ | ||
| 172 | 174 | foreach ($gateway_response as $key => $value) : |
| 173 | 175 | $loop++; |
| 174 | 176 | ?> |
| 175 | 177 | <div class="<?php echo $loop % 2 === 0 ? 'bg-white' : 'bg-gray-50'; ?> px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6"> |
| 176 | - <dt class="text-sm font-medium text-gray-500"><?php echo ucwords(str_replace('_', ' ', $key)); ?></dt> | |
| 178 | + <dt class="text-sm font-medium text-gray-500"><?php echo esc_html(ucwords(str_replace('_', ' ', $key))); ?></dt> | |
| 177 | 179 | <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"> |
| 178 | 180 | <?php |
| 179 | 181 | if (is_array($value)) { |
| 180 | 182 | echo '<pre class="text-xs bg-gray-100 p-2 rounded overflow-x-auto">' . esc_html(json_encode($value, JSON_PRETTY_PRINT)) . '</pre>'; |