Skip to content

Commit

Permalink
Fix "Undefined array key" notices.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Jan 10, 2023
1 parent 69a4bcc commit 4677a8d
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions views/payment-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@
* @since 1.0.0
*/

$field_amount = '';

if ( \array_key_exists( 'pronamic_pay_amount_field', $instance->post_content ) ) {
$field_amount = $instance->post_content['pronamic_pay_amount_field'];
}

$field_method = '';

if ( \array_key_exists( 'pronamic_pay_payment_method_field', $instance->post_content ) ) {
$field_method = $instance->post_content['pronamic_pay_payment_method_field'];
}

$config_id = 0;

if ( \array_key_exists( 'pronamic_pay_config_id', $instance->post_content ) ) {
$config_id = $instance->post_content['pronamic_pay_config_id'];
}

$transaction_description = '';

if ( \array_key_exists( 'pronamic_pay_transaction_description', $instance->post_content ) ) {
$transaction_description = $instance->post_content['pronamic_pay_transaction_description'];
}

$delay_notifications = '';

if ( \array_key_exists( 'pronamic_pay_delay_notifications', $instance->post_content ) ) {
$delay_notifications = $instance->post_content['pronamic_pay_delay_notifications'];
}

?>
<table class="form-table">
<tr>
Expand All @@ -25,8 +55,6 @@
<td>
<?php

$current = $instance->post_content['pronamic_pay_amount_field'];

printf(
'<select name="%s">',
esc_attr( $this->get_field_name( 'pronamic_pay_amount_field' ) )
Expand All @@ -44,7 +72,7 @@
printf(
'<option value="%s" %s>%s</option>',
esc_attr( $value ),
selected( $current, $value, false ),
selected( $field_amount, $value, false ),
esc_html( $label )
);
}
Expand All @@ -61,8 +89,6 @@
<td>
<?php

$current = $instance->post_content['pronamic_pay_payment_method_field'];

printf(
'<select name="%s">',
esc_attr( $this->get_field_name( 'pronamic_pay_payment_method_field' ) )
Expand All @@ -84,7 +110,7 @@
printf(
'<option value="%s" %s>%s</option>',
esc_attr( $value ),
selected( $current, $value, false ),
selected( $field_method, $value, false ),
esc_html( $label )
);
}
Expand Down Expand Up @@ -114,7 +140,7 @@
\printf(
'<option value="%s" %s>%s</option>',
\esc_attr( $value ),
\selected( $instance->post_content['pronamic_pay_config_id'], $value, false ),
\selected( $config_id, $value, false ),
\esc_html( $label )
);
}
Expand All @@ -134,7 +160,7 @@
printf(
'<input type="text" name="%s" value="%s" class="large-text frm_help" title="" data-original-title="%s" />',
esc_attr( $this->get_field_name( 'pronamic_pay_transaction_description' ) ),
esc_attr( $instance->post_content['pronamic_pay_transaction_description'] ),
esc_attr( $transaction_description ),
esc_attr__( 'Enter a transaction description, you can use Formidable Forms shortcodes.', 'pronamic_ideal' )
);

Expand All @@ -152,7 +178,7 @@
printf(
'<input type="checkbox" name="%s" title="" %s /> %s',
esc_attr( $this->get_field_name( 'pronamic_pay_delay_notifications' ) ),
checked( $instance->post_content['pronamic_pay_delay_notifications'], 'on', false ),
checked( $delay_notifications, 'on', false ),
esc_attr__( 'Delay email notifications until payment has been received.', 'pronamic_ideal' )
);

Expand Down

0 comments on commit 4677a8d

Please sign in to comment.