Skip to content

Commit 60a5850

Browse files
committed
WPCS Updates
1 parent 42f1706 commit 60a5850

File tree

6 files changed

+28
-17
lines changed

6 files changed

+28
-17
lines changed

includes/classes/class-confirm-payment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ protected function update_payment_dates( $data ) {
269269
} else {
270270
if ( $this->oamount !== $amount_paid ) {
271271
$return = [
272-
'message' => sprintf( __( 'Invalid amount Paid. Amount required is %s<b>%s</b>', 'pff-paystack' ), $this->meta['currency'], number_format( $this->oamount ) ),
272+
// translators: %1$s: currency, %2$s: formatted amount required
273+
'message' => sprintf( __( 'Invalid amount Paid. Amount required is %1$s<b>%2$s</b>', 'pff-paystack' ), $this->meta['currency'], number_format( $this->oamount ) ),
273274
'result' => 'failed',
274275
];
275276
} else {

includes/classes/class-email-invoice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function get_html_body() {
125125
<tbody>
126126
<tr>
127127
<td class="column_cell font_default" align="center" valign="top" style="padding:16px 16px 0;font-family:Helvetica,Arial,sans-serif;font-size:15px;text-align:left;vertical-align:top;color:#888">
128-
<small class="text-muted" style="font-size:86%;font-weight:normal;color:#b3b3b5"><?php echo date('F j,Y'); ?></small>
128+
<small class="text-muted" style="font-size:86%;font-weight:normal;color:#b3b3b5"><?php echo esc_html( gmdate('F j,Y') ); ?></small>
129129
<h6 style="font-family:Helvetica,Arial,sans-serif;margin-left:0;margin-right:0;margin-top:0;margin-bottom:8px;padding:0;font-size:16px;line-height:24px;font-weight:bold;color:#666"><?php echo esc_html( $this->name ); ?></h6>
130130
<p style="font-family:Helvetica,Arial,sans-serif;font-size:15px;line-height:23px;margin-top:8px;margin-bottom:8px"><?php echo esc_html( $this->email ); ?></p>
131131
</td>
@@ -206,7 +206,7 @@ public function get_html_body() {
206206
<tbody>
207207
<tr>
208208
<td class="column_cell font_default" align="center" valign="top" style="padding:16px;font-family:Helvetica,Arial,sans-serif;font-size:15px;text-align:left;vertical-align:top;color:#b3b3b5;padding-bottom:0;padding-top:16px">
209-
<strong><?php echo get_option('blogname'); ?></strong><br>
209+
<strong><?php echo esc_html( get_option('blogname') ); ?></strong><br>
210210
</td>
211211
</tr>
212212
</tbody>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ public function get_html_body() {
163163
<tbody>
164164
<tr>
165165
<td class="column_cell font_default" align="center" valign="top" style="padding:16px 16px 0;font-family:Helvetica,Arial,sans-serif;font-size:15px;text-align:center;vertical-align:top;color:#888">
166-
<small style="font-size:86%;font-weight:normal"><strong>Notice</strong><br>
167-
You're getting this email because someone made a payment of <?php $this->currency . ' ' . number_format($this->amount); ?> to <a href="<?php echo get_bloginfo('url') ?>" style="display:inline-block;text-decoration:none;font-family:Helvetica,Arial,sans-serif;color:#2f68b4"><?php echo get_option('blogname'); ?></a>.</small>
166+
<small style="font-size:86%;font-weight:normal"><strong><?php echo esc_html__( 'Notice', 'pff-paystack' ); ?></strong><br>
167+
<?php echo esc_html__( 'You\'re getting this email because someone made a payment of', 'pff-paystack' ); ?> <?php $this->currency . ' ' . number_format($this->amount); ?> <?php echo esc_html__( 'to', 'pff-paystack' ); ?> <a href="<?php echo get_bloginfo( 'url' ) ?>" style="display:inline-block;text-decoration:none;font-family:Helvetica,Arial,sans-serif;color:#2f68b4"><?php echo esc_html( get_option( 'blogname' ) ); ?></a>.</small>
168168
</td>
169169
</tr>
170170
</tbody>
@@ -186,7 +186,7 @@ public function get_html_body() {
186186
<tbody>
187187
<tr>
188188
<td class="column_cell font_default" align="center" valign="top" style="padding:16px;font-family:Helvetica,Arial,sans-serif;font-size:15px;text-align:left;vertical-align:top;color:#b3b3b5;padding-bottom:0;padding-top:16px">
189-
<strong><?php echo get_option('blogname'); ?></strong><br>
189+
<strong><?php echo esc_html( get_option( 'blogname' ) ); ?></strong><br>
190190
</td>
191191
</tr>
192192
</tbody>

includes/classes/class-email-receipt.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function get_html_body() {
163163
// translators: %1$s is the currency code, %2$s is the formatted amount
164164
esc_html__( 'Amount : %1$s %2$s', 'pff-paystack' ),
165165
esc_html( $this->currency ),
166-
number_format_i18n( $this->amount )
166+
esc_html( number_format_i18n( $this->amount ) )
167167
);
168168
?><br>
169169
<?php

includes/classes/class-field-shortcodes.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ public function textarea_field( $atts ) {
9494

9595
$code .= '</label>';
9696
$code .= '<div class="input">';
97-
$code .= '<textarea id="' . esc_attr( $id ) . '" name="' . esc_attr( $name ) . '" rows="3" placeholder="' . sprintf( esc_attr__( 'Enter %s', 'pff-paystack' ), $name ) . '" ' . esc_attr( $required ) . '></textarea></div></div>';
97+
$code .= '<textarea id="' . esc_attr( $id ) . '" name="' . esc_attr( $name ) . '" rows="3" placeholder="' .
98+
// translators: %s: textarea field to be entered by the user
99+
sprintf( esc_attr__( 'Enter %s', 'pff-paystack' ), $name ) .
100+
'" ' . esc_attr( $required ) . '></textarea></div></div>';
98101

99102
return $code;
100103
}
@@ -210,7 +213,10 @@ public function datepicker_field( $atts ) {
210213

211214
$code .= '</label>';
212215
$code .= '<div class="input">';
213-
$code .= '<input type="date" id="' . esc_attr( $id ) . '" class="date-picker" name="' . esc_attr( $name ) . '" placeholder="' . sprintf( esc_attr__( 'Enter %s', 'pff-paystack' ), $name ) . '" ' . esc_attr( $required ) . ' /></div></div>';
216+
$code .= '<input type="date" id="' . esc_attr( $id ) . '" class="date-picker" name="' . esc_attr( $name ) . '" placeholder="' .
217+
// translators: %s: datepicker field to be selected by the user
218+
sprintf( esc_attr__( 'Enter %s', 'pff-paystack' ), $name ) .
219+
'" ' . esc_attr( $required ) . ' /></div></div>';
214220

215221
return $code;
216222
}

includes/classes/class-helpers.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,19 @@ public function get_allowed_html() {
561561
* @return string User's IP address.
562562
*/
563563
public function get_the_user_ip() {
564+
$ip = '';
565+
564566
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
565-
$ip = $_SERVER['HTTP_CLIENT_IP'];
567+
$ip = sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
566568
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
567-
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
568-
} else {
569-
$ip = $_SERVER['REMOTE_ADDR'];
569+
$ip = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) );
570+
} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
571+
$ip = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
570572
}
573+
571574
return $ip;
572575
}
576+
573577

574578
/**
575579
* Get the DB records by the transaction code supplied.
@@ -770,7 +774,7 @@ public function generate_new_code( $length = 10 ) {
770774
$random_string = '';
771775

772776
for ( $i = 0; $i < $length; $i++ ) {
773-
$random_string .= $characters[ rand( 0, $characters_length - 1 ) ];
777+
$random_string .= $characters[ wp_rand( 0, $characters_length - 1 ) ];
774778
}
775779

776780
return time() . '_' . $random_string;
@@ -786,17 +790,17 @@ public function generate_new_code( $length = 10 ) {
786790
public function check_code( $code ) {
787791
global $wpdb;
788792
$table = $wpdb->prefix . PFF_PAYSTACK_TABLE;
789-
790793
$o_exist = $wpdb->get_results(
791794
$wpdb->prepare(
792-
"SELECT * FROM {$table} WHERE txn_code = %s",
795+
"SELECT * FROM %i WHERE txn_code = %s",
796+
$table,
793797
$code
794798
)
795799
);
796-
797800
return ( count( $o_exist ) > 0 );
798801
}
799802

803+
800804
/**
801805
* Takes the amount and processes the "transactional" fees.
802806
*

0 commit comments

Comments
 (0)