Issues (1182)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

includes/admin/wc-meta-box-functions.php (10 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
* WooCommerce Meta Box Functions
4
*
5
* @author      WooThemes
6
* @category    Core
7
* @package     WooCommerce/Admin/Functions
8
* @version     2.3.0
9
*/
10
if ( ! defined( 'ABSPATH' ) ) {
11
	exit; // Exit if accessed directly
12
}
13
14
/**
15
 * Output a text input box.
16
 *
17
 * @param array $field
18
 */
19
function woocommerce_wp_text_input( $field ) {
20
	global $thepostid, $post;
21
22
	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
23
	$field['placeholder']   = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
24
	$field['class']         = isset( $field['class'] ) ? $field['class'] : 'short';
25
	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
26
	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
27
	$field['value']         = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
28
	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
29
	$field['type']          = isset( $field['type'] ) ? $field['type'] : 'text';
30
	$data_type              = empty( $field['data_type'] ) ? '' : $field['data_type'];
31
32
	switch ( $data_type ) {
33
		case 'price' :
34
			$field['class'] .= ' wc_input_price';
35
			$field['value']  = wc_format_localized_price( $field['value'] );
36
			break;
37
		case 'decimal' :
38
			$field['class'] .= ' wc_input_decimal';
39
			$field['value']  = wc_format_localized_decimal( $field['value'] );
40
			break;
41
		case 'stock' :
42
			$field['class'] .= ' wc_input_stock';
43
			$field['value']  = wc_stock_amount( $field['value'] );
44
			break;
45
		case 'url' :
46
			$field['class'] .= ' wc_input_url';
47
			$field['value']  = esc_url( $field['value'] );
48
			break;
49
50
		default :
51
			break;
52
	}
53
54
	// Custom attribute handling
55
	$custom_attributes = array();
56
57 View Code Duplication
	if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
66 View Code Duplication
	if ( ! empty( $field['description'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
68
		if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
69
			echo wc_help_tip( $field['description'] );
70
		} else {
71
			echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
72
		}
73
	}
74
	echo '</p>';
75
}
76
77
/**
78
 * Output a hidden input box.
79
 *
80
 * @param array $field
81
 */
82
function woocommerce_wp_hidden_input( $field ) {
83
	global $thepostid, $post;
84
85
	$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
86
	$field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
87
	$field['class'] = isset( $field['class'] ) ? $field['class'] : '';
88
89
	echo '<input type="hidden" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) .  '" /> ';
90
}
91
92
/**
93
 * Output a textarea input box.
94
 *
95
 * @param array $field
96
 */
97
function woocommerce_wp_textarea_input( $field ) {
98
	global $thepostid, $post;
99
100
	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
101
	$field['placeholder']   = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
102
	$field['class']         = isset( $field['class'] ) ? $field['class'] : 'short';
103
	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
104
	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
105
	$field['value']         = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
106
107
	// Custom attribute handling
108
	$custom_attributes = array();
109
110 View Code Duplication
	if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
119 View Code Duplication
	if ( ! empty( $field['description'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
120
121
		if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
122
			echo wc_help_tip( $field['description'] );
123
		} else {
124
			echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
125
		}
126
	}
127
	echo '</p>';
128
}
129
130
/**
131
 * Output a checkbox input box.
132
 *
133
 * @param array $field
134
 */
135
function woocommerce_wp_checkbox( $field ) {
136
	global $thepostid, $post;
137
138
	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
139
	$field['class']         = isset( $field['class'] ) ? $field['class'] : 'checkbox';
140
	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
141
	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
142
	$field['value']         = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
143
	$field['cbvalue']       = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'yes';
144
	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
145
146
	// Custom attribute handling
147
	$custom_attributes = array();
148
149 View Code Duplication
	if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
158 View Code Duplication
	if ( ! empty( $field['description'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
159
160
		if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
161
			echo wc_help_tip( $field['description'] );
162
		} else {
163
			echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
164
		}
165
	}
166
167
	echo '</p>';
168
}
169
170
/**
171
 * Output a select input box.
172
 *
173
 * @param array $field
174
 */
175
function woocommerce_wp_select( $field ) {
176
	global $thepostid, $post;
177
178
	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
179
	$field['class']         = isset( $field['class'] ) ? $field['class'] : 'select short';
180
	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
181
	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
182
	$field['value']         = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
183
	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
184
185
	// Custom attribute handling
186
	$custom_attributes = array();
187
188 View Code Duplication
	if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
197 View Code Duplication
	foreach ( $field['options'] as $key => $value ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
198
		echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>';
199
	}
200
201
	echo '</select> ';
202
203 View Code Duplication
	if ( ! empty( $field['description'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
204
205
		if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
206
			echo wc_help_tip( $field['description'] );
207
		} else {
208
			echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
209
		}
210
	}
211
	echo '</p>';
212
}
213
214
/**
215
 * Output a radio input box.
216
 *
217
 * @param array $field
218
 */
219
function woocommerce_wp_radio( $field ) {
220
	global $thepostid, $post;
221
222
	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
223
	$field['class']         = isset( $field['class'] ) ? $field['class'] : 'select short';
224
	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
225
	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
226
	$field['value']         = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
227
	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
228
229
	echo '<fieldset class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><legend>' . wp_kses_post( $field['label'] ) . '</legend><ul class="wc-radios">';
230
231
	foreach ( $field['options'] as $key => $value ) {
232
233
		echo '<li><label><input
234
				name="' . esc_attr( $field['name'] ) . '"
235
				value="' . esc_attr( $key ) . '"
236
				type="radio"
237
				class="' . esc_attr( $field['class'] ) . '"
238
				style="' . esc_attr( $field['style'] ) . '"
239
				' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '
240
				/> ' . esc_html( $value ) . '</label>
241
		</li>';
242
	}
243
	echo '</ul>';
244
245 View Code Duplication
	if ( ! empty( $field['description'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
246
247
		if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
248
			echo wc_help_tip( $field['description'] );
249
		} else {
250
			echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
251
		}
252
	}
253
254
	echo '</fieldset>';
255
}
256