Skip to content

Commit 2d57c1c

Browse files
authored
Merge pull request #276 from skyverge/fix-gateways-settings-warning
Fix a PHP warning in 7.2 from the gateway settings
2 parents d9f53cc + b64d4ad commit 2d57c1c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

woocommerce/payment-gateway/class-sv-wc-payment-gateway.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,19 +3134,25 @@ protected function add_authorization_charge_form_fields( $form_fields ) {
31343134
}
31353135

31363136
// get a list of the "paid" status names
3137-
$paid_statuses = array_map( 'wc_get_order_status_name', SV_WC_Plugin_Compatibility::wc_get_is_paid_statuses() );
3137+
$paid_statuses = array_map( 'wc_get_order_status_name', (array) SV_WC_Plugin_Compatibility::wc_get_is_paid_statuses() );
31383138

31393139
// do some oxford comma magic
3140-
$last_status = array_pop( $paid_statuses );
3141-
array_push( $paid_statuses, "or {$last_status}" );
3142-
$separator = count( $last_status ) < 3 ? ' ' : ', ';
3140+
if ( count( $paid_statuses ) > 1 ) {
3141+
3142+
$last_status = array_pop( $paid_statuses );
3143+
3144+
/* translators: a conjuction used in the list of order status names, such as "Processing, Completed, or Shipped" */
3145+
array_push( $paid_statuses, __( 'or', 'woocommerce-plugin-framework' ) . ' ' . $last_status );
3146+
}
3147+
3148+
$separator = count( $paid_statuses ) < 3 ? ' ' : ', ';
31433149

31443150
$form_fields['enable_paid_capture'] = array(
31453151
'label' => __( 'Capture Paid Orders', 'woocommerce-plugin-framework' ),
31463152
'type' => 'checkbox',
31473153
'description' => sprintf(
31483154
__( 'Automatically capture orders when they are changed to %s.', 'woocommerce-plugin-framework' ),
3149-
implode( $separator, $paid_statuses )
3155+
esc_html( ! empty( $paid_statuses ) ? implode( $separator, $paid_statuses ) : __( 'a paid status', 'woocommerce-plugin-framework' ) )
31503156
),
31513157
'default' => 'no',
31523158
);

0 commit comments

Comments
 (0)