<?php if (!st_check_service_available('st_cars')) { return; } if (function_exists('vc_map') and class_exists('TravelerObject')) { $list_taxonomy = st_list_taxonomy('st_cars'); $list_taxonomy = array_merge(array("---Select---" => ""), $list_taxonomy); $list_location = TravelerObject::get_list_location(); $list_location_data[__('-- Select --', ST_TEXTDOMAIN)] = ''; if (!empty($list_location)) { foreach ($list_location as $k => $v) { $list_location_data[$v['title']] = $v['id']; } } $param = array(array("type" => "textfield", "holder" => "div", "heading" => __("List ID in Car", ST_TEXTDOMAIN), "param_name" => "st_ids", "description" => __("Ids separated by commas", ST_TEXTDOMAIN), 'value' => ""), array("type" => "textfield", "holder" => "div", "heading" => __("Number cars", ST_TEXTDOMAIN), "param_name" => "st_number_cars", "description" => "", 'value' => 4), array("type" => "dropdown", "holder" => "div", "heading" => __("Order By", ST_TEXTDOMAIN), "param_name" => "st_orderby", "description" => "", 'edit_field_class' => 'vc_col-sm-6', 'value' => function_exists('st_get_list_order_by') ? st_get_list_order_by(array(__('Sale', ST_TEXTDOMAIN) => 'sale', __('Featured', ST_TEXTDOMAIN) => 'featured')) : array()), array("type" => "dropdown", "holder" => "div", "heading" => __("Order", ST_TEXTDOMAIN), "param_name" => "st_order", 'value' => array(__('--Select--', ST_TEXTDOMAIN) => '', __('Asc', ST_TEXTDOMAIN) => 'asc', __('Desc', ST_TEXTDOMAIN) => 'desc'), 'edit_field_class' => 'vc_col-sm-6'), array("type" => "dropdown", "holder" => "div", "heading" => __("Items per row", ST_TEXTDOMAIN), "param_name" => "st_cars_of_row", 'edit_field_class' => 'vc_col-sm-12', "value" => array(__('--Select--', ST_TEXTDOMAIN) => '', __('Four', ST_TEXTDOMAIN) => 4, __('Three', ST_TEXTDOMAIN) => 3, __('Two', ST_TEXTDOMAIN) => 2)), array("type" => "dropdown", "holder" => "div", "heading" => __("Sort By Taxonomy", ST_TEXTDOMAIN), "param_name" => "sort_taxonomy", "description" => "", "value" => $list_taxonomy)); $data_vc = STCars::get_taxonomy_and_id_term_car(); $param = array_merge($param, $data_vc['list_vc']); vc_map(array("name" => __("ST List of Cars", ST_TEXTDOMAIN), "base" => "st_list_cars", "content_element" => true, "icon" => "icon-st", "category" => "Shinetheme", "params" => $param)); } if (!function_exists('st_vc_list_cars')) { function st_vc_list_cars($attr, $content = false) { $data_vc = STCars::get_taxonomy_and_id_term_car(); $param = array('st_ids' => '', 'taxonomy' => '', 'st_number_cars' => 4, 'st_order' => '', 'st_orderby' => '', 'st_cars_of_row' => 4, 'sort_taxonomy' => '', 'st_location' => ''); $param = array_merge($param, $data_vc['list_id_vc']); $data = wp_parse_args($attr, $param); extract($data); $query = array('post_type' => 'st_cars', 'posts_per_page' => $st_number_cars, 'order' => $st_order, 'orderby' => $st_orderby); if (!empty($st_ids)) { $query['post__in'] = explode(',', $st_ids);
public function form($instance) { // title // list post type checkbox // review checkbox // location select if (isset($instance['title'])) { $title = $instance['title']; } else { $title = __('Title', ST_TEXTDOMAIN); } if (isset($instance['post_type'])) { $post_type = $instance['post_type']; } if (isset($instance['count_review'])) { $count_review = $instance['count_review']; } ?> <div class='location_widget_item'> <p> <label ><?php echo balancetags("Title", ST_TEXTDOMAIN); ?> </label> <input value='<?php echo esc_attr($title); ?> ' type='text' name='<?php echo $this->get_field_name('title'); ?> '/> </p> <p> <label><?php echo balancetags("Post type select ", ST_TEXTDOMAIN); ?> </label> <?php $get_post_type_list_active = STLocation::get_post_type_list_active(); if (!empty($get_post_type_list_active) and is_array($get_post_type_list_active)) { foreach (STLocation::get_post_type_list_active() as $key => $value) { ?> <br> <input <?php if (!empty($post_type) and $post_type and in_array($value, $post_type)) { echo esc_attr('checked'); } ?> id ='<?php echo esc_attr("st_w_" . $value); ?> ' value = '<?php echo esc_attr($value); ?> ' type='checkbox' name='<?php echo balancetags($this->get_field_name('post_type')); ?> []'/> <label ><?php echo esc_attr(STLocation::get_post_type_name($value, true)); ?> </label> <?php } } ?> </p> <p> <label><?php echo balancetags("Count Review", ST_TEXTDOMAIN); ?> </label> <input <?php if (!empty($count_review) and $count_review == 'on') { echo "checked"; } ?> type='checkbox' name='<?php echo balancetags($this->get_field_name('count_review')); ?> '/> </p> <p> <label><?php echo esc_attr("Location select", ST_TEXTDOMAIN); ?> </label> <?php $list_location = TravelerObject::get_list_location(); if (!empty($instance['location'])) { $old_location = $instance['location']; } //$old_location = $instance['location']; ?> <select name="<?php echo balancetags($this->get_field_name('location')); ?> " class="form-control"> <option value=""><?php _e('-- Select --', ST_TEXTDOMAIN); ?> </option> <?php foreach ($list_location as $k => $v) { ?> <option <?php if (!empty($old_location) and $old_location == $v['id']) { echo 'selected'; } ?> value="<?php echo esc_html($v['id']); ?> "> <?php echo esc_html($v['title']); ?> </option> <?php } ?> </select> </p> </div> <?php }