plugin updates

This commit is contained in:
Tony Volpe
2024-02-21 16:19:46 +00:00
parent c72f206574
commit 21d4c85c00
1214 changed files with 102269 additions and 179257 deletions

View File

@@ -158,7 +158,14 @@ function woocommerce_wp_checkbox( $field, WC_Data $data = null ) {
$field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
$field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false;
// Custom attribute handling
/**
* These values are what get passed vis $_POST depending on if the field is checked or not. If no unchecked_value is
* provided, the $_POST will not be set. This maintains backwards compatibility where consumers would use `isset`.
*/
$field['checked_value'] = isset( $field['checked_value'] ) ? $field['checked_value'] : $field['cbvalue'];
$field['unchecked_value'] = isset( $field['unchecked_value'] ) ? $field['unchecked_value'] : null;
// Custom attribute handling.
$custom_attributes = array();
if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
@@ -168,6 +175,14 @@ function woocommerce_wp_checkbox( $field, WC_Data $data = null ) {
}
}
if ( ! empty( $field['style'] ) ) {
$custom_attributes[] = 'style="' . esc_attr( $field['style'] ) . '"';
}
if ( ! empty( $field['class'] ) ) {
$custom_attributes[] = 'class="' . esc_attr( $field['class'] ) . '"';
}
echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '">
<label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label>';
@@ -175,7 +190,19 @@ function woocommerce_wp_checkbox( $field, WC_Data $data = null ) {
echo wc_help_tip( $field['description'] );
}
echo '<input type="checkbox" class="' . esc_attr( $field['class'] ) . '" style="' . esc_attr( $field['style'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['cbvalue'] ) . '" ' . checked( $field['value'], $field['cbvalue'], false ) . ' ' . implode( ' ', $custom_attributes ) . '/> ';
// Output a hidden field so a value is POSTed if the box is not checked.
if ( ! is_null( $field['unchecked_value'] ) ) {
printf( '<input type="hidden" name="%1$s" value="%2$s" />', esc_attr( $field['name'] ), esc_attr( $field['unchecked_value'] ) );
}
printf(
'<input type="checkbox" name="%1$s" id="%2$s" value="%3$s" %4$s %5$s />',
esc_attr( $field['name'] ),
esc_attr( $field['id'] ),
esc_attr( $field['checked_value'] ),
checked( $field['value'], $field['checked_value'], false ),
implode( ' ', $custom_attributes ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) {
echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
@@ -194,7 +221,8 @@ function woocommerce_wp_select( $field, WC_Data $data = null ) {
global $post;
$field = wp_parse_args(
$field, array(
$field,
array(
'class' => 'select short',
'style' => '',
'wrapper_class' => '',