Code Duplication    Length = 5-6 lines in 7 locations

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/admin/class-wc-admin-settings.php 1 location

@@ 252-256 (lines=5) @@
249
			// Custom attribute handling
250
			$custom_attributes = array();
251
252
			if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) {
253
				foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) {
254
					$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
255
				}
256
			}
257
258
			// Description handling
259
			$field_description = self::get_field_description( $value );

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

@@ 339-344 (lines=6) @@
336
	public function get_custom_attribute_html( $data ) {
337
		$custom_attributes = array();
338
339
		if ( ! empty( $data['custom_attributes'] ) && is_array( $data['custom_attributes'] ) ) {
340
			foreach ( $data['custom_attributes'] as $attribute => $attribute_value ) {
341
				$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
342
			}
343
		}
344
345
		return implode( ' ', $custom_attributes );
346
	}
347

includes/wc-template-functions.php 1 location

@@ 1798-1802 (lines=5) @@
1795
		// Custom attribute handling
1796
		$custom_attributes = array();
1797
1798
		if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {
1799
			foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) {
1800
				$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
1801
			}
1802
		}
1803
1804
		if ( ! empty( $args['validate'] ) ) {
1805
			foreach( $args['validate'] as $validate ) {