/var/www/html_uk/wp-content/plugins/automatewoo/includes/Fields/Category.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
<?php
// phpcs:ignoreFile

namespace AutomateWoo\Fields;

use 
AutomateWoo\Fields_Helper;

if ( ! 
defined'ABSPATH' ) ) exit;

/**
 * @class Category
 */
class Category extends Field {

    protected 
$name 'category';

    protected 
$type 'category';


    function 
__construct() {
        
parent::__construct();
        
$this->set_title__'Product category''automatewoo' ) );
        
$this->set_placeholder__'[Select]''automatewoo' ) );
    }


    
/**
     * @param $value
     */
    
function render$value ) {
        
?>

        <select name="<?php echo esc_attr$this->get_full_name() ); ?>"
                class="wc-enhanced-select <?php echo esc_attr$this->get_classes() ); ?>"
                data-placeholder="<?php echo esc_attr$this->get_placeholder() ); ?>">

            <option value=""><?php echo esc_html$this->get_placeholder() ); ?></option>

            <?php

            $categories 
Fields_Helper::get_categories_list();

            foreach ( 
$categories as $category_id => $category_name ) {
                echo 
'<option value="' esc_attr$category_id ) . '" ' selected$category_id$valuefalse ) . '>' esc_html$category_name ) . '</option>';
            }
            
?>
        </select>

        <script type="text/javascript">
            jQuery( 'body' ).trigger( 'wc-enhanced-select-init' );
        </script>

    <?php
    
}

}