Shipping Settings: Replace tables only for use in modals (#42795)

This commit is contained in:
Paul Sealock 2023-12-14 14:02:58 +13:00 committed by GitHub
commit 4e98801e8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Revert Shipping Settings change of replacing tables, replace only for use in JS powered modals.

View File

@ -510,11 +510,13 @@
// `<table class="form-table" />` elements added by the Settings API need to be removed.
// Modern browsers won't interpret other table elements like `td` not in a `table`, so
// Removing the `table` is sufficient.
const htmlContent = $( html );
const tables = htmlContent.find( 'table.form-table' );
const originalTable = $( html );
const htmlContent = $( '<div class="wc-shipping-zone-method-fields" />' );
htmlContent.html( originalTable.html() );
tables.each( ( i ) => {
const table = $( tables[ i ] );
const innerTables = htmlContent.find( 'table.form-table' );
innerTables.each( ( i ) => {
const table = $( innerTables[ i ] );
const div = $( '<div class="wc-shipping-zone-method-fields" />' );
div.html( table.html() );
table.replaceWith( div );

View File

@ -460,7 +460,7 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
$settings_html = $this->generate_settings_html( $this->get_form_fields(), false );
}
return '<div class="wc-shipping-zone-method-fields">' . $settings_html . '</div>';
return '<table class="form-table">' . $settings_html . '</table>';
}
/**