| 1 |
<?php |
| 2 |
/** |
| 3 |
* PPOM Fields Manager Class |
| 4 |
**/ |
| 5 |
|
| 6 |
/* |
| 7 |
**========== Direct access not allowed =========== |
| 8 |
*/ |
| 9 |
if( ! defined('ABSPATH') ) die('Not Allowed'); |
| 10 |
|
| 11 |
|
| 12 |
class WPComment_Fields_Meta { |
| 13 |
|
| 14 |
private static $ins; |
| 15 |
|
| 16 |
|
| 17 |
function __construct() { |
| 18 |
|
| 19 |
add_action('admin_enqueue_scripts', array($this, 'load_script')); |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
public static function get_instance() { |
| 24 |
// create a new object if it doesn't exist. |
| 25 |
is_null(self::$ins) && self::$ins = new self; |
| 26 |
return self::$ins; |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
/* |
| 31 |
**============ Load all scripts =========== |
| 32 |
*/ |
| 33 |
function load_script($hook) { |
| 34 |
|
| 35 |
if( ! isset($_GET['page']) || $_GET['page'] != "wpcomment") return; |
| 36 |
|
| 37 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 38 |
|
| 39 |
// Preloader script |
| 40 |
wp_enqueue_script('wpcomment-perload', WPCOMMENT_URL."/js/admin/pre-load.js", array('jquery'), WPCOMMENT_VERSION, true); |
| 41 |
|
| 42 |
// Bootstrap Files |
| 43 |
wp_enqueue_style('wpcomment-bs', WPCOMMENT_URL."/css/bootstrap/bootstrap.min.css"); |
| 44 |
|
| 45 |
// PPOM Meta Table File |
| 46 |
// wp_enqueue_script('wpcomment-meta-table', WPCOMMENT_URL."/js/admin/wpcomment-meta-table.js", array('jquery'), WPCOMMENT_VERSION, true); |
| 47 |
|
| 48 |
// Font-awesome File |
| 49 |
if( wpcomment_load_fontawesome() ) { |
| 50 |
wp_enqueue_style('wpcomment-fontawsome', WPCOMMENT_URL."/css/font-awesome/css/font-awesome.min.css"); |
| 51 |
} |
| 52 |
|
| 53 |
// Swal Files |
| 54 |
wp_enqueue_style('wpcomment-swal', WPCOMMENT_URL."/css/sweetalert.css"); |
| 55 |
wp_enqueue_script('wpcomment-swal', WPCOMMENT_URL."/js/sweetalert.js", array('jquery'), WPCOMMENT_VERSION, true); |
| 56 |
|
| 57 |
// Select2 Files |
| 58 |
wp_enqueue_style('wpcomment-select2', WPCOMMENT_URL."/css/select2.css"); |
| 59 |
wp_enqueue_script('wpcomment-select2', WPCOMMENT_URL."/js/select2.js", array('jquery'), WPCOMMENT_VERSION, true); |
| 60 |
|
| 61 |
if (isset($_GET['do_meta']) && $_GET['do_meta'] == 'edit') { |
| 62 |
|
| 63 |
// CSS Code Editor Files |
| 64 |
wp_enqueue_style('wpcomment-codemirror-theme', WPCOMMENT_URL."/css/codemirror-theme.css"); |
| 65 |
$css_code_editor = wp_enqueue_code_editor(array( 'type' => 'text/css' )); |
| 66 |
// wpcomment_pa($css_code_editor); exit; |
| 67 |
if (false !== $css_code_editor) { |
| 68 |
$css_code_editor['codemirror']['autoRefresh'] = true; |
| 69 |
$css_code_editor['codemirror']['theme'] = 'darcula'; |
| 70 |
wp_add_inline_script( |
| 71 |
'code-editor', |
| 72 |
sprintf( |
| 73 |
'jQuery( function() { wp.codeEditor.initialize( "wpcomment-css-editor", %s ); } );', |
| 74 |
wp_json_encode( $css_code_editor ) |
| 75 |
) |
| 76 |
); |
| 77 |
} |
| 78 |
|
| 79 |
// Js Code Editor Files |
| 80 |
$js_code_editor = wp_enqueue_code_editor(array( 'type' => 'text/javascript' )); |
| 81 |
if (false !== $js_code_editor) { |
| 82 |
$js_code_editor['codemirror']['autoRefresh'] = true; |
| 83 |
$js_code_editor['codemirror']['theme'] = 'darcula'; |
| 84 |
wp_add_inline_script( |
| 85 |
'code-editor', |
| 86 |
sprintf( |
| 87 |
'jQuery( function() { wp.codeEditor.initialize( "wpcomment-js-editor", %s ); } );', |
| 88 |
wp_json_encode( $js_code_editor ) |
| 89 |
) |
| 90 |
); |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
// Tabletojson JS File |
| 95 |
wp_enqueue_script('wpcomment-tabletojson', WPCOMMENT_URL."/js/admin/jquery.tabletojson.min.js", array('jquery'), WPCOMMENT_VERSION, true); |
| 96 |
|
| 97 |
// Datatable Files |
| 98 |
// wp_enqueue_style('wpcomment-datatables', WPCOMMENT_URL."/js/datatable/datatables.min.css"); |
| 99 |
// wp_enqueue_script('wpcomment-datatables', WPCOMMENT_URL."/js/datatable/jquery.dataTables.min.js", array('jquery'), WPCOMMENT_VERSION, true); |
| 100 |
|
| 101 |
// Description Tooltips JS File |
| 102 |
wp_enqueue_script('wpcomment-tooltip', WPCOMMENT_URL."/js/wpcomment-tooltip.js", array('jquery'), WPCOMMENT_VERSION, true); |
| 103 |
|
| 104 |
// Add the color picker css file |
| 105 |
wp_enqueue_style( 'wp-color-picker' ); |
| 106 |
|
| 107 |
// PPOM Admin Files |
| 108 |
wp_enqueue_style('wpcomment-field', WPCOMMENT_URL."/css/wpcomment-admin.css", '', WPCOMMENT_VERSION); |
| 109 |
wp_enqueue_script('wpcomment-field', WPCOMMENT_URL."/js/admin/wpcomment-admin.js", array('wpcomment-swal','wpcomment-select2','wpcomment-tabletojson','wpcomment-tooltip','jquery-ui-core', 'jquery-ui-sortable','wpcomment-perload','wp-color-picker'), WPCOMMENT_VERSION, true); |
| 110 |
|
| 111 |
wp_enqueue_media (); |
| 112 |
|
| 113 |
$wpcomment_admin_meta = array( |
| 114 |
'plugin_admin_page' => admin_url( 'admin.php?page=wpcomment'), |
| 115 |
'loader' => WPCOMMENT_URL.'/images/loading.gif', |
| 116 |
); |
| 117 |
|
| 118 |
// localize wpcomment_vars |
| 119 |
wp_localize_script( 'wpcomment-field', 'wpcomment_vars', $wpcomment_admin_meta); |
| 120 |
// wp_localize_script( 'wpcomment-meta-table', 'wpcomment_vars', $wpcomment_admin_meta); |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
/* |
| 125 |
**============ Render all fields =========== |
| 126 |
*/ |
| 127 |
function render_field_settings() { |
| 128 |
|
| 129 |
$html = ''; |
| 130 |
$html .= '<div id="wpcomment-fields-wrapper">'; |
| 131 |
foreach( WPCOMMENT_ADMIN()->get_all_inputs() as $fields_type => $meta ) { |
| 132 |
|
| 133 |
$field_title = isset($meta -> title) ? $meta -> title : null; |
| 134 |
$field_desc = isset($meta -> desc) ? $meta -> desc : null; |
| 135 |
$settings = isset($meta -> settings) ? $meta -> settings : array(); |
| 136 |
|
| 137 |
$settings = $this->wpcomment_tabs_panel_classes($settings); |
| 138 |
|
| 139 |
// new model |
| 140 |
$html .= '<div class="wpcomment-modal-box wpcomment-slider wpcomment-field-'.esc_attr($fields_type).'">'; |
| 141 |
$html .= '<header>'; |
| 142 |
$html .= '<h3>'.sprintf(__("%s","wpcomment"), $field_title).'</h3>'; |
| 143 |
$html .= '</header>'; |
| 144 |
$html .= '<div class="wpcomment-modal-body">'; |
| 145 |
|
| 146 |
$html .= $this->render_field_meta($settings, $fields_type); |
| 147 |
|
| 148 |
$html .= '</div>'; |
| 149 |
$html .= '<footer>'; |
| 150 |
$html .= '<span class="wpcomment-req-field-id"></span>'; |
| 151 |
$html .= '<button type="button" class="btn btn-default wpcomment-close-checker wpcomment-close-fields wpcomment-js-modal-close" style="margin-right: 5px;">'.esc_html__( 'close', 'wp-comment-fields' ).'</button>'; |
| 152 |
$html .= '<button type="button" class="btn btn-primary wpcomment-field-checker wpcomment-add-field" data-field-type="'.esc_attr($field_title).'">'.esc_html__( 'Add Field', 'wp-comment-fields' ).'</button>'; |
| 153 |
$html .= '</footer>'; |
| 154 |
$html .= '</div>'; |
| 155 |
} |
| 156 |
|
| 157 |
$html .= '</div>'; |
| 158 |
echo wpcomment_esc_html($html); |
| 159 |
} |
| 160 |
|
| 161 |
/* |
| 162 |
**============ Render all fields meta =========== |
| 163 |
*/ |
| 164 |
function render_field_meta($field_meta, $fields_type, $field_index='', $save_meta='') { |
| 165 |
// wpcomment_pa($save_meta); |
| 166 |
$html = ''; |
| 167 |
$html .= '<div data-table-id="'.esc_attr($fields_type).'" class="row wpcomment-tabs wpcomment-fields-actions" data-field-no="'.esc_attr($field_index).'">'; |
| 168 |
$html .= '<input type="hidden" name="wpcomment['.$field_index.'][type]" value="'.$fields_type.'" class="wpcomment-meta-field" data-metatype="type">'; |
| 169 |
$html .= '<div class="col-md-12 wpcomment-tabs-header">'; |
| 170 |
|
| 171 |
|
| 172 |
$wpcomment_field_tabs = $this->wpcomment_fields_tabs($fields_type); |
| 173 |
foreach ($wpcomment_field_tabs as $tab_index => $tab_meta) { |
| 174 |
|
| 175 |
$tab_label = isset($tab_meta['label']) ? $tab_meta['label'] : ''; |
| 176 |
$tab_class = isset($tab_meta['class']) ? $tab_meta['class'] : ''; |
| 177 |
$tab_depend = isset($tab_meta['field_depend']) ? $tab_meta['field_depend'] : array(); |
| 178 |
$not_allowed = isset($tab_meta['not_allowed']) ? $tab_meta['not_allowed'] : array(); |
| 179 |
$tab_class = implode(' ',$tab_class); |
| 180 |
|
| 181 |
if ( in_array('all', $tab_depend) && !in_array($fields_type, $not_allowed)) { |
| 182 |
|
| 183 |
$html .= '<label for="'.esc_attr($tab_index).'" id="'.esc_attr($tab_index).'" class="'.esc_attr($tab_class).'">'.$tab_label.'</label>'; |
| 184 |
}else if( in_array($fields_type, $tab_depend) ){ |
| 185 |
|
| 186 |
$html .= '<label for="'.esc_attr($tab_index).'" id="'.esc_attr($tab_index).'" class="'.esc_attr($tab_class).'">'.$tab_label.'</label>'; |
| 187 |
} |
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
$html .= '</div>'; |
| 192 |
if ($field_meta) { |
| 193 |
|
| 194 |
foreach ($field_meta as $fields_meta_key => $meta) { |
| 195 |
|
| 196 |
$title = isset($meta['title']) ? $meta['title'] : ''; |
| 197 |
$desc = isset($meta['desc']) ? $meta['desc'] : ''; |
| 198 |
$type = isset($meta['type']) ? $meta['type'] : ''; |
| 199 |
$link = isset($meta['link']) ? $meta['link'] : ''; |
| 200 |
$values = isset($save_meta[$fields_meta_key]) ? $save_meta[$fields_meta_key] : ''; |
| 201 |
|
| 202 |
$default_value = isset($meta ['default']) ? $meta ['default'] : ''; |
| 203 |
// wpcomment_pa($fields_meta_key); |
| 204 |
|
| 205 |
if ( empty( $values) ){ |
| 206 |
$values = $default_value; |
| 207 |
} |
| 208 |
|
| 209 |
$input_wrapper_classes = isset($meta['col_classes']) ? $meta['col_classes'] : array(); |
| 210 |
// $input_wrapper_classes = array('col-md-6', 'col-sm-6'); |
| 211 |
|
| 212 |
if (empty($input_wrapper_classes)) { |
| 213 |
$input_wrapper_classes = array('col-md-6', 'col-sm-12'); |
| 214 |
} |
| 215 |
|
| 216 |
$panel_classes = isset($meta['tabs_class']) ? $meta['tabs_class'] : array_merge($input_wrapper_classes, array('wpcomment_handle_fields_tab')); |
| 217 |
$panel_classes[] = 'wpcomment-control-all-fields-tabs'; |
| 218 |
|
| 219 |
if ($type == 'checkbox') { |
| 220 |
$panel_classes[] = 'wpcomment-checkboxe-style'; |
| 221 |
} |
| 222 |
if (!empty($panel_classes)) { |
| 223 |
$panel_classes = implode(' ',$panel_classes); |
| 224 |
} |
| 225 |
|
| 226 |
$html .= '<div data-meta-id="'.esc_attr($fields_meta_key).'" class="'.esc_attr($panel_classes).'">'; |
| 227 |
$html .= '<div class="form-group">'; |
| 228 |
|
| 229 |
$html .= '<label>'.sprintf(__("%s","wpcomment"), $title).''; |
| 230 |
$html .= '<span class="wpcomment-helper-icon" data-wpcomment-tooltip="wpcomment_tooltip" title="'.sprintf(__("%s","wpcomment"),$desc).'">'; |
| 231 |
$html .= '<i class="dashicons dashicons-editor-help"></i>'; |
| 232 |
$html .= '</span>'.$link.''; |
| 233 |
$html .= '</label>'; |
| 234 |
$html .= $this-> render_all_input_types( $fields_meta_key, $meta, $fields_type, $field_index, $values ); |
| 235 |
|
| 236 |
$html .= '</div>'; |
| 237 |
$html .= '</div>'; |
| 238 |
|
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
$html .= '</div>'; |
| 243 |
|
| 244 |
return ($html); |
| 245 |
} |
| 246 |
|
| 247 |
|
| 248 |
/* |
| 249 |
* this function is rendring input field for settings |
| 250 |
*/ |
| 251 |
function render_all_input_types($name, $data, $fields_type, $field_index, $values ) { |
| 252 |
// wpcomment_pa($values); |
| 253 |
|
| 254 |
$type = (isset( $data ['type'] ) ? $data ['type'] : ''); |
| 255 |
|
| 256 |
$options = (isset( $data ['options'] ) ? $data ['options'] : ''); |
| 257 |
$placeholders = isset($data['placeholders']) ? $data['placeholders'] : ''; |
| 258 |
|
| 259 |
$existing_name = 'name="wpcomment['.esc_attr($field_index).']['.esc_attr($name).']"'; |
| 260 |
|
| 261 |
$html_input = ''; |
| 262 |
|
| 263 |
if(!is_array($values)) |
| 264 |
$values = stripslashes($values); |
| 265 |
|
| 266 |
switch ($type) { |
| 267 |
|
| 268 |
case 'number': |
| 269 |
case 'text' : |
| 270 |
// wpcomment_pa($values); |
| 271 |
$html_input .= '<input data-metatype="'.esc_attr($name).'" type="'.esc_attr($type).'" value="' . esc_html( $values ). '" class="form-control wpcomment-meta-field"'; |
| 272 |
|
| 273 |
if( $field_index != '') { |
| 274 |
|
| 275 |
$html_input .= $existing_name; |
| 276 |
} |
| 277 |
|
| 278 |
$html_input .= ' />'; |
| 279 |
break; |
| 280 |
|
| 281 |
case 'color': |
| 282 |
$html_input .= '<div class="wpcomment-color-picker-cloner">'; |
| 283 |
$html_input .= '<input data-alpha-enabled="true" data-metatype="'.esc_attr($name).'" type="text" value="' . esc_html( $values ). '" class="form-control wpcomment-meta-field wpcomment-color-picker-init"'; |
| 284 |
|
| 285 |
if( $field_index != '') { |
| 286 |
|
| 287 |
$html_input .= $existing_name; |
| 288 |
} |
| 289 |
|
| 290 |
$html_input .= '>'; |
| 291 |
$html_input .= '</div>'; |
| 292 |
break; |
| 293 |
|
| 294 |
case 'textarea' : |
| 295 |
|
| 296 |
$html_input .= '<textarea data-metatype="'.esc_attr($name).'" class="form-control wpcomment-meta-field wpcomment-adjust-box-height"'; |
| 297 |
|
| 298 |
if( $field_index != '') { |
| 299 |
|
| 300 |
$html_input .= $existing_name; |
| 301 |
} |
| 302 |
|
| 303 |
$html_input .= '>' . esc_html( $values ) . '</textarea>'; |
| 304 |
|
| 305 |
break; |
| 306 |
|
| 307 |
case 'select' : |
| 308 |
|
| 309 |
$html_input .= '<select id="'.$name.'" data-metatype="'.esc_attr($name).'" class="form-control wpcomment-meta-field"'; |
| 310 |
|
| 311 |
if( $field_index != '') { |
| 312 |
|
| 313 |
$html_input .= $existing_name; |
| 314 |
} |
| 315 |
|
| 316 |
$html_input .= '>'; |
| 317 |
|
| 318 |
foreach ( $options as $key => $val ) { |
| 319 |
$selected = ($key == $values) ? 'selected="selected"' : ''; |
| 320 |
$html_input .= '<option value="' . $key . '" ' . $selected . '>' . esc_html( $val ) . '</option>'; |
| 321 |
} |
| 322 |
$html_input .= '</select>'; |
| 323 |
|
| 324 |
break; |
| 325 |
|
| 326 |
case 'paired' : |
| 327 |
|
| 328 |
$plc_option = (!empty($placeholders)) ? $placeholders[0] : __('Option',"wpcomment"); |
| 329 |
$plc_id = (isset($placeholders[3]) && !empty($placeholders)) ? $placeholders[3] : __('Unique Option ID)', "wpcomment"); |
| 330 |
|
| 331 |
$opt_index0 = 1; |
| 332 |
$html_input .= '<ul class="wpcomment-options-container wpcomment-options-sortable">'; |
| 333 |
|
| 334 |
if($values){ |
| 335 |
// wpcomment_pa($values); |
| 336 |
$last_array_id = max(array_keys($values)); |
| 337 |
|
| 338 |
foreach ($values as $opt_index => $option){ |
| 339 |
|
| 340 |
$option_id = wpcomment_get_option_id($option); |
| 341 |
$html_input .= '<li class="data-options wpcomment-sortable-handle" style="display: flex;" data-condition-type="simple_options">'; |
| 342 |
$html_input .= '<span class="dashicons dashicons-move"></span>'; |
| 343 |
$html_input .= '<input type="text" class="option-title form-control wpcomment-option-keys" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][option]" value="'.esc_attr(stripslashes($option['option'])).'" placeholder="'.$plc_option.'" data-metatype="option" data-opt-index="'.esc_attr($opt_index).'">'; |
| 344 |
$html_input .= '<input type="text" class="option-id form-control wpcomment-option-keys" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][id]" value="'.esc_attr($option_id).'" placeholder="'.$plc_id.'" data-metatype="id" data-opt-index="'.esc_attr($opt_index).'">'; |
| 345 |
|
| 346 |
$html_input .= '<button class="btn btn-success wpcomment-add-option" data-option-type="paired"><i class="fa fa-plus" aria-hidden="true"></i></button>'; |
| 347 |
$html_input .= '<button class="btn btn-danger wpcomment-remove-option"><i class="fa fa-minus" aria-hidden="true"></i></button>'; |
| 348 |
|
| 349 |
$html_input .= '</li>'; |
| 350 |
|
| 351 |
$opt_index0 = $last_array_id; |
| 352 |
$opt_index0++; |
| 353 |
|
| 354 |
} |
| 355 |
}else{ |
| 356 |
$html_input .= '<li class="data-options" style="display: flex;" data-condition-type="simple_options">'; |
| 357 |
$html_input .= '<span class="dashicons dashicons-move"></span>'; |
| 358 |
$html_input .= '<input type="text" class="option-title form-control wpcomment-option-keys" placeholder="'.$plc_option.'" data-metatype="option">'; |
| 359 |
$html_input .= '<input type="text" class="option-id form-control wpcomment-option-keys" placeholder="'.$plc_id.'" data-metatype="id">'; |
| 360 |
|
| 361 |
$html_input .= '<button class="btn btn-success wpcomment-add-option" data-option-type="paired"><i class="fa fa-plus" aria-hidden="true"></i></button>'; |
| 362 |
$html_input .= '<button class="btn btn-danger wpcomment-remove-option"><i class="fa fa-minus" aria-hidden="true"></i></button>'; |
| 363 |
|
| 364 |
$html_input .= '</li>'; |
| 365 |
} |
| 366 |
$html_input .= '<input type="hidden" id="wpcomment-meta-opt-index" value="'.esc_attr($opt_index0).'">'; |
| 367 |
$html_input .= '<ul/>'; |
| 368 |
|
| 369 |
break; |
| 370 |
|
| 371 |
case 'paired-palettes'; |
| 372 |
|
| 373 |
$plc_option = (!empty($placeholders)) ? $placeholders[0] : __('Option',"wpcomment"); |
| 374 |
$plc_price = (!empty($placeholders)) ? $placeholders[1] : __('Price (optional)', "wpcomment"); |
| 375 |
$plc_label = (!empty($placeholders)) ? $placeholders[2] : __('Label', "wpcomment"); |
| 376 |
$plc_id = (isset($placeholders[3]) && !empty($placeholders)) ? $placeholders[3] : __('Unique Option ID)', "wpcomment"); |
| 377 |
|
| 378 |
$opt_index0 = 1; |
| 379 |
$html_input .= '<ul class="wpcomment-options-container wpcomment-options-sortable '.$type.'">'; |
| 380 |
|
| 381 |
if($values){ |
| 382 |
// wpcomment_pa($values); |
| 383 |
$last_array_id = max(array_keys($values)); |
| 384 |
|
| 385 |
foreach ($values as $opt_index => $option){ |
| 386 |
|
| 387 |
$label = isset($option['label']) ? $option['label'] : ''; |
| 388 |
$isfixed = isset($option['isfixed']) ? $option['isfixed'] : ''; |
| 389 |
|
| 390 |
$option_id = wpcomment_get_option_id($option); |
| 391 |
$html_input .= '<li class="data-options wpcomment-sortable-handle" style="display: flex;">'; |
| 392 |
$html_input .= '<span class="dashicons dashicons-move"></span>'; |
| 393 |
$html_input .= '<input type="text" class="option-title form-control wpcomment-option-keys" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][option]" value="'.esc_attr(stripslashes($option['option'])).'" placeholder="'.$plc_option.'" data-metatype="option" data-opt-index="'.esc_attr($opt_index).'">'; |
| 394 |
$html_input .= '<input type="text" class="option-label form-control wpcomment-option-keys" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][label]" value="'.esc_attr($label).'" placeholder="'.$plc_label.'" data-metatype="label" data-opt-index="'.esc_attr($opt_index).'">'; |
| 395 |
$html_input .= '<input type="text" class="option-id form-control wpcomment-option-keys" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][id]" value="'.esc_attr($option_id).'" placeholder="'.$plc_id.'" data-metatype="id" data-opt-index="'.esc_attr($opt_index).'">'; |
| 396 |
|
| 397 |
$html_input .= '<button class="btn btn-success wpcomment-add-option" data-option-type="paired"><i class="fa fa-plus" aria-hidden="true"></i></button>'; |
| 398 |
$html_input .= '<button class="btn btn-danger wpcomment-remove-option"><i class="fa fa-minus" aria-hidden="true"></i></button>'; |
| 399 |
|
| 400 |
$html_input .= '</li>'; |
| 401 |
|
| 402 |
$opt_index0 = $last_array_id; |
| 403 |
$opt_index0++; |
| 404 |
|
| 405 |
} |
| 406 |
}else{ |
| 407 |
$html_input .= '<li class="data-options" style="display: flex;">'; |
| 408 |
$html_input .= '<span class="dashicons dashicons-move"></span>'; |
| 409 |
$html_input .= '<input type="text" class="option-title form-control wpcomment-option-keys" placeholder="'.$plc_option.'" data-metatype="option">'; |
| 410 |
|
| 411 |
$html_input .= '<input type="text" class="option-label form-control wpcomment-option-keys" placeholder="'.$plc_label.'" data-metatype="label">'; |
| 412 |
|
| 413 |
$html_input .= '<input type="text" class="option-id form-control wpcomment-option-keys" placeholder="'.$plc_id.'" data-metatype="id">'; |
| 414 |
|
| 415 |
|
| 416 |
$html_input .= '<button class="btn btn-success wpcomment-add-option" data-option-type="paired"><i class="fa fa-plus" aria-hidden="true"></i></button>'; |
| 417 |
$html_input .= '<button class="btn btn-danger wpcomment-remove-option"><i class="fa fa-minus" aria-hidden="true"></i></button>'; |
| 418 |
|
| 419 |
$html_input .= '</li>'; |
| 420 |
} |
| 421 |
$html_input .= '<input type="hidden" id="wpcomment-meta-opt-index" value="'.esc_attr($opt_index0).'">'; |
| 422 |
$html_input .= '<ul/>'; |
| 423 |
|
| 424 |
break; |
| 425 |
|
| 426 |
|
| 427 |
case 'font_paired' : |
| 428 |
|
| 429 |
$plc_option = (!empty($placeholders)) ? $placeholders[0] : __('Data Name',"wpcomment"); |
| 430 |
$plc_price = (!empty($placeholders)) ? $placeholders[1] : __('Font Name', "wpcomment"); |
| 431 |
|
| 432 |
$opt_index0 = 1; |
| 433 |
$html_input .= '<ul class="wpcomment-options-container wpcomment-options-sortable">'; |
| 434 |
|
| 435 |
if($values){ |
| 436 |
$last_array_id = max(array_keys($values)); |
| 437 |
|
| 438 |
foreach ($values as $opt_index => $option){ |
| 439 |
|
| 440 |
$weight = isset($option['weight']) ? $option['weight'] : ''; |
| 441 |
|
| 442 |
$html_input .= '<li class="data-options wpcomment-sortable-handle" style="display: flex;">'; |
| 443 |
$html_input .= '<span class="dashicons dashicons-move"></span>'; |
| 444 |
$html_input .= '<input type="text" class="option-title form-control wpcomment-option-keys" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][dataname]" value="'.esc_attr(stripslashes($option['dataname'])).'" placeholder="'.$plc_option.'" data-metatype="dataname" data-opt-index="'.esc_attr($opt_index).'">'; |
| 445 |
$html_input .= '<input type="text" class="form-control wpcomment-option-keys" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][font_name]" value="'.esc_attr($option['font_name']).'" placeholder="'.$plc_price.'" data-metatype="font_name" data-opt-index="'.esc_attr($opt_index).'">'; |
| 446 |
|
| 447 |
|
| 448 |
$html_input .= '<button class="btn btn-success wpcomment-add-option" data-option-type="paired"><i class="fa fa-plus" aria-hidden="true"></i></button>'; |
| 449 |
$html_input .= '</li>'; |
| 450 |
|
| 451 |
$opt_index0 = $last_array_id; |
| 452 |
$opt_index0++; |
| 453 |
|
| 454 |
} |
| 455 |
}else{ |
| 456 |
$html_input .= '<li class="data-options" style="display: flex;">'; |
| 457 |
$html_input .= '<span class="dashicons dashicons-move"></span>'; |
| 458 |
$html_input .= '<input type="text" class="option-title form-control wpcomment-option-keys" placeholder="'.$plc_option.'" data-metatype="dataname">'; |
| 459 |
$html_input .= '<input type="text" class="form-control wpcomment-option-keys" placeholder="'.$plc_price.'" data-metatype="font_name">'; |
| 460 |
|
| 461 |
$html_input .= '<button class="btn btn-success wpcomment-add-option" data-option-type="paired"><i class="fa fa-plus" aria-hidden="true"></i></button>'; |
| 462 |
$html_input .= '</li>'; |
| 463 |
} |
| 464 |
$html_input .= '<input type="hidden" id="wpcomment-meta-opt-index" value="'.esc_attr($opt_index0).'">'; |
| 465 |
$html_input .= '<ul/>'; |
| 466 |
|
| 467 |
break; |
| 468 |
|
| 469 |
|
| 470 |
case 'paired-cropper' : |
| 471 |
|
| 472 |
$opt_index0 = 1; |
| 473 |
$html_input .= '<ul class="wpcomment-options-container wpcomment-cropper-boundary">'; |
| 474 |
|
| 475 |
if($values){ |
| 476 |
// wpcomment_pa($values); |
| 477 |
$last_array_id = max(array_keys($values)); |
| 478 |
foreach ($values as $opt_index => $option){ |
| 479 |
|
| 480 |
$price = isset($option['price']) ? $option['price'] : ''; |
| 481 |
|
| 482 |
$html_input .= '<li class="data-options" style=display:flex;>'; |
| 483 |
$html_input .= '<span class="dashicons dashicons-move"></span>'; |
| 484 |
$html_input .= '<input type="text" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][option]" value="'.esc_attr(stripslashes($option['option'])).'" placeholder="'.__('Label',"wpcomment").'" class="form-control wpcomment-option-keys" data-metatype="option" data-opt-index="'.esc_attr($opt_index).'">'; |
| 485 |
$html_input .= '<input type="text" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][width]" value="'.esc_attr(stripslashes($option['width'])).'" placeholder="'.__('Width',"wpcomment").'" class="form-control wpcomment-option-keys" data-metatype="width" data-opt-index="'.esc_attr($opt_index).'">'; |
| 486 |
$html_input .= '<input type="text" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][height]" value="'.esc_attr($option['height']).'" placeholder="'.__('Height',"wpcomment").'" class="form-control wpcomment-option-keys" data-metatype="height" data-opt-index="'.esc_attr($opt_index).'">'; |
| 487 |
$html_input .= '<input type="text" name="wpcomment['.esc_attr($field_index).'][options]['.esc_attr($opt_index).'][price]" value="'.esc_attr($price).'" placeholder="'.__('Price (optional)',"wpcomment").'" class="form-control wpcomment-option-keys" data-metatype="price" data-opt-index="'.esc_attr($opt_index).'">'; |
| 488 |
|
| 489 |
$html_input .= '<button class="btn btn-success wpcomment-add-option" data-option-type="paired-cropper"><i class="fa fa-plus" aria-hidden="true"></i></button>'; |
| 490 |
$html_input .= '<button class="btn btn-danger wpcomment-remove-option"><i class="fa fa-minus" aria-hidden="true"></i></button>'; |
| 491 |
|
| 492 |
$html_input .= '</li>'; |
| 493 |
|
| 494 |
$opt_index0 = $last_array_id; |
| 495 |
$opt_index0++; |
| 496 |
} |
| 497 |
}else{ |
| 498 |
$html_input .= '<li class="data-options" style=display:flex;>'; |
| 499 |
$html_input .= '<span class="dashicons dashicons-move"></span>'; |
| 500 |
$html_input .= '<input type="text" placeholder="'.__('option',"wpcomment").'" class="form-control wpcomment-option-keys" data-metatype="option">'; |
| 501 |
$html_input .= '<input type="text" placeholder="'.__('Width',"wpcomment").'" class="form-control wpcomment-option-keys" data-metatype="width">'; |
| 502 |
$html_input .= '<input type="text" placeholder="'.__('Height',"wpcomment").'" class="form-control wpcomment-option-keys" data-metatype="height">'; |
| 503 |
$html_input .= '<input type="text" placeholder="'.__('Price (optional)',"wpcomment").'" class="form-control wpcomment-option-keys" data-metatype="price">'; |
| 504 |
|
| 505 |
$html_input .= '<button class="btn btn-success wpcomment-add-option" data-option-type="paired-cropper"><i class="fa fa-plus" aria-hidden="true"></i></button>'; |
| 506 |
$html_input .= '<button class="btn btn-danger wpcomment-remove-option"><i class="fa fa-minus" aria-hidden="true"></i></button>'; |
| 507 |
|
| 508 |
$html_input .= '</li>'; |
| 509 |
} |
| 510 |
$html_input .= '<input type="hidden" id="wpcomment-meta-opt-index" value="'.esc_attr($opt_index0).'">'; |
| 511 |
$html_input .= '<ul/>'; |
| 512 |
|
| 513 |
break; |
| 514 |
|
| 515 |
case 'checkbox' : |
| 516 |
|
| 517 |
if ($options) { |
| 518 |
foreach ( $options as $key => $val ) { |
| 519 |
|
| 520 |
parse_str ( $values, $saved_data ); |
| 521 |
$checked = ''; |
| 522 |
if ( isset( $saved_data ['editing_tools'] ) && $saved_data ['editing_tools']) { |
| 523 |
if (in_array($key, $saved_data['editing_tools'])) { |
| 524 |
$checked = 'checked="checked"'; |
| 525 |
}else{ |
| 526 |
$checked = ''; |
| 527 |
} |
| 528 |
} |
| 529 |
|
| 530 |
// For event Calendar Addon |
| 531 |
if ( isset( $saved_data ['cal_addon_disable_days'] ) && $saved_data ['cal_addon_disable_days']) { |
| 532 |
if (in_array($key, $saved_data['cal_addon_disable_days'])) { |
| 533 |
$checked = 'checked="checked"'; |
| 534 |
}else{ |
| 535 |
$checked = ''; |
| 536 |
} |
| 537 |
} |
| 538 |
// $html_input .= '<option value="' . $key . '" ' . $selected . '>' . $val . '</option>'; |
| 539 |
$html_input .= '<label style="float:left;">'; |
| 540 |
$html_input .= '<input type="checkbox" value="' . $key . '" name="wpcomment['.esc_attr($field_index).']['.esc_attr($name).'][]" ' . $checked . '> ' . $val . '<br>'; |
| 541 |
$html_input .= '<span></span>'; |
| 542 |
$html_input .= '</label>'; |
| 543 |
} |
| 544 |
} else { |
| 545 |
$checked = ( (isset($values) && $values != '' ) ? 'checked = "checked"' : '' ); |
| 546 |
|
| 547 |
$html_input .= '<label style="float:left;">'; |
| 548 |
$html_input .= '<input type="checkbox" class="wpcomment-meta-field" data-metatype="'.esc_attr($name).'" ' . $checked . ''; |
| 549 |
|
| 550 |
if( $field_index != '') { |
| 551 |
|
| 552 |
$html_input .= $existing_name; |
| 553 |
} |
| 554 |
|
| 555 |
$html_input .= '>'; |
| 556 |
|
| 557 |
$html_input .= '<span></span>'; |
| 558 |
$html_input .= '</label>'; |
| 559 |
|
| 560 |
} |
| 561 |
break; |
| 562 |
|
| 563 |
case 'html-conditions' : |
| 564 |
|
| 565 |
$condition_index = 1; |
| 566 |
$rule_i = 1; |
| 567 |
if($values){ |
| 568 |
// wpcomment_pa($values); |
| 569 |
$condition_rules = isset($values['rules']) ? $values['rules'] : array(); |
| 570 |
$last_array_id = max(array_keys($condition_rules)); |
| 571 |
|
| 572 |
$visibility_show = ($values['visibility'] == 'Show') ? 'selected="selected"' : ''; |
| 573 |
$visibility_hide = ($values['visibility'] == 'Hide') ? 'selected="selected"' : ''; |
| 574 |
$bound_all = ($values['bound'] == 'All') ? 'selected="selected"' : ''; |
| 575 |
$bound_any = ($values['bound'] == 'Any') ? 'selected="selected"' : ''; |
| 576 |
|
| 577 |
$html_input = '<div class="row wpcomment-condition-style-wrap">'; |
| 578 |
$html_input .= '<div class="col-md-3 col-sm-3">'; |
| 579 |
$html_input .= '<select name="wpcomment['.esc_attr($field_index).'][conditions][visibility]" class="form-control wpcomment-condition-visible-bound" data-metatype="visibility">'; |
| 580 |
$html_input .= '<option '.$visibility_show.' value="Show">'.__( 'Show', 'wp-comment-fields' ).'</option>'; |
| 581 |
$html_input .= '<option '.$visibility_hide.' value="Hide">'.__( 'Hide', 'wp-comment-fields' ).'</option>'; |
| 582 |
$html_input .= '</select>'; |
| 583 |
$html_input .= '</div>'; |
| 584 |
|
| 585 |
$html_input .= '<div class="col-md-2 col-sm-2">'; |
| 586 |
$html_input .= '<p>'.__( 'only if', 'wp-comment-fields' ).'</p>'; |
| 587 |
$html_input .= '</div>'; |
| 588 |
|
| 589 |
$html_input .= '<div class="col-md-3 col-sm-3">'; |
| 590 |
$html_input .= '<select name="wpcomment['.esc_attr($field_index).'][conditions][bound]" class="form-control wpcomment-condition-visible-bound" data-metatype="bound">'; |
| 591 |
$html_input .= '<option '.$bound_all.' value="All">'.__( 'All', 'wp-comment-fields' ).'</option>'; |
| 592 |
$html_input .= '<option '.$bound_any.' value="Any">'.__( 'Any', 'wp-comment-fields' ).'</option>'; |
| 593 |
$html_input .= '</select>'; |
| 594 |
$html_input .= '</div>'; |
| 595 |
|
| 596 |
$html_input .= '<div class="col-md-4 col-sm-4">'; |
| 597 |
$html_input .='<p>'.__( 'of the following matches', 'wp-comment-fields' ).'</p>'; |
| 598 |
$html_input .= '</div>'; |
| 599 |
$html_input .= '</div>'; |
| 600 |
|
| 601 |
$html_input .= '<div class="row wpcomment-condition-clone-js">'; |
| 602 |
foreach ($condition_rules as $rule_index => $condition){ |
| 603 |
|
| 604 |
$element_values = isset($condition['element_values']) ? stripslashes($condition['element_values']) : ''; |
| 605 |
$element = isset($condition['elements']) ? stripslashes($condition['elements']) : ''; |
| 606 |
$operator_is = ($condition['operators'] == 'is') ? 'selected="selected"' : ''; |
| 607 |
$operator_not = ($condition['operators'] == 'not') ? 'selected="selected"' : ''; |
| 608 |
$operator_greater = ($condition['operators'] == 'greater than') ? 'selected="selected"' : ''; |
| 609 |
$operator_less = ($condition['operators'] == 'less than') ? 'selected="selected"' : ''; |
| 610 |
|
| 611 |
$html_input .= '<div class="webcontact-rules" id="rule-box-'.esc_attr($rule_i).'">'; |
| 612 |
$html_input .= '<div class="col-md-12 col-sm-12"><label>'.__('Rule ', "wpcomment") . $rule_i++ .'</label></div>'; |
| 613 |
|
| 614 |
// conditional elements |
| 615 |
$html_input .= '<div class="col-md-4 col-sm-4">'; |
| 616 |
$html_input .= '<select name="wpcomment['.esc_attr($field_index).'][conditions][rules]['.esc_attr($rule_index).'][elements]" class="form-control wpcomment-conditional-keys" data-metatype="elements" |
| 617 |
data-existingvalue="'.esc_attr($element).'" >'; |
| 618 |
$html_input .= '<option>'.$element.'</option>'; |
| 619 |
$html_input .= '</select>'; |
| 620 |
$html_input .= '</div>'; |
| 621 |
|
| 622 |
// is value meta |
| 623 |
$html_input .= '<div class="col-md-2 col-sm-2">'; |
| 624 |
$html_input .= '<select name="wpcomment['.esc_attr($field_index).'][conditions][rules]['.esc_attr($rule_index).'][operators]" class="form-control wpcomment-conditional-keys" data-metatype="operators">'; |
| 625 |
$html_input .= '<option '.$operator_is.' value="is">'. __('is', "wpcomment").'</option>'; |
| 626 |
$html_input .= '<option '.$operator_not.' value="not">'. __('not', "wpcomment").'</option>'; |
| 627 |
$html_input .= '<option '.$operator_greater.' value="greater than">'. __('greater than', "wpcomment").'</option>'; |
| 628 |
$html_input .= '<option '.$operator_less.' value="less than">'. __('less than', "wpcomment").'</option>'; |
| 629 |
$html_input .= '</select> '; |
| 630 |
$html_input .= '</div>'; |
| 631 |
|
| 632 |
// conditional elements values |
| 633 |
$html_input .= '<div class="col-md-4 col-sm-4">'; |
| 634 |
|
| 635 |
$html_input .= '<select name="wpcomment['.esc_attr($field_index).'][conditions][rules]['.esc_attr($rule_index).'][element_values]" class="form-control wpcomment-conditional-keys" data-metatype="element_values" |
| 636 |
data-existingvalue="'.esc_attr($element_values).'" >'; |
| 637 |
$html_input .= '<option>'.$element_values.'</option>'; |
| 638 |
$html_input .= '</select>'; |
| 639 |
|
| 640 |
// $html_input .= '<input type="text" name="wpcomment['.esc_attr($field_index).'][conditions][rules]['.esc_attr($rule_index).'][element_values]" class="form-control wpcomment-conditional-keys" value="'.esc_attr($element_values).'" placeholder="Enter Option" data-metatype="element_values">'; |
| 641 |
$html_input .= '</div>'; |
| 642 |
|
| 643 |
// Add and remove btn |
| 644 |
$html_input .= '<div class="col-md-2 col-sm-2">'; |
| 645 |
$html_input .= '<button class="btn btn-success wpcomment-add-rule" data-index="5"><i class="fa fa-plus" aria-hidden="true"></i></button>'; |
| 646 |
$html_input .= '</div>'; |
| 647 |
$html_input .= '</div>'; |
| 648 |
|
| 649 |
$condition_index = $last_array_id; |
| 650 |
$condition_index++; |
| 651 |
} |
| 652 |
$html_input .= '</div>'; |
| 653 |
}else{ |
| 654 |
|
| 655 |
$html_input .= '<div class="row wpcomment-condition-style-wrap">'; |
| 656 |
$html_input .= '<div class="col-md-4 col-sm-4">'; |
| 657 |
$html_input .= '<select class="form-control wpcomment-condition-visible-bound" data-metatype="visibility">'; |
| 658 |
$html_input .= '<option value="Show">'.__('Show', "wpcomment").'</option>'; |
| 659 |
$html_input .= '<option value="Hide">'. __('Hide', "wpcomment").'</option>'; |
| 660 |
$html_input .= '</select> '; |
| 661 |
$html_input .= '</div>'; |
| 662 |
$html_input .= '<div class="col-md-4 col-sm-4">'; |
| 663 |
$html_input .= '<select class="form-control wpcomment-condition-visible-bound" data-metatype="bound">'; |
| 664 |
$html_input .= '<option value="All">'. __('All', "wpcomment").'</option>'; |
| 665 |
$html_input .= '<option value="Any">'. __('Any', "wpcomment").'</option>'; |
| 666 |
$html_input .= '</select> '; |
| 667 |
$html_input .= '</div>'; |
| 668 |
$html_input .= '<div class="col-md-4 col-sm-4">'; |
| 669 |
$html_input .='<p>'. __(' of the following matches', "wpcomment").'</p>'; |
| 670 |
$html_input .= '</div>'; |
| 671 |
$html_input .= '</div>'; |
| 672 |
|
| 673 |
$html_input .= '<div class="row wpcomment-condition-clone-js">'; |
| 674 |
$html_input .= '<div class="webcontact-rules" id="rule-box-'.esc_attr($rule_i).'">'; |
| 675 |
$html_input .= '<div class="col-md-12 col-sm-12"><label>'.__('Rule ', "wpcomment") . $rule_i++ .'</label></div>'; |
| 676 |
|
| 677 |
// conditional elements |
| 678 |
$html_input .= '<div class="col-md-4 col-sm-4">'; |
| 679 |
$html_input .= '<select data-metatype="elements" class="wpcomment-conditional-keys form-control"></select>'; |
| 680 |
$html_input .= '</div>'; |
| 681 |
|
| 682 |
// is |
| 683 |
$html_input .= '<div class="col-md-2 col-sm-2">'; |
| 684 |
$html_input .= '<select data-metatype="operators" class="wpcomment-conditional-keys form-control">'; |
| 685 |
$html_input .= '<option value="is">'. __('is', "wpcomment").'</option>'; |
| 686 |
$html_input .= '<option value="not">'. __('not', "wpcomment").'</option>'; |
| 687 |
$html_input .= '<option value="greater than">'. __('greater than', "wpcomment").'</option>'; |
| 688 |
$html_input .= '<option value="less than">'. __('less than', "wpcomment").'</option>'; |
| 689 |
$html_input .= '</select> '; |
| 690 |
$html_input .= '</div>'; |
| 691 |
|
| 692 |
// conditional elements values |
| 693 |
$html_input .= '<div class="col-md-4 col-sm-4">'; |
| 694 |
|
| 695 |
$html_input .= '<select data-metatype="element_values" class="wpcomment-conditional-keys form-control"></select>'; |
| 696 |
|
| 697 |
|
| 698 |
// $html_input .= '<input type="text" class="form-control wpcomment-conditional-keys" placeholder="Enter Option" data-metatype="element_values">'; |
| 699 |
$html_input .= '</div>'; |
| 700 |
|
| 701 |
// Add and remove btn |
| 702 |
$html_input .= '<div class="col-md-2 col-sm-2">'; |
| 703 |
$html_input .= '<button class="btn btn-success wpcomment-add-rule" data-index="5"><i class="fa fa-plus" aria-hidden="true"></i></button>'; |
| 704 |
$html_input .= '</div>'; |
| 705 |
|
| 706 |
$html_input .= '</div>'; |
| 707 |
$html_input .= '</div>'; |
| 708 |
} |
| 709 |
$html_input .= '<input type="hidden" class="wpcomment-condition-last-id" value="'.esc_attr($condition_index).'">'; |
| 710 |
|
| 711 |
break; |
| 712 |
|
| 713 |
case 'pre-images' : |
| 714 |
|
| 715 |
$html_input .= '<div class="pre-upload-box table-responsive">'; |
| 716 |
|
| 717 |
$html_input .= '<button class="btn btn-info wpcomment-pre-upload-image-btn" data-metatype="images">'.__('Select/Upload Image', "wpcomment").'</button>'; |
| 718 |
// wpcomment_pa($value); |
| 719 |
|
| 720 |
$opt_index0 = 0; |
| 721 |
$html_input .= '<ul class="wpcomment-options-container">'; |
| 722 |
if ($values) { |
| 723 |
|
| 724 |
$last_array_id = max(array_keys($values)); |
| 725 |
|
| 726 |
foreach ($values as $opt_index => $pre_uploaded_image){ |
| 727 |
|
| 728 |
$image_link = (isset($pre_uploaded_image['link']) ? $pre_uploaded_image['link'] : ''); |
| 729 |
$image_id = (isset($pre_uploaded_image['id']) ? $pre_uploaded_image['id'] : ''); |
| 730 |
$image_url = (isset($pre_uploaded_image['url']) ? $pre_uploaded_image['url'] : ''); |
| 731 |
|
| 732 |
$image_name = isset($pre_uploaded_image['link']) ? basename($pre_uploaded_image['link']) : ''; |
| 733 |
|
| 734 |
$html_input .= '<li class="data-options" data-condition-type="image_options">'; |
| 735 |
$html_input .= '<span class="dashicons dashicons-move" style="margin-bottom: 7px;margin-top: 2px;"></span>'; |
| 736 |
$html_input .= '<span class="wpcomment-uploader-img-title">'.$image_name.'</span>'; |
| 737 |
$html_input .= '<div style="display: flex;">'; |
| 738 |
$html_input .= '<div class="wpcomment-uploader-img-center">'; |
| 739 |
$html_input .= '<img width="60" src="'.esc_url($image_link).'" style="width: 34px;">'; |
| 740 |
$html_input .= '</div>'; |
| 741 |
$html_input .= '<input type="hidden" name="wpcomment['.esc_attr($field_index).'][images]['.esc_attr($opt_index).'][link]" value="'.esc_url($image_link).'" data-opt-index="'.esc_attr($opt_index).'" data-metatype="link">'; |
| 742 |
$html_input .= '<input type="hidden" name="wpcomment['.esc_attr($field_index).'][images]['.esc_attr($opt_index).'][id]" value="'.esc_attr($image_id).'" data-opt-index="'.esc_attr($opt_index).'" data-metatype="id">'; |
| 743 |
$html_input .= '<input class="form-control wpcomment-image-option-title" type="text" placeholder="Title" value="'.esc_attr(stripslashes($pre_uploaded_image['title'])).'" name="wpcomment['.esc_attr($field_index).'][images]['.esc_attr($opt_index).'][title]" data-opt-index="'.esc_attr($opt_index).'" data-metatype="title">'; |
| 744 |
// $html_input .= '<input class="form-control" type="text" placeholder="URL" value="'.esc_url(stripslashes($pre_uploaded_image['url'])).'" name="wpcomment['.esc_attr($field_index).'][images]['.esc_attr($opt_index).'][url]" data-opt-index="'.esc_attr($opt_index).'" data-metatype="url">'; |
| 745 |
|
| 746 |
$html_input .= '<button class="btn btn-danger wpcomment-pre-upload-delete" style="height: 35px;"><i class="fa fa-times" aria-hidden="true"></i></button>'; |
| 747 |
$html_input .= '</div>'; |
| 748 |
$html_input .= '</li>'; |
| 749 |
|
| 750 |
$opt_index0 = $last_array_id; |
| 751 |
$opt_index0++; |
| 752 |
} |
| 753 |
} |
| 754 |
$html_input .= '</ul>'; |
| 755 |
$html_input .= '<input type="hidden" id="wpcomment-meta-opt-index" value="'.esc_attr($opt_index0).'">'; |
| 756 |
|
| 757 |
$html_input .= '</div>'; |
| 758 |
|
| 759 |
break; |
| 760 |
|
| 761 |
case 'imageselect' : |
| 762 |
|
| 763 |
$html_input .= '<div class="pre-upload-box table-responsive">'; |
| 764 |
|
| 765 |
$html_input .= '<button class="btn btn-info wpcomment-pre-upload-image-btn" data-metatype="imageselect">'.__('Select/Upload Image', "wpcomment").'</button>'; |
| 766 |
|
| 767 |
$opt_index0 = 0; |
| 768 |
$html_input .= '<ul class="wpcomment-options-container">'; |
| 769 |
if ($values && is_array($values)) { |
| 770 |
|
| 771 |
$last_array_id = max(array_keys($values)); |
| 772 |
|
| 773 |
foreach ($values as $opt_index => $pre_uploaded_image){ |
| 774 |
|
| 775 |
$image_link = (isset($pre_uploaded_image['link']) ? $pre_uploaded_image['link'] : ''); |
| 776 |
$image_id = (isset($pre_uploaded_image['id']) ? $pre_uploaded_image['id'] : ''); |
| 777 |
$image_description = (isset($pre_uploaded_image['description']) ? $pre_uploaded_image['description'] : ''); |
| 778 |
|
| 779 |
$image_name = isset($pre_uploaded_image['link']) ? basename($pre_uploaded_image['link']) : ''; |
| 780 |
|
| 781 |
$html_input .= '<li class="data-options" data-condition-type="image_options">'; |
| 782 |
$html_input .= '<span class="dashicons dashicons-move" style="margin-bottom: 7px;margin-top: 2px;"></span>'; |
| 783 |
$html_input .= '<span class="wpcomment-uploader-img-title">'.$image_name.'</span>'; |
| 784 |
$html_input .= '<div style="display: flex;">'; |
| 785 |
$html_input .= '<div class="wpcomment-uploader-img-center">'; |
| 786 |
$html_input .= '<img width="60" src="'.esc_url($image_link).'" style="width: 34px;">'; |
| 787 |
$html_input .= '</div>'; |
| 788 |
$html_input .= '<input type="hidden" name="wpcomment['.esc_attr($field_index).'][images]['.esc_attr($opt_index).'][link]" value="'.esc_url($image_link).'" data-opt-index="'.esc_attr($opt_index).'" data-metatype="link">'; |
| 789 |
$html_input .= '<input type="hidden" name="wpcomment['.esc_attr($field_index).'][images]['.esc_attr($opt_index).'][id]" value="'.esc_attr($image_id).'" data-opt-index="'.esc_attr($opt_index).'" data-metatype="id">'; |
| 790 |
$html_input .= '<input class="form-control wpcomment-image-option-title" type="text" placeholder="Title" value="'.esc_attr(stripslashes($pre_uploaded_image['title'])).'" name="wpcomment['.esc_attr($field_index).'][images]['.esc_attr($opt_index).'][title]" data-opt-index="'.esc_attr($opt_index).'" data-metatype="title">'; |
| 791 |
$html_input .= '<input class="form-control" type="text" placeholder="Price" value="'.esc_attr(stripslashes($pre_uploaded_image['price'])).'" name="wpcomment['.esc_attr($field_index).'][images]['.esc_attr($opt_index).'][price]" data-opt-index="'.esc_attr($opt_index).'" data-metatype="price">'; |
| 792 |
$html_input .= '<input class="form-control" type="text" placeholder="Description" value="'.esc_attr($image_description).'" name="wpcomment['.esc_attr($field_index).'][images]['.esc_attr($opt_index).'][description]" data-opt-index="'.esc_attr($opt_index).'" data-metatype="description">'; |
| 793 |
$html_input .= '<button class="btn btn-danger wpcomment-pre-upload-delete" style="height: 35px;"><i class="fa fa-times" aria-hidden="true"></i></button>'; |
| 794 |
$html_input .= '</div>'; |
| 795 |
$html_input .= '</li>'; |
| 796 |
|
| 797 |
$opt_index0 = $last_array_id; |
| 798 |
$opt_index0++; |
| 799 |
} |
| 800 |
} |
| 801 |
$html_input .= '</ul>'; |
| 802 |
$html_input .= '<input type="hidden" id="wpcomment-meta-opt-index" value="'.esc_attr($opt_index0).'">'; |
| 803 |
|
| 804 |
$html_input .= '</div>'; |
| 805 |
|
| 806 |
break; |
| 807 |
|
| 808 |
case 'pre-audios' : |
| 809 |
|
| 810 |
$html_input .= '<div class="pre-upload-box">'; |
| 811 |
$html_input .= '<button class="btn btn-info wpcomment-pre-upload-image-btn" data-metatype="audio">'.__('Select Audio/Video', "wpcomment").'</button>'; |
| 812 |
|
| 813 |
$html_input .= '<ul class="wpcomment-options-container">'; |
| 814 |
$opt_index0 = 0; |
| 815 |
// wpcomment_pa($values); |
| 816 |
if ($values) { |
| 817 |
$last_array_id = max(array_keys($values)); |
| 818 |
foreach ($values as $opt_index => $pre_uploaded_image){ |
| 819 |
|
| 820 |
$image_link = (isset($pre_uploaded_image['link']) ? $pre_uploaded_image['link'] : ''); |
| 821 |
$image_id = (isset($pre_uploaded_image['id']) ? $pre_uploaded_image['id'] : ''); |
| 822 |
$image_url = (isset($pre_uploaded_image['url']) ? $pre_uploaded_image['url'] : ''); |
| 823 |
$media_title = (isset($pre_uploaded_image['title']) ? stripslashes($pre_uploaded_image['title']) : ''); |
| 824 |
$media_price = (isset($pre_uploaded_image['price']) ? stripslashes($pre_uploaded_image['price']) : ''); |
| 825 |
|
| 826 |
$html_input .= '<li class="data-options">'; |
| 827 |
$html_input .= '<span class="dashicons dashicons-move" style="margin-bottom: 7px;margin-top: 2px;"></span>'; |
| 828 |
$html_input .= '<div style="display: flex;">'; |
| 829 |
$html_input .= '<div class="wpcomment-uploader-img-center">'; |
| 830 |
$html_input .= '<span class="dashicons dashicons-admin-media" style="margin-top: 5px;"></span>'; |
| 831 |
$html_input .= '</div>'; |
| 832 |
$html_input .= '<input type="hidden" name="wpcomment['.esc_attr($field_index).'][audio]['.esc_attr($opt_index).'][link]" value="'.esc_url($image_link).'" data-opt-index="'.esc_attr($opt_index).'" data-metatype="link">'; |
| 833 |
$html_input .= '<input type="hidden" name="wpcomment['.esc_attr($field_index).'][audio]['.esc_attr($opt_index).'][id]" value="'.esc_attr($image_id).'" data-opt-index="'.esc_attr($opt_index).'" data-metatype="id">'; |
| 834 |
$html_input .= '<input class="form-control" type="text" placeholder="Title" value="'.esc_attr($media_title).'" name="wpcomment['.esc_attr($field_index).'][audio]['.esc_attr($opt_index).'][title]" data-opt-index="'.esc_attr($opt_index).'" data-metatype="title">'; |
| 835 |
$html_input .= '<input class="form-control" type="text" placeholder="Price (fix or %)" value="'.esc_attr($media_price).'" name="wpcomment['.esc_attr($field_index).'][audio]['.esc_attr($opt_index).'][price]" data-opt-index="'.esc_attr($opt_index).'" data-metatype="price">'; |
| 836 |
$html_input .= '<button class="btn btn-danger wpcomment-pre-upload-delete" style="height: 35px;"><i class="fa fa-times" aria-hidden="true"></i></button>'; |
| 837 |
$html_input .= '</div>'; |
| 838 |
$html_input .= '</li>'; |
| 839 |
|
| 840 |
$opt_index0 = $last_array_id; |
| 841 |
$opt_index0++; |
| 842 |
|
| 843 |
} |
| 844 |
} |
| 845 |
$html_input .= '</ul>'; |
| 846 |
$html_input .= '<input type="hidden" id="wpcomment-meta-opt-index" value="'.esc_attr($opt_index0).'">'; |
| 847 |
$html_input .= '</div>'; |
| 848 |
|
| 849 |
break; |
| 850 |
} |
| 851 |
|
| 852 |
return apply_filters('wpcomment_render_input_types', $html_input, $type, $name, $values, $options, $field_index); |
| 853 |
} |
| 854 |
|
| 855 |
|
| 856 |
function wpcomment_fields_tabs($fields_type){ |
| 857 |
|
| 858 |
$tabs = array(); |
| 859 |
|
| 860 |
$tabs = array ( |
| 861 |
'fields_tab' => array ( |
| 862 |
'label' => __ ( 'Fields', 'wp-comment-fields' ), |
| 863 |
'class' => array('wpcomment-tabs-label', 'wpcomment-active-tab'), |
| 864 |
'field_depend'=> array('all') |
| 865 |
), |
| 866 |
'condition_tab' => array ( |
| 867 |
'label' => __ ( 'Conditions', 'wp-comment-fields' ), |
| 868 |
'class' => array('wpcomment-tabs-label','wpcomment-condition-tab-js'), |
| 869 |
'field_depend'=> array('all'), |
| 870 |
'not_allowed'=> array('hidden','koll') |
| 871 |
), |
| 872 |
'add_option_tab' => array ( |
| 873 |
'label' => __ ( 'Add Options', 'wp-comment-fields' ), |
| 874 |
'class' => array('wpcomment-tabs-label'), |
| 875 |
'field_depend'=> array('select','radio','checkbox','cropper', 'cropper2', 'quantities','pricematrix','palettes','fixedprice','bulkquantity') |
| 876 |
), |
| 877 |
'add_images_tab' => array ( |
| 878 |
'label' => __ ( 'Add Images', 'wp-comment-fields' ), |
| 879 |
'class' => array('wpcomment-tabs-label'), |
| 880 |
'field_depend'=> array('image','imageselect') |
| 881 |
), |
| 882 |
'add_audio_video_tab' => array ( |
| 883 |
'label' => __ ( 'Add Audio/Video', 'wp-comment-fields' ), |
| 884 |
'class' => array('wpcomment-tabs-label'), |
| 885 |
'field_depend'=> array('audio') |
| 886 |
), |
| 887 |
|
| 888 |
// Font Picker Addon tabs |
| 889 |
'fonts_family_tab' => array ( |
| 890 |
'label' => __ ( 'Fonts Family', 'wp-comment-fields' ), |
| 891 |
'class' => array('wpcomment-tabs-label'), |
| 892 |
'field_depend'=> array('fonts') |
| 893 |
), |
| 894 |
'custom_fonts_tab' => array ( |
| 895 |
'label' => __ ( 'Custom Fonts', 'wp-comment-fields' ), |
| 896 |
'class' => array('wpcomment-tabs-label'), |
| 897 |
'field_depend'=> array('fonts') |
| 898 |
), |
| 899 |
|
| 900 |
'image_dimension_tab' => array ( |
| 901 |
'label' => __ ( 'Image Dimensions', 'wp-comment-fields' ), |
| 902 |
'class' => array('wpcomment-tabs-label'), |
| 903 |
'field_depend'=> array('file') |
| 904 |
), |
| 905 |
|
| 906 |
|
| 907 |
); |
| 908 |
|
| 909 |
return apply_filters('wpcomment_fields_tabs_show', $tabs, $fields_type); |
| 910 |
|
| 911 |
} |
| 912 |
|
| 913 |
|
| 914 |
function wpcomment_tabs_panel_classes($settings){ |
| 915 |
|
| 916 |
|
| 917 |
foreach ($settings as $fields_meta_key => $meta) { |
| 918 |
|
| 919 |
$type = isset($meta['type']) ? $meta['type'] : ''; |
| 920 |
|
| 921 |
if ($type == 'html-conditions') { |
| 922 |
|
| 923 |
$settings['conditions']['tabs_class'] = array('wpcomment_handle_condition_tab','col-md-12'); |
| 924 |
}else if($type == 'paired' || $type == 'paired-cropper' |
| 925 |
|| $type == 'paired-quantity' || |
| 926 |
$type == 'paired-pricematrix' || |
| 927 |
$type == 'bulk-quantity' || $type == 'paired-palettes') { |
| 928 |
//Bulk Quantity Addon Tabs |
| 929 |
//Fixed Price Addon Tabs |
| 930 |
|
| 931 |
$settings['options']['tabs_class'] = array('wpcomment_handle_add_option_tab','col-md-12'); |
| 932 |
}else if( $type == 'pre-images' || $type == 'imageselect') { // Image DropDown Addon Tabs |
| 933 |
|
| 934 |
$settings['images']['tabs_class'] = array('wpcomment_handle_add_images_tab','col-md-12'); |
| 935 |
}else if( $type == 'pre-audios' ) { |
| 936 |
|
| 937 |
$settings['audio']['tabs_class'] = array('wpcomment_handle_add_audio_video_tab','col-md-12'); |
| 938 |
}else if($fields_meta_key== 'logic') { |
| 939 |
|
| 940 |
$settings['logic']['tabs_class'] = array('wpcomment_handle_condition_tab','col-md-12'); |
| 941 |
} |
| 942 |
|
| 943 |
// Fonts Picker Addon tabs |
| 944 |
if ($fields_meta_key == 'fonts') { |
| 945 |
$settings['fonts']['tabs_class'] = array('wpcomment_handle_fonts_family_tab','col-md-12'); |
| 946 |
}elseif ($fields_meta_key == 'custom_fonts') { |
| 947 |
$settings['custom_fonts']['tabs_class'] = array('wpcomment_handle_custom_fonts_tab','col-md-12'); |
| 948 |
} |
| 949 |
|
| 950 |
// Image Dimensions Options (File Input) |
| 951 |
if ($fields_meta_key == 'min_img_h') { |
| 952 |
$settings['min_img_h']['tabs_class'] = array('wpcomment_handle_image_dimension_tab','col-md-6'); |
| 953 |
$settings['max_img_h']['tabs_class'] = array('wpcomment_handle_image_dimension_tab','col-md-6'); |
| 954 |
$settings['min_img_w']['tabs_class'] = array('wpcomment_handle_image_dimension_tab','col-md-6'); |
| 955 |
$settings['max_img_w']['tabs_class'] = array('wpcomment_handle_image_dimension_tab','col-md-6'); |
| 956 |
$settings['img_dimension_error']['tabs_class'] = array('wpcomment_handle_image_dimension_tab','col-md-6'); |
| 957 |
} |
| 958 |
|
| 959 |
} |
| 960 |
|
| 961 |
return apply_filters('wpcomment_tabs_panel_classes', $settings); |
| 962 |
} |
| 963 |
|
| 964 |
} |
| 965 |
|
| 966 |
WPCOMMENT_FIELDS_META(); |
| 967 |
function WPCOMMENT_FIELDS_META(){ |
| 968 |
return WPComment_Fields_Meta::get_instance(); |
| 969 |
} |