From 68c147a4916b507037457f4b264ba46a6adfeb3c Mon Sep 17 00:00:00 2001 From: Corey McKrill <916023+coreymckrill@users.noreply.github.com> Date: Thu, 4 Jan 2024 16:08:31 -0800 Subject: [PATCH] Settings: Make minor corrections to the HTML markup of settings fields (#43166) * Corrections to HTML markup of settings controls * Remove deprecated `valign` attributes from table row elements * Remove orphaned quotation marks from the end of table row elements Co-authored-by: Sagehen Studio <2924107+sagehenstudio@users.noreply.github.com> * Enable title prop for `info` setting type This gives the `` for the info setting type a closing tag since its not self-closing. It also allows for adding a `title` prop to the info setting type, to match all the other setting types. * Add changelog file * phpcs cleanup --------- Co-authored-by: Sagehen Studio <2924107+sagehenstudio@users.noreply.github.com> --- .../changelog/remix-41077-settings-html-fixes | 4 ++ .../admin/class-wc-admin-settings.php | 42 ++++++++++++------- 2 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 plugins/woocommerce/changelog/remix-41077-settings-html-fixes diff --git a/plugins/woocommerce/changelog/remix-41077-settings-html-fixes b/plugins/woocommerce/changelog/remix-41077-settings-html-fixes new file mode 100644 index 00000000000..abeadae0e22 --- /dev/null +++ b/plugins/woocommerce/changelog/remix-41077-settings-html-fixes @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +Make minor corrections to the HTML markup of settings fields diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-settings.php b/plugins/woocommerce/includes/admin/class-wc-admin-settings.php index a0ec737087e..a322828e5b2 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-settings.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-settings.php @@ -253,6 +253,11 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : $value['value'] = self::get_option( $value['id'], $value['default'] ); } + $row_class_attribute = ''; + if ( $value['row_class'] ) { + $row_class_attribute = " class=\"{$value['row_class']}\""; + } + // Custom attribute handling. $custom_attributes = array(); @@ -287,8 +292,9 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : break; case 'info': - ?>"> - + ?>> + + '; @@ -320,7 +326,8 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : case 'tel': $option_value = $value['value']; - ?>"> + ?> + > @@ -345,7 +352,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : $option_value = $value['value']; ?> - "> + > @@ -373,7 +380,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : $option_value = $value['value']; ?> - "> + > @@ -399,7 +406,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : $option_value = $value['value']; ?> - "> + > @@ -442,7 +449,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : $show_desc_at_end = $value['desc_at_end'] ?? false; ?> - "> + > @@ -509,13 +516,18 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : $visibility_class[] = $value['row_class']; } + $container_class_attribute = ''; + if ( count( $visibility_class ) > 0 ) { + $container_class_attribute = ' class="' . implode( ' ', $visibility_class ) . '"'; + } + $must_disable = $value['disabled'] ?? false; if ( ! isset( $value['checkboxgroup'] ) || 'start' === $value['checkboxgroup'] ) { $has_tooltip = isset( $value['tooltip'] ) && '' !== $value['tooltip']; $tooltip_container_class = $has_tooltip ? 'with-tooltip' : ''; ?> - + > @@ -525,7 +537,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : -
+ > - "> + > @@ -614,7 +626,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : } ?> - "> + @@ -639,7 +651,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : ); } ?> - "> + @@ -679,7 +691,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : $state = '*'; } ?> - "> + > @@ -703,7 +715,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : asort( $countries ); ?> - "> + > @@ -732,7 +744,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : ); $option_value = wc_parse_relative_date_option( $value['value'] ); ?> - "> + >