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 General Settings |
||
4 | * |
||
5 | * @package WooCommerce/Admin |
||
6 | */ |
||
7 | |||
8 | defined( 'ABSPATH' ) || exit; |
||
9 | |||
10 | if ( class_exists( 'WC_Settings_General', false ) ) { |
||
11 | return new WC_Settings_General(); |
||
12 | } |
||
13 | |||
14 | /** |
||
15 | * WC_Admin_Settings_General. |
||
16 | */ |
||
17 | class WC_Settings_General extends WC_Settings_Page { |
||
18 | |||
19 | /** |
||
20 | * Constructor. |
||
21 | */ |
||
22 | public function __construct() { |
||
23 | $this->id = 'general'; |
||
24 | $this->label = __( 'General', 'woocommerce' ); |
||
25 | |||
26 | parent::__construct(); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Get settings array. |
||
31 | * |
||
32 | * @return array |
||
33 | */ |
||
34 | 14 | public function get_settings() { |
|
35 | |||
36 | 14 | $currency_code_options = get_woocommerce_currencies(); |
|
37 | |||
38 | 14 | foreach ( $currency_code_options as $code => $name ) { |
|
39 | 14 | $currency_code_options[ $code ] = $name . ' (' . get_woocommerce_currency_symbol( $code ) . ')'; |
|
40 | } |
||
41 | |||
42 | $woocommerce_default_customer_address_options = array( |
||
43 | 14 | '' => __( 'No location by default', 'woocommerce' ), |
|
44 | 14 | 'base' => __( 'Shop base address', 'woocommerce' ), |
|
45 | 14 | 'geolocation' => __( 'Geolocate', 'woocommerce' ), |
|
46 | 14 | 'geolocation_ajax' => __( 'Geolocate (with page caching support)', 'woocommerce' ), |
|
47 | ); |
||
48 | |||
49 | 14 | if ( version_compare( PHP_VERSION, '5.4', '<' ) ) { |
|
50 | unset( $woocommerce_default_customer_address_options['geolocation'], $woocommerce_default_customer_address_options['geolocation_ajax'] ); |
||
51 | } |
||
52 | |||
53 | 14 | $settings = apply_filters( |
|
54 | 14 | 'woocommerce_general_settings', |
|
55 | array( |
||
56 | |||
57 | array( |
||
58 | 14 | 'title' => __( 'Store Address', 'woocommerce' ), |
|
59 | 14 | 'type' => 'title', |
|
60 | 14 | 'desc' => __( 'This is where your business is located. Tax rates and shipping rates will use this address.', 'woocommerce' ), |
|
61 | 14 | 'id' => 'store_address', |
|
62 | ), |
||
63 | |||
64 | array( |
||
65 | 14 | 'title' => __( 'Address line 1', 'woocommerce' ), |
|
66 | 14 | 'desc' => __( 'The street address for your business location.', 'woocommerce' ), |
|
67 | 14 | 'id' => 'woocommerce_store_address', |
|
68 | 14 | 'default' => '', |
|
69 | 14 | 'type' => 'text', |
|
70 | 'desc_tip' => true, |
||
71 | ), |
||
72 | |||
73 | array( |
||
74 | 14 | 'title' => __( 'Address line 2', 'woocommerce' ), |
|
75 | 14 | 'desc' => __( 'An additional, optional address line for your business location.', 'woocommerce' ), |
|
76 | 14 | 'id' => 'woocommerce_store_address_2', |
|
77 | 14 | 'default' => '', |
|
78 | 14 | 'type' => 'text', |
|
79 | 'desc_tip' => true, |
||
80 | ), |
||
81 | |||
82 | array( |
||
83 | 14 | 'title' => __( 'City', 'woocommerce' ), |
|
84 | 14 | 'desc' => __( 'The city in which your business is located.', 'woocommerce' ), |
|
85 | 14 | 'id' => 'woocommerce_store_city', |
|
86 | 14 | 'default' => '', |
|
87 | 14 | 'type' => 'text', |
|
88 | 'desc_tip' => true, |
||
89 | ), |
||
90 | |||
91 | array( |
||
92 | 14 | 'title' => __( 'Country / State', 'woocommerce' ), |
|
93 | 14 | 'desc' => __( 'The country and state or province, if any, in which your business is located.', 'woocommerce' ), |
|
94 | 14 | 'id' => 'woocommerce_default_country', |
|
95 | 14 | 'default' => 'GB', |
|
96 | 14 | 'type' => 'single_select_country', |
|
97 | 'desc_tip' => true, |
||
98 | ), |
||
99 | |||
100 | array( |
||
101 | 14 | 'title' => __( 'Postcode / ZIP', 'woocommerce' ), |
|
102 | 14 | 'desc' => __( 'The postal code, if any, in which your business is located.', 'woocommerce' ), |
|
103 | 14 | 'id' => 'woocommerce_store_postcode', |
|
104 | 14 | 'css' => 'min-width:50px;', |
|
105 | 14 | 'default' => '', |
|
106 | 14 | 'type' => 'text', |
|
107 | 'desc_tip' => true, |
||
108 | ), |
||
109 | |||
110 | array( |
||
111 | 'type' => 'sectionend', |
||
112 | 'id' => 'store_address', |
||
113 | ), |
||
114 | |||
115 | array( |
||
116 | 14 | 'title' => __( 'General options', 'woocommerce' ), |
|
117 | 14 | 'type' => 'title', |
|
118 | 14 | 'desc' => '', |
|
119 | 14 | 'id' => 'general_options', |
|
120 | ), |
||
121 | |||
122 | array( |
||
123 | 14 | 'title' => __( 'Selling location(s)', 'woocommerce' ), |
|
124 | 14 | 'desc' => __( 'This option lets you limit which countries you are willing to sell to.', 'woocommerce' ), |
|
125 | 14 | 'id' => 'woocommerce_allowed_countries', |
|
126 | 14 | 'default' => 'all', |
|
127 | 14 | 'type' => 'select', |
|
128 | 14 | 'class' => 'wc-enhanced-select', |
|
129 | 14 | 'css' => 'min-width: 350px;', |
|
130 | 'desc_tip' => true, |
||
131 | 'options' => array( |
||
132 | 14 | 'all' => __( 'Sell to all countries', 'woocommerce' ), |
|
133 | 14 | 'all_except' => __( 'Sell to all countries, except for…', 'woocommerce' ), |
|
134 | 14 | 'specific' => __( 'Sell to specific countries', 'woocommerce' ), |
|
135 | ), |
||
136 | ), |
||
137 | |||
138 | array( |
||
139 | 14 | 'title' => __( 'Sell to all countries, except for…', 'woocommerce' ), |
|
140 | 14 | 'desc' => '', |
|
141 | 14 | 'id' => 'woocommerce_all_except_countries', |
|
142 | 14 | 'css' => 'min-width: 350px;', |
|
143 | 14 | 'default' => '', |
|
144 | 14 | 'type' => 'multi_select_countries', |
|
145 | ), |
||
146 | |||
147 | array( |
||
148 | 14 | 'title' => __( 'Sell to specific countries', 'woocommerce' ), |
|
149 | 14 | 'desc' => '', |
|
150 | 14 | 'id' => 'woocommerce_specific_allowed_countries', |
|
151 | 14 | 'css' => 'min-width: 350px;', |
|
152 | 14 | 'default' => '', |
|
153 | 14 | 'type' => 'multi_select_countries', |
|
154 | ), |
||
155 | |||
156 | array( |
||
157 | 14 | 'title' => __( 'Shipping location(s)', 'woocommerce' ), |
|
158 | 14 | 'desc' => __( 'Choose which countries you want to ship to, or choose to ship to all locations you sell to.', 'woocommerce' ), |
|
159 | 14 | 'id' => 'woocommerce_ship_to_countries', |
|
160 | 14 | 'default' => '', |
|
161 | 14 | 'type' => 'select', |
|
162 | 14 | 'class' => 'wc-enhanced-select', |
|
163 | 'desc_tip' => true, |
||
164 | 'options' => array( |
||
165 | 14 | '' => __( 'Ship to all countries you sell to', 'woocommerce' ), |
|
166 | 14 | 'all' => __( 'Ship to all countries', 'woocommerce' ), |
|
167 | 14 | 'specific' => __( 'Ship to specific countries only', 'woocommerce' ), |
|
168 | 14 | 'disabled' => __( 'Disable shipping & shipping calculations', 'woocommerce' ), |
|
169 | ), |
||
170 | ), |
||
171 | |||
172 | array( |
||
173 | 14 | 'title' => __( 'Ship to specific countries', 'woocommerce' ), |
|
174 | 14 | 'desc' => '', |
|
175 | 14 | 'id' => 'woocommerce_specific_ship_to_countries', |
|
176 | 14 | 'css' => '', |
|
177 | 14 | 'default' => '', |
|
178 | 14 | 'type' => 'multi_select_countries', |
|
179 | ), |
||
180 | |||
181 | array( |
||
182 | 14 | 'title' => __( 'Default customer location', 'woocommerce' ), |
|
183 | 14 | 'id' => 'woocommerce_default_customer_address', |
|
184 | 14 | 'desc_tip' => __( 'This option determines a customers default location. The MaxMind GeoLite Database will be periodically downloaded to your wp-content directory if using geolocation.', 'woocommerce' ), |
|
185 | 14 | 'default' => 'geolocation', |
|
186 | 14 | 'type' => 'select', |
|
187 | 14 | 'class' => 'wc-enhanced-select', |
|
188 | 14 | 'options' => $woocommerce_default_customer_address_options, |
|
189 | ), |
||
190 | |||
191 | array( |
||
192 | 14 | 'title' => __( 'Enable taxes', 'woocommerce' ), |
|
193 | 14 | 'desc' => __( 'Enable tax rates and calculations', 'woocommerce' ), |
|
194 | 14 | 'id' => 'woocommerce_calc_taxes', |
|
195 | 14 | 'default' => 'no', |
|
196 | 14 | 'type' => 'checkbox', |
|
197 | 14 | 'desc_tip' => __( 'Rates will be configurable and taxes will be calculated during checkout.', 'woocommerce' ), |
|
198 | ), |
||
199 | |||
200 | array( |
||
201 | 14 | 'title' => __( 'Enable coupons', 'woocommerce' ), |
|
202 | 14 | 'desc' => __( 'Enable the use of coupon codes', 'woocommerce' ), |
|
203 | 14 | 'id' => 'woocommerce_enable_coupons', |
|
204 | 14 | 'default' => 'yes', |
|
205 | 14 | 'type' => 'checkbox', |
|
206 | 14 | 'checkboxgroup' => 'start', |
|
207 | 14 | 'show_if_checked' => 'option', |
|
208 | 14 | 'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ), |
|
209 | ), |
||
210 | |||
211 | array( |
||
212 | 14 | 'desc' => __( 'Calculate coupon discounts sequentially', 'woocommerce' ), |
|
213 | 14 | 'id' => 'woocommerce_calc_discounts_sequentially', |
|
214 | 14 | 'default' => 'no', |
|
215 | 14 | 'type' => 'checkbox', |
|
216 | 14 | 'desc_tip' => __( 'When applying multiple coupons, apply the first coupon to the full price and the second coupon to the discounted price and so on.', 'woocommerce' ), |
|
217 | 14 | 'show_if_checked' => 'yes', |
|
218 | 14 | 'checkboxgroup' => 'end', |
|
219 | 'autoload' => false, |
||
220 | ), |
||
221 | |||
222 | array( |
||
223 | 'type' => 'sectionend', |
||
224 | 'id' => 'general_options', |
||
225 | ), |
||
226 | |||
227 | array( |
||
228 | 14 | 'title' => __( 'Currency options', 'woocommerce' ), |
|
229 | 14 | 'type' => 'title', |
|
230 | 14 | 'desc' => __( 'The following options affect how prices are displayed on the frontend.', 'woocommerce' ), |
|
231 | 14 | 'id' => 'pricing_options', |
|
232 | ), |
||
233 | |||
234 | array( |
||
235 | 14 | 'title' => __( 'Currency', 'woocommerce' ), |
|
236 | 14 | 'desc' => __( 'This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ), |
|
237 | 14 | 'id' => 'woocommerce_currency', |
|
238 | 14 | 'default' => 'GBP', |
|
239 | 14 | 'type' => 'select', |
|
240 | 14 | 'class' => 'wc-enhanced-select', |
|
241 | 'desc_tip' => true, |
||
242 | 14 | 'options' => $currency_code_options, |
|
243 | ), |
||
244 | |||
245 | array( |
||
246 | 14 | 'title' => __( 'Currency position', 'woocommerce' ), |
|
247 | 14 | 'desc' => __( 'This controls the position of the currency symbol.', 'woocommerce' ), |
|
248 | 14 | 'id' => 'woocommerce_currency_pos', |
|
249 | 14 | 'class' => 'wc-enhanced-select', |
|
250 | 14 | 'default' => 'left', |
|
251 | 14 | 'type' => 'select', |
|
252 | 'options' => array( |
||
253 | 14 | 'left' => __( 'Left', 'woocommerce' ), |
|
254 | 14 | 'right' => __( 'Right', 'woocommerce' ), |
|
255 | 14 | 'left_space' => __( 'Left with space', 'woocommerce' ), |
|
256 | 14 | 'right_space' => __( 'Right with space', 'woocommerce' ), |
|
257 | ), |
||
258 | 'desc_tip' => true, |
||
259 | ), |
||
260 | |||
261 | array( |
||
262 | 14 | 'title' => __( 'Thousand separator', 'woocommerce' ), |
|
263 | 14 | 'desc' => __( 'This sets the thousand separator of displayed prices.', 'woocommerce' ), |
|
264 | 14 | 'id' => 'woocommerce_price_thousand_sep', |
|
265 | 14 | 'css' => 'width:50px;', |
|
266 | 14 | 'default' => ',', |
|
267 | 14 | 'type' => 'text', |
|
268 | 'desc_tip' => true, |
||
269 | ), |
||
270 | |||
271 | array( |
||
272 | 14 | 'title' => __( 'Decimal separator', 'woocommerce' ), |
|
273 | 14 | 'desc' => __( 'This sets the decimal separator of displayed prices.', 'woocommerce' ), |
|
274 | 14 | 'id' => 'woocommerce_price_decimal_sep', |
|
275 | 14 | 'css' => 'width:50px;', |
|
276 | 14 | 'default' => '.', |
|
277 | 14 | 'type' => 'text', |
|
278 | 'desc_tip' => true, |
||
279 | ), |
||
280 | |||
281 | array( |
||
282 | 14 | 'title' => __( 'Number of decimals', 'woocommerce' ), |
|
283 | 14 | 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'woocommerce' ), |
|
284 | 14 | 'id' => 'woocommerce_price_num_decimals', |
|
285 | 14 | 'css' => 'width:50px;', |
|
286 | 14 | 'default' => '2', |
|
287 | 'desc_tip' => true, |
||
288 | 14 | 'type' => 'number', |
|
289 | 'custom_attributes' => array( |
||
290 | 'min' => 0, |
||
291 | 'step' => 1, |
||
292 | ), |
||
293 | ), |
||
294 | |||
295 | array( |
||
296 | 'type' => 'sectionend', |
||
297 | 'id' => 'pricing_options', |
||
298 | ), |
||
299 | |||
300 | ) |
||
301 | ); |
||
302 | |||
303 | 14 | return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings ); |
|
304 | } |
||
305 | |||
306 | /** |
||
307 | * Output a color picker input box. |
||
308 | * |
||
309 | * @param mixed $name Name of input. |
||
310 | * @param string $id ID of input. |
||
311 | * @param mixed $value Value of input. |
||
312 | * @param string $desc (default: '') Description for input. |
||
313 | */ |
||
314 | public function color_picker( $name, $id, $value, $desc = '' ) { |
||
0 ignored issues
–
show
|
|||
315 | echo '<div class="color_box">' . wc_help_tip( $desc ) . ' |
||
316 | <input name="' . esc_attr( $id ) . '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div> |
||
317 | </div>'; |
||
318 | } |
||
319 | |||
320 | /** |
||
321 | * Output the settings. |
||
322 | */ |
||
323 | public function output() { |
||
324 | $settings = $this->get_settings(); |
||
325 | |||
326 | WC_Admin_Settings::output_fields( $settings ); |
||
327 | } |
||
328 | |||
329 | /** |
||
330 | * Save settings. |
||
331 | */ |
||
332 | public function save() { |
||
333 | $settings = $this->get_settings(); |
||
334 | |||
335 | WC_Admin_Settings::save_fields( $settings ); |
||
336 | } |
||
337 | } |
||
338 | |||
339 | return new WC_Settings_General(); |
||
340 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.