| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) exit; // if direct access |
| 3 |
if (!class_exists('settings_tabs_field')) { |
| 4 |
class settings_tabs_field |
| 5 |
{ |
| 6 |
|
| 7 |
public function allowed() |
| 8 |
{ |
| 9 |
|
| 10 |
return wp_kses_allowed_html('post'); |
| 11 |
} |
| 12 |
public $custom = array( |
| 13 |
'select' => array( |
| 14 |
'name' => true, |
| 15 |
'id' => true, |
| 16 |
'class' => true, |
| 17 |
'multiple' => true, |
| 18 |
), |
| 19 |
'option' => array( |
| 20 |
'value' => true, |
| 21 |
'selected' => true, |
| 22 |
), |
| 23 |
'optgroup' => array( |
| 24 |
'label' => true, |
| 25 |
), |
| 26 |
'input' => array( |
| 27 |
'type' => true, |
| 28 |
'name' => true, |
| 29 |
'value' => true, |
| 30 |
'class' => true, |
| 31 |
'id' => true, |
| 32 |
'checked' => true, |
| 33 |
'placeholder' => true, |
| 34 |
), |
| 35 |
'label' => array( |
| 36 |
'for' => true, |
| 37 |
'class' => true, |
| 38 |
), |
| 39 |
); |
| 40 |
|
| 41 |
public function allowed_html() |
| 42 |
{ |
| 43 |
|
| 44 |
return array_merge($this->allowed(), $this->custom); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
//public $asset_dir_url = ''; |
| 49 |
public function __construct() {} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
function admin_scripts() |
| 60 |
{ |
| 61 |
wp_enqueue_script('jquery'); |
| 62 |
wp_enqueue_script('jquery-ui-sortable'); |
| 63 |
wp_enqueue_script('jquery-ui-core'); |
| 64 |
wp_enqueue_script('jquery-ui-accordion'); |
| 65 |
wp_enqueue_style('jquery-ui'); |
| 66 |
wp_enqueue_script('wp-color-picker'); |
| 67 |
wp_enqueue_style('wp-color-picker'); |
| 68 |
wp_enqueue_style('select2'); |
| 69 |
wp_enqueue_script('select2'); |
| 70 |
wp_enqueue_style('font-awesome-5'); |
| 71 |
wp_enqueue_style('settings-tabs'); |
| 72 |
wp_enqueue_script('settings-tabs'); |
| 73 |
wp_enqueue_script('code-editor'); |
| 74 |
wp_enqueue_style('code-editor'); |
| 75 |
wp_enqueue_script('jquery.lazy'); |
| 76 |
wp_enqueue_script('jquery-ui-datepicker'); |
| 77 |
|
| 78 |
if (function_exists('wp_enqueue_editor')) { |
| 79 |
wp_enqueue_editor(); |
| 80 |
} |
| 81 |
} |
| 82 |
function field_template($option) |
| 83 |
{ |
| 84 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 85 |
$wraper_class = isset($option['wraper_class']) ? $option['wraper_class'] : ""; |
| 86 |
$conditions = isset($option['conditions']) ? $option['conditions'] : array(); |
| 87 |
$is_error = isset($option['is_error']) ? $option['is_error'] : false; |
| 88 |
$error_details = isset($option['error_details']) ? $option['error_details'] : ''; |
| 89 |
if (!empty($conditions)) : |
| 90 |
$depends = ''; |
| 91 |
$field = isset($conditions['field']) ? $conditions['field'] : ''; |
| 92 |
$cond_value = isset($conditions['value']) ? $conditions['value'] : ''; |
| 93 |
$type = isset($conditions['type']) ? $conditions['type'] : ''; |
| 94 |
$pattern = isset($conditions['pattern']) ? $conditions['pattern'] : ''; |
| 95 |
$modifier = isset($conditions['modifier']) ? $conditions['modifier'] : ''; |
| 96 |
$like = isset($conditions['like']) ? $conditions['like'] : ''; |
| 97 |
$strict = isset($conditions['strict']) ? $conditions['strict'] : ''; |
| 98 |
$empty = isset($conditions['empty']) ? $conditions['empty'] : ''; |
| 99 |
$sign = isset($conditions['sign']) ? $conditions['sign'] : ''; |
| 100 |
$min = isset($conditions['min']) ? $conditions['min'] : ''; |
| 101 |
$max = isset($conditions['max']) ? $conditions['max'] : ''; |
| 102 |
$depends .= "{'[name=$field]':"; |
| 103 |
$depends .= '{'; |
| 104 |
if (!empty($type)) : |
| 105 |
$depends .= "'type':"; |
| 106 |
$depends .= "'" . $type . "'"; |
| 107 |
endif; |
| 108 |
if (!empty($modifier)) : |
| 109 |
$depends .= ",'modifier':"; |
| 110 |
$depends .= "'" . $modifier . "'"; |
| 111 |
endif; |
| 112 |
if (!empty($like)) : |
| 113 |
$depends .= ",'like':"; |
| 114 |
$depends .= "'" . $like . "'"; |
| 115 |
endif; |
| 116 |
if (!empty($strict)) : |
| 117 |
$depends .= ",'strict':"; |
| 118 |
$depends .= "'" . $strict . "'"; |
| 119 |
endif; |
| 120 |
if (!empty($empty)) : |
| 121 |
$depends .= ",'empty':"; |
| 122 |
$depends .= "'" . $empty . "'"; |
| 123 |
endif; |
| 124 |
if (!empty($sign)) : |
| 125 |
$depends .= ",'sign':"; |
| 126 |
$depends .= "'" . $sign . "'"; |
| 127 |
endif; |
| 128 |
if (!empty($min)) : |
| 129 |
$depends .= ",'min':"; |
| 130 |
$depends .= "'" . $min . "'"; |
| 131 |
endif; |
| 132 |
if (!empty($max)) : |
| 133 |
$depends .= ",'max':"; |
| 134 |
$depends .= "'" . $max . "'"; |
| 135 |
endif; |
| 136 |
if (!empty($cond_value)) : |
| 137 |
$depends .= ",'value':"; |
| 138 |
if (is_array($cond_value)) : |
| 139 |
$count = count($cond_value); |
| 140 |
$i = 1; |
| 141 |
$depends .= "["; |
| 142 |
foreach ($cond_value as $val) : |
| 143 |
$depends .= "'" . $val . "'"; |
| 144 |
if ($i < $count) |
| 145 |
$depends .= ","; |
| 146 |
$i++; |
| 147 |
endforeach; |
| 148 |
$depends .= "]"; |
| 149 |
else : |
| 150 |
$depends .= "["; |
| 151 |
$depends .= "'" . $cond_value . "'"; |
| 152 |
$depends .= "]"; |
| 153 |
endif; |
| 154 |
endif; |
| 155 |
$depends .= '}}'; |
| 156 |
endif; |
| 157 |
ob_start(); |
| 158 |
?> |
| 159 |
<div <?php if (!empty($depends)) { ?> data-depends="[<?php echo esc_attr($depends); ?>]" <?php } ?> class="setting-field <?php if ($is_error) echo 'field-error'; ?> <?php echo esc_attr($wraper_class); ?> <?php if (!empty($depends)) echo 'dependency-field'; ?>"> |
| 160 |
<div class="field-lable ">%s</div> |
| 161 |
<div class="field-input">%s |
| 162 |
<p class="description">%s</p> |
| 163 |
<?php if ($is_error && !empty($error_details)) : ?> |
| 164 |
<p class="error-details"><i class="fas fa-exclamation-circle"></i> <?php echo esc_html($error_details); ?></p> |
| 165 |
<?php endif; ?> |
| 166 |
</div> |
| 167 |
</div> |
| 168 |
<?php |
| 169 |
return ob_get_clean(); |
| 170 |
} |
| 171 |
function generate_field($option) |
| 172 |
{ |
| 173 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 174 |
$type = isset($option['type']) ? $option['type'] : ""; |
| 175 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 176 |
if (empty($id)) return; |
| 177 |
if (isset($option['type']) && $option['type'] === 'select') $this->field_select($option); |
| 178 |
elseif (isset($option['type']) && $option['type'] === 'select2') $this->field_select2($option); |
| 179 |
elseif (isset($option['type']) && $option['type'] === 'checkbox') $this->field_checkbox($option); |
| 180 |
elseif (isset($option['type']) && $option['type'] === 'radio') $this->field_radio($option); |
| 181 |
elseif (isset($option['type']) && $option['type'] === 'radio_image') $this->field_radio_image($option); |
| 182 |
elseif (isset($option['type']) && $option['type'] === 'textarea') $this->field_textarea($option); |
| 183 |
elseif (isset($option['type']) && $option['type'] === 'scripts_js') $this->field_scripts_js($option); |
| 184 |
elseif (isset($option['type']) && $option['type'] === 'scripts_css') $this->field_scripts_css($option); |
| 185 |
elseif (isset($option['type']) && $option['type'] === 'number') $this->field_number($option); |
| 186 |
elseif (isset($option['type']) && $option['type'] === 'text') $this->field_text($option); |
| 187 |
elseif (isset($option['type']) && $option['type'] === 'text_icon') $this->field_text_icon($option); |
| 188 |
elseif (isset($option['type']) && $option['type'] === 'text_multi') $this->field_text_multi($option); |
| 189 |
elseif (isset($option['type']) && $option['type'] === 'hidden') $this->field_hidden($option); |
| 190 |
elseif (isset($option['type']) && $option['type'] === 'range') $this->field_range($option); |
| 191 |
elseif (isset($option['type']) && $option['type'] === 'colorpicker') $this->field_colorpicker($option); |
| 192 |
elseif (isset($option['type']) && $option['type'] === 'colorpicker_multi') $this->field_colorpicker_multi($option); |
| 193 |
elseif (isset($option['type']) && $option['type'] === 'datepicker') $this->field_datepicker($option); |
| 194 |
elseif (isset($option['type']) && $option['type'] === 'faq') $this->field_faq($option); |
| 195 |
elseif (isset($option['type']) && $option['type'] === 'addons_grid') $this->field_addons_grid($option); |
| 196 |
elseif (isset($option['type']) && $option['type'] === 'custom_html') $this->field_custom_html($option); |
| 197 |
elseif (isset($option['type']) && $option['type'] === 'repeatable') $this->field_repeatable($option); |
| 198 |
elseif (isset($option['type']) && $option['type'] === 'media') $this->field_media($option); |
| 199 |
elseif (isset($option['type']) && $option['type'] === 'media_url') $this->field_media_url($option); |
| 200 |
elseif (isset($option['type']) && $option['type'] === 'option_group') $this->field_option_group($option); |
| 201 |
elseif (isset($option['type']) && $option['type'] === 'option_group_accordion') $this->field_option_group_accordion($option); |
| 202 |
elseif (isset($option['type']) && $option['type'] === 'wp_editor') $this->field_wp_editor($option); |
| 203 |
elseif (isset($option['type']) && $option['type'] === 'textarea_editor') $this->field_textarea_editor($option); |
| 204 |
elseif (isset($option['type']) && $option['type'] === $type) do_action("settings_tabs_field_$type", $option); |
| 205 |
} |
| 206 |
public function field_option_group_accordion($option) |
| 207 |
{ |
| 208 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 209 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 210 |
$sortable = isset($option['sortable']) ? $option['sortable'] : false; |
| 211 |
$args_index = isset($option['args_index']) ? $option['args_index'] : array(); |
| 212 |
$args_index_default = isset($option['args_index_default']) ? $option['args_index_default'] : array(); |
| 213 |
$args_index_hide = isset($option['args_index_hide']) ? $option['args_index_hide'] : array(); |
| 214 |
$args_index = !empty($args_index) ? $args_index : $args_index_default; |
| 215 |
$args = isset($option['args']) ? $option['args'] : array(); |
| 216 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 217 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 218 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 219 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 220 |
$group_details = isset($option['details']) ? $option['details'] : ""; |
| 221 |
if ($is_pro == true) { |
| 222 |
$group_details = '<span class="pro-feature">' . $pro_text . '</span> ' . $group_details; |
| 223 |
} |
| 224 |
ob_start(); |
| 225 |
?> |
| 226 |
<div class="option-group-accordion-wrap" id="<?php echo esc_attr($css_id); ?>"> |
| 227 |
<div sortable="<?php echo esc_attr($sortable) ? 'true' : 'false'; ?>" class='option-group-accordion accordion'> |
| 228 |
<?php |
| 229 |
if (!empty($args_index)) |
| 230 |
foreach ($args_index as $index) : |
| 231 |
//foreach( $args as $key => $value ): |
| 232 |
$group_title = isset($args[$index]['title']) ? $args[$index]['title'] : ''; |
| 233 |
$is_hide = isset($args_index_hide[$index]) ? $args_index_hide[$index] : false; |
| 234 |
//$link = $value['link']; |
| 235 |
$options = isset($args[$index]['options']) ? $args[$index]['options'] : array(); |
| 236 |
?> |
| 237 |
<div class="group"> |
| 238 |
<h3 class="accordion-title"> |
| 239 |
<?php if ($sortable) : ?> |
| 240 |
<span class="sort"><i class="fas fa-sort"></i></span> |
| 241 |
<?php endif; ?> |
| 242 |
<span class="title-text"><?php echo esc_html($group_title); ?></span> |
| 243 |
</h3> |
| 244 |
<div class="accordion-content"> |
| 245 |
<?php |
| 246 |
if (!empty($options)) : |
| 247 |
foreach ($options as $option) : |
| 248 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 249 |
$type = isset($option['type']) ? $option['type'] : ""; |
| 250 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 251 |
if (isset($option['type']) && $option['type'] === 'select') $this->field_select($option); |
| 252 |
elseif (isset($option['type']) && $option['type'] === 'select2') $this->field_select2($option); |
| 253 |
elseif (isset($option['type']) && $option['type'] === 'checkbox') $this->field_checkbox($option); |
| 254 |
elseif (isset($option['type']) && $option['type'] === 'radio') $this->field_radio($option); |
| 255 |
elseif (isset($option['type']) && $option['type'] === 'radio_image') $this->field_radio_image($option); |
| 256 |
elseif (isset($option['type']) && $option['type'] === 'textarea') $this->field_textarea($option); |
| 257 |
elseif (isset($option['type']) && $option['type'] === 'scripts_js') $this->field_scripts_js($option); |
| 258 |
elseif (isset($option['type']) && $option['type'] === 'scripts_css') $this->field_scripts_css($option); |
| 259 |
elseif (isset($option['type']) && $option['type'] === 'number') $this->field_number($option); |
| 260 |
elseif (isset($option['type']) && $option['type'] === 'text') $this->field_text($option); |
| 261 |
elseif (isset($option['type']) && $option['type'] === 'text_icon') $this->field_text_icon($option); |
| 262 |
elseif (isset($option['type']) && $option['type'] === 'text_multi') $this->field_text_multi($option); |
| 263 |
elseif (isset($option['type']) && $option['type'] === 'hidden') $this->field_hidden($option); |
| 264 |
elseif (isset($option['type']) && $option['type'] === 'range') $this->field_range($option); |
| 265 |
elseif (isset($option['type']) && $option['type'] === 'colorpicker') $this->field_colorpicker($option); |
| 266 |
elseif (isset($option['type']) && $option['type'] === 'colorpicker_multi') $this->field_colorpicker_multi($option); |
| 267 |
elseif (isset($option['type']) && $option['type'] === 'datepicker') $this->field_datepicker($option); |
| 268 |
elseif (isset($option['type']) && $option['type'] === 'faq') $this->field_faq($option); |
| 269 |
elseif (isset($option['type']) && $option['type'] === 'addons_grid') $this->field_addons_grid($option); |
| 270 |
elseif (isset($option['type']) && $option['type'] === 'custom_html') $this->field_custom_html($option); |
| 271 |
elseif (isset($option['type']) && $option['type'] === 'repeatable') $this->field_repeatable($option); |
| 272 |
elseif (isset($option['type']) && $option['type'] === 'media') $this->field_media($option); |
| 273 |
elseif (isset($option['type']) && $option['type'] === 'media_url') $this->field_media_url($option); |
| 274 |
endforeach; |
| 275 |
endif; |
| 276 |
?> |
| 277 |
</div> <!-- ..accordion-content --> |
| 278 |
</div><!-- .group --> |
| 279 |
<?php |
| 280 |
//endforeach; |
| 281 |
endforeach; |
| 282 |
?> |
| 283 |
</div> <!-- .option-group-accordion --> |
| 284 |
</div><!-- .option-group-accordion-wrap --> |
| 285 |
<?php |
| 286 |
$input_html = ob_get_clean(); |
| 287 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($group_details)), $this->allowed_html()); |
| 288 |
} |
| 289 |
public function field_option_group($option) |
| 290 |
{ |
| 291 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 292 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 293 |
$options = isset($option['options']) ? $option['options'] : array(); |
| 294 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 295 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 296 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 297 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 298 |
$group_details = isset($option['details']) ? $option['details'] : ""; |
| 299 |
if ($is_pro == true) { |
| 300 |
$group_details = '<span class="pro-feature">' . $pro_text . '</span> ' . $group_details; |
| 301 |
} |
| 302 |
ob_start(); |
| 303 |
?> |
| 304 |
<div id="<?php echo esc_attr($css_id); ?>"> |
| 305 |
<?php |
| 306 |
if (!empty($options)) : |
| 307 |
foreach ($options as $option) : |
| 308 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 309 |
$type = isset($option['type']) ? $option['type'] : ""; |
| 310 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 311 |
if (isset($option['type']) && $option['type'] === 'select') $this->field_select($option); |
| 312 |
elseif (isset($option['type']) && $option['type'] === 'select2') $this->field_select2($option); |
| 313 |
elseif (isset($option['type']) && $option['type'] === 'checkbox') $this->field_checkbox($option); |
| 314 |
elseif (isset($option['type']) && $option['type'] === 'radio') $this->field_radio($option); |
| 315 |
elseif (isset($option['type']) && $option['type'] === 'radio_image') $this->field_radio_image($option); |
| 316 |
elseif (isset($option['type']) && $option['type'] === 'textarea') $this->field_textarea($option); |
| 317 |
elseif (isset($option['type']) && $option['type'] === 'scripts_js') $this->field_scripts_js($option); |
| 318 |
elseif (isset($option['type']) && $option['type'] === 'scripts_css') $this->field_scripts_css($option); |
| 319 |
elseif (isset($option['type']) && $option['type'] === 'number') $this->field_number($option); |
| 320 |
elseif (isset($option['type']) && $option['type'] === 'text') $this->field_text($option); |
| 321 |
elseif (isset($option['type']) && $option['type'] === 'text_icon') $this->field_text_icon($option); |
| 322 |
elseif (isset($option['type']) && $option['type'] === 'text_multi') $this->field_text_multi($option); |
| 323 |
elseif (isset($option['type']) && $option['type'] === 'hidden') $this->field_hidden($option); |
| 324 |
elseif (isset($option['type']) && $option['type'] === 'range') $this->field_range($option); |
| 325 |
elseif (isset($option['type']) && $option['type'] === 'colorpicker') $this->field_colorpicker($option); |
| 326 |
elseif (isset($option['type']) && $option['type'] === 'colorpicker_multi') $this->field_colorpicker_multi($option); |
| 327 |
elseif (isset($option['type']) && $option['type'] === 'datepicker') $this->field_datepicker($option); |
| 328 |
elseif (isset($option['type']) && $option['type'] === 'faq') $this->field_faq($option); |
| 329 |
elseif (isset($option['type']) && $option['type'] === 'addons_grid') $this->field_addons_grid($option); |
| 330 |
elseif (isset($option['type']) && $option['type'] === 'custom_html') $this->field_custom_html($option); |
| 331 |
elseif (isset($option['type']) && $option['type'] === 'repeatable') $this->field_repeatable($option); |
| 332 |
elseif (isset($option['type']) && $option['type'] === 'media') $this->field_media($option); |
| 333 |
elseif (isset($option['type']) && $option['type'] === 'media_url') $this->field_media_url($option); |
| 334 |
endforeach; |
| 335 |
endif; |
| 336 |
?> |
| 337 |
</div> |
| 338 |
<?php |
| 339 |
$input_html = ob_get_clean(); |
| 340 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($group_details)), $this->allowed_html()); |
| 341 |
} |
| 342 |
public function field_media($option) |
| 343 |
{ |
| 344 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 345 |
if (empty($id)) return; |
| 346 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 347 |
$field_name = isset($option['field_name']) ? $option['field_name'] : $id; |
| 348 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 349 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 350 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 351 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 352 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 353 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 354 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 355 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 356 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 357 |
$value = !empty($value) ? $value : $default; |
| 358 |
$media_url = wp_get_attachment_url($value); |
| 359 |
$media_type = get_post_mime_type($value); |
| 360 |
$media_title = !empty($value) ? get_the_title($value) : "Placeholder"; |
| 361 |
$media_url = !empty($media_url) ? $media_url : $default; |
| 362 |
$media_url = !empty($media_url) ? $media_url : $placeholder; |
| 363 |
$media_basename = wp_basename($media_type); |
| 364 |
$field_name = !empty($field_name) ? $field_name : $id; |
| 365 |
$field_name = !empty($parent) ? $parent . '[' . $field_name . ']' : $field_name; |
| 366 |
ob_start(); |
| 367 |
//wp_enqueue_media(); |
| 368 |
?> |
| 369 |
<div id="input-wrapper-<?php echo esc_attr($css_id); ?>" class="input-wrapper field-media-wrapper |
| 370 |
field-media-wrapper-<?php echo esc_attr($css_id); ?>"> |
| 371 |
<div class="media-preview-wrap" style="width: 150px;margin-bottom: 10px;background: #eee;padding: 5px; text-align: center;word-break: break-all;"> |
| 372 |
<?php |
| 373 |
if ("audio/mpeg" == $media_type) { |
| 374 |
?> |
| 375 |
<div class="media-preview" class="dashicons dashicons-format-audio" style="font-size: 70px;display: inline;"></div> |
| 376 |
<div class="media-title"><?php echo esc_html($media_title); ?></div> |
| 377 |
<?php |
| 378 |
} elseif ( |
| 379 |
"images/png" == $media_type || |
| 380 |
"image/png" == $media_type || |
| 381 |
"images/gif" == $media_type || |
| 382 |
"image/gif" == $media_type || |
| 383 |
"images/jpeg" == $media_type || |
| 384 |
"image/jpeg" == $media_type || |
| 385 |
"images/jpg" == $media_type || |
| 386 |
"image/jpg" == $media_type || |
| 387 |
"images/ico" == $media_type || |
| 388 |
"image/ico" == $media_type |
| 389 |
) { |
| 390 |
?> |
| 391 |
<img class="media-preview" src="<?php echo esc_url($media_url); ?>" style="width:100%" /> |
| 392 |
<div class="media-title"><?php echo esc_html($media_title); ?></div> |
| 393 |
<?php |
| 394 |
} else { |
| 395 |
?> |
| 396 |
<img class="media-preview" src="<?php echo esc_url($media_url); ?>" style="width:100%" /> |
| 397 |
<div class="media-title"><?php echo esc_html($media_title); ?></div> |
| 398 |
<?php |
| 399 |
} |
| 400 |
?> |
| 401 |
</div> |
| 402 |
<input class="media-input-value" type="hidden" name="<?php echo esc_attr($field_name); ?>" id="media_input_<?php echo esc_attr($css_id); ?>" value="<?php echo esc_attr($value); ?>" /> |
| 403 |
<div class="media-upload button" id="media_upload_<?php echo esc_attr($css_id); ?>"> |
| 404 |
<?php echo "Upload"; ?></div> |
| 405 |
<div placeholder="<?php echo esc_attr($placeholder); ?>" class="clear button" id="media_clear_<?php echo esc_attr($css_id); ?>"><?php echo 'Clear'; ?></div> |
| 406 |
<div class="error-mgs"></div> |
| 407 |
</div> |
| 408 |
<?php |
| 409 |
$input_html = ob_get_clean(); |
| 410 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 411 |
} |
| 412 |
public function field_media_url($option) |
| 413 |
{ |
| 414 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 415 |
if (empty($id)) return; |
| 416 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 417 |
$field_name = isset($option['field_name']) ? $option['field_name'] : $id; |
| 418 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 419 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 420 |
$placeholder_img = isset($option['placeholder_img']) ? $option['placeholder_img'] : ""; |
| 421 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 422 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 423 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 424 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 425 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 426 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 427 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 428 |
$value = !empty($value) ? $value : $default; |
| 429 |
$media_url = $value; |
| 430 |
$media_type = get_post_mime_type($value); |
| 431 |
$media_title = get_the_title($value); |
| 432 |
$media_url = !empty($media_url) ? $media_url : ''; |
| 433 |
$media_url = !empty($media_url) ? $media_url : $placeholder_img; |
| 434 |
$field_name = !empty($field_name) ? $field_name : $id; |
| 435 |
$field_name = !empty($parent) ? $parent . '[' . $field_name . ']' : $field_name; |
| 436 |
wp_enqueue_media(); |
| 437 |
ob_start(); |
| 438 |
?> |
| 439 |
<div id="input-wrapper-<?php echo esc_attr($css_id); ?>" class="input-wrapper field-media-url-wrapper |
| 440 |
field-media-wrapper-<?php echo esc_attr($css_id); ?>"> |
| 441 |
<div class="media-preview-wrap" style="width: 150px;margin-bottom: 10px;background: #eee;padding: 5px; text-align: center;"> |
| 442 |
<?php |
| 443 |
if ("audio/mpeg" == $media_type) { |
| 444 |
?> |
| 445 |
<div class="media-preview" class="dashicons dashicons-format-audio" style="font-size: 70px;display: inline;"></div> |
| 446 |
<?php |
| 447 |
} elseif ( |
| 448 |
"images/png" == $media_type || "images/jpg" == $media_type || "images/jpeg" == $media_type || |
| 449 |
"images/gif" == $media_type || |
| 450 |
"images/ico" == $media_type |
| 451 |
) { |
| 452 |
?> |
| 453 |
<img class="media-preview" src="<?php echo esc_url($media_url); ?>" style="width:100%" /> |
| 454 |
<?php |
| 455 |
} else { |
| 456 |
?> |
| 457 |
<img class="media-preview" src="<?php echo esc_url($media_url); ?>" style="width:100%" /> |
| 458 |
<?php |
| 459 |
} |
| 460 |
?> |
| 461 |
</div> |
| 462 |
<input type="text" placeholder="<?php echo esc_attr($placeholder); ?>" name="<?php echo esc_attr($field_name); ?>" id="media_input_<?php echo esc_attr($css_id); ?>" value="<?php echo esc_attr($value); ?>" /> |
| 463 |
<div class="media-upload button" id="media_upload_<?php echo esc_attr($css_id); ?>"> |
| 464 |
<?php echo 'Upload'; ?></div> |
| 465 |
<div class="clear button" id="media_clear_<?php echo esc_attr($css_id); ?>"> |
| 466 |
<?php echo 'Clear'; ?></div> |
| 467 |
<div class="error-mgs"></div> |
| 468 |
</div> |
| 469 |
<?php |
| 470 |
$input_html = ob_get_clean(); |
| 471 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 472 |
} |
| 473 |
public function field_repeatable($option) |
| 474 |
{ |
| 475 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 476 |
if (empty($id)) return; |
| 477 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 478 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 479 |
$field_name = isset($option['field_name']) ? $option['field_name'] : $id; |
| 480 |
$field_name = !empty($parent) ? $parent . '[' . $field_name . ']' : $field_name; |
| 481 |
$sortable = isset($option['sortable']) ? $option['sortable'] : true; |
| 482 |
$collapsible = isset($option['collapsible']) ? $option['collapsible'] : true; |
| 483 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 484 |
$values = isset($option['value']) ? $option['value'] : array(); |
| 485 |
$fields = isset($option['fields']) ? $option['fields'] : array(); |
| 486 |
$title_field = isset($option['title_field']) ? $option['title_field'] : ''; |
| 487 |
$remove_text = isset($option['remove_text']) ? $option['remove_text'] : '<i class="fas fa-times"></i>'; |
| 488 |
$limit = isset($option['limit']) ? $option['limit'] : ''; |
| 489 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 490 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 491 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 492 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 493 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 494 |
$settings_tabs_field = new settings_tabs_field(); |
| 495 |
ob_start(); |
| 496 |
?> |
| 497 |
<div class="item-wrap collapsible"> |
| 498 |
<div class="header"> |
| 499 |
<span class="remove" onclick="jQuery(this).parent().parent().remove()"><?php echo wp_kses_post($remove_text); ?></span> |
| 500 |
<?php |
| 501 |
if ($sortable) : |
| 502 |
?> |
| 503 |
<span class="sort"><i class="fas fa-arrows-alt"></i></span> |
| 504 |
<?php |
| 505 |
endif; |
| 506 |
?> |
| 507 |
<span class="title-text">#TIMEINDEX</span> |
| 508 |
</div> |
| 509 |
<?php |
| 510 |
if (!empty($fields)) : |
| 511 |
foreach ($fields as $field) : |
| 512 |
$fieldType = isset($field['type']) ? $field['type'] : ''; |
| 513 |
$field['parent'] = $field_name . '[TIMEINDEX]'; |
| 514 |
?> |
| 515 |
<div class="item"> |
| 516 |
<?php if ($collapsible) : ?> |
| 517 |
<div class="content"> |
| 518 |
<?php endif; ?> |
| 519 |
<?php |
| 520 |
$settings_tabs_field->generate_field($field); |
| 521 |
?> |
| 522 |
<?php if ($collapsible) : ?> |
| 523 |
</div> |
| 524 |
<?php endif; ?> |
| 525 |
</div> |
| 526 |
<?php |
| 527 |
endforeach; |
| 528 |
endif; |
| 529 |
?> |
| 530 |
</div> |
| 531 |
<?php |
| 532 |
$fieldHtml = ob_get_clean(); |
| 533 |
$fieldHtml = preg_replace("/[\r\n]+/", "\n", $fieldHtml); |
| 534 |
$fieldHtml = preg_replace("/\s+/", ' ', $fieldHtml); |
| 535 |
ob_start(); |
| 536 |
?> |
| 537 |
<div id="input-wrapper-<?php echo esc_attr($css_id); ?>" class=" input-wrapper field-repeatable-wrapper |
| 538 |
field-repeatable-wrapper-<?php echo esc_attr($css_id); ?>"> |
| 539 |
<div data-add_html="<?php echo esc_attr($fieldHtml); ?>" class="add-repeat-field" data-wrapper-id="<?php echo esc_attr($css_id); ?>"><i class="far fa-plus-square"></i> |
| 540 |
<?php echo 'Add'; ?></div> |
| 541 |
<div class="repeatable-field-list sortable" id="<?php echo esc_attr($css_id); ?>"> |
| 542 |
<?php |
| 543 |
if (!empty($values)) : |
| 544 |
$count = 1; |
| 545 |
foreach ($values as $index => $val) : |
| 546 |
$title_field_val = !empty($val[$title_field]) ? $val[$title_field] : '#' . $count; |
| 547 |
?> |
| 548 |
<div class="item-wrap <?php if ($collapsible) echo 'collapsible'; ?>" index="<?php echo esc_attr($index); ?>"> |
| 549 |
<?php if ($collapsible) : ?> |
| 550 |
<div class="header"> |
| 551 |
<?php endif; ?> |
| 552 |
<span class="remove" onclick="jQuery(this).parent().parent().remove()"><?php echo wp_kses_post($remove_text); ?></span> |
| 553 |
<?php if ($sortable) : ?> |
| 554 |
<span class="sort"><i class="fas fa-arrows-alt"></i></span> |
| 555 |
<?php endif; ?> |
| 556 |
<span class="title-text"><?php echo esc_html($title_field_val); ?></span> |
| 557 |
<?php if ($collapsible) : ?> |
| 558 |
</div> |
| 559 |
<?php endif; ?> |
| 560 |
<?php |
| 561 |
foreach ($fields as $field_index => $field) : |
| 562 |
$fieldId = $field['id']; |
| 563 |
$field_css_id = isset($field['css_id']) ? str_replace('TIMEINDEX', $index, $field['css_id']) : ''; |
| 564 |
$title_field_class = ($title_field == $field_index) ? 'title-field' : ''; |
| 565 |
?> |
| 566 |
<div class="item <?php echo esc_attr($title_field_class); ?>"> |
| 567 |
<?php if ($collapsible) : ?> |
| 568 |
<div class="content"> |
| 569 |
<?php endif; ?> |
| 570 |
<?php |
| 571 |
$field['parent'] = $field_name . '[' . $index . ']'; |
| 572 |
$field['css_id'] = $field_css_id; |
| 573 |
$field['value'] = isset($val[$fieldId]) ? $val[$fieldId] : ''; |
| 574 |
$settings_tabs_field->generate_field($field); |
| 575 |
if ($collapsible) : ?> |
| 576 |
</div> |
| 577 |
<?php endif; ?> |
| 578 |
</div> |
| 579 |
<?php |
| 580 |
endforeach; ?> |
| 581 |
</div> |
| 582 |
<?php |
| 583 |
$count++; |
| 584 |
endforeach; |
| 585 |
else : |
| 586 |
?> |
| 587 |
<?php |
| 588 |
endif; |
| 589 |
?> |
| 590 |
</div> |
| 591 |
<div class="error-mgs"></div> |
| 592 |
</div> |
| 593 |
<?php |
| 594 |
$input_html = ob_get_clean(); |
| 595 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 596 |
} |
| 597 |
public function field_select($option) |
| 598 |
{ |
| 599 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 600 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 601 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 602 |
$args = isset($option['args']) ? $option['args'] : array(); |
| 603 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 604 |
$disabled = isset($option['disabled']) ? $option['disabled'] : false; |
| 605 |
$disabledMessage = isset($option['disabledMessage']) ? $option['disabledMessage'] : ''; |
| 606 |
$multiple = isset($option['multiple']) ? $option['multiple'] : false; |
| 607 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 608 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 609 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 610 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 611 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 612 |
if ($is_pro == true) { |
| 613 |
$details = '<span class="pro-feature">' . $pro_text . '</span> ' . $details; |
| 614 |
} |
| 615 |
if ($multiple) { |
| 616 |
$value = isset($option['value']) ? $option['value'] : array(); |
| 617 |
$field_name = !empty($parent) ? $parent . '[' . $id . '][]' : $id . '[]'; |
| 618 |
$default = isset($option['default']) ? $option['default'] : array(); |
| 619 |
} else { |
| 620 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 621 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 622 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 623 |
} |
| 624 |
$value = !empty($value) ? $value : $default; |
| 625 |
ob_start(); |
| 626 |
?> |
| 627 |
<select <?php if ($multiple) echo 'multiple'; ?> <?php if ($disabled) echo 'disabled'; ?> name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>"> |
| 628 |
<?php |
| 629 |
foreach ($args as $key => $name) : |
| 630 |
if ($multiple) { |
| 631 |
$selected = in_array($key, $value) ? "selected" : ""; |
| 632 |
} else { |
| 633 |
$selected = $value == $key ? "selected" : ""; |
| 634 |
} |
| 635 |
?> |
| 636 |
<option <?php echo esc_attr($selected); ?> value="<?php echo esc_attr($key); ?>"><?php echo esc_html($name); ?> |
| 637 |
</option> |
| 638 |
<?php |
| 639 |
endforeach; |
| 640 |
?> |
| 641 |
</select> |
| 642 |
<?php |
| 643 |
if ($multiple) : |
| 644 |
?> |
| 645 |
<div class="button select-reset"><?php echo 'Reset'; ?></div><br> |
| 646 |
<?php |
| 647 |
endif; |
| 648 |
?> |
| 649 |
<?php if ($disabled) : ?> |
| 650 |
<div class="disabled"><?php echo wp_kses_post($disabledMessage); ?></div> |
| 651 |
<?php endif; ?> |
| 652 |
<?php |
| 653 |
$input_html = ob_get_clean(); |
| 654 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 655 |
} |
| 656 |
public function field_select2($option) |
| 657 |
{ |
| 658 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 659 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 660 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 661 |
$args = isset($option['args']) ? $option['args'] : array(); |
| 662 |
$multiple = isset($option['multiple']) ? $option['multiple'] : ""; |
| 663 |
$attributes = isset($option['attributes']) ? $option['attributes'] : array(); |
| 664 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 665 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 666 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 667 |
if ($multiple) { |
| 668 |
$value = isset($option['value']) ? $option['value'] : array(); |
| 669 |
$field_name = !empty($parent) ? $parent . '[' . $id . '][]' : $id . '[]'; |
| 670 |
$default = isset($option['default']) ? $option['default'] : array(); |
| 671 |
} else { |
| 672 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 673 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 674 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 675 |
} |
| 676 |
$value = !empty($value) ? $value : $default; |
| 677 |
//$value = get_post_meta( $post_id, $id, true ); |
| 678 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 679 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 680 |
$attributes_html = ''; |
| 681 |
foreach ($attributes as $attributeId => $attribute) : |
| 682 |
$attributes_html = $attributeId . '=' . $attribute . ' '; |
| 683 |
endforeach; |
| 684 |
ob_start(); |
| 685 |
?> |
| 686 |
<select <?php echo esc_attr($attributes_html); ?> class="select2" <?php if ($multiple) echo 'multiple'; ?> name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>"> |
| 687 |
<?php |
| 688 |
foreach ($args as $key => $name) : |
| 689 |
if ($multiple) { |
| 690 |
$selected = in_array($key, $value) ? "selected" : ""; |
| 691 |
} else { |
| 692 |
$selected = ($key == $value) ? "selected" : ""; |
| 693 |
} |
| 694 |
?> |
| 695 |
<option <?php echo esc_attr($selected); ?> value="<?php echo esc_attr($key); ?>"><?php echo esc_html($name); ?> |
| 696 |
</option> |
| 697 |
<?php |
| 698 |
endforeach; |
| 699 |
?> |
| 700 |
</select> |
| 701 |
<?php |
| 702 |
$input_html = ob_get_clean(); |
| 703 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 704 |
} |
| 705 |
public function field_text_multi($option) |
| 706 |
{ |
| 707 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 708 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 709 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 710 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 711 |
$default = isset($option['default']) ? $option['default'] : array(); |
| 712 |
$values = isset($option['value']) ? $option['value'] : $default; |
| 713 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 714 |
$remove_text = isset($option['remove_text']) ? $option['remove_text'] : '<i class="fas fa-times"></i>'; |
| 715 |
$sortable = isset($option['sortable']) ? $option['sortable'] : true; |
| 716 |
$allow_clone = isset($option['allow_clone']) ? $option['allow_clone'] : false; |
| 717 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 718 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 719 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 720 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 721 |
if ($is_pro == true) { |
| 722 |
$details = '<span class="pro-feature">' . $pro_text . '</span> ' . $details; |
| 723 |
} |
| 724 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 725 |
ob_start(); |
| 726 |
?> |
| 727 |
<div id="input-wrapper-<?php echo esc_attr($id); ?>" class="input-wrapper input-text-multi-wrapper |
| 728 |
input-text-multi-wrapper-<?php echo esc_attr($css_id); ?>"> |
| 729 |
<span data-placeholder="<?php echo esc_attr($placeholder); ?>" data-sort="<?php echo esc_attr($sortable); ?>" data-clone="<?php echo esc_attr($allow_clone); ?>" data-name="<?php echo esc_attr($field_name); ?>[]" class="button add-item"><?php echo 'Add'; ?></span> |
| 730 |
<div class="field-list <?php if ($sortable) { |
| 731 |
echo 'sortable'; |
| 732 |
} ?>" id="<?php echo esc_attr($css_id); ?>"> |
| 733 |
<?php |
| 734 |
if (!empty($values)) : |
| 735 |
foreach ($values as $value) : |
| 736 |
?> |
| 737 |
<div class="item"> |
| 738 |
<input type="text" name="<?php echo esc_attr($field_name); ?>[]" placeholder="<?php |
| 739 |
echo esc_attr($placeholder); ?>" value="<?php echo esc_attr($value); ?>" /> |
| 740 |
<?php if ($allow_clone) : ?> |
| 741 |
<span class="button clone"><i class="far fa-clone"></i></span> |
| 742 |
<?php endif; ?> |
| 743 |
<?php if ($sortable) : ?> |
| 744 |
<span class="button sort"><i class="fas fa-arrows-alt"></i></span> |
| 745 |
<?php endif; ?> |
| 746 |
<span class="button remove" onclick="jQuery(this).parent().remove()"><?php echo wp_kses_post($remove_text); ?></span> |
| 747 |
</div> |
| 748 |
<?php |
| 749 |
endforeach; |
| 750 |
else : |
| 751 |
?> |
| 752 |
<div class="item"> |
| 753 |
<input type="text" name="<?php echo esc_attr($field_name); ?>[]" placeholder="<?php |
| 754 |
echo esc_attr($placeholder); ?>" value="" /> |
| 755 |
<?php if ($allow_clone) : ?> |
| 756 |
<span class="button clone"><i class="far fa-clone"></i></span> |
| 757 |
<?php endif; ?> |
| 758 |
<?php if ($sortable) : ?> |
| 759 |
<span class="button sort"><i class="fas fa-arrows-alt"></i></span> |
| 760 |
<?php endif; ?> |
| 761 |
<span class="button remove" onclick="jQuery(this).parent().remove()"><?php echo wp_kses_post($remove_text); ?></span> |
| 762 |
</div> |
| 763 |
<?php |
| 764 |
endif; |
| 765 |
?> |
| 766 |
</div> |
| 767 |
<div class="error-mgs"></div> |
| 768 |
</div> |
| 769 |
<?php |
| 770 |
$input_html = ob_get_clean(); |
| 771 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 772 |
} |
| 773 |
public function field_hidden($option) |
| 774 |
{ |
| 775 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 776 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 777 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 778 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 779 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 780 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 781 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 782 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 783 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 784 |
$value = !empty($value) ? $value : $default; |
| 785 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 786 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 787 |
if ($is_pro == true) { |
| 788 |
$details = '<span class="pro-feature">' . $pro_text . '</span> ' . $details; |
| 789 |
} |
| 790 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 791 |
ob_start(); |
| 792 |
?> |
| 793 |
<input type="hidden" class="" name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>" placeholder="<?php echo esc_attr($placeholder); ?>" value="<?php echo esc_attr($value); ?>" /> |
| 794 |
<?php |
| 795 |
$input_html = ob_get_clean(); |
| 796 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 797 |
} |
| 798 |
public function field_text($option) |
| 799 |
{ |
| 800 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 801 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 802 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 803 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 804 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 805 |
$value = isset($option['value']) ? $option['value'] : $default; |
| 806 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 807 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 808 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 809 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 810 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 811 |
if ($is_pro == true) { |
| 812 |
$details = '<span class="pro-feature">' . $pro_text . '</span> ' . $details; |
| 813 |
} |
| 814 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 815 |
ob_start(); |
| 816 |
?> |
| 817 |
<input type="text" class="" name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>" placeholder="<?php echo esc_attr($placeholder); ?>" value="<?php echo esc_attr($value); ?>" /> |
| 818 |
<?php |
| 819 |
$input_html = ob_get_clean(); |
| 820 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 821 |
} |
| 822 |
public function field_number($option) |
| 823 |
{ |
| 824 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 825 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 826 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 827 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 828 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 829 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 830 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 831 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 832 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 833 |
$value = !empty($value) ? $value : $default; |
| 834 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 835 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 836 |
if ($is_pro == true) { |
| 837 |
$details = '<span class="pro-feature">' . $pro_text . '</span> ' . $details; |
| 838 |
} |
| 839 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 840 |
ob_start(); |
| 841 |
?> |
| 842 |
<input type="number" class="" name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>" placeholder="<?php echo esc_attr($placeholder); ?>" value="<?php echo esc_attr($value); ?>" /> |
| 843 |
<?php |
| 844 |
$input_html = ob_get_clean(); |
| 845 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 846 |
} |
| 847 |
public function field_wp_editor($option) |
| 848 |
{ |
| 849 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 850 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 851 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 852 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 853 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 854 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 855 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 856 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 857 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 858 |
$value = !empty($value) ? $value : $default; |
| 859 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 860 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 861 |
if ($is_pro == true) { |
| 862 |
$details = '<span class="pro-feature">' . $pro_text . '</span> ' . $details; |
| 863 |
} |
| 864 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 865 |
$editor_settings = isset($option['editor_settings']) ? $option['editor_settings'] : array('textarea_name' => $field_name, 'teeny' => true, 'textarea_rows' => 15,); |
| 866 |
ob_start(); |
| 867 |
?> |
| 868 |
<div id="field-wrapper-<?php echo esc_attr($id); ?>" class="<?php if (!empty($depends)) echo 'dependency-field'; ?> field-wrapper field-wp_editor-wrapper |
| 869 |
field-wp_editor-wrapper-<?php echo esc_attr($id); ?>"> |
| 870 |
<?php |
| 871 |
wp_editor($value, $css_id, $editor_settings); |
| 872 |
?> |
| 873 |
<div class="error-mgs"></div> |
| 874 |
</div> |
| 875 |
<?php |
| 876 |
$input_html = ob_get_clean(); |
| 877 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 878 |
} |
| 879 |
public function field_text_icon($option) |
| 880 |
{ |
| 881 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 882 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 883 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 884 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 885 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 886 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 887 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 888 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 889 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 890 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 891 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 892 |
$option_value = empty($value) ? $default : $value; |
| 893 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 894 |
ob_start(); |
| 895 |
?> |
| 896 |
<div class="text-icon"> |
| 897 |
<span class="icon"><?php echo esc_html($option_value); ?></span><input type="text" class="" name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>" placeholder="<?php echo esc_attr($placeholder); ?>" value="<?php echo esc_attr($option_value); ?>" /> |
| 898 |
</div> |
| 899 |
|
| 900 |
|
| 901 |
<?php |
| 902 |
$input_html = ob_get_clean(); |
| 903 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 904 |
} |
| 905 |
public function field_range($option) |
| 906 |
{ |
| 907 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 908 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 909 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 910 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 911 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 912 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 913 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 914 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 915 |
$value = !empty($value) ? $value : $default; |
| 916 |
$args = isset($option['args']) ? $option['args'] : ""; |
| 917 |
$min = isset($args['min']) ? $args['min'] : ''; |
| 918 |
$max = isset($args['max']) ? $args['max'] : ''; |
| 919 |
$step = isset($args['step']) ? $args['step'] : ''; |
| 920 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 921 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 922 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 923 |
ob_start(); |
| 924 |
?> |
| 925 |
<div class="range-input"> |
| 926 |
<span class="range-value"><?php echo esc_html($value); ?></span><input type="range" min="<?php if ($min) echo esc_attr($min); ?>" max="<?php if ($max) echo esc_attr($max); ?>" step="<?php if ($step) echo esc_attr($step); ?>" class="" name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>" class="range" value="<?php echo esc_attr($value); ?>" /> |
| 927 |
</div> |
| 928 |
|
| 929 |
|
| 930 |
<?php |
| 931 |
$input_html = ob_get_clean(); |
| 932 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 933 |
} |
| 934 |
public function field_textarea($option) |
| 935 |
{ |
| 936 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 937 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 938 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 939 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 940 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 941 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 942 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 943 |
$value = !empty($value) ? $value : $default; |
| 944 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 945 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 946 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 947 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 948 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 949 |
if ($is_pro == true) { |
| 950 |
$details = '<span class="pro-feature">' . $pro_text . '</span> ' . $details; |
| 951 |
} |
| 952 |
ob_start(); |
| 953 |
?> |
| 954 |
<textarea name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>" cols="40" rows="5" placeholder="<?php echo esc_attr($placeholder); ?>"><?php echo esc_html($value); ?></textarea> |
| 955 |
<?php |
| 956 |
$input_html = ob_get_clean(); |
| 957 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 958 |
} |
| 959 |
public function field_textarea_editor($option) |
| 960 |
{ |
| 961 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 962 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 963 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 964 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 965 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 966 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 967 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 968 |
$value = !empty($value) ? $value : $default; |
| 969 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 970 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 971 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 972 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 973 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 974 |
if ($is_pro == true) { |
| 975 |
$details = '<span class="pro-feature">' . $pro_text . '</span> ' . $details; |
| 976 |
} |
| 977 |
ob_start(); |
| 978 |
?> |
| 979 |
<textarea editor_enabled="no" class="textarea-editor" name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>" cols="40" rows="5" placeholder="<?php echo esc_attr($placeholder); ?>"><?php echo esc_html($value); ?></textarea> |
| 980 |
<?php |
| 981 |
$input_html = ob_get_clean(); |
| 982 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 983 |
} |
| 984 |
public function field_scripts_js($option) |
| 985 |
{ |
| 986 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 987 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 988 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 989 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 990 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 991 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 992 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 993 |
$value = !empty($value) ? $value : $default; |
| 994 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 995 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 996 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 997 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 998 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 999 |
ob_start(); |
| 1000 |
?> |
| 1001 |
<textarea name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>" class="code-editor" cols="40" rows="5" placeholder="<?php echo esc_attr($placeholder); ?>"><?php echo esc_html($value); ?></textarea> |
| 1002 |
|
| 1003 |
<?php |
| 1004 |
$input_html = ob_get_clean(); |
| 1005 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 1006 |
} |
| 1007 |
public function field_scripts_css($option) |
| 1008 |
{ |
| 1009 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 1010 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 1011 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 1012 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 1013 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 1014 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 1015 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 1016 |
$value = !empty($value) ? $value : $default; |
| 1017 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 1018 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 1019 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 1020 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 1021 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 1022 |
?> |
| 1023 |
<?php |
| 1024 |
ob_start(); |
| 1025 |
?> |
| 1026 |
<textarea name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>" class="css_editor" cols="40" rows="5" placeholder="<?php echo esc_attr($placeholder); ?>"><?php echo esc_html($value); ?></textarea> |
| 1027 |
|
| 1028 |
<?php |
| 1029 |
$input_html = ob_get_clean(); |
| 1030 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 1031 |
} |
| 1032 |
public function field_checkbox($option) |
| 1033 |
{ |
| 1034 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 1035 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 1036 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 1037 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 1038 |
$for = isset($option['for']) ? $option['for'] : ""; |
| 1039 |
$args = isset($option['args']) ? $option['args'] : array(); |
| 1040 |
$style = isset($option['style']) ? $option['style'] : array(); |
| 1041 |
$style_inline = isset($style['inline']) ? $style['inline'] : true; |
| 1042 |
$option_value = isset($option['value']) ? $option['value'] : ''; |
| 1043 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 1044 |
$option_value = !empty($option_value) ? $option_value : $default; |
| 1045 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 1046 |
?> |
| 1047 |
<div class="setting-field"> |
| 1048 |
<div class="field-lable"><?php if (!empty($title)) echo esc_html($title); ?></div> |
| 1049 |
<div class="field-input"> |
| 1050 |
<?php |
| 1051 |
if (!empty($args)) |
| 1052 |
foreach ($args as $key => $value) : |
| 1053 |
//$checked = ( $key == $option_value ) ? "checked" : ""; |
| 1054 |
$checked = in_array($key, $option_value) ? "checked" : ""; |
| 1055 |
$for = !empty($for) ? $for . '-' . $id . "-" . $key : $id . "-" . $key; |
| 1056 |
?> |
| 1057 |
<label for='<?php echo esc_attr($for); ?>'><input name='<?php echo esc_attr($field_name); ?>[]' type='checkbox' id='<?php echo esc_attr($for); ?>' value='<?php echo esc_attr($key); ?>' <?php echo esc_attr($checked); ?>><span><?php echo esc_html($value); ?></span></label> |
| 1058 |
<?php |
| 1059 |
if (!$style_inline) { |
| 1060 |
?> |
| 1061 |
<br> |
| 1062 |
<?php |
| 1063 |
} |
| 1064 |
endforeach; |
| 1065 |
?> |
| 1066 |
<p class="description"><?php if (!empty($details)) echo esc_html($details); ?></p> |
| 1067 |
</div> |
| 1068 |
</div> |
| 1069 |
<?php |
| 1070 |
} |
| 1071 |
public function field_radio($option) |
| 1072 |
{ |
| 1073 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 1074 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 1075 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 1076 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 1077 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 1078 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 1079 |
$for = isset($option['for']) ? $option['for'] : ""; |
| 1080 |
$args = isset($option['args']) ? $option['args'] : array(); |
| 1081 |
$style = isset($option['style']) ? $option['style'] : array(); |
| 1082 |
$style_inline = isset($style['inline']) ? $style['inline'] : true; |
| 1083 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 1084 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 1085 |
$option_value = isset($option['value']) ? $option['value'] : ''; |
| 1086 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 1087 |
$option_value = !empty($option_value) ? $option_value : $default; |
| 1088 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 1089 |
ob_start(); |
| 1090 |
if (!empty($args)) |
| 1091 |
foreach ($args as $key => $value) : |
| 1092 |
$for = ''; |
| 1093 |
$checked = ($key == $option_value) ? "checked" : ""; |
| 1094 |
$for = !empty($for) ? $for . '-' . $css_id . "-" . $key : $css_id . "-" . $key; |
| 1095 |
?> |
| 1096 |
<label for="<?php echo esc_attr($for); ?>"><input name="<?php echo esc_attr($field_name); ?>" type="radio" id="<?php echo esc_attr($for); ?>" value="<?php echo esc_attr($key); ?>" <?php echo esc_attr($checked); ?>><span><?php echo esc_html($value); ?></span></label> |
| 1097 |
<?php |
| 1098 |
if (!$style_inline) { |
| 1099 |
?> |
| 1100 |
<br> |
| 1101 |
<?php |
| 1102 |
} |
| 1103 |
endforeach; |
| 1104 |
$input_html = ob_get_clean(); |
| 1105 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 1106 |
} |
| 1107 |
public function field_radio_image($option) |
| 1108 |
{ |
| 1109 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 1110 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 1111 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 1112 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 1113 |
$args = isset($option['args']) ? $option['args'] : array(); |
| 1114 |
//$args = is_array( $args ) ? $args : $this->generate_args_from_string( $args ); |
| 1115 |
$option_value = isset($option['value']) ? $option['value'] : ''; |
| 1116 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 1117 |
$lazy_load_img = isset($option['lazy_load_img']) ? $option['lazy_load_img'] : ''; |
| 1118 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 1119 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 1120 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 1121 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 1122 |
$width = isset($option['width']) ? $option['width'] : "250px"; |
| 1123 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 1124 |
$option_value = empty($option_value) ? $default : $option_value; |
| 1125 |
ob_start(); |
| 1126 |
?> |
| 1127 |
<div class="radio-img"> |
| 1128 |
<?php |
| 1129 |
foreach ($args as $key => $value) : |
| 1130 |
$name = isset($value['name']) ? $value['name'] : ''; |
| 1131 |
$thumb = isset($value['thumb']) ? $value['thumb'] : ''; |
| 1132 |
$disabled = isset($value['disabled']) ? $value['disabled'] : ''; |
| 1133 |
$pro_msg = isset($value['pro_msg']) ? $value['pro_msg'] : ''; |
| 1134 |
$link = isset($value['link']) ? $value['link'] : ''; |
| 1135 |
$link_text = isset($value['link_text']) ? $value['link_text'] : 'Go'; |
| 1136 |
$checked = ($key == $option_value) ? "checked" : ""; |
| 1137 |
?> |
| 1138 |
<label style="width: <?php echo esc_attr($width); ?>;" title="<?php echo esc_attr($name); ?>" data-value="<?php echo esc_attr($key); ?>" class="<?php if ($checked == 'checked') echo 'active'; ?> <?php if ($disabled == true) echo 'disabled'; ?>"> |
| 1139 |
<input <?php if ($disabled) echo 'disabled'; ?> name="<?php echo esc_attr($field_name); ?>" type="radio" id="<?php echo esc_attr($css_id); ?>-<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($key); ?>" <?php echo esc_attr($checked); ?>> |
| 1140 |
<?php |
| 1141 |
if (!empty($thumb)) : |
| 1142 |
?> |
| 1143 |
<img alt="<?php echo esc_attr($name); ?>" src="<?php echo esc_url($thumb); ?>"> |
| 1144 |
<div class="name"><?php echo esc_html($name); ?></div> |
| 1145 |
<?php |
| 1146 |
else : |
| 1147 |
echo esc_html($name); |
| 1148 |
endif; |
| 1149 |
?> |
| 1150 |
<?php if ($disabled == true) : ?> |
| 1151 |
<span class="pro-msg"><?php echo esc_html($pro_msg); ?></span> |
| 1152 |
<?php endif; ?> |
| 1153 |
<?php if (!empty($link)) : ?> |
| 1154 |
<a target="_blank" class="link" href="<?php echo esc_url($link); ?>"><?php echo esc_html($link_text); ?></a> |
| 1155 |
<?php endif; ?> |
| 1156 |
</label> |
| 1157 |
<?php |
| 1158 |
endforeach; |
| 1159 |
?> |
| 1160 |
</div> |
| 1161 |
<?php |
| 1162 |
$input_html = ob_get_clean(); |
| 1163 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 1164 |
} |
| 1165 |
public function field_datepicker($option) |
| 1166 |
{ |
| 1167 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 1168 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 1169 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 1170 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 1171 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 1172 |
$format = isset($option['format']) ? $option['format'] : ""; |
| 1173 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 1174 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 1175 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 1176 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 1177 |
$value = !empty($value) ? $value : $default; |
| 1178 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 1179 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 1180 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 1181 |
|
| 1182 |
ob_start(); |
| 1183 |
?> |
| 1184 |
<input type="text" autocomplete="off" name="<?php echo esc_attr($field_name); ?>" class="datepicker" id="<?php echo esc_attr($css_id); ?>" placeholder="<?php echo esc_attr($placeholder); ?>" value="<?php echo esc_attr($value); ?>" format="<?php echo esc_attr($format); ?>" /> |
| 1185 |
|
| 1186 |
<?php |
| 1187 |
$input_html = ob_get_clean(); |
| 1188 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 1189 |
} |
| 1190 |
public function field_colorpicker($option) |
| 1191 |
{ |
| 1192 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 1193 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 1194 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 1195 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 1196 |
$placeholder = isset($option['placeholder']) ? $option['placeholder'] : ""; |
| 1197 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 1198 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 1199 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 1200 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 1201 |
$value = !empty($value) ? $value : $default; |
| 1202 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 1203 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 1204 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 1205 |
ob_start(); |
| 1206 |
?> |
| 1207 |
<input colorPicker="" name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($css_id); ?>" placeholder="<?php echo esc_attr(esc_attr($placeholder)); ?>" value="<?php echo esc_attr($value); ?>" /> |
| 1208 |
<?php |
| 1209 |
$input_html = ob_get_clean(); |
| 1210 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 1211 |
} |
| 1212 |
public function field_colorpicker_multi($option) |
| 1213 |
{ |
| 1214 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 1215 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 1216 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 1217 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 1218 |
$args = isset($option['args']) ? $option['args'] : ""; |
| 1219 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 1220 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 1221 |
$value = isset($option['value']) ? $option['value'] : ''; |
| 1222 |
$default = isset($option['default']) ? $option['default'] : ''; |
| 1223 |
$value = !empty($value) ? $value : $default; |
| 1224 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 1225 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 1226 |
$field_name = !empty($parent) ? $parent . '[' . $id . ']' : $id; |
| 1227 |
ob_start(); |
| 1228 |
if (!empty($args)) : |
| 1229 |
foreach ($args as $arg_key => $arg) : |
| 1230 |
$item_value = isset($value[$arg_key]) ? $value[$arg_key] : $arg; |
| 1231 |
?> |
| 1232 |
<div class=""> |
| 1233 |
<span><?php echo esc_html($arg_key); ?></span> |
| 1234 |
<input name="<?php echo esc_attr($field_name); ?>[<?php echo esc_attr($arg_key); ?>]" id="<?php echo esc_attr($arg_key . '-' . $css_id); ?>" class="color-picker" value="<?php echo esc_attr($item_value); ?>" /> |
| 1235 |
|
| 1236 |
</div> |
| 1237 |
<?php |
| 1238 |
endforeach; |
| 1239 |
endif; |
| 1240 |
$input_html = ob_get_clean(); |
| 1241 |
echo wp_kses(sprintf($field_template, esc_html($title), $input_html, wp_kses_post($details)), $this->allowed_html()); |
| 1242 |
} |
| 1243 |
public function field_custom_html($option) |
| 1244 |
{ |
| 1245 |
$id = isset($option['id']) ? $option['id'] : ""; |
| 1246 |
$css_id = isset($option['css_id']) ? $option['css_id'] : $id; |
| 1247 |
$parent = isset($option['parent']) ? $option['parent'] : ""; |
| 1248 |
$field_template = isset($option['field_template']) ? $option['field_template'] : $this->field_template($option); |
| 1249 |
$html = isset($option['html']) ? $option['html'] : ""; |
| 1250 |
$is_pro = isset($option['is_pro']) ? $option['is_pro'] : false; |
| 1251 |
$pro_text = isset($option['pro_text']) ? $option['pro_text'] : ''; |
| 1252 |
$title = isset($option['title']) ? $option['title'] : ""; |
| 1253 |
$details = isset($option['details']) ? $option['details'] : ""; |
| 1254 |
echo wp_kses(sprintf($field_template, esc_html($title), $html, wp_kses_post($details)), $this->allowed_html()); |
| 1255 |
} |
| 1256 |
} |
| 1257 |
} |
| 1258 |
|