| @@ -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\Invoice; |
| 11 | 15 | use EasyInvoice\Models\Payment; |
| 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 | |
| 18 | 22 | <div class="p-8"> |
| @@ -17,13 +21,13 @@ | ||
| 17 | 21 | |
| 18 | 22 | <div class="p-8"> |
| 19 | 23 | <div class="flex justify-between items-center mb-6"> |
| 20 | 24 | <h1 class="text-2xl font-bold text-gray-900"> |
| 21 | - <?php _e('Edit Payment', 'easy-invoice'); ?> | |
| 25 | + <?php esc_html_e('Edit Payment', 'easy-invoice'); ?> | |
| 22 | 26 | </h1> |
| 23 | - <a href="<?php echo admin_url('admin.php?page=easy-invoice-payments'); ?>" | |
| 27 | + <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice-payments')); ?>" | |
| 24 | 28 | 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"> |
| 25 | - <?php _e('Back to Payments', 'easy-invoice'); ?> | |
| 29 | + <?php esc_html_e('Back to Payments', 'easy-invoice'); ?> | |
| 26 | 30 | </a> |
| 27 | 31 | </div> |
| 28 | 32 | |
| 29 | 33 | |
| @@ -28,9 +32,9 @@ | ||
| 28 | 32 | |
| 29 | 33 | |
| 30 | 34 | |
| 31 | 35 | <div class="bg-white shadow overflow-hidden sm:rounded-lg"> |
| 32 | - <form method="post" action="<?php echo admin_url('admin-ajax.php'); ?>" id="edit-payment-form" class="space-y-6 p-6"> | |
| 36 | + <form method="post" action="<?php echo esc_url(admin_url('admin-ajax.php')); ?>" id="edit-payment-form" class="space-y-6 p-6"> | |
| 33 | 37 | <?php wp_nonce_field('easy_invoice_payment', 'payment_nonce'); ?> |
| 34 | 38 | <input type="hidden" name="action" value="easy_invoice_update_payment"> |
| 35 | 39 | <input type="hidden" name="payment_id" value="<?php echo esc_attr($payment->getId()); ?>"> |
| 36 | 40 | |
| @@ -36,13 +40,13 @@ | ||
| 36 | 40 | |
| 37 | 41 | <div class="grid grid-cols-1 gap-6 sm:grid-cols-2"> |
| 38 | 42 | <div> |
| 39 | 43 | <label for="invoice_id" class="block text-sm font-medium text-gray-700"> |
| 40 | - <?php _e('Invoice', 'easy-invoice'); ?> <span class="text-red-500">*</span> | |
| 44 | + <?php esc_html_e('Invoice', 'easy-invoice'); ?> <span class="text-red-500">*</span> | |
| 41 | 45 | </label> |
| 42 | 46 | <select name="invoice_id" id="invoice_id" required |
| 43 | 47 | class="mt-1 block w-full pl-3 pr-10 py-2 text-base border border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"> |
| 44 | - <option value=""><?php _e('Select Invoice', 'easy-invoice'); ?></option> | |
| 48 | + <option value=""><?php esc_html_e('Select Invoice', 'easy-invoice'); ?></option> | |
| 45 | 49 | <?php |
| 46 | 50 | // Get current payment's invoice ID |
| 47 | 51 | $current_invoice_id = $payment->getInvoiceId(); |
| 48 | 52 | |
| @@ -113,10 +117,10 @@ | ||
| 113 | 117 | } |
| 114 | 118 | |
| 115 | 119 | printf( |
| 116 | 120 | '<option value="%d" %s>%s - %s</option>', |
| 117 | - $invoice->getId(), | |
| 118 | - $is_selected ? 'selected="selected"' : '', | |
| 121 | + (int) $invoice->getId(), | |
| 122 | + $is_selected ? 'selected="selected"' : '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- literal attribute. | |
| 119 | 123 | esc_html($invoice_number), |
| 120 | 124 | esc_html($currency_symbol . number_format($total, 2)) |
| 121 | 125 | ); |
| 122 | 126 | } |
| @@ -125,13 +129,13 @@ | ||
| 125 | 129 | </div> |
| 126 | 130 | |
| 127 | 131 | <div> |
| 128 | 132 | <label for="payment_method" class="block text-sm font-medium text-gray-700"> |
| 129 | - <?php _e('Payment Method', 'easy-invoice'); ?> <span class="text-red-500">*</span> | |
| 133 | + <?php esc_html_e('Payment Method', 'easy-invoice'); ?> <span class="text-red-500">*</span> | |
| 130 | 134 | </label> |
| 131 | 135 | <select name="payment_method" id="payment_method" required |
| 132 | 136 | class="mt-1 block w-full pl-3 pr-10 py-2 text-base border border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"> |
| 133 | - <option value=""><?php _e('Select Payment Method', 'easy-invoice'); ?></option> | |
| 137 | + <option value=""><?php esc_html_e('Select Payment Method', 'easy-invoice'); ?></option> | |
| 134 | 138 | <?php |
| 135 | 139 | $current_payment_method = $payment->getPaymentMethod(); |
| 136 | 140 | if (empty($current_payment_method)) { |
| 137 | 141 | $current_payment_method = get_post_meta($payment->getId(), '_payment_method', true); |
| @@ -165,13 +169,13 @@ | ||
| 165 | 169 | </div> |
| 166 | 170 | |
| 167 | 171 | <div> |
| 168 | 172 | <label for="amount" class="block text-sm font-medium text-gray-700"> |
| 169 | - <?php _e('Amount', 'easy-invoice'); ?> <span class="text-red-500">*</span> | |
| 173 | + <?php esc_html_e('Amount', 'easy-invoice'); ?> <span class="text-red-500">*</span> | |
| 170 | 174 | </label> |
| 171 | 175 | <div class="mt-1 relative rounded-md shadow-sm"> |
| 172 | 176 | <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"> |
| 173 | - <span class="text-gray-500 sm:text-sm"><?php echo get_option('easy_invoice_currency_symbol', '$'); ?></span> | |
| 177 | + <span class="text-gray-500 sm:text-sm"><?php echo esc_html(get_option('easy_invoice_currency_symbol', '$')); ?></span> | |
| 174 | 178 | </div> |
| 175 | 179 | <input type="number" name="amount" id="amount" step="0.01" required |
| 176 | 180 | value="<?php echo esc_attr($payment->getAmount()); ?>" |
| 177 | 181 | class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 pl-7 pr-3 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" |
| @@ -180,9 +184,9 @@ | ||
| 180 | 184 | </div> |
| 181 | 185 | |
| 182 | 186 | <div> |
| 183 | 187 | <label for="payment_date" class="block text-sm font-medium text-gray-700"> |
| 184 | - <?php _e('Payment Date', 'easy-invoice'); ?> <span class="text-red-500">*</span> | |
| 188 | + <?php esc_html_e('Payment Date', 'easy-invoice'); ?> <span class="text-red-500">*</span> | |
| 185 | 189 | </label> |
| 186 | 190 | <input type="date" name="payment_date" id="payment_date" |
| 187 | 191 | value="<?php |
| 188 | 192 | $payment_date = $payment->getPaymentDate(); |
| @@ -189,9 +193,9 @@ | ||
| 189 | 193 | if (empty($payment_date)) { |
| 190 | 194 | $payment_date = get_post_meta($payment->getId(), '_payment_date', true); |
| 191 | 195 | } |
| 192 | 196 | if (empty($payment_date)) { |
| 193 | - $payment_date = date('Y-m-d'); | |
| 197 | + $payment_date = current_time('Y-m-d'); | |
| 194 | 198 | } |
| 195 | 199 | |
| 196 | 200 | // Ensure date is in YYYY-MM-DD format for HTML date input |
| 197 | 201 | if (!empty($payment_date)) { |
| @@ -196,11 +200,11 @@ | ||
| 196 | 200 | // Ensure date is in YYYY-MM-DD format for HTML date input |
| 197 | 201 | if (!empty($payment_date)) { |
| 198 | 202 | $timestamp = strtotime($payment_date); |
| 199 | 203 | if ($timestamp) { |
| 200 | - $payment_date = date('Y-m-d', $timestamp); | |
| 204 | + $payment_date = gmdate('Y-m-d', $timestamp); | |
| 201 | 205 | } else { |
| 202 | - $payment_date = date('Y-m-d'); | |
| 206 | + $payment_date = current_time('Y-m-d'); | |
| 203 | 207 | } |
| 204 | 208 | } |
| 205 | 209 | |
| 206 | 210 | echo esc_attr($payment_date); |
| @@ -209,27 +213,27 @@ | ||
| 209 | 213 | </div> |
| 210 | 214 | |
| 211 | 215 | <div> |
| 212 | 216 | <label for="status" class="block text-sm font-medium text-gray-700"> |
| 213 | - <?php _e('Status', 'easy-invoice'); ?> <span class="text-red-500">*</span> | |
| 217 | + <?php esc_html_e('Status', 'easy-invoice'); ?> <span class="text-red-500">*</span> | |
| 214 | 218 | </label> |
| 215 | 219 | <select name="status" id="status" required |
| 216 | 220 | class="mt-1 block w-full pl-3 pr-10 py-2 text-base border border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"> |
| 217 | - <option value="pending" <?php selected($payment->getStatus(), 'pending'); ?>><?php _e('Pending', 'easy-invoice'); ?></option> | |
| 218 | - <option value="completed" <?php selected($payment->getStatus(), 'completed'); ?>><?php _e('Completed', 'easy-invoice'); ?></option> | |
| 219 | - <option value="failed" <?php selected($payment->getStatus(), 'failed'); ?>><?php _e('Failed', 'easy-invoice'); ?></option> | |
| 220 | - <option value="refunded" <?php selected($payment->getStatus(), 'refunded'); ?>><?php _e('Refunded', 'easy-invoice'); ?></option> | |
| 221 | + <option value="pending" <?php selected($payment->getStatus(), 'pending'); ?>><?php esc_html_e('Pending', 'easy-invoice'); ?></option> | |
| 222 | + <option value="completed" <?php selected($payment->getStatus(), 'completed'); ?>><?php esc_html_e('Completed', 'easy-invoice'); ?></option> | |
| 223 | + <option value="failed" <?php selected($payment->getStatus(), 'failed'); ?>><?php esc_html_e('Failed', 'easy-invoice'); ?></option> | |
| 224 | + <option value="refunded" <?php selected($payment->getStatus(), 'refunded'); ?>><?php esc_html_e('Refunded', 'easy-invoice'); ?></option> | |
| 221 | 225 | </select> |
| 222 | 226 | </div> |
| 223 | 227 | |
| 224 | 228 | <div class="sm:col-span-2"> |
| 225 | 229 | <label for="notes" class="block text-sm font-medium text-gray-700"> |
| 226 | - <?php _e('Notes', 'easy-invoice'); ?> | |
| 230 | + <?php esc_html_e('Notes', 'easy-invoice'); ?> | |
| 227 | 231 | </label> |
| 228 | 232 | <div class="mt-1"> |
| 229 | 233 | <textarea name="notes" id="notes" rows="3" |
| 230 | 234 | class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" |
| 231 | - placeholder="<?php _e('Add any additional notes about this payment...', 'easy-invoice'); ?>"><?php echo wp_kses_post($payment->getNotes()); ?></textarea> | |
| 235 | + placeholder="<?php echo esc_js(__('Add any additional notes about this payment...', 'easy-invoice')); ?>"><?php echo wp_kses_post($payment->getNotes()); ?></textarea> | |
| 232 | 236 | </div> |
| 233 | 237 | </div> |
| 234 | 238 | </div> |
| 235 | 239 | |
| @@ -236,9 +240,9 @@ | ||
| 236 | 240 | <div class="pt-5"> |
| 237 | 241 | <div class="flex justify-end"> |
| 238 | 242 | <button type="submit" |
| 239 | 243 | class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"> |
| 240 | - <?php _e('Update Payment', 'easy-invoice'); ?> | |
| 244 | + <?php esc_html_e('Update Payment', 'easy-invoice'); ?> | |
| 241 | 245 | </button> |
| 242 | 246 | </div> |
| 243 | 247 | </div> |
| 244 | 248 | </form> |
| @@ -260,16 +264,16 @@ | ||
| 260 | 264 | processData: false, |
| 261 | 265 | contentType: false, |
| 262 | 266 | success: function(response) { |
| 263 | 267 | if (response.success) { |
| 264 | - EasyInvoiceToast.success(response.data.message || '<?php _e('Payment updated successfully', 'easy-invoice'); ?>'); | |
| 268 | + EasyInvoiceToast.success(response.data.message || '<?php echo esc_js(__('Payment updated successfully', 'easy-invoice')); ?>'); | |
| 265 | 269 | } else { |
| 266 | - EasyInvoiceToast.error(response.data.message || '<?php _e('An error occurred', 'easy-invoice'); ?>'); | |
| 270 | + EasyInvoiceToast.error(response.data.message || '<?php echo esc_js(__('An error occurred', 'easy-invoice')); ?>'); | |
| 267 | 271 | } |
| 268 | 272 | }, |
| 269 | 273 | error: function() { |
| 270 | - EasyInvoiceToast.error('<?php _e('An error occurred', 'easy-invoice'); ?>'); | |
| 274 | + EasyInvoiceToast.error('<?php echo esc_js(__('An error occurred', 'easy-invoice')); ?>'); | |
| 271 | 275 | } |
| 272 | 276 | }); |
| 273 | 277 | }); |
| 274 | 278 | }); |
| 275 | 279 | </script> |