Skip to content

Fix HTML Rendering Issues in WooCommerce PostFinanceCheckout Plugin #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 30 additions & 31 deletions includes/admin/class-wc-postfinancecheckout-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,51 +352,50 @@ public function store_attribute_options( $product, $data_storage ) { //phpcs:ign
* Display attribute options edit screen
*/
public function display_attribute_options_edit() {
if ( ! isset( $_GET['edit'] ) ) {// phpcs:ignore
if ( ! isset( $_GET['edit'] ) ) {
return;
} else {
$edit = esc_url_raw( wp_unslash( $_GET['edit'] ) );// phpcs:ignore
$edit = absint( $_GET['edit'] );
}
$edit = absint( $edit );
$checked = false;
$attribute_options = WC_PostFinanceCheckout_Entity_Attribute_Options::load_by_attribute_id( $edit );
if ( $attribute_options->get_id() > 0 && $attribute_options->get_send() ) {
$checked = true;
}
echo esc_html(
'<tr class="form-field form-required">
<th scope="row" valign="top">
<label for="postfinancecheckout_attribute_option_send">'
) . esc_html__( 'Send attribute to PostFinance Checkout.', 'woo-postfinancecheckout' ) . esc_html(
'</label>
</th>
<td>
<input name="postfinancecheckout_attribute_option_send" id="postfinancecheckout_attribute_option_send" type="checkbox" value="1" '
) . esc_attr( checked( $checked, true, false ) ) . esc_html(
'/>
<p class="description">'
) . esc_html__( 'Should this product attribute be sent to PostFinance Checkout as line item attribute?', 'woo-postfinancecheckout' ) . esc_html(
'</p>
</td>
</tr>'
);
?>
<tr class="form-field form-required">
<th scope="row" valign="top">
<label for="postfinancecheckout_attribute_option_send">
<?php esc_html_e( 'Send attribute to PostFinance Checkout.', 'woo-postfinancecheckout' ); ?>
</label>
</th>
<td>
<input name="postfinancecheckout_attribute_option_send" id="postfinancecheckout_attribute_option_send" type="checkbox" value="1" <?php checked( $checked, true ); ?> />
<p class="description">
<?php esc_html_e( 'Should this product attribute be sent to PostFinance Checkout as line item attribute?', 'woo-postfinancecheckout' ); ?>
</p>
</td>
</tr>
<?php
}



/**
* Display attribute options add screen
*/
public function display_attribute_options_add() {
echo esc_html(
'<div class="form-field">
<label for="postfinancecheckout_attribute_option_send"><input name="postfinancecheckout_attribute_option_send" id="postfinancecheckout_attribute_option_send" type="checkbox" value="1">'
) . esc_html__( 'Send attribute to PostFinance Checkout.', 'woo-postfinancecheckout' ) . esc_html(
'</label>
<p class="description">'
) . esc_html__( 'Should this product attribute be sent to PostFinance Checkout as line item attribute?', 'woo-postfinancecheckout' ) .
esc_html(
'</p>
</div>'
);
?>
<div class="form-field">
<label for="postfinancecheckout_attribute_option_send">
<input name="postfinancecheckout_attribute_option_send" id="postfinancecheckout_attribute_option_send" type="checkbox" value="1">
<?php esc_html_e( 'Send attribute to PostFinance Checkout.', 'woo-postfinancecheckout' ); ?>
</label>
<p class="description">
<?php esc_html_e( 'Should this product attribute be sent to PostFinance Checkout as line item attribute?', 'woo-postfinancecheckout' ); ?>
</p>
</div>
<?php
}
}

Expand Down
60 changes: 31 additions & 29 deletions includes/class-wc-postfinancecheckout-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,42 +273,44 @@ public function init_form_fields() {
public function generate_info_html( $key, $data ) {
$field_key = $this->get_field_key( $key );
$defaults = array(
'title' => '',
'class' => '',
'css' => '',
'placeholder' => '',
'desc_tip' => true,
'description' => '',
'title' => '',
'class' => '',
'css' => '',
'placeholder' => '',
'desc_tip' => true,
'description' => '',
'custom_attributes' => array(),
);

$data = wp_parse_args( $data, $defaults );

ob_start();
?>
<tr valign="top">
<th scope="row" class="titledesc">
<?php // phpcs:ignore ?>
<?php echo esc_html( $this->get_tooltip_html( $data ) ); ?>
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
</th>
<td class="forminp">
<fieldset>
<legend class="screen-reader-text">
<span><?php echo wp_kses_post( $data['title'] ); ?></span>
</legend>
<div class="input-text regular-input <?php echo esc_attr( $data['class'] ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php echo esc_html( $this->get_custom_attribute_html( $data ) ); ?> >
<?php echo esc_html( $data['value'] ); ?>
</div>
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row" class="titledesc">
<?php echo $this->get_tooltip_html( $data ); // Output the tooltip HTML directly ?>
<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo esc_html( $data['title'] ); ?></label>
</th>
<td class="forminp">
<fieldset>
<legend class="screen-reader-text">
<span><?php echo esc_html( $data['title'] ); ?></span>
</legend>
<div
class="input-text regular-input <?php echo esc_attr( $data['class'] ); ?>"
id="<?php echo esc_attr( $field_key ); ?>"
style="<?php echo esc_attr( $data['css'] ); ?>"
<?php echo $this->get_custom_attribute_html( $data ); // Output custom attributes ?>
>
<?php echo wp_kses_post( $data['value'] ); ?>
</div>
</fieldset>
</td>
</tr>
<?php

return ob_get_clean();
}

/**
} /**
* Validate Info Field.
*
* @param string $key Field key++.
Expand Down