Skip to content

Commit 07d6626

Browse files
committed
Replacing the __( with a proper escaping translation file.
1 parent f7b5ed5 commit 07d6626

16 files changed

+460
-460
lines changed

includes/classes/class-confirm-payment.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function confirm_payment() {
121121
if ( ! isset( $_POST['nonce'] ) || false === wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'pff-paystack-confirm' ) ) {
122122
$response = array(
123123
'error' => true,
124-
'error_message' => __( 'Nonce verification is required.', 'pff-paystack' ),
124+
'error_message' => esc_html__( 'Nonce verification is required.', 'pff-paystack' ),
125125
);
126126

127127
exit( wp_json_encode( $response ) );
@@ -132,7 +132,7 @@ public function confirm_payment() {
132132
if ( ! isset( $_POST['code'] ) || '' === trim( wp_unslash( $_POST['code'] ) ) ) {
133133
$response = array(
134134
'error' => true,
135-
'error_message' => __( 'Did you make a payment?', 'pff-paystack' ),
135+
'error_message' => esc_html__( 'Did you make a payment?', 'pff-paystack' ),
136136
);
137137

138138
exit( wp_json_encode( $response ) );
@@ -169,14 +169,14 @@ public function confirm_payment() {
169169
}
170170
} else {
171171
$response = [
172-
'message' => __( 'Failed to connect to Paystack.', 'pff-paystack' ),
172+
'message' => esc_html__( 'Failed to connect to Paystack.', 'pff-paystack' ),
173173
'result' => 'failed',
174174
];
175175
}
176176

177177
} else {
178178
$response = [
179-
'message' => __( 'Payment Verification Failed', 'pff-paystack' ),
179+
'message' => esc_html__( 'Payment Verification Failed', 'pff-paystack' ),
180180
'result' => 'failed',
181181
];
182182
}
@@ -244,7 +244,7 @@ public function confirm_payment() {
244244
*/
245245
public function add_param_to_url( $url, $ref ) {
246246
// Parse the URL.
247-
$parsed_url = parse_url( $url );
247+
$parsed_url = wp_parse_url( $url );
248248

249249
// Parse query parameters into an array.
250250
parse_str( isset( $parsed_url['query'] ) ? $parsed_url['query'] : '', $query_params );
@@ -312,7 +312,7 @@ protected function update_payment_dates( $data ) {
312312
global $wpdb;
313313
$table = $wpdb->prefix . PFF_PAYSTACK_TABLE;
314314
$return = [
315-
'message' => __( 'DB not updated.', 'pff-paystack' ),
315+
'message' => esc_html__( 'DB not updated.', 'pff-paystack' ),
316316
'result' => 'failed',
317317
];
318318

@@ -355,7 +355,7 @@ protected function update_payment_dates( $data ) {
355355
if ( (int) $this->oamount !== (int) $amount_paid ) {
356356
$return = [
357357
// translators: %1$s: currency, %2$s: formatted amount required
358-
'message' => sprintf( __( 'Invalid amount Paid. Amount required is %1$s<b>%2$s</b>', 'pff-paystack' ), $this->meta['currency'], number_format( $this->oamount ) ),
358+
'message' => sprintf( esc_html__( 'Invalid amount Paid. Amount required is %1$s<b>%2$s</b>', 'pff-paystack' ), $this->meta['currency'], number_format( $this->oamount ) ),
359359
'result' => 'failed',
360360
];
361361
} else {

includes/classes/class-email-invoice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function send_invoice( $form_id, $currency, $amount, $name, $email, $code
6060

6161
$this->subject = sprintf(
6262
// Translators: %1$s is the currency code, %2$s is the formatted amount
63-
__( 'Payment Invoice for %1$s %2$s', 'text-domain' ),
63+
esc_html__( 'Payment Invoice for %1$s %2$s', 'text-domain' ),
6464
$currency,
6565
number_format( $amount )
6666
);

includes/classes/class-email-receipt-owner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function send_receipt_owner( $form_id, $currency, $amount, $name, $email, $code,
5656
$this->metadata = $metadata;
5757

5858
// Custom Values
59-
$this->subject = __( 'You just received a payment' , 'pff-paystack' );
59+
$this->subject = esc_html__( 'You just received a payment' , 'pff-paystack' );
6060
$this->heading = get_post_meta( $form_id, '_heading', true );
6161
$this->sitemessage = get_post_meta( $form_id, '_message', true );
6262

includes/classes/class-field-shortcodes.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct() {
3737
public function text_field( $atts ) {
3838
$atts = shortcode_atts(
3939
array(
40-
'name' => __( 'Title', 'pff-paystack' ),
40+
'name' => esc_html__( 'Title', 'pff-paystack' ),
4141
'required' => '0',
4242
),
4343
$atts,
@@ -71,7 +71,7 @@ public function text_field( $atts ) {
7171
public function textarea_field( $atts ) {
7272
$atts = shortcode_atts(
7373
array(
74-
'name' => __( 'Title', 'pff-paystack' ),
74+
'name' => esc_html__( 'Title', 'pff-paystack' ),
7575
'required' => '0',
7676
),
7777
$atts,
@@ -106,7 +106,7 @@ public function textarea_field( $atts ) {
106106
public function checkbox_field( $atts ) {
107107
$atts = shortcode_atts(
108108
array(
109-
'name' => __( 'Title', 'pff-paystack' ),
109+
'name' => esc_html__( 'Title', 'pff-paystack' ),
110110
'options' => '',
111111
'required' => '0',
112112
),
@@ -150,7 +150,7 @@ public function checkbox_field( $atts ) {
150150
public function input_field( $atts ) {
151151
$atts = shortcode_atts(
152152
array(
153-
'name' => __( 'Title', 'pff-paystack' ),
153+
'name' => esc_html__( 'Title', 'pff-paystack' ),
154154
'required' => '0',
155155
),
156156
$atts,
@@ -172,7 +172,7 @@ public function input_field( $atts ) {
172172
$code .= '</label>';
173173
$code .= '<div class="input append-small-btn">';
174174
$code .= '<div class="file-button">';
175-
$code .= __( 'Browse', 'pff-paystack' );
175+
$code .= esc_html__( 'Browse', 'pff-paystack' );
176176
$code .= '<input type="file" id="' . esc_attr( $fileInputId ) . '" name="' . esc_attr( $name ) . '" onchange="document.getElementById(\'' . esc_attr( $textInputId ) . '\').value = this.value;" ' . esc_attr( $required ) . '>';
177177
$code .= '</div>';
178178
$code .= '<input type="text" id="' . esc_attr( $textInputId ) . '" readonly="" placeholder="' . esc_attr__( 'No file selected', 'pff-paystack' ) . '">';
@@ -189,7 +189,7 @@ public function input_field( $atts ) {
189189
public function datepicker_field( $atts ) {
190190
$atts = shortcode_atts(
191191
array(
192-
'name' => __( 'Title', 'pff-paystack' ),
192+
'name' => esc_html__( 'Title', 'pff-paystack' ),
193193
'required' => '0',
194194
),
195195
$atts,
@@ -223,7 +223,7 @@ public function datepicker_field( $atts ) {
223223
public function select_field( $atts ) {
224224
$atts = shortcode_atts(
225225
array(
226-
'name' => __( 'Title', 'pff-paystack' ),
226+
'name' => esc_html__( 'Title', 'pff-paystack' ),
227227
'options' => '',
228228
'required' => '0',
229229
),
@@ -264,7 +264,7 @@ public function select_field( $atts ) {
264264
public function radio_field( $atts ) {
265265
$atts = shortcode_atts(
266266
array(
267-
'name' => __( 'Title', 'pff-paystack' ),
267+
'name' => esc_html__( 'Title', 'pff-paystack' ),
268268
'options' => '',
269269
'required' => '0',
270270
),

includes/classes/class-form-shortcode.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function form_shortcode( $atts ) {
144144
if ( $show_form ) {
145145

146146
if ( 'yes' === $this->meta['useinventory'] && 0 >= $this->stock ) {
147-
echo '<h1>' . __( 'Out of Stock', 'pff-paystack' ) . '</h1>';
147+
$html[] = '<h1>' . esc_html__( 'Out of Stock', 'pff-paystack' ) . '</h1>';
148148
} else {
149149
// Form title
150150
if ( $this->meta['hidetitle'] != 1 ) {
@@ -180,13 +180,13 @@ public function form_shortcode( $atts ) {
180180
}
181181

182182
} else {
183-
$html[] = '<h5>' . __( 'You must be logged in to make a payment.', 'pff-paystack' ) . '</h5>';
183+
$html[] = '<h5>' . esc_html__( 'You must be logged in to make a payment.', 'pff-paystack' ) . '</h5>';
184184
}
185185
} else {
186-
$html[] = '<h5>' . __( 'Invalid Paystack form ID or the form does not exist.', 'pff-paystack' ) . '</h5>';
186+
$html[] = '<h5>' . esc_html__( 'Invalid Paystack form ID or the form does not exist.', 'pff-paystack' ) . '</h5>';
187187
}
188188
} else {
189-
$html[] = '<h5>' . __( 'No Paystack form ID provided.', 'pff-paystack' ) . '</h5>';
189+
$html[] = '<h5>' . esc_html__( 'No Paystack form ID provided.', 'pff-paystack' ) . '</h5>';
190190
}
191191

192192
$html = implode( '', $html );
@@ -242,7 +242,7 @@ public function set_meta_data( $obj ) {
242242
$this->meta['paymentoptions'] = array_map( 'sanitize_text_field', $this->meta['paymentoptions'] );
243243
}
244244

245-
$this->meta['planerrorcode'] = __( 'Input Correct Recurring Plan Code', 'pff-paystack' );
245+
$this->meta['planerrorcode'] = esc_html__( 'Input Correct Recurring Plan Code', 'pff-paystack' );
246246

247247
if ( 'plan' === $this->meta['recur'] ) {
248248
if ( '' === $this->meta['recurplan'] ) {
@@ -307,9 +307,9 @@ public function get_hidden_fields() {
307307
*/
308308
public function get_fullname_field() {
309309
$html = '<div class="span12 unit">
310-
<label class="label">' . __( 'Full Name', 'pff-paystack' ) . ' <span>*</span></label>
310+
<label class="label">' . esc_html__( 'Full Name', 'pff-paystack' ) . ' <span>*</span></label>
311311
<div class="input">
312-
<input type="text" name="pf-fname" placeholder="' . __( 'First & Last Name', 'pff-paystack' ) . '" value="' . esc_attr( $this->user['fullname'] ) . '" required>
312+
<input type="text" name="pf-fname" placeholder="' . esc_html__( 'First & Last Name', 'pff-paystack' ) . '" value="' . esc_attr( $this->user['fullname'] ) . '" required>
313313
</div>
314314
</div>';
315315
return $html;
@@ -322,9 +322,9 @@ public function get_fullname_field() {
322322
*/
323323
public function get_email_field() {
324324
$html = '<div class="span12 unit">
325-
<label class="label">' . __( 'Email', 'pff-paystack' ) . ' <span>*</span></label>
325+
<label class="label">' . esc_html__( 'Email', 'pff-paystack' ) . ' <span>*</span></label>
326326
<div class="input">
327-
<input type="email" name="pf-pemail" placeholder="' . __( 'Enter Email Address', 'pff-paystack' ) . '" id="pf-email" value="' . esc_attr( $this->user['email'] ) . '" ' . ( $this->meta['loggedin'] == 'yes' ? 'readonly' : '' ) . ' required>
327+
<input type="email" name="pf-pemail" placeholder="' . esc_html__( 'Enter Email Address', 'pff-paystack' ) . '" id="pf-email" value="' . esc_attr( $this->user['email'] ) . '" ' . ( $this->meta['loggedin'] == 'yes' ? 'readonly' : '' ) . ' required>
328328
</div>
329329
</div>';
330330
return $html;
@@ -371,7 +371,7 @@ public function get_amount_field() {
371371
} else {
372372

373373
if ( '' === $this->meta['variableamount'] || 0 === $this->meta['variableamount'] || ! is_array( $this->meta['paymentoptions'] ) ) {
374-
$html[] = __( 'Form Error, set variable amount string', 'pff-paystack' );
374+
$html[] = esc_html__( 'Form Error, set variable amount string', 'pff-paystack' );
375375
} else if ( count( $this->meta['paymentoptions'] ) > 0 ) {
376376
$html[] = '<div class="select">
377377
<input type="hidden" id="pf-vname" name="pf-vname" />
@@ -538,44 +538,44 @@ public function get_retry_form( $code = '' ) {
538538

539539

540540
$html[] = '<div class="divider-text gap-top-20 gap-bottom-45">
541-
<span>' . __( 'Payment Invoice', 'pff-paystack' ) . '</span>
541+
<span>' . esc_html__( 'Payment Invoice', 'pff-paystack' ) . '</span>
542542
</div>';
543543

544544
$html[] = '<div class="j-row">';
545545

546546
$html[] = '<div class="span12 unit">
547-
<label class="label inline">' . __( 'Email:', 'pff-paystack' ) . '</label>
547+
<label class="label inline">' . esc_html__( 'Email:', 'pff-paystack' ) . '</label>
548548
<strong><a href="mailto:' . esc_attr( $record->email ) . '">' . esc_html( $record->email ) . '</a></strong>
549549
</div>';
550550

551551
$html[] = '<div class="span12 unit">
552-
<label class="label inline">' . __( 'Amount:', 'pff-paystack' ) . '</label>
552+
<label class="label inline">' . esc_html__( 'Amount:', 'pff-paystack' ) . '</label>
553553
<strong>' . esc_html( $this->meta['currency'] . number_format( $record->amount ) ) . '</strong>
554554
</div>';
555555

556556

557557
$html[] = $this->helpers->format_meta_as_display_fields( $record->metadata );
558558

559559
$html[] = '<div class="span12 unit">
560-
<label class="label inline">' . __( 'Date:', 'pff-paystack' ) . '</label>
560+
<label class="label inline">' . esc_html__( 'Date:', 'pff-paystack' ) . '</label>
561561
<strong>' . esc_html( $record->created_at ) . '</strong>
562562
</div>';
563563

564564
if ( 1 === intval( $record->paid ) ) {
565565
$html[] = '<div class="span12 unit">
566-
<label class="label inline">' . __( 'Payment Status:', 'pff-paystack' ) . '</label>
567-
<strong>' . __( 'Successful', 'pff-paystack' ) . '</strong>
566+
<label class="label inline">' . esc_html__( 'Payment Status:', 'pff-paystack' ) . '</label>
567+
<strong>' . esc_html__( 'Successful', 'pff-paystack' ) . '</strong>
568568
</div>';
569569
}
570570

571571
$html[] = '</div>';
572572
$html[] = '</div>';
573573

574574
$html[] = '<div class="footer">';
575-
$html[] = '<small><span style="color: red;">*</span> ' . __( 'are compulsory', 'pff-paystack' ) . '</small><br>';
575+
$html[] = '<small><span style="color: red;">*</span> ' . esc_html__( 'are compulsory', 'pff-paystack' ) . '</small><br>';
576576
$html[] = '<img class="paystack-cardlogos size-full wp-image-1096" alt="cardlogos" src="' . esc_url( PFF_PAYSTACK_PLUGIN_URL . '/assets/images/[email protected]' ) . '">';
577577
if ( 0 === intval( $record->paid ) ) {
578-
$html[] = '<button type="submit" class="primary-btn" id="submitbtn">' . __( 'Retry Payment', 'pff-paystack' ) . '</button>';
578+
$html[] = '<button type="submit" class="primary-btn" id="submitbtn">' . esc_html__( 'Retry Payment', 'pff-paystack' ) . '</button>';
579579
}
580580

581581
$html[] = ' </div>';

includes/classes/class-form-submit.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,21 @@ protected function valid_submission() {
9797

9898
if ( ! isset( $_POST['pf-nonce'] ) || false === wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['pf-nonce'] ) ), 'pff-paystack-invoice' ) ) {
9999
$this->response['result'] = 'failed';
100-
$this->response['message'] = __( 'Nonce verification is required.', 'pff-paystack' );
100+
$this->response['message'] = esc_html__( 'Nonce verification is required.', 'pff-paystack' );
101101
return false;
102102
}
103103

104104
if ( ! isset( $_POST['pf-id'] ) || '' == trim( sanitize_text_field( wp_unslash( $_POST['pf-id'] ) ) ) ) {
105105
$this->response['result'] = 'failed';
106-
$this->response['message'] = __( 'A form ID is required', 'pff-paystack' );
106+
$this->response['message'] = esc_html__( 'A form ID is required', 'pff-paystack' );
107107
return false;
108108
} else {
109109
$this->form_id = sanitize_text_field( wp_unslash( $_POST['pf-id'] ) );
110110
}
111111

112112
if ( ! isset( $_POST['pf-pemail'] ) || '' == trim( sanitize_text_field( wp_unslash( $_POST['pf-pemail'] ) ) ) ) {
113113
$this->response['result'] = 'failed';
114-
$this->response['message'] = __( 'Email is required', 'pff-paystack' );
114+
$this->response['message'] = esc_html__( 'Email is required', 'pff-paystack' );
115115
return false;
116116
}
117117
return true;
@@ -248,7 +248,7 @@ public function process_images() {
248248
if ( $value['size'] > $max_file_size ) {
249249
$response['result'] = 'failed';
250250
// translators: %s: maximum upload file size in MB
251-
$response['message'] = sprintf( __( 'Max upload size is %sMB', 'pff-paystack' ), $this->meta['filelimit'] );
251+
$response['message'] = sprintf( esc_html__( 'Max upload size is %sMB', 'pff-paystack' ), $this->meta['filelimit'] );
252252
exit( wp_json_encode( $response ) );
253253
} else {
254254
$attachment_id = media_handle_upload( $key_name, $this->form_id );
@@ -265,7 +265,7 @@ public function process_images() {
265265
'display_name' => ucwords( str_replace( '_', ' ', $key_name ) ),
266266
'variable_name' => $key_name,
267267
'type' => 'text',
268-
'value' => __( 'No file Uploaded', 'pff-paystack' ),
268+
'value' => esc_html__( 'No file Uploaded', 'pff-paystack' ),
269269
);
270270
}
271271
}
@@ -307,7 +307,7 @@ public function submit_action() {
307307

308308
// Store the single unit price.
309309
$this->fixed_metadata[] = array(
310-
'display_name' => __( 'Unit Price', 'pff-paystack' ),
310+
'display_name' => esc_html__( 'Unit Price', 'pff-paystack' ),
311311
'variable_name' => 'Unit_Price',
312312
'type' => 'text',
313313
'value' => $this->meta['currency'] . number_format( $amount ),
@@ -478,15 +478,15 @@ public function process_recurring_plans( $amount ) {
478478
if ( 'none' !== $plan_code ) {
479479
$this->meta['plancode'] = $plan_code;
480480
$this->fixed_metadata[] = array(
481-
'display_name' => __( 'Plan', 'pff-paystack' ),
481+
'display_name' => esc_html__( 'Plan', 'pff-paystack' ),
482482
'variable_name' => 'Plan',
483483
'type' => 'text',
484484
'value' => $plan_code,
485485
);
486486

487487
if ( false !== $has_interval ) {
488488
$this->fixed_metadata[] = array(
489-
'display_name' => __( 'Plan Interval', 'pff-paystack' ),
489+
'display_name' => esc_html__( 'Plan Interval', 'pff-paystack' ),
490490
'variable_name' => 'Plan Interval',
491491
'type' => 'text',
492492
'value' => $has_interval,

includes/classes/class-forms-list.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function quick_edit_links( $actions, $post ) {
3636
if ( get_post_type( $post ) === 'paystack_form' ) {
3737
unset( $actions['view'] );
3838
unset( $actions['quick edit'] );
39-
$actions['export'] = '<a href="' . admin_url( 'edit.php?post_type=paystack_form&page=submissions&form=' . $post->ID ) . '" >' . __( 'View Payments', 'payment_forms' ) . '</a>';
39+
$actions['export'] = '<a href="' . admin_url( 'edit.php?post_type=paystack_form&page=submissions&form=' . $post->ID ) . '" >' . esc_html__( 'View Payments', 'payment_forms' ) . '</a>';
4040
}
4141
return $actions;
4242
}
@@ -50,10 +50,10 @@ public function quick_edit_links( $actions, $post ) {
5050
public function register_columns( $columns ) {
5151
$columns = array(
5252
'cb' => '<input type="checkbox" />',
53-
'title' => __( 'Name', 'pff-paystack' ),
54-
'shortcode' => __( 'Shortcode', 'pff-paystack' ),
55-
'payments' => __( 'Payments', 'pff-paystack' ),
56-
'date' => __( 'Date', 'pff-paystack' )
53+
'title' => esc_html__( 'Name', 'pff-paystack' ),
54+
'shortcode' => esc_html__( 'Shortcode', 'pff-paystack' ),
55+
'payments' => esc_html__( 'Payments', 'pff-paystack' ),
56+
'date' => esc_html__( 'Date', 'pff-paystack' )
5757
);
5858
return $columns;
5959
}

0 commit comments

Comments
 (0)