/var/www/(Del)hsihk.com/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-settings.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
<?php
/**
 * WooCommerce Admin Settings Class.
 *
 * @author         WooThemes
 * @category     Admin
 * @package     WooCommerce/Admin
 * @version     2.2.0
 */

if ( ! defined'ABSPATH' ) ) {
    exit; 
// Exit if accessed directly
}

if ( ! 
class_exists'WC_Admin_Settings' ) ) :

/**
 * WC_Admin_Settings
 */
class WC_Admin_Settings {

    private static 
$settings = array();
    private static 
$errors   = array();
    private static 
$messages = array();

    
/**
     * Include the settings page classes
     */
    
public static function get_settings_pages() {
        if ( empty( 
self::$settings ) ) {
            
$settings = array();

            include_once( 
'settings/class-wc-settings-page.php' );

            
$settings[] = include( 'settings/class-wc-settings-general.php' );
            
$settings[] = include( 'settings/class-wc-settings-products.php' );
            
$settings[] = include( 'settings/class-wc-settings-tax.php' );
            
$settings[] = include( 'settings/class-wc-settings-checkout.php' );
            
$settings[] = include( 'settings/class-wc-settings-shipping.php' );
            
$settings[] = include( 'settings/class-wc-settings-accounts.php' );
            
$settings[] = include( 'settings/class-wc-settings-emails.php' );
            
$settings[] = include( 'settings/class-wc-settings-integrations.php' );

            
self::$settings apply_filters'woocommerce_get_settings_pages'$settings );
        }

        return 
self::$settings;
    }

    
/**
     * Save the settings
     */
    
public static function save() {
        global 
$current_tab;

        if ( empty( 
$_REQUEST['_wpnonce'] ) || ! wp_verify_nonce$_REQUEST['_wpnonce'], 'woocommerce-settings' ) ) {
            die( 
__'Action failed. Please refresh the page and retry.''woocommerce' ) );
        }

        
// Trigger actions
        
do_action'woocommerce_settings_save_' $current_tab );
        
do_action'woocommerce_update_options_' $current_tab );
        
do_action'woocommerce_update_options' );

        
// Clear any unwanted data
        
delete_transient'woocommerce_cache_excluded_uris' );

        
self::add_message__'Your settings have been saved.''woocommerce' ) );
        
self::check_download_folder_protection();

        
// Re-add endpoints and flush rules
        
WC()->query->init_query_vars();
        
WC()->query->add_endpoints();
        
flush_rewrite_rules();

        
do_action'woocommerce_settings_saved' );
    }

    
/**
     * Add a message
     * @param string $text
     */
    
public static function add_message$text ) {
        
self::$messages[] = $text;
    }

    
/**
     * Add an error
     * @param string $text
     */
    
public static function add_error$text ) {
        
self::$errors[] = $text;
    }

    
/**
     * Output messages + errors
     * @return string
     */
    
public static function show_messages() {
        if ( 
sizeofself::$errors ) > ) {
            foreach ( 
self::$errors as $error ) {
                echo 
'<div id="message" class="error fade"><p><strong>' esc_html$error ) . '</strong></p></div>';
            }
        } elseif ( 
sizeofself::$messages ) > ) {
            foreach ( 
self::$messages as $message ) {
                echo 
'<div id="message" class="updated fade"><p><strong>' esc_html$message ) . '</strong></p></div>';
            }
        }
    }

    
/**
     * Settings page.
     *
     * Handles the display of the main woocommerce settings page in admin.
     *
     * @return void
     */
    
public static function output() {
        global 
$current_section$current_tab;

        
do_action'woocommerce_settings_start' );

        
wp_enqueue_script'woocommerce_settings'WC()->plugin_url() . '/assets/js/admin/settings.min.js', array( 'jquery''jquery-ui-datepicker''jquery-ui-sortable''iris''chosen' ), WC()->versiontrue );

        
wp_localize_script'woocommerce_settings''woocommerce_settings_params', array(
            
'i18n_nav_warning' => __'The changes you made will be lost if you navigate away from this page.''woocommerce' )
        ) );

        
// Include settings pages
        
self::get_settings_pages();

        
// Get current tab/section
        
$current_tab     = empty( $_GET['tab'] ) ? 'general' sanitize_title$_GET['tab'] );
        
$current_section = empty( $_REQUEST['section'] ) ? '' sanitize_title$_REQUEST['section'] );

        
// Save settings if data has been posted
        
if ( ! empty( $_POST ) ) {
            
self::save();
        }

        
// Add any posted messages
        
if ( ! empty( $_GET['wc_error'] ) ) {
            
self::add_errorstripslashes$_GET['wc_error'] ) );
        }

        if ( ! empty( 
$_GET['wc_message'] ) ) {
            
self::add_messagestripslashes$_GET['wc_message'] ) );
        }

        
self::show_messages();

        
// Get tabs for the settings page
        
$tabs apply_filters'woocommerce_settings_tabs_array', array() );

        include 
'views/html-admin-settings.php';
    }

    
/**
     * Get a setting from the settings API.
     *
     * @param mixed $option_name
     * @return string
     */
    
public static function get_option$option_name$default '' ) {
        
// Array value
        
if ( strstr$option_name'[' ) ) {

            
parse_str$option_name$option_array );

            
// Option name is first key
            
$option_name currentarray_keys$option_array ) );

            
// Get value
            
$option_values get_option$option_name'' );

            
$key key$option_array$option_name ] );

            if ( isset( 
$option_values$key ] ) ) {
                
$option_value $option_values$key ];
            } else {
                
$option_value null;
            }

        
// Single value
        
} else {
            
$option_value get_option$option_namenull );
        }

        if ( 
is_array$option_value ) ) {
            
$option_value array_map'stripslashes'$option_value );
        } elseif ( ! 
is_null$option_value ) ) {
            
$option_value stripslashes$option_value );
        }

        return 
$option_value === null $default $option_value;
    }

    
/**
     * Output admin fields.
     *
     * Loops though the woocommerce options array and outputs each field.
     *
     * @param array $options Opens array to output
     */
    
public static function output_fields$options ) {
        foreach ( 
$options as $value ) {
            if ( ! isset( 
$value['type'] ) ) {
                continue;
            }
            if ( ! isset( 
$value['id'] ) ) {
                
$value['id'] = '';
            }
            if ( ! isset( 
$value['title'] ) ) {
                
$value['title'] = isset( $value['name'] ) ? $value['name'] : '';
            }
            if ( ! isset( 
$value['class'] ) ) {
                
$value['class'] = '';
            }
            if ( ! isset( 
$value['css'] ) ) {
                
$value['css'] = '';
            }
            if ( ! isset( 
$value['default'] ) ) {
                
$value['default'] = '';
            }
            if ( ! isset( 
$value['desc'] ) ) {
                
$value['desc'] = '';
            }
            if ( ! isset( 
$value['desc_tip'] ) ) {
                
$value['desc_tip'] = false;
            }

            
// Custom attribute handling
            
$custom_attributes = array();

            if ( ! empty( 
$value['custom_attributes'] ) && is_array$value['custom_attributes'] ) ) {
                foreach ( 
$value['custom_attributes'] as $attribute => $attribute_value ) {
                    
$custom_attributes[] = esc_attr$attribute ) . '="' esc_attr$attribute_value ) . '"';
                }
            }

            
// Description handling
            
if ( true === $value['desc_tip'] ) {
                
$description '';
                
$tip $value['desc'];
            } elseif ( ! empty( 
$value['desc_tip'] ) ) {
                
$description $value['desc'];
                
$tip $value['desc_tip'];
            } elseif ( ! empty( 
$value['desc'] ) ) {
                
$description $value['desc'];
                
$tip '';
            } else {
                
$description $tip '';
            }

            if ( 
$description && in_array$value['type'], array( 'textarea''radio' ) ) ) {
                
$description '<p style="margin-top:0">' wp_kses_post$description ) . '</p>';
            } elseif ( 
$description && in_array$value['type'], array( 'checkbox' ) ) ) {
                
$description =  wp_kses_post$description );
            } elseif ( 
$description ) {
                
$description '<span class="description">' wp_kses_post$description ) . '</span>';
            }

            if ( 
$tip && in_array$value['type'], array( 'checkbox' ) ) ) {

                
$tip '<p class="description">' $tip '</p>';

            } elseif ( 
$tip ) {

                
$tip '<img class="help_tip" data-tip="' esc_attr$tip ) . '" src="' WC()->plugin_url() . '/assets/images/help.png" height="16" width="16" />';

            }

            
// Switch based on type
            
switch ( $value['type'] ) {

                
// Section Titles
                
case 'title':
                    if ( ! empty( 
$value['title'] ) ) {
                        echo 
'<h3>' esc_html$value['title'] ) . '</h3>';
                    }
                    if ( ! empty( 
$value['desc'] ) ) {
                        echo 
wpautopwptexturizewp_kses_post$value['desc'] ) ) );
                    }
                    echo 
'<table class="form-table">'"\n\n";
                    if ( ! empty( 
$value['id'] ) ) {
                        
do_action'woocommerce_settings_' sanitize_title$value['id'] ) );
                    }
                    break;

                
// Section Ends
                
case 'sectionend':
                    if ( ! empty( 
$value['id'] ) ) {
                        
do_action'woocommerce_settings_' sanitize_title$value['id'] ) . '_end' );
                    }
                    echo 
'</table>';
                    if ( ! empty( 
$value['id'] ) ) {
                        
do_action'woocommerce_settings_' sanitize_title$value['id'] ) . '_after' );
                    }
                    break;

                
// Standard text inputs and subtypes like 'number'
                
case 'text':
                case 
'email':
                case 
'number':
                case 
'color' :
                case 
'password' :

                    
$type         $value['type'];
                    
$class        '';
                    
$option_value self::get_option$value['id'], $value['default'] );

                    if ( 
$value['type'] == 'color' ) {
                        
$type 'text';
                        
$value['class'] .= 'colorpick';
                        
$description .= '<div id="colorPickerDiv_' esc_attr$value['id'] ) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>';
                    }

                    
?><tr valign="top">
                        <th scope="row" class="titledesc">
                            <label for="<?php echo esc_attr$value['id'] ); ?>"><?php echo esc_html$value['title'] ); ?></label>
                            <?php echo $tip?>
                        </th>
                        <td class="forminp forminp-<?php echo sanitize_title$value['type'] ) ?>">
                            <input
                                name="<?php echo esc_attr$value['id'] ); ?>"
                                id="<?php echo esc_attr$value['id'] ); ?>"
                                type="<?php echo esc_attr$type ); ?>"
                                style="<?php echo esc_attr$value['css'] ); ?>"
                                value="<?php echo esc_attr$option_value ); ?>"
                                class="<?php echo esc_attr$value['class'] ); ?>"
                                <?php echo implode' '$custom_attributes ); ?>
                                /> <?php echo $description?>
                        </td>
                    </tr><?php
                    
break;

                
// Textarea
                
case 'textarea':

                    
$option_value self::get_option$value['id'], $value['default'] );

                    
?><tr valign="top">
                        <th scope="row" class="titledesc">
                            <label for="<?php echo esc_attr$value['id'] ); ?>"><?php echo esc_html$value['title'] ); ?></label>
                            <?php echo $tip?>
                        </th>
                        <td class="forminp forminp-<?php echo sanitize_title$value['type'] ) ?>">
                            <?php echo $description?>

                            <textarea
                                name="<?php echo esc_attr$value['id'] ); ?>"
                                id="<?php echo esc_attr$value['id'] ); ?>"
                                style="<?php echo esc_attr$value['css'] ); ?>"
                                class="<?php echo esc_attr$value['class'] ); ?>"
                                <?php echo implode' '$custom_attributes ); ?>
                                ><?php echo esc_textarea$option_value );  ?></textarea>
                        </td>
                    </tr><?php
                    
break;

                
// Select boxes
                
case 'select' :
                case 
'multiselect' :

                    
$option_value self::get_option$value['id'], $value['default'] );

                    
?><tr valign="top">
                        <th scope="row" class="titledesc">
                            <label for="<?php echo esc_attr$value['id'] ); ?>"><?php echo esc_html$value['title'] ); ?></label>
                            <?php echo $tip?>
                        </th>
                        <td class="forminp forminp-<?php echo sanitize_title$value['type'] ) ?>">
                            <select
                                name="<?php echo esc_attr$value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'?>"
                                id="<?php echo esc_attr$value['id'] ); ?>"
                                style="<?php echo esc_attr$value['css'] ); ?>"
                                class="<?php echo esc_attr$value['class'] ); ?>"
                                <?php echo implode' '$custom_attributes ); ?>
                                <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' ''?>
                                >
                                <?php
                                    
foreach ( $value['options'] as $key => $val ) {
                                        
?>
                                        <option value="<?php echo esc_attr$key ); ?><?php

                                            
if ( is_array$option_value ) ) {
                                                
selectedin_array$key$option_value ), true );
                                            } else {
                                                
selected$option_value$key );
                                            }

                                        
?>><?php echo $val ?></option>
                                        <?php
                                    
}
                                
?>
                           </select> <?php echo $description?>
                        </td>
                    </tr><?php
                    
break;

                
// Radio inputs
                
case 'radio' :

                    
$option_value self::get_option$value['id'], $value['default'] );

                    
?><tr valign="top">
                        <th scope="row" class="titledesc">
                            <label for="<?php echo esc_attr$value['id'] ); ?>"><?php echo esc_html$value['title'] ); ?></label>
                            <?php echo $tip?>
                        </th>
                        <td class="forminp forminp-<?php echo sanitize_title$value['type'] ) ?>">
                            <fieldset>
                                <?php echo $description?>
                                <ul>
                                <?php
                                    
foreach ( $value['options'] as $key => $val ) {
                                        
?>
                                        <li>
                                            <label><input
                                                name="<?php echo esc_attr$value['id'] ); ?>"
                                                value="<?php echo $key?>"
                                                type="radio"
                                                style="<?php echo esc_attr$value['css'] ); ?>"
                                                class="<?php echo esc_attr$value['class'] ); ?>"
                                                <?php echo implode' '$custom_attributes ); ?>
                                                <?php checked$key$option_value ); ?>
                                                /> <?php echo $val ?></label>
                                        </li>
                                        <?php
                                    
}
                                
?>
                                </ul>
                            </fieldset>
                        </td>
                    </tr><?php
                    
break;

                
// Checkbox input
                
case 'checkbox' :

                    
$option_value    self::get_option$value['id'], $value['default'] );
                    
$visbility_class = array();

                    if ( ! isset( 
$value['hide_if_checked'] ) ) {
                        
$value['hide_if_checked'] = false;
                    }
                    if ( ! isset( 
$value['show_if_checked'] ) ) {
                        
$value['show_if_checked'] = false;
                    }
                    if ( 
'yes' == $value['hide_if_checked'] || 'yes' == $value['show_if_checked'] ) {
                        
$visbility_class[] = 'hidden_option';
                    }
                    if ( 
'option' == $value['hide_if_checked'] ) {
                        
$visbility_class[] = 'hide_options_if_checked';
                    }
                    if ( 
'option' == $value['show_if_checked'] ) {
                        
$visbility_class[] = 'show_options_if_checked';
                    }

                    if ( ! isset( 
$value['checkboxgroup'] ) || 'start' == $value['checkboxgroup'] ) {
                        
?>
                            <tr valign="top" class="<?php echo esc_attrimplode' '$visbility_class ) ); ?>">
                                <th scope="row" class="titledesc"><?php echo esc_html$value['title'] ) ?></th>
                                <td class="forminp forminp-checkbox">
                                    <fieldset>
                        <?php
                    
} else {
                        
?>
                            <fieldset class="<?php echo esc_attrimplode' '$visbility_class ) ); ?>">
                        <?php
                    
}

                    if ( ! empty( 
$value['title'] ) ) {
                        
?>
                            <legend class="screen-reader-text"><span><?php echo esc_html$value['title'] ) ?></span></legend>
                        <?php
                    
}

                    
?>
                        <label for="<?php echo $value['id'?>">
                            <input
                                name="<?php echo esc_attr$value['id'] ); ?>"
                                id="<?php echo esc_attr$value['id'] ); ?>"
                                type="checkbox"
                                value="1"
                                <?php checked$option_value'yes'); ?>
                                <?php echo implode' '$custom_attributes ); ?>
                            /> <?php echo $description ?>
                        </label> <?php echo $tip?>
                    <?php

                    
if ( ! isset( $value['checkboxgroup'] ) || 'end' == $value['checkboxgroup'] ) {
                                    
?>
                                    </fieldset>
                                </td>
                            </tr>
                        <?php
                    
} else {
                        
?>
                            </fieldset>
                        <?php
                    
}
                    break;

                
// Image width settings
                
case 'image_width' :

                    
$image_size str_replace'_image_size'''$value'id' ] );
                    
$size   wc_get_image_size$image_size );
                    
$width  = isset( $size'width' ] )  ? $size'width' ]  : $value'default' ][ 'width' ];
                    
$height = isset( $size'height' ] ) ? $size'height' ] : $value'default' ][ 'height' ];
                    
$crop   = isset( $size'crop' ] )   ? $size'crop' ]   : $value'default' ][ 'crop' ];

                    
$disabled_attr    '';
                    
$disabled_message '';

                    if ( 
has_filter'woocommerce_get_image_size_' $image_size ) ) {
                        
$disabled_attr 'disabled="disabled"';
                        
$disabled_message "<p><small>" __'The settings of this image size have been disabled because its values are being overwritten by a filter.''woocommerce' ) . "</small></p>";
                    }

                    
?><tr valign="top">
                        <th scope="row" class="titledesc"><?php echo esc_html$value['title'] ) ?> <?php echo $tip; echo $disabled_message?></th>
                        <td class="forminp image_width_settings">

                            <input name="<?php echo esc_attr$value['id'] ); ?>[width]" <?php echo $disabled_attr?> id="<?php echo esc_attr$value['id'] ); ?>-width" type="text" size="3" value="<?php echo $width?>" /> &times; <input name="<?php echo esc_attr$value['id'] ); ?>[height]" <?php echo $disabled_attr?> id="<?php echo esc_attr$value['id'] ); ?>-height" type="text" size="3" value="<?php echo $height?>" />px

                            <label><input name="<?php echo esc_attr$value['id'] ); ?>[crop]" <?php echo $disabled_attr?> id="<?php echo esc_attr$value['id'] ); ?>-crop" type="checkbox" value="1" <?php checked1$crop ); ?> /> <?php _e'Hard Crop?''woocommerce' ); ?></label>

                            </td>
                    </tr><?php
                    
break;

                
// Single page selects
                
case 'single_select_page' :

                    
$args = array(
                        
'name'             => $value['id'],
                        
'id'               => $value['id'],
                        
'sort_column'      => 'menu_order',
                        
'sort_order'       => 'ASC',
                        
'show_option_none' => ' ',
                        
'class'            => $value['class'],
                        
'echo'             => false,
                        
'selected'         => absintself::get_option$value['id'] ) )
                    );

                    if ( isset( 
$value['args'] ) ) {
                        
$args wp_parse_args$value['args'], $args );
                    }

                    
?><tr valign="top" class="single_select_page">
                        <th scope="row" class="titledesc"><?php echo esc_html$value['title'] ) ?> <?php echo $tip?></th>
                        <td class="forminp">
                            <?php echo str_replace(' id='" data-placeholder='" __'Select a page&hellip;''woocommerce' ) .  "' style='" $value['css'] . "' class='" $value['class'] . "' id="wp_dropdown_pages$args ) ); ?> <?php echo $description?>
                        </td>
                    </tr><?php
                    
break;

                
// Single country selects
                
case 'single_select_country' :
                    
$country_setting = (string) self::get_option$value['id'] );
                    
$countries       WC()->countries->countries;

                    if ( 
strstr$country_setting':' ) ) {
                        
$country_setting explode':'$country_setting );
                        
$country         current$country_setting );
                        
$state           end$country_setting );
                    } else {
                        
$country $country_setting;
                        
$state   '*';
                    }
                    
?><tr valign="top">
                        <th scope="row" class="titledesc">
                            <label for="<?php echo esc_attr$value['id'] ); ?>"><?php echo esc_html$value['title'] ); ?></label>
                            <?php echo $tip?>
                        </th>
                        <td class="forminp"><select name="<?php echo esc_attr$value['id'] ); ?>" style="<?php echo esc_attr$value['css'] ); ?>" data-placeholder="<?php _e'Choose a country&hellip;''woocommerce' ); ?>" title="<?php _e'Country''woocommerce' ?>" class="chosen_select">
                            <?php WC()->countries->country_dropdown_options$country$state ); ?>
                        </select> <?php echo $description?>
                        </td>
                    </tr><?php
                    
break;

                
// Country multiselects
                
case 'multi_select_countries' :

                    
$selections = (array) self::get_option$value['id'] );

                    if ( ! empty( 
$value['options'] ) ) {
                        
$countries $value['options'];
                    } else {
                        
$countries WC()->countries->countries;
                    }

                    
asort$countries );
                    
?><tr valign="top">
                        <th scope="row" class="titledesc">
                            <label for="<?php echo esc_attr$value['id'] ); ?>"><?php echo esc_html$value['title'] ); ?></label>
                            <?php echo $tip?>
                        </th>
                        <td class="forminp">
                            <select multiple="multiple" name="<?php echo esc_attr$value['id'] ); ?>[]" style="width:350px" data-placeholder="<?php _e'Choose countries&hellip;''woocommerce' ); ?>" title="<?php _e'Country''woocommerce' ?>" class="chosen_select">
                                <?php
                                    
if ( $countries ) {
                                        foreach ( 
$countries as $key => $val ) {
                                            echo 
'<option value="' esc_attr$key ) . '" ' selectedin_array$key$selections ), truefalse ).'>' $val '</option>';
                                        }
                                    }
                                
?>
                            </select> <?php echo ( $description ) ? $description ''?> </br><a class="select_all button" href="#"><?php _e'Select all''woocommerce' ); ?></a> <a class="select_none button" href="#"><?php _e'Select none''woocommerce' ); ?></a>
                        </td>
                    </tr><?php
                    
break;

                
// Default: run an action
                
default:
                    
do_action'woocommerce_admin_field_' $value['type'], $value );
                    break;
            }
        }
    }

    
/**
     * Save admin fields.
     *
     * Loops though the woocommerce options array and outputs each field.
     *
     * @param array $options Opens array to output
     * @return bool
     */
    
public static function save_fields$options ) {
        if ( empty( 
$_POST ) ) {
            return 
false;
        }

        
// Options to update will be stored here
        
$update_options = array();

        
// Loop options and get values to save
        
foreach ( $options as $value ) {
            if ( ! isset( 
$value['id'] ) || ! isset( $value['type'] ) ) {
                continue;
            }

            
// Get posted value
            
if ( strstr$value['id'], '[' ) ) {
                
parse_str$value['id'], $option_name_array );

                
$option_name  currentarray_keys$option_name_array ) );
                
$setting_name key$option_name_array$option_name ] );

                
$option_value = isset( $_POST$option_name ][ $setting_name ] ) ? stripslashes_deep$_POST$option_name ][ $setting_name ] ) : null;
            } else {
                
$option_name  $value['id'];
                
$setting_name '';
                
$option_value = isset( $_POST$value['id'] ] ) ? stripslashes_deep$_POST$value['id'] ] ) : null;
            }

            
// Format value
            
switch ( sanitize_title$value['type'] ) ) {
                case 
'checkbox' :
                    
$option_value is_null$option_value ) ? 'no' 'yes';
                    break;
                case 
'textarea' :
                    
$option_value wp_kses_posttrim$option_value ) );
                    break;
                case 
'text' :
                case 
'email':
                case 
'number':
                case 
'select' :
                case 
'color' :
                case 
'password' :
                case 
'single_select_page' :
                case 
'single_select_country' :
                case 
'radio' :
                    if ( 
in_array$value['id'], array( 'woocommerce_price_thousand_sep''woocommerce_price_decimal_sep' ) ) ) {
                        
$option_value wp_kses_post$option_value );

                    } elseif ( 
'woocommerce_price_num_decimals' == $value['id'] ) {
                        
$option_value is_null$option_value ) ? absint$option_value );

                    } elseif ( 
'woocommerce_hold_stock_minutes' == $value['id'] ) {
                        
$option_value = ! empty( $option_value ) ? absint$option_value ) : ''// Allow > 0 or set to ''

                        
wp_clear_scheduled_hook'woocommerce_cancel_unpaid_orders' );

                        if ( 
'' !== $option_value ) {
                            
wp_schedule_single_eventtime() + ( absint$option_value ) * 60 ), 'woocommerce_cancel_unpaid_orders' );
                        }

                    } else {
                        
$option_value wc_clean$option_value );
                    }
                    break;
                case 
'multiselect' :
                case 
'multi_select_countries' :
                    
$option_value array_filterarray_map'wc_clean', (array) $option_value ) );
                    break;
                case 
'image_width' :
                    if ( isset( 
$option_value['width'] ) ) {
                        
$update_options$value['id'] ]['width']  = wc_clean$option_value['width'] );
                        
$update_options$value['id'] ]['height'] = wc_clean$option_value['height'] );
                        
$update_options$value['id'] ]['crop']   = isset( $option_value['crop'] ) ? 0;
                    } else {
                        
$update_options$value['id'] ]['width']  = $value['default']['width'];
                        
$update_options$value['id'] ]['height'] = $value['default']['height'];
                        
$update_options$value['id'] ]['crop']   = $value['default']['crop'];
                    }
                    break;
                default :
                    
do_action'woocommerce_update_option_' sanitize_title$value['type'] ), $value );
                    break;
            }

            if ( ! 
is_null$option_value ) ) {
                
// Check if option is an array
                
if ( $option_name && $setting_name ) {
                    
// Get old option value
                    
if ( ! isset( $update_options$option_name ] ) ) {
                        
$update_options$option_name ] = get_option$option_name, array() );
                    }

                    if ( ! 
is_array$update_options$option_name ] ) ) {
                        
$update_options$option_name ] = array();
                    }

                    
$update_options$option_name ][ $setting_name ] = $option_value;

                
// Single value
                
} else {
                    
$update_options$option_name ] = $option_value;
                }
            }

            
// Custom handling
            
do_action'woocommerce_update_option'$value );
        }

        
// Now save the options
        
foreach ( $update_options as $name => $value ) {
            
update_option$name$value );
        }

        return 
true;
    }

    
/**
     * Checks which method we're using to serve downloads
     *
     * If using force or x-sendfile, this ensures the .htaccess is in place
     *
     * @return void
     */
    
public static function check_download_folder_protection() {
        
$upload_dir      wp_upload_dir();
        
$downloads_url   $upload_dir['basedir'] . '/woocommerce_uploads';
        
$download_method get_option('woocommerce_file_download_method');

        if ( 
'redirect' == $download_method ) {

            
// Redirect method - don't protect
            
if ( file_exists$downloads_url '/.htaccess' ) ) {
                
unlink$downloads_url '/.htaccess' );
            }

        } else {

            
// Force method - protect, add rules to the htaccess file
            
if ( ! file_exists$downloads_url '/.htaccess' ) ) {
                if ( 
$file_handle = @fopen$downloads_url '/.htaccess''w' ) ) {
                    
fwrite$file_handle'deny from all' );
                    
fclose$file_handle );
                }
            }
        }
    }
}

endif;