public function edit_extra($id = 0) { $wpdevart_extras = array('extra_field1' => array('name' => 'extra_field1', 'label' => __('Adults', 'booking-calendar'), 'type' => 'extras_field', 'items' => array('field_item1' => array('name' => 'field_item1', 'label' => '1', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '1'), 'field_item2' => array('name' => 'field_item2', 'label' => '2', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '2'), 'field_item3' => array('name' => 'field_item3', 'label' => '3', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '3'), 'field_item4' => array('name' => 'field_item4', 'label' => '4', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '4')), 'default' => ''), 'extra_field2' => array('name' => 'extra_field2', 'label' => __('Children ', 'booking-calendar'), 'type' => 'extras_field', 'items' => array('field_item1' => array('name' => 'field_item1', 'label' => '1', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '1'), 'field_item2' => array('name' => 'field_item2', 'label' => '2', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '2'), 'field_item3' => array('name' => 'field_item3', 'label' => '3', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '3'), 'field_item4' => array('name' => 'field_item4', 'label' => '4', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '4')), 'default' => '')); if ($id != 0) { $extra_rows = $this->model_obj->get_extra_rows($id); $value = json_decode($extra_rows->data, true); $wpdevart_extras = $value; $last_element = end($wpdevart_extras); $max_id = str_replace('extra_field', '', $last_element['name']); } else { $max_id = 2; } ?> <div id="wpdevart_extras" class="wpdevart-item-container wpdevart-main-item-container"> <?php if ($id != 0) { ?> <div class="div-for-clear"> <span class="admin_logo"></span> <h1>Edit Extra <a href="http://wpdevart.com/wordpress-booking-calendar-plugin/"><span class="pro_feature"> (Upgrade to Pro Version)</span></a></h1> </div> <?php } else { ?> <div class="div-for-clear"> <span class="admin_logo"></span> <h1>Edit Extra <a href="http://wpdevart.com/wordpress-booking-calendar-plugin/"><span class="pro_feature"> (Upgrade to Pro Version)</span></a></h1> </div> <?php } ?> <form action="?page=wpdevart-extras" method="post"> <div id="wpdevart_wpdevart-item_title"> <span>Extra Name</span> <input type="text" name="title" value="<?php if (isset($extra_rows->title)) { echo esc_attr($extra_rows->title); } ?> "> <input type="submit" value="Save" class="action-link wpda-input" name="save"> <input type="submit" value="Apply" class="action-link wpda-input" name="apply"> <div id="add_field_container"> <div id="add_extra_field" data-max="<?php echo $max_id; ?> "> </div> </div> </div> <?php ?> <div class="wpdevart-item-section"> <h3>Extras fields</h3> <div class="wpdevart-item-section-cont"> <?php foreach ($wpdevart_extras as $key => $wpdevart_extra) { $sett_value = $wpdevart_extras[$key]; wpdevart_bc_Library::wpdevart_extras_field($wpdevart_extra, $sett_value); } ?> <div id="new_extra_fields"> </div> </div> </div> <input type="hidden" name="task" value="save"> <input type="hidden" name="id" value="<?php echo $id; ?> "> </form> </div> <?php }
public function wpdevart_add_extra_field() { $max_id = 0; $count = 0; if (isset($_POST['wpdevart_extra_field_max'])) { $max_id = esc_html($_POST['wpdevart_extra_field_max']); } if (isset($_POST['wpdevart_extra_field_count'])) { $count = esc_html($_POST['wpdevart_extra_field_count']); } $args = array('name' => 'extra_field' . ($max_id + 1 + $count), 'label' => __('New Extra', 'booking-calendar'), 'type' => 'extras_field', 'items' => array('field_item1' => array('name' => 'field_item1', 'label' => '1', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '1'), 'field_item2' => array('name' => 'field_item2', 'label' => '2', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '2'), 'field_item3' => array('name' => 'field_item3', 'label' => '3', 'operation' => '+', 'price_type' => 'price', 'price_percent' => '0', 'order' => '3')), 'default' => ''); wpdevart_bc_Library::wpdevart_extras_field($args, $args); wp_die(); }