/var/www/hkosl.com/aga/wp-content/plugins/smart-slider-3/includes/integrations/acf.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
<?php
add_action
('acf/register_fields', array(
    
'acf_field_smart_slider_3',
    
'register_fields'
));
add_action('acf/include_fields', array(
    
'acf_field_smart_slider_3',
    
'register_fields'
));


class 
acf_field_smart_slider_3 extends acf_field {

    public 
$label 'Smart Slider 3';

    public static function 
register_fields() {
        new 
acf_field_smart_slider_3();
    }

    function 
__construct() {
        
$this->name 'acf_smartslider3';

        
parent::__construct();
    }

    function 
load_value($value$post_id$field) {
        return 
$value;
    }

    function 
update_value($value$field$post_id) {
        return 
$value;
    }

    public function 
format_value($value$field) {
        if (
is_admin()) {
            return 
$value;
        }

        if (!
$value) {
            return 
false;
        }

        if (!
is_numeric($value)) {
            return 
do_shortcode('[smartslider3 alias="' $value '"]');
        }

        return 
do_shortcode('[smartslider3 slider=' $value ']');
    }

    public function 
format_value_for_api($value$field) {

        if (
is_admin()) {
            return 
$value;
        }

        return 
$this->format_value($value$field);
    }

    function 
load_field($field) {
        return 
$field;
    }

    public function 
create_field($field) {
        
$this->render_field($field);
    }

    public function 
render_field($field) {

        
N2base::getApplication('smartslider')
              ->
getApplicationType('backend');
        
N2Loader::import("models.Sliders""smartslider");

        
$slidersModel = new N2SmartsliderSlidersModel();

        
$choices = array();
        foreach (
$slidersModel->getAll(0) AS $slider) {
            if (
$slider['type'] == 'group') {

                
$subChoices = array();
                if (!empty(
$slider['alias'])) {
                    
$subChoices[$slider['alias']] = n2_('Whole group') . ' - ' $slider['title'] . ' #Alias: ' $slider['alias'];
                }
                
$subChoices[$slider['id']] = n2_('Whole group') . ' - ' $slider['title'] . ' #' $slider['id'];
                foreach (
$slidersModel->getAll($slider['id']) AS $_slider) {
                    if (!empty(
$_slider['alias'])) {
                        
$subChoices[$_slider['alias']] = $_slider['title'] . ' #Alias: ' $_slider['alias'];
                    }
                    
$subChoices[$_slider['id']] = $_slider['title'] . ' #' $_slider['id'];
                }

                
$choices[$slider['id']] = array(
                    
'label'   => $slider['title'] . ' #' $slider['id'],
                    
'choices' => $subChoices
                
);
            } else {
                if (!empty(
$slider['alias'])) {
                    
$choices[$slider['alias']] = $slider['title'] . ' #Alias: ' $slider['alias'];
                }
                
$choices[$slider['id']] = $slider['title'] . ' #' $slider['id'];
            }
        }

        
?>
        <table style="width:100%;border:0;">
            <tr>
                <td style="white-space: nowrap;">
                    <a href="#" onclick="<?php echo SmartSlider3::sliderSelectAction("jQuery('#" $field['id'] . "')"); ?>return false;" class="button" title="<?php echo n2_('Select slider'); ?>"><?php echo n2_('Select slider'); ?></a>
                    <span style="line-height:2;padding:10px;"><?php n2_e('OR'); ?></span>
                </td>
                <td style="width:90%;">
                    <select id="<?php echo $field['id']; ?>" class="<?php echo $field['class']; ?>" name="<?php echo $field['name']; ?>">
                        <?php if (!isset($field['required']) || !$field['required']): ?>
                            <option value=""><?php n2_e('None'); ?></option>
                        <?php endif; ?>
                        <?php
                        
foreach ($choices AS $id => $choice) {
                            if (
is_array($choice)) {
                                
?>
                                <optgroup label="<?php echo $choice['label']; ?>">
                                <?php
                                
foreach ($choice['choices'] AS $_id => $_choice) {
                                    
?>
                                    <option <?php if ($_id == $field['value']){ ?>selected <?php ?>value="<?php echo $_id?>"><?php echo $_choice?></option>
                                    <?php
                                
}
                                
?>
                            </optgroup>
                                <?php
                            
} else {
                                
?>
                                <option <?php if ($id == $field['value']){ ?>selected <?php ?>value="<?php echo $id?>"><?php echo $choice?></option>
                                <?php
                            
}
                        }
                        
?>
                    </select>
                </td>
            </tr>
        </table>
        <?php
    
}

    function 
create_options($field) {

    }

    function 
input_admin_enqueue_scripts() {

    }

    function 
input_admin_head() {

    }

    function 
field_group_admin_enqueue_scripts() {

    }

    function 
field_group_admin_head() {

    }
}