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 `<th>` 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>
This commit is contained in:
parent
ca5813d4f7
commit
68c147a491
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: update
|
||||||
|
|
||||||
|
Make minor corrections to the HTML markup of settings fields
|
|
@ -253,6 +253,11 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
$value['value'] = self::get_option( $value['id'], $value['default'] );
|
$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 attribute handling.
|
||||||
$custom_attributes = array();
|
$custom_attributes = array();
|
||||||
|
|
||||||
|
@ -287,8 +292,9 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'info':
|
case 'info':
|
||||||
?><tr valign="top"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
?><tr<?php echo esc_html( $row_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc"/><td style="<?php echo esc_attr( $value['css'] ); ?>">
|
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?></th>
|
||||||
|
<td style="<?php echo esc_attr( $value['css'] ); ?>">
|
||||||
<?php
|
<?php
|
||||||
echo wp_kses_post( wpautop( wptexturize( $value['text'] ) ) );
|
echo wp_kses_post( wpautop( wptexturize( $value['text'] ) ) );
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
|
@ -320,7 +326,8 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
case 'tel':
|
case 'tel':
|
||||||
$option_value = $value['value'];
|
$option_value = $value['value'];
|
||||||
|
|
||||||
?><tr valign="top"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
?>
|
||||||
|
<tr<?php echo esc_html( $row_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
@ -345,7 +352,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
$option_value = $value['value'];
|
$option_value = $value['value'];
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr valign="top"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
<tr<?php echo esc_html( $row_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
@ -373,7 +380,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
$option_value = $value['value'];
|
$option_value = $value['value'];
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr valign="top"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
<tr<?php echo esc_html( $row_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
@ -399,7 +406,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
$option_value = $value['value'];
|
$option_value = $value['value'];
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr valign="top"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
<tr<?php echo esc_html( $row_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
@ -442,7 +449,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
$show_desc_at_end = $value['desc_at_end'] ?? false;
|
$show_desc_at_end = $value['desc_at_end'] ?? false;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr valign="top"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
<tr<?php echo esc_html( $row_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
@ -509,13 +516,18 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
$visibility_class[] = $value['row_class'];
|
$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;
|
$must_disable = $value['disabled'] ?? false;
|
||||||
|
|
||||||
if ( ! isset( $value['checkboxgroup'] ) || 'start' === $value['checkboxgroup'] ) {
|
if ( ! isset( $value['checkboxgroup'] ) || 'start' === $value['checkboxgroup'] ) {
|
||||||
$has_tooltip = isset( $value['tooltip'] ) && '' !== $value['tooltip'];
|
$has_tooltip = isset( $value['tooltip'] ) && '' !== $value['tooltip'];
|
||||||
$tooltip_container_class = $has_tooltip ? 'with-tooltip' : '';
|
$tooltip_container_class = $has_tooltip ? 'with-tooltip' : '';
|
||||||
?>
|
?>
|
||||||
<tr valign="top" class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>">
|
<tr<?php echo esc_html( $container_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?></th>
|
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?></th>
|
||||||
<td class="forminp forminp-checkbox <?php echo esc_html( $tooltip_container_class ); ?>">
|
<td class="forminp forminp-checkbox <?php echo esc_html( $tooltip_container_class ); ?>">
|
||||||
<?php if ( $has_tooltip ) : ?>
|
<?php if ( $has_tooltip ) : ?>
|
||||||
|
@ -525,7 +537,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
<fieldset class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>">
|
<fieldset<?php echo esc_html( $container_class_attribute ); ?>>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +592,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr valign="top"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
<tr<?php echo esc_html( $row_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html . $disabled_message; // WPCS: XSS ok. ?></label>
|
<label><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html . $disabled_message; // WPCS: XSS ok. ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
@ -614,7 +626,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr valign="top" class="single_select_page"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
<tr class="single_select_page <?php echo esc_attr( $value['row_class'] ); ?>">
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
<label><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
@ -639,7 +651,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tr valign="top" class="single_select_page"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
<tr class="single_select_page <?php echo esc_attr( $value['row_class'] ); ?>">
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
@ -679,7 +691,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
$state = '*';
|
$state = '*';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tr valign="top"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
<tr<?php echo esc_html( $row_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
@ -703,7 +715,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
|
|
||||||
asort( $countries );
|
asort( $countries );
|
||||||
?>
|
?>
|
||||||
<tr valign="top"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
<tr<?php echo esc_html( $row_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
@ -732,7 +744,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
||||||
);
|
);
|
||||||
$option_value = wc_parse_relative_date_option( $value['value'] );
|
$option_value = wc_parse_relative_date_option( $value['value'] );
|
||||||
?>
|
?>
|
||||||
<tr valign="top"<?php echo $value['row_class'] ? ' class="' . esc_attr( $value['row_class'] ) . '"' : '' ?>">
|
<tr<?php echo esc_html( $row_class_attribute ); ?>>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?> <?php echo $tooltip_html; // WPCS: XSS ok. ?></label>
|
||||||
</th>
|
</th>
|
||||||
|
|
Loading…
Reference in New Issue