|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file used for adding fields to the products category taxonomy page and saving those values correctly :) |
|
4
|
|
|
* |
|
5
|
|
|
* @package wp-e-commerce |
|
6
|
|
|
* @since 3.8 |
|
7
|
|
|
* @todo UI needs a lot of loving - lots of padding issues, if we have these boxes, they should be sortable, closable, hidable, etc. |
|
8
|
|
|
*/ |
|
9
|
|
|
function wpsc_ajax_set_variation_order(){ |
|
10
|
|
|
global $wpdb; |
|
11
|
|
|
$sort_order = $_POST['sort_order']; |
|
12
|
|
|
$parent_id = $_POST['parent_id']; |
|
13
|
|
|
|
|
14
|
|
|
$result = true; |
|
15
|
|
|
foreach( $sort_order as $key => $value ) { |
|
16
|
|
|
|
|
17
|
|
|
if ( empty( $value ) ) { |
|
18
|
|
|
continue; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
$value = preg_replace( '/[^0-9]/', '', $value ); |
|
22
|
|
|
|
|
23
|
|
|
if ( ! wpsc_update_meta( $value, 'sort_order', absint( $key ), 'wpsc_variation' ) ) { |
|
24
|
|
|
$result = false; |
|
25
|
|
|
} |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* WP eCommerce edit and add product category page functions |
|
31
|
|
|
* |
|
32
|
|
|
* These are the main WPSC Admin functions |
|
33
|
|
|
* |
|
34
|
|
|
* @package wp-e-commerce |
|
35
|
|
|
* @since 3.7 |
|
36
|
|
|
*/ |
|
37
|
|
|
|
|
38
|
|
|
function wpsc_ajax_set_category_order(){ |
|
39
|
|
|
global $wpdb; |
|
40
|
|
|
$sort_order = $_POST['sort_order']; |
|
41
|
|
|
$parent_id = $_POST['parent_id']; |
|
42
|
|
|
|
|
43
|
|
|
$result = true; |
|
44
|
|
|
foreach ( $sort_order as $key=>$value ){ |
|
45
|
|
|
if ( empty( $value ) ) |
|
46
|
|
|
continue; |
|
47
|
|
|
|
|
48
|
|
|
$value = preg_replace( '/[^0-9]/', '', $value ); |
|
49
|
|
|
|
|
50
|
|
|
if ( ! wpsc_update_meta( $value, 'sort_order', $key, 'wpsc_category' ) ) |
|
51
|
|
|
$result = false; |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
add_filter( 'manage_edit-wpsc_product_category_columns', 'wpsc_custom_category_columns' ); |
|
56
|
|
|
add_filter( 'manage_wpsc_product_category_custom_column', 'wpsc_custom_category_column_data', 10, 3); |
|
57
|
|
|
add_action( 'wpsc_product_category_add_form_fields', 'wpsc_admin_category_forms_add' ); // After left-col |
|
58
|
|
|
add_action( 'wpsc_product_category_edit_form_fields', 'wpsc_admin_category_forms_edit' ); // After left-col |
|
59
|
|
|
add_action( 'created_wpsc_product_category', 'wpsc_save_category_set', 10 , 2 ); //After created |
|
60
|
|
|
add_action( 'edited_wpsc_product_category', 'wpsc_save_category_set', 10 , 2 ); //After saved |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* wpsc_custom_category_columns |
|
64
|
|
|
* Adds images column to category column. |
|
65
|
|
|
* @internal Don't feel handle column is necessary, but you would add it here if you wanted to |
|
66
|
|
|
* @param (array) columns | Array of columns assigned to this taxonomy |
|
67
|
|
|
* @return (array) columns | Modified array of columns |
|
68
|
|
|
*/ |
|
69
|
|
|
|
|
70
|
|
|
function wpsc_custom_category_columns( $columns ) { |
|
71
|
|
|
// Doing it this funny way to ensure that image stays in far left, even if other items are added via plugin. |
|
72
|
|
|
unset( $columns["cb"] ); |
|
73
|
|
|
|
|
74
|
|
|
$custom_array = array( |
|
75
|
|
|
'cb' => '<input type="checkbox" />', |
|
76
|
|
|
'image' => __( 'Image', 'wp-e-commerce' ) |
|
77
|
|
|
); |
|
78
|
|
|
|
|
79
|
|
|
$columns = array_merge( $custom_array, $columns ); |
|
80
|
|
|
|
|
81
|
|
|
return $columns; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Custom Category Column Data |
|
86
|
|
|
* |
|
87
|
|
|
* Adds images to the custom category column. |
|
88
|
|
|
* |
|
89
|
|
|
* @param string $string Column output. |
|
90
|
|
|
* @param string $column_name Column name. |
|
91
|
|
|
* @param string $term_id Term ID. |
|
92
|
|
|
* @return string Updated column output. |
|
93
|
|
|
*/ |
|
94
|
|
|
function wpsc_custom_category_column_data( $string, $column_name, $term_id ) { |
|
95
|
|
|
if ( 'image' == $column_name ) { |
|
96
|
|
|
$term = get_term_by( 'id', $term_id, 'wpsc_product_category' ); |
|
97
|
|
|
$image = wpsc_get_categorymeta( $term_id, 'image' ); |
|
98
|
|
|
$noimage = defined( 'WPSC_CORE_THEME_URL' ) ? WPSC_CORE_THEME_URL . '/wpsc-images/noimage.png' : WPSC_TE_V2_URL . '/theming/assets/images/noimage.png'; |
|
99
|
|
|
|
|
100
|
|
|
$format = '<img src="%s" title="%s" alt="%2$s" width="30" height="30" />'; |
|
101
|
|
|
if ( ! empty( $image ) ) { |
|
102
|
|
|
$string = sprintf( $format, WPSC_CATEGORY_URL . $image, esc_attr( $term->name ) ); |
|
103
|
|
|
} else { |
|
104
|
|
|
$string = sprintf( $format, $noimage, esc_attr( $term->name ) ); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
return $string; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* wpsc_admin_get_category_array |
|
112
|
|
|
* Recursively step through the categories and return it in a clean multi demensional array |
|
113
|
|
|
* for use in other list functions |
|
114
|
|
|
* @param int $parent_id |
|
|
|
|
|
|
115
|
|
|
*/ |
|
116
|
|
|
function wpsc_admin_get_category_array( $parent_id = null ){ |
|
117
|
|
|
global $wpdb; |
|
118
|
|
|
|
|
119
|
|
|
$orderedList = array(); |
|
120
|
|
|
|
|
121
|
|
|
if ( ! isset( $parent_id ) ) |
|
122
|
|
|
$parent_id = 0; |
|
123
|
|
|
|
|
124
|
|
|
$category_list = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=' . $parent_id ); |
|
125
|
|
|
|
|
126
|
|
|
if ( ! is_array( $category_list ) ) { |
|
127
|
|
|
return false; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
foreach ( $category_list as $category ) { |
|
131
|
|
|
$category_order = wpsc_get_categorymeta( $category->term_id, 'order' ); |
|
132
|
|
|
$category_image = wpsc_get_categorymeta( $category->term_id, 'image' ); |
|
133
|
|
|
|
|
134
|
|
|
if ( ! isset( $category_order ) || $category_order == 0 ) |
|
135
|
|
|
$category_order = ( count( $orderedList ) + 1 ); |
|
136
|
|
|
print "<!-- setting category Order number to " . $category_order . "-->"; |
|
137
|
|
|
$orderedList[$category_order]['id'] = $category->term_id; |
|
138
|
|
|
$orderedList[$category_order]['name'] = $category->name; |
|
139
|
|
|
$orderedList[$category_order]['image'] = $category_image; |
|
140
|
|
|
$orderedList[$category_order]['parent_id'] = $parent_id; |
|
141
|
|
|
$orderedList[$category_order]['children'] = wpsc_admin_get_category_array( $category->term_id ); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
ksort( $orderedList ); |
|
145
|
|
|
return $orderedList; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* wpsc_admin_category_group_list, prints the left hand side of the add categories page |
|
150
|
|
|
* nothing returned |
|
151
|
|
|
*/ |
|
152
|
|
|
function wpsc_admin_category_forms_add() { |
|
153
|
|
|
global $wpdb; |
|
154
|
|
|
$category_value_count = 0; |
|
155
|
|
|
$display_type = isset( $category['display_type'] ) ? $category['display_type'] : ''; |
|
|
|
|
|
|
156
|
|
|
?> |
|
157
|
|
|
|
|
158
|
|
|
<h3><?php esc_html_e('Advanced Store Settings', 'wp-e-commerce'); ?></h3> |
|
159
|
|
|
<h4><?php esc_html_e('Presentation Settings', 'wp-e-commerce'); ?></h4> |
|
160
|
|
|
<p class='description'><?php esc_html_e( 'These settings override the general presentation settings found in Settings > Store > Presentation.', 'wp-e-commerce' ); ?></p> |
|
161
|
|
|
<div style="margin: 15px 0 15px 0"> |
|
162
|
|
|
<label for='image'><?php esc_html_e( 'Category Image' , 'wp-e-commerce' ); ?></label> |
|
163
|
|
|
<input type='file' name='image' value='' /> |
|
164
|
|
|
</div> |
|
165
|
|
|
<div class="form-field"> |
|
166
|
|
|
<label for='display_type'><?php esc_html_e( 'Product Display', 'wp-e-commerce' ); ?></label> |
|
167
|
|
|
<select name='display_type'> |
|
168
|
|
|
<option value='default'<?php checked( $display_type, 'default' ); ?>><?php esc_html_e('Default View', 'wp-e-commerce'); ?></option> |
|
169
|
|
|
<option value='list'<?php disabled( _wpsc_is_display_type_supported( 'list' ), false ); ?><?php checked( $display_type, 'list' ); ?>><?php esc_html_e('List View', 'wp-e-commerce'); ?></option> |
|
170
|
|
|
<option value='grid'<?php disabled( _wpsc_is_display_type_supported( 'grid' ), false ); ?><?php checked( $display_type, 'grid' ); ?>><?php esc_html_e('Grid View', 'wp-e-commerce'); ?></option> |
|
171
|
|
|
</select> |
|
172
|
|
|
</div> |
|
173
|
|
|
<?php if ( function_exists( "getimagesize" ) ) : ?> |
|
174
|
|
|
<div class="form-field"> |
|
175
|
|
|
<?php esc_html_e( 'Thumbnail Size', 'wp-e-commerce' ); ?> |
|
176
|
|
|
<fieldset class="wpsc-width-height-fields"> |
|
177
|
|
|
<legend class="screen-reader-text"><span><?php esc_html_e( 'Thumbnail Size', 'wp-e-commerce' ); ?></span></legend> |
|
178
|
|
|
<label for="image_width"><?php esc_html_e( 'Width', 'wp-e-commerce' ); ?></label> |
|
179
|
|
|
<input name="image_width" type="number" step="1" min="0" id="image_width" value="<?php if ( isset( $category['image_width'] ) ) echo esc_attr( $category['image_width'] ); ?>" class="small-text" style="width: 70px"> |
|
180
|
|
|
<label for="large_size_h"><?php esc_html_e( 'Height', 'wp-e-commerce' ); ?></label> |
|
181
|
|
|
<input name="image_height" type="number" step="1" min="0" id="image_height" value="<?php if ( isset( $category['image_height'] ) ) echo esc_attr( $category['image_height'] ); ?>" class="small-text" style="width: 70px"> |
|
182
|
|
|
</fieldset> |
|
183
|
|
|
</div> |
|
184
|
|
|
<?php endif;?> |
|
185
|
|
|
|
|
186
|
|
|
<!-- START OF TARGET MARKET SELECTION --> |
|
187
|
|
|
<?php |
|
188
|
|
|
|
|
189
|
|
|
$category_id = ''; |
|
190
|
|
|
|
|
191
|
|
|
if ( isset( $_GET['tag_ID'] ) ) { |
|
192
|
|
|
$category_id = absint( $_GET['tag_ID'] ); |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
$countrylist = WPSC_Countries::get_countries_array( true, true ); |
|
196
|
|
|
$selectedCountries = wpsc_get_meta( $category_id, 'target_market', 'wpsc_category' ); |
|
197
|
|
|
?> |
|
198
|
|
|
<h4><?php esc_html_e( 'Restrict to Target Markets', 'wp-e-commerce' )?></h4> |
|
199
|
|
|
<div class='form-field'> |
|
200
|
|
|
<?php if ( wpsc_is_suhosin_enabled() ) : ?> |
|
201
|
|
|
<em><?php esc_html_e( "The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature, then disable the suhosin extension. If you can not do this, you will need to contact your hosting provider.", 'wp-e-commerce' ); ?></em> |
|
202
|
|
|
<?php else: ?> |
|
203
|
|
|
<div class='multiple-select-container'> |
|
204
|
|
|
<span><?php esc_html_e( 'Select', 'wp-e-commerce' ); ?> <a href='' class='wpsc_select_all'><?php esc_html_e( 'All', 'wp-e-commerce' ); ?></a> <a href='' class='wpsc_select_none'><?php esc_html_e( 'None', 'wp-e-commerce' ); ?></a></span><br /> |
|
205
|
|
|
<div id='resizeable' class='ui-widget-content multiple-select'> |
|
206
|
|
|
<?php foreach( $countrylist as $country ): ?> |
|
207
|
|
|
<?php if ( in_array( $country['id'], (array)$selectedCountries ) ): ?> |
|
208
|
|
|
<input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo $country['id']; ?>' value='<?php echo $country['id']; ?>' checked='<?php echo $country['visible']; ?>' /> |
|
209
|
|
|
<label for="countrylist2-<?php echo $country['id']; ?>"><?php echo esc_html( $country['country'] ); ?></label><br /> |
|
210
|
|
|
<?php else: ?> |
|
211
|
|
|
<input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo $country['id']; ?>' value='<?php echo $country['id']; ?>' /> |
|
212
|
|
|
<label for="countrylist2-<?php echo $country['id']; ?>"><?php echo esc_html( $country['country'] ); ?></label><br /> |
|
213
|
|
|
<?php endif; ?> |
|
214
|
|
|
<?php endforeach; ?> |
|
215
|
|
|
</div> |
|
216
|
|
|
</div> |
|
217
|
|
|
<span class='wpscsmall description'><?php esc_html_e( 'Select the markets you are selling this category to.', 'wp-e-commerce' ); ?><span> |
|
218
|
|
|
<?php endif; ?> |
|
219
|
|
|
</div> |
|
220
|
|
|
|
|
221
|
|
|
<!-- Checkout settings --> |
|
222
|
|
|
<h4><?php esc_html_e( 'Checkout Settings', 'wp-e-commerce' ); ?></h4> |
|
223
|
|
|
|
|
224
|
|
|
<?php |
|
225
|
|
|
if ( ! isset( $category['term_id'] ) ) $category['term_id'] = ''; |
|
|
|
|
|
|
226
|
|
|
$used_additonal_form_set = wpsc_get_categorymeta( $category['term_id'], 'use_additional_form_set' ); |
|
227
|
|
|
?> |
|
228
|
|
|
<div class='form-field'> |
|
229
|
|
|
<label for="use_additional_form_set"><?php esc_html_e( 'Category requires additional checkout form fields', 'wp-e-commerce' ); ?></label> |
|
230
|
|
|
<select name='use_additional_form_set'> |
|
231
|
|
|
<option value=''><?php esc_html_e( 'None', 'wp-e-commerce' ); ?></option> |
|
232
|
|
|
<?php |
|
233
|
|
|
$checkout_sets = get_option( 'wpsc_checkout_form_sets' ); |
|
234
|
|
|
unset( $checkout_sets[0] ); |
|
235
|
|
|
|
|
236
|
|
|
foreach ( (array)$checkout_sets as $key => $value ) { |
|
237
|
|
|
$selected_state = ""; |
|
238
|
|
|
if ( $used_additonal_form_set == $key ) |
|
239
|
|
|
$selected_state = "selected='selected'"; |
|
240
|
|
|
?> |
|
241
|
|
|
<option <?php echo $selected_state; ?> value='<?php echo $key; ?>'><?php echo esc_html( $value ); ?></option> |
|
242
|
|
|
<?php |
|
243
|
|
|
} |
|
244
|
|
|
?> |
|
245
|
|
|
</select> |
|
246
|
|
|
</div> |
|
247
|
|
|
|
|
248
|
|
|
<?php $uses_billing_address = (bool)wpsc_get_categorymeta( $category['term_id'], 'uses_billing_address' ); ?> |
|
249
|
|
|
<div> |
|
250
|
|
|
<label><?php esc_html_e( 'Address to calculate shipping with', 'wp-e-commerce' ); ?></label> |
|
251
|
|
|
<label><input type="radio" value="0" name="uses_billing_address" <?php checked( $uses_billing_address, 0 ); ?> /> <?php esc_html_e( 'Shipping Address (default)', 'wp-e-commerce' ); ?></label> |
|
252
|
|
|
<label><input type="radio" value="1" name="uses_billing_address" <?php checked( $uses_billing_address, 1 ); ?> /> <?php esc_html_e( 'Billing Address', 'wp-e-commerce' ); ?></label> |
|
253
|
|
|
<p class='description'><?php esc_html_e( 'Products in this category will use the address specified to calculate shipping costs.', 'wp-e-commerce' ); ?></p> |
|
254
|
|
|
</div> |
|
255
|
|
|
|
|
256
|
|
|
<table class="category_forms"> |
|
257
|
|
|
<tr> |
|
258
|
|
|
|
|
259
|
|
|
</tr> |
|
260
|
|
|
</table> |
|
261
|
|
|
<?php |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* Check whether a display type (such as grid, list) is supported. |
|
266
|
|
|
* |
|
267
|
|
|
* @since 3.8.9 |
|
268
|
|
|
* @access private |
|
269
|
|
|
* @param string $display_type Display type |
|
270
|
|
|
* @return bool Return true if display type is supported. |
|
271
|
|
|
*/ |
|
272
|
|
|
function _wpsc_is_display_type_supported( $display_type ) { |
|
273
|
|
|
$callback = 'product_display_' . $display_type; |
|
274
|
|
|
return function_exists( $callback ); |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
function wpsc_admin_category_forms_edit() { |
|
278
|
|
|
global $wpdb; |
|
279
|
|
|
|
|
280
|
|
|
$category_value_count = 0; |
|
281
|
|
|
$category_name = ''; |
|
282
|
|
|
$category = array(); |
|
283
|
|
|
|
|
284
|
|
|
$category_id = absint( $_REQUEST["tag_ID"] ); |
|
285
|
|
|
$category = get_term( $category_id, 'wpsc_product_category', ARRAY_A ); |
|
286
|
|
|
$category['nice-name'] = wpsc_get_categorymeta( $category['term_id'], 'nice-name' ); |
|
287
|
|
|
$category['description'] = wpsc_get_categorymeta( $category['term_id'], 'description' ); |
|
288
|
|
|
$category['image'] = wpsc_get_categorymeta( $category['term_id'], 'image' ); |
|
289
|
|
|
$category['fee'] = wpsc_get_categorymeta( $category['term_id'], 'fee' ); |
|
290
|
|
|
$category['active'] = wpsc_get_categorymeta( $category['term_id'], 'active' ); |
|
291
|
|
|
$category['order'] = wpsc_get_categorymeta( $category['term_id'], 'order' ); |
|
292
|
|
|
$category['display_type'] = wpsc_get_categorymeta( $category['term_id'], 'display_type' ); |
|
293
|
|
|
$category['image_height'] = wpsc_get_categorymeta( $category['term_id'], 'image_height' ); |
|
294
|
|
|
$category['image_width'] = wpsc_get_categorymeta( $category['term_id'], 'image_width' ); |
|
295
|
|
|
$category['use_additional_form_set'] = wpsc_get_categorymeta( $category['term_id'], 'use_additional_form_set' ); |
|
296
|
|
|
|
|
297
|
|
|
?> |
|
298
|
|
|
|
|
299
|
|
|
<tr> |
|
300
|
|
|
<td colspan="2"> |
|
301
|
|
|
<h3><?php esc_html_e( 'Advanced Store Settings', 'wp-e-commerce' ); ?></h3> |
|
302
|
|
|
<h4><?php esc_html_e( 'Shortcodes and Template Tags', 'wp-e-commerce' ); ?></h4> |
|
303
|
|
|
<p class='description'><?php esc_html_e( 'These settings override the general presentation settings found in Settings > Store > Presentation.', 'wp-e-commerce' ); ?></p> |
|
304
|
|
|
</td> |
|
305
|
|
|
</tr> |
|
306
|
|
|
|
|
307
|
|
|
|
|
308
|
|
|
<tr class="form-field"> |
|
309
|
|
|
<th scope="row" valign="top"> |
|
310
|
|
|
<label for="display_type"><?php esc_html_e( 'Catalog View', 'wp-e-commerce' ); ?></label> |
|
311
|
|
|
</th> |
|
312
|
|
|
<td> |
|
313
|
|
|
<?php |
|
314
|
|
|
$display_type = isset( $category['display_type'] ) ? $category['display_type'] : ''; |
|
315
|
|
|
?> |
|
316
|
|
|
<select name='display_type'> |
|
317
|
|
|
<option value='default'<?php selected( $display_type, 'default' ); ?>><?php esc_html_e( 'Default View', 'wp-e-commerce' ); ?></option> |
|
318
|
|
|
<option value='list'<?php disabled( _wpsc_is_display_type_supported( 'list' ), false ); ?><?php selected( $display_type, 'list' ); ?>><?php esc_html_e('List View', 'wp-e-commerce'); ?></option> |
|
319
|
|
|
<option value='grid' <?php disabled( _wpsc_is_display_type_supported( 'grid' ), false ); ?><?php selected( $display_type, 'grid' ); ?>><?php esc_html_e( 'Grid View', 'wp-e-commerce' ); ?></option> |
|
320
|
|
|
</select><br /> |
|
321
|
|
|
</td> |
|
322
|
|
|
</tr> |
|
323
|
|
|
<tr class="form-field"> |
|
324
|
|
|
<th scope="row" valign="top"> |
|
325
|
|
|
<label for="image"><?php esc_html_e( 'Category Image', 'wp-e-commerce' ); ?></label> |
|
326
|
|
|
</th> |
|
327
|
|
|
<td> |
|
328
|
|
|
<?php |
|
329
|
|
|
$category_image = wpsc_category_image( $category['term_id'] ); |
|
330
|
|
|
if ( $category_image ) |
|
|
|
|
|
|
331
|
|
|
echo '<p><img src=' . esc_url( $category_image ) . ' alt="' . esc_attr( $category['name'] ) . '" title="' . esc_attr( $category['name'] ) . '" class="wpsc_category_image" /></p>'; |
|
332
|
|
|
?> |
|
333
|
|
|
<input type='file' name='image' value='' /><br /> |
|
334
|
|
|
<label><input type='checkbox' name='deleteimage' class="wpsc_cat_box" value='1' /><?php esc_html_e( 'Delete Image', 'wp-e-commerce' ); ?></label><br/> |
|
335
|
|
|
<span class="description"><?php esc_html_e( 'You can set an image for the category here. If one exists, check the box to delete.', 'wp-e-commerce' ); ?></span> |
|
336
|
|
|
</td> |
|
337
|
|
|
</tr> |
|
338
|
|
|
<?php if ( function_exists( "getimagesize" ) ) : ?> |
|
339
|
|
|
<tr class="form-field"> |
|
340
|
|
|
<th scope="row" valign="top"> |
|
341
|
|
|
<label for="image"><?php esc_html_e( 'Thumbnail Size', 'wp-e-commerce' ); ?></label> |
|
342
|
|
|
</th> |
|
343
|
|
|
<td> |
|
344
|
|
|
<fieldset class="wpsc-width-height-fields"> |
|
345
|
|
|
<legend class="screen-reader-text"><span><?php esc_html_e( 'Thumbnail Size', 'wp-e-commerce' ); ?></span></legend> |
|
346
|
|
|
<label for="image_width"><?php esc_html_e( 'Width', 'wp-e-commerce' ); ?></label> |
|
347
|
|
|
<input name="image_width" type="number" step="1" min="0" id="image_width" value="<?php if ( isset( $category['image_width'] ) ) echo esc_attr( $category['image_width'] ); ?>" class="small-text"> |
|
348
|
|
|
<label for="large_size_h"><?php esc_html_e( 'Height', 'wp-e-commerce' ); ?></label> |
|
349
|
|
|
<input name="image_height" type="number" step="1" min="0" id="image_height" value="<?php if ( isset( $category['image_height'] ) ) echo esc_attr( $category['image_height'] ); ?>" class="small-text"> |
|
350
|
|
|
</fieldset> |
|
351
|
|
|
</td> |
|
352
|
|
|
</tr> |
|
353
|
|
|
<?php endif; // 'getimagesize' condition ?> |
|
354
|
|
|
|
|
355
|
|
|
|
|
356
|
|
|
<tr> |
|
357
|
|
|
<td colspan="2"><h4><?php esc_html_e( 'Shortcodes and Template Tags', 'wp-e-commerce' ); ?></h4></td> |
|
358
|
|
|
</tr> |
|
359
|
|
|
|
|
360
|
|
|
<tr class="form-field"> |
|
361
|
|
|
<th scope="row" valign="top"> |
|
362
|
|
|
<label for="image"><?php esc_html_e( 'Display Category Shortcode', 'wp-e-commerce' ); ?></label> |
|
363
|
|
|
</th> |
|
364
|
|
|
<td> |
|
365
|
|
|
<code>[wpsc_products category_url_name='<?php echo $category["slug"]; ?>']</code><br /> |
|
366
|
|
|
<span class="description"><?php esc_html_e( 'Shortcodes are used to display a particular category or group within any WordPress page or post.', 'wp-e-commerce' ); ?></span> |
|
367
|
|
|
</td> |
|
368
|
|
|
</tr> |
|
369
|
|
|
<tr class="form-field"> |
|
370
|
|
|
<th scope="row" valign="top"> |
|
371
|
|
|
<label for="image"><?php esc_html_e( 'Display Category Template Tag', 'wp-e-commerce' ); ?></label> |
|
372
|
|
|
</th> |
|
373
|
|
|
<td> |
|
374
|
|
|
<code><?php echo wpsc_display_products_page( array( 'category_url_name' => '<?php echo $category["slug"]; ?>' ) ); ?></code><br /> |
|
375
|
|
|
<span class="description"><?php esc_html_e( 'Template tags are used to display a particular category or group within your theme / template.', 'wp-e-commerce' ); ?></span> |
|
376
|
|
|
</td> |
|
377
|
|
|
</tr> |
|
378
|
|
|
|
|
379
|
|
|
<!-- START OF TARGET MARKET SELECTION --> |
|
380
|
|
|
|
|
381
|
|
|
<tr> |
|
382
|
|
|
<td colspan="2"> |
|
383
|
|
|
<h4><?php esc_html_e( 'Target Market Restrictions', 'wp-e-commerce' ); ?></h4> |
|
384
|
|
|
</td> |
|
385
|
|
|
</tr> |
|
386
|
|
|
<?php |
|
387
|
|
|
$countrylist = WPSC_Countries::get_countries_array( true, true ); |
|
388
|
|
|
$selectedCountries = wpsc_get_meta( $category_id,'target_market','wpsc_category' ); |
|
389
|
|
|
?> |
|
390
|
|
|
<tr> |
|
391
|
|
|
<th scope="row" valign="top"> |
|
392
|
|
|
<label for="image"><?php esc_html_e( 'Target Markets', 'wp-e-commerce' ); ?></label> |
|
393
|
|
|
</th> |
|
394
|
|
|
<td> |
|
395
|
|
|
<?php if ( wpsc_is_suhosin_enabled() ) : ?> |
|
396
|
|
|
<em><?php esc_html_e( 'The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature, then disable the suhosin extension. If you can not do this, you will need to contact your hosting provider.','wp-e-commerce' ); ?></em> |
|
397
|
|
|
<?php else : ?> |
|
398
|
|
|
<span><?php esc_html_e( 'Select', 'wp-e-commerce' ); ?>: <a href='' class='wpsc_select_all'><?php esc_html_e( 'All', 'wp-e-commerce' ); ?></a> <a href='' class='wpsc_select_none'><?php esc_html_e( 'None', 'wp-e-commerce' ); ?></a></span><br /> |
|
399
|
|
|
<div id='resizeable' class='ui-widget-content multiple-select'> |
|
400
|
|
|
<?php foreach( $countrylist as $country ) { |
|
401
|
|
|
if ( in_array( $country['id'], (array)$selectedCountries ) ) { |
|
402
|
|
|
?> |
|
403
|
|
|
<input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo $country['id']; ?>' value='<?php echo $country['id']; ?>' checked='<?php echo $country['visible']; ?>' /> |
|
404
|
|
|
<label for="countrylist2-<?php echo $country['id']; ?>"><?php echo esc_html( $country['country'] ); ?></label><br /> |
|
405
|
|
|
<?php |
|
406
|
|
|
} else { |
|
407
|
|
|
?> |
|
408
|
|
|
<input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo $country['id']; ?>' value='<?php echo $country['id']; ?>' /> |
|
409
|
|
|
<label for="countrylist2-<?php echo $country['id']; ?>"><?php echo esc_html( $country['country'] ); ?></label><br /> |
|
410
|
|
|
<?php |
|
411
|
|
|
} |
|
412
|
|
|
} ?> |
|
413
|
|
|
</div> |
|
414
|
|
|
<?php endif; ?><br /> |
|
415
|
|
|
<span class="description"><?php esc_html_e( 'Select the markets you are selling this category to.', 'wp-e-commerce' ); ?></span> |
|
416
|
|
|
</td> |
|
417
|
|
|
</tr> |
|
418
|
|
|
|
|
419
|
|
|
<!-- Checkout settings --> |
|
420
|
|
|
|
|
421
|
|
|
<tr> |
|
422
|
|
|
<td colspan="2"> |
|
423
|
|
|
<h4><?php esc_html_e( 'Checkout Settings', 'wp-e-commerce' ); ?></h4> |
|
424
|
|
|
</td> |
|
425
|
|
|
</tr> |
|
426
|
|
|
<?php |
|
427
|
|
|
if ( !isset( $category['term_id'] ) ) |
|
428
|
|
|
$category['term_id'] = ''; |
|
429
|
|
|
|
|
430
|
|
|
$used_additonal_form_set = wpsc_get_categorymeta( $category['term_id'], 'use_additional_form_set' ); |
|
431
|
|
|
$checkout_sets = get_option('wpsc_checkout_form_sets'); |
|
432
|
|
|
unset($checkout_sets[0]); |
|
433
|
|
|
$uses_billing_address = (bool)wpsc_get_categorymeta( $category['term_id'], 'uses_billing_address' ); |
|
434
|
|
|
?> |
|
435
|
|
|
<tr class="form-field"> |
|
436
|
|
|
<th scope="row" valign="top"> |
|
437
|
|
|
<label for="image"><?php esc_html_e( 'Category requires additional checkout form fields', 'wp-e-commerce' ); ?></label> |
|
438
|
|
|
</th> |
|
439
|
|
|
<td> |
|
440
|
|
|
<select name='use_additional_form_set'> |
|
441
|
|
|
<option value=''><?php esc_html_e( 'None', 'wp-e-commerce' ); ?></option> |
|
442
|
|
|
<?php |
|
443
|
|
|
foreach( (array) $checkout_sets as $key => $value ) { |
|
444
|
|
|
$selected_state = ""; |
|
445
|
|
|
if ( $used_additonal_form_set == $key ) { |
|
446
|
|
|
$selected_state = "selected='selected'"; |
|
447
|
|
|
} ?> |
|
448
|
|
|
<option <?php echo $selected_state; ?> value='<?php echo $key; ?>'><?php echo esc_html( $value ); ?></option> |
|
449
|
|
|
<?php |
|
450
|
|
|
} |
|
451
|
|
|
?> |
|
452
|
|
|
</select> |
|
453
|
|
|
</td> |
|
454
|
|
|
</tr> |
|
455
|
|
|
|
|
456
|
|
|
<tr class="form-field"> |
|
457
|
|
|
<th scope="row" valign="top"> |
|
458
|
|
|
<label><?php esc_html_e( 'Address to calculate shipping with', 'wp-e-commerce' ); ?></label> |
|
459
|
|
|
</th> |
|
460
|
|
|
<td> |
|
461
|
|
|
<label><input type="radio" class="wpsc_cat_box" value="0" name="uses_billing_address" <?php echo ( ( $uses_billing_address != true ) ? 'checked="checked"' : '' ); ?> /> <?php esc_html_e( 'Shipping Address (default)', 'wp-e-commerce' ); ?></label><br /> |
|
|
|
|
|
|
462
|
|
|
<label><input type="radio" class="wpsc_cat_box" value="1" name="uses_billing_address" <?php echo ( ( $uses_billing_address == true ) ? 'checked="checked"' : '' ); ?> /> <?php esc_html_e( 'Billing Address', 'wp-e-commerce' ); ?></label> |
|
|
|
|
|
|
463
|
|
|
<p class='description'><?php esc_html_e( 'Products in this category will use the address specified to calculate shipping costs.', 'wp-e-commerce' ); ?></p> |
|
464
|
|
|
</td> |
|
465
|
|
|
</tr> |
|
466
|
|
|
|
|
467
|
|
|
<?php |
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
/** |
|
471
|
|
|
* wpsc_save_category_set, Saves the category set data |
|
472
|
|
|
* @param nothing |
|
473
|
|
|
* @return nothing |
|
474
|
|
|
*/ |
|
475
|
|
|
function wpsc_save_category_set( $category_id, $tt_id ) { |
|
|
|
|
|
|
476
|
|
|
global $wpdb; |
|
477
|
|
|
|
|
478
|
|
|
if ( ! empty( $_POST ) ) { |
|
479
|
|
|
/* Image Processing Code*/ |
|
480
|
|
|
if ( ! empty( $_FILES['image'] ) && preg_match( "/\.(gif|jp(e)*g|png){1}$/i", $_FILES['image']['name'] ) ) { |
|
481
|
|
|
if ( function_exists( "getimagesize" ) ) { |
|
482
|
|
|
if ( isset( $_POST['width'] ) && ( (int) $_POST['width'] > 10 && (int) $_POST['width'] < 512 ) && ( (int)$_POST['height'] > 10 && (int)$_POST['height'] < 512 ) ) { |
|
483
|
|
|
$width = (int) $_POST['width']; |
|
484
|
|
|
$height = (int) $_POST['height']; |
|
485
|
|
|
image_processing( $_FILES['image']['tmp_name'], ( WPSC_CATEGORY_DIR.$_FILES['image']['name'] ), $width, $height, 'image' ); |
|
486
|
|
|
} else { |
|
487
|
|
|
image_processing( $_FILES['image']['tmp_name'], ( WPSC_CATEGORY_DIR.$_FILES['image']['name'] ), null, null, 'image' ); |
|
488
|
|
|
} |
|
489
|
|
|
$image = esc_sql( $_FILES['image']['name'] ); |
|
490
|
|
|
} else { |
|
491
|
|
|
$new_image_path = ( WPSC_CATEGORY_DIR.basename($_FILES['image']['name'] ) ); |
|
492
|
|
|
move_uploaded_file( $_FILES['image']['tmp_name'], $new_image_path ); |
|
493
|
|
|
$stat = stat( dirname( $new_image_path ) ); |
|
494
|
|
|
$perms = $stat['mode'] & 0000666; |
|
495
|
|
|
@ chmod( $new_image_path, $perms ); |
|
|
|
|
|
|
496
|
|
|
$image = esc_sql( $_FILES['image']['name'] ); |
|
497
|
|
|
} |
|
498
|
|
|
} else { |
|
499
|
|
|
$image = ''; |
|
500
|
|
|
} |
|
501
|
|
|
//Good to here |
|
502
|
|
|
if ( isset( $_POST['tag_ID'] ) ) { |
|
503
|
|
|
//Editing |
|
504
|
|
|
$category_id = (int) $_POST['tag_ID']; |
|
505
|
|
|
$category = get_term_by( 'id', $category_id, 'wpsc_product_category' ); |
|
506
|
|
|
$url_name = $category->slug; |
|
507
|
|
|
|
|
508
|
|
|
} |
|
509
|
|
|
if ( isset( $_POST['deleteimage'] ) && $_POST['deleteimage'] == 1 ) { |
|
510
|
|
|
wpsc_delete_categorymeta( $category_id, 'image' ); |
|
511
|
|
|
} else if ( $image != '' ) { |
|
512
|
|
|
wpsc_update_categorymeta( $category_id, 'image', $image ); |
|
513
|
|
|
} |
|
514
|
|
|
|
|
515
|
|
|
if ( ! empty( $_POST['height'] ) && is_numeric( $_POST['height'] ) && ! empty( $_POST['width'] ) && is_numeric( $_POST['width'] ) && $image == null ) { |
|
516
|
|
|
$imagedata = wpsc_get_categorymeta( $category_id, 'image' ); |
|
517
|
|
|
if ( $imagedata != null ) { |
|
518
|
|
|
$height = (int) $_POST['height']; |
|
519
|
|
|
$width = (int) $_POST['width']; |
|
520
|
|
|
$imagepath = WPSC_CATEGORY_DIR . $imagedata; |
|
521
|
|
|
$image_output = WPSC_CATEGORY_DIR . $imagedata; |
|
522
|
|
|
image_processing( $imagepath, $image_output, $width, $height ); |
|
523
|
|
|
} |
|
524
|
|
|
} |
|
525
|
|
|
|
|
526
|
|
|
wpsc_update_categorymeta( $category_id, 'fee', '0' ); |
|
527
|
|
|
wpsc_update_categorymeta( $category_id, 'active', '1' ); |
|
528
|
|
|
wpsc_update_categorymeta( $category_id, 'order', '0' ); |
|
529
|
|
|
|
|
530
|
|
|
if ( isset( $_POST['display_type'] ) ) { |
|
531
|
|
|
wpsc_update_categorymeta( $category_id, 'display_type', esc_sql( stripslashes( $_POST['display_type'] ) ) ); |
|
532
|
|
|
} |
|
533
|
|
|
|
|
534
|
|
|
if ( isset( $_POST['image_height'] ) ) { |
|
535
|
|
|
wpsc_update_categorymeta( $category_id, 'image_height', (int) $_POST['image_height'] ); |
|
536
|
|
|
} |
|
537
|
|
|
|
|
538
|
|
|
if ( isset( $_POST['image_width'] ) ) { |
|
539
|
|
|
wpsc_update_categorymeta( $category_id, 'image_width', (int) $_POST['image_width'] ); |
|
540
|
|
|
} |
|
541
|
|
|
|
|
542
|
|
|
if ( ! empty( $_POST['use_additional_form_set'] ) ) { |
|
543
|
|
|
wpsc_update_categorymeta( $category_id, 'use_additional_form_set', absint( $_POST['use_additional_form_set'] ) ); |
|
544
|
|
|
} else { |
|
545
|
|
|
wpsc_delete_categorymeta( $category_id, 'use_additional_form_set' ); |
|
546
|
|
|
} |
|
547
|
|
|
|
|
548
|
|
|
if ( ! empty( $_POST['uses_billing_address'] ) ) { |
|
549
|
|
|
wpsc_update_categorymeta( $category_id, 'uses_billing_address', 1 ); |
|
550
|
|
|
$uses_additional_forms = true; |
|
551
|
|
|
} else { |
|
552
|
|
|
wpsc_update_categorymeta( $category_id, 'uses_billing_address', 0 ); |
|
553
|
|
|
$uses_additional_forms = false; |
|
554
|
|
|
} |
|
555
|
|
|
|
|
556
|
|
|
if ( ! empty( $_POST['countrylist2'] ) && ( $category_id > 0 ) ) { |
|
557
|
|
|
$AllSelected = false; |
|
558
|
|
|
$countryList = $wpdb->get_col( "SELECT `id` FROM `" . WPSC_TABLE_CURRENCY_LIST . "`" ); |
|
559
|
|
|
|
|
560
|
|
|
if ( $AllSelected != true ){ |
|
|
|
|
|
|
561
|
|
|
$posted_countries = array_map( 'intval', $_POST['countrylist2'] ); |
|
562
|
|
|
$unselectedCountries = array_diff( $countryList, $posted_countries ); |
|
563
|
|
|
//find the countries that are selected |
|
564
|
|
|
$selectedCountries = array_intersect( $countryList, $posted_countries ); |
|
565
|
|
|
wpsc_update_categorymeta( $category_id, 'target_market', $selectedCountries ); |
|
566
|
|
|
} |
|
|
|
|
|
|
567
|
|
|
|
|
568
|
|
|
} elseif ( ! isset( $_POST['countrylist2'] ) ){ |
|
569
|
|
|
wpsc_update_categorymeta( $category_id, 'target_market', '' ); |
|
570
|
|
|
$AllSelected = true; |
|
571
|
|
|
} |
|
|
|
|
|
|
572
|
|
|
|
|
573
|
|
|
} |
|
574
|
|
|
} |
|
575
|
|
|
|
|
576
|
|
|
|
|
577
|
|
|
?> |
|
578
|
|
|
|
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.