Code Duplication    Length = 5-6 lines in 7 locations

includes/admin/class-wc-admin-settings.php 1 location

@@ 237-241 (lines=5) @@
234
			// Custom attribute handling
235
			$custom_attributes = array();
236
237
			if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) {
238
				foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) {
239
					$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
240
				}
241
			}
242
243
			// Description handling
244
			$field_description = self::get_field_description( $value );

includes/admin/wc-meta-box-functions.php 4 locations

@@ 57-62 (lines=6) @@
54
	// Custom attribute handling
55
	$custom_attributes = array();
56
57
	if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
58
59
		foreach ( $field['custom_attributes'] as $attribute => $value ){
60
			$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
61
		}
62
	}
63
64
	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><input type="' . esc_attr( $field['type'] ) . '" class="' . esc_attr( $field['class'] ) . '" style="' . esc_attr( $field['style'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" ' . implode( ' ', $custom_attributes ) . ' /> ';
65
@@ 110-115 (lines=6) @@
107
	// Custom attribute handling
108
	$custom_attributes = array();
109
110
	if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
111
112
		foreach ( $field['custom_attributes'] as $attribute => $value ){
113
			$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
114
		}
115
	}
116
117
	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><textarea class="' . esc_attr( $field['class'] ) . '" style="' . esc_attr( $field['style'] ) . '"  name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" rows="2" cols="20" ' . implode( ' ', $custom_attributes ) . '>' . esc_textarea( $field['value'] ) . '</textarea> ';
118
@@ 149-154 (lines=6) @@
146
	// Custom attribute handling
147
	$custom_attributes = array();
148
149
	if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
150
151
		foreach ( $field['custom_attributes'] as $attribute => $value ){
152
			$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
153
		}
154
	}
155
156
	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><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 ) . '/> ';
157
@@ 188-193 (lines=6) @@
185
	// Custom attribute handling
186
	$custom_attributes = array();
187
188
	if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
189
190
		foreach ( $field['custom_attributes'] as $attribute => $value ){
191
			$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
192
		}
193
	}
194
195
	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><select id="' . esc_attr( $field['id'] ) . '" name="' . esc_attr( $field['name'] ) . '" class="' . esc_attr( $field['class'] ) . '" style="' . esc_attr( $field['style'] ) . '" ' . implode( ' ', $custom_attributes ) . '>';
196

includes/wc-template-functions.php 1 location

@@ 1724-1728 (lines=5) @@
1721
		// Custom attribute handling
1722
		$custom_attributes = array();
1723
1724
		if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
1725
			foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
1726
				$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
1727
			}
1728
		}
1729
1730
		if ( ! empty( $args['validate'] ) ) {
1731
			foreach( $args['validate'] as $validate ) {

includes/abstracts/abstract-wc-settings-api.php 1 location

@@ 287-292 (lines=6) @@
284
	public function get_custom_attribute_html( $data ) {
285
		$custom_attributes = array();
286
287
		if ( ! empty( $data['custom_attributes'] ) && is_array( $data['custom_attributes'] ) ) {
288
			foreach ( $data['custom_attributes'] as $attribute => $attribute_value ) {
289
				$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
290
			}
291
		}
292
293
		return implode( ' ', $custom_attributes );
294
	}
295