<?php } else { echo '<label>' . get_the_title($field) . '</label>'; if (!imic_array_empty($specs)) { echo '<select data-empty="true" id="field-' . ($field + 2648) . '" name="' . esc_attr($spec_slug) . '" class="form-control selectpicker ' . $get_child . '"> <option disabled value="" selected>' . __('Any', 'framework') . '</option>'; foreach ($specs as $spec) { echo '<option value="' . esc_attr($spec['imic_plugin_specification_values']) . '">' . esc_attr($spec['imic_plugin_specification_values']) . '</option>'; } echo '</select>'; } else { echo '<input type="text" name="' . esc_attr($spec_slug) . '" value="" class="form-control">'; } } echo '</div>'; if (imic_get_child_values_status($specs) == 1) { //echo "saibaba"; $child_label = get_post_meta($field, 'imic_plugin_sub_field_label', true); echo '<div class="col-md-3 col-sm-3" id="field-' . ($field * 111 + 2648) . '"> <label>' . $child_label . '</label>'; echo '<select data-empty="true" name="' . esc_attr($child_label) . '" class="form-control selectpicker"> <option disabled value="" selected>' . __('Select ', 'framework') . get_the_title($field) . '</option>'; echo '</select>'; echo '</div>'; } } } else { echo '<div class="col-md-12">'; echo esc_attr_e('Please select search fields from Theme Options', 'framework'); echo '</div>'; }
} elseif ($int == 1) { if ($numeric_specs_type == 0) { $spec_slug = "int_" . imic_the_slug($field); } else { $spec_slug = "range_" . imic_the_slug($field); $min_val = get_post_meta($field, 'imic_plugin_range_min_value', true); $max_val = get_post_meta($field, 'imic_plugin_range_max_value', true); $steps = get_post_meta($field, 'imic_plugin_range_steps', true); $min_val = $min_val != '' ? $min_val : 0; $max_val = $max_val != '' ? $max_val : 100000; $steps = $steps != '' ? $steps : 1000; } } elseif ($int == 2) { $spec_slug = "char_" . imic_the_slug($field); } $get_child = imic_get_child_values_status($specs) == 1 ? 'get-child-field' : ''; echo '<div class="col-md-4 col-sm-4">'; if ($int == 1) { ?> <b><?php echo esc_attr(get_the_title($field)); echo ' ' . $value_label; ?> <input class="search-range" type="hidden" name="<?php echo esc_attr($spec_slug); ?> " value=""><span class="left"><?php echo esc_attr($min_val); ?> </span> - <span class="right"><?php
function imic_search($atts, $content = null) { extract(shortcode_atts(array("title" => "", "option" => 1, "column" => 12), $atts)); $output = ''; global $imic_options; $form_class = $option == 1 ? 'search1' : 'search2'; $listing_url = imic_get_template_url("template-listing.php"); $listing_id = imic_get_template_id('template-listing.php'); $output = '<form class="' . $form_class . '" method="get" action="' . esc_url($listing_url) . '"> <input type="hidden" value="' . esc_attr($listing_id) . '" name="page_id"> <div class="row">'; if ($option == 1) { $search_fields = isset($imic_options['search_widget1']) ? $imic_options['search_widget1'] : array(); } else { $search_fields = isset($imic_options['search_widget2']) ? $imic_options['search_widget2'] : array(); } $count = 1; if (!empty($search_fields)) { foreach ($search_fields as $field) { if (class_exists('SitePress') && ICL_LANGUAGE_CODE == imic_langcode_post_id($field)) { $specs = get_post_meta($field, 'specifications_value', true); $int = get_post_meta($field, 'imic_plugin_spec_char_type', true); if ($int == 0) { $spec_slug = imic_the_slug($field); } else { $spec_slug = "int_" . imic_the_slug($field); } $get_child = imic_get_child_values_status($specs) == 1 ? 'get-child-field' : ''; $output .= '<div class="col-md-' . esc_attr($column) . ' col-sm-' . esc_attr($column) . '"> <label>' . get_the_title($field) . '</label>'; if (!imic_array_empty($specs)) { $output .= '<select data-empty="true" id="' . $option . 'field-' . ($field + 2648) . '" name="' . esc_attr($spec_slug) . '" class="form-control selectpicker ' . $get_child . '"> <option disabled value="" selected>' . __('Any', 'framework') . '</option>'; foreach ($specs as $spec) { $output .= '<option value="' . esc_attr($spec['imic_plugin_specification_values']) . '">' . esc_attr($spec['imic_plugin_specification_values']) . '</option>'; } $output .= '</select>'; } else { $output .= '<input type="text" name="' . esc_attr($spec_slug) . '" value="" class="form-control">'; } $output .= '</div>'; if (imic_get_child_values_status($specs) == 1) { //echo "saibaba"; $child_label = get_post_meta($field, 'imic_plugin_sub_field_label', true); $output .= '<div class="col-md-' . esc_attr($column) . ' col-sm-' . esc_attr($column) . '" id="' . $option . 'field-' . ($field * 111 + 2648) . '"> <label>' . $child_label . '</label>'; $output .= '<select data-empty="true" name="' . esc_attr($child_label) . '" class="form-control selectpicker"> <option disabled value="" selected>' . __('Select ', 'framework') . get_the_title($field) . '</option>'; $output .= '</select>'; $output .= '</div>'; } } else { $specs = get_post_meta($field, 'specifications_value', true); $int = get_post_meta($field, 'imic_plugin_spec_char_type', true); if ($int == 0) { $spec_slug = imic_the_slug($field); } else { $spec_slug = "int_" . imic_the_slug($field); } $get_child = imic_get_child_values_status($specs) == 1 ? 'get-child-field' : ''; $output .= '<div class="col-md-' . esc_attr($column) . ' col-sm-' . esc_attr($column) . '"> <label>' . get_the_title($field) . '</label>'; if (!imic_array_empty($specs)) { $output .= '<select data-empty="true" id="' . $option . 'field-' . ($field + 2648) . '" name="' . esc_attr($spec_slug) . '" class="form-control selectpicker ' . $get_child . '"> <option disabled value="" selected>' . __('Any', 'framework') . '</option>'; foreach ($specs as $spec) { $output .= '<option value="' . esc_attr($spec['imic_plugin_specification_values']) . '">' . esc_attr($spec['imic_plugin_specification_values']) . '</option>'; } $output .= '</select>'; } else { $output .= '<input type="text" name="' . esc_attr($spec_slug) . '" value="" class="form-control">'; } $output .= '</div>'; if (imic_get_child_values_status($specs) == 1) { //echo "saibaba"; $child_label = get_post_meta($field, 'imic_plugin_sub_field_label', true); $output .= '<div class="col-md-' . esc_attr($column) . ' col-sm-' . esc_attr($column) . '" id="' . $option . 'field-' . ($field * 111 + 2648) . '"> <label>' . $child_label . '</label>'; $output .= '<select data-empty="true" name="' . esc_attr($child_label) . '" class="form-control selectpicker"> <option disabled value="" selected>' . __('Select ', 'framework') . get_the_title($field) . '</option>'; $output .= '</select>'; $output .= '</div>'; } } } } else { $output .= '<div class="col-md-12">'; $output .= esc_attr__('Please select search fields from Theme Options', 'framework'); $output .= '</div>'; } $output .= '</div> <div class="row"> <div class="col-md-6"> </div> <div class="col-md-6"> <input type="submit" class="btn btn-block btn-info btn-lg" value="' . esc_attr__('Search', 'framework') . '"> </div> </div> </form>'; return $output; }
/** * Print the Meta Box content */ function imic_event_feilds_output() { global $post, $line_icons; global $ints; // Add an nonce field so we can check for it later. wp_nonce_field('event_schedule_meta_box', 'event_schedule_meta_box_nonce'); $feat_data = get_post_meta($post->ID, 'feat_data', true); $car_id = $post->ID; ?> <div id="field_group"> <div id="field_wrap"> <?php $specification = get_posts(array('post_type' => 'specification', 'posts_per_page' => -1, 'post_status' => 'publish', 'meta_query' => array(array('key' => 'imic_plugin_show_for_vehicle', 'value' => '1', 'compare' => '=')))); $ids = $ints = $chars = array(); foreach ($specification as $post_specs) { $int = get_post_meta($post_specs->ID, 'imic_plugin_spec_char_type', true); if ($int == 0) { $ids[] = $post_specs->ID; } elseif ($int == 2) { $chars[] = $post_specs->ID; } elseif ($int == 1) { $ints[] = $post_specs->ID; } } $ids = imic_filter_lang_specs_plugin($ids); $chars = imic_filter_lang_specs_plugin($chars); $ints = imic_filter_lang_specs_plugin($ints); $i = 0; foreach ($ids as $id) { $spec_key = 'ss'; $title = $position = $spec_value = $this_id = ''; if (!empty($feat_data['sch_title'])) { if (in_array($id, $feat_data['sch_title'])) { $spec_key = array_search($id, $feat_data['sch_title']); } elseif (in_array($id * 111, $feat_data['sch_title'])) { $spec_key = array_search($id * 111, $feat_data['sch_title']); } else { $spec_key = 'ss'; } } $this_id = $id; if (isset($feat_data['start_time'][$spec_key]) || $spec_key != 'ss') { $spec_value = $feat_data['start_time'][$spec_key]; } if (isset($feat_data['sch_title'][$spec_key]) && $spec_key != 'ss') { $this_id = $feat_data['sch_title'][$spec_key]; } $values = get_post_meta($this_id, 'specifications_value', true); ?> <div class="field_row"> <div class="rwmb-meta-box"> <div class="rwmb-field rwmb-select-wrapper"><div class="rwmb-label"> <label><?php echo get_the_title($this_id); ?> </label></div> <?php if (imic_get_specs_values_status($values) == 1) { ?> <div class="rwmb-input"> <select type="text" class="meta_feat_title rwmb-select" name="featured[start_time][]" > <option value=""><?php _e('Select', 'framework'); ?> </option> <?php foreach ($values as $value) { $select = $spec_value == $value['imic_plugin_specification_values'] ? 'selected="selected"' : ''; echo '<option ' . $select . ' value="' . $value['imic_plugin_specification_values'] . '">' . $value['imic_plugin_specification_values'] . '</option>'; } ?> </select> </div> <?php } else { ?> <div class="rwmb-input"><input type="text" class="meta_feat_title" name="featured[start_time][]" value="<?php echo esc_attr($spec_value); ?> "/></div> <?php } ?> </div> <div class="form_field" style="display:none;"><div class="rwmb-label"> <label><?php _e('Title', 'framework'); ?> </label></div><div class="rwmb-input"> <input type="text" class="meta_sch_title" name="featured[sch_title][]" value="<?php echo esc_attr($this_id); ?> " /></div> </div> <?php if (imic_get_child_values_status($values) == 1) { ?> <div class="rwmb-field rwmb-select-wrapper"><div class="rwmb-label"> <label><?php echo get_post_meta($this_id, 'imic_plugin_sub_field_label', true); ?> </label></div> <div class="rwmb-input"><input type="text" class="meta_feat_title" name="featured[start_time][]" value="<?php echo !empty($feat_data) ? $feat_data['start_time'][array_search($this_id * 111, $feat_data['sch_title'])] : ''; ?> "/></div> </div> <div class="form_field" style="display:none;"><div class="rwmb-label"> <label><?php _e('Title', 'framework'); ?> </label></div><div class="rwmb-input"> <input type="text" class="meta_sch_title" name="featured[sch_title][]" value="<?php echo esc_attr($this_id * 111); ?> " /></div> </div> <?php } ?> </div> <div class="clear" /></div> </div> <?php //} // endif $i++; } // endforeach foreach ($chars as $char) { $values = get_post_meta($char, 'specifications_value', true); $char_slug = imic_the_slug($char); $spec_value = get_post_meta($post->ID, 'char_' . $char_slug, true); ?> <div class="field_row"> <div class="rwmb-meta-box"> <div class="rwmb-field rwmb-select-wrapper"><div class="rwmb-label"> <label><?php echo get_the_title($char); ?> </label></div> <?php if (!empty($values[1])) { $parent_class = imic_get_child_values_status($values) == 1 ? 'parent-spec' : ''; ?> <div class="rwmb-input"> <select type="text" data-specid="<?php echo esc_attr($char); ?> " data-listid="<?php echo esc_attr($post->ID); ?> " class="meta_feat_title rwmb-select <?php echo esc_attr($parent_class); ?> " name="char_<?php echo esc_attr($char_slug); ?> " > <option value=""><?php _e('Select', 'framework'); ?> </option> <?php foreach ($values as $value) { $select = $spec_value == $value['imic_plugin_specification_values'] ? 'selected="selected"' : ''; echo '<option ' . $select . ' value="' . $value['imic_plugin_specification_values'] . '">' . $value['imic_plugin_specification_values'] . '</option>'; } ?> </select> </div> <?php } else { ?> <div class="rwmb-input"><input type="text" class="meta_feat_title" name="char_<?php echo esc_attr($char_slug); ?> " value="<?php echo esc_attr($spec_value); ?> "/></div> <?php } ?> </div> <?php if (!empty($values[0]['imic_plugin_specification_values_child'])) { ?> <div class="rwmb-field rwmb-select-wrapper"><div class="rwmb-label"> <label><?php echo get_post_meta($char, 'imic_plugin_sub_field_label', true); ?> </label></div> <div class="rwmb-input child-spec"> <?php if ($spec_value != '') { $current_value = get_post_meta($post->ID, 'child_' . $char_slug, true); echo '<select type="text" class="meta_feat_title rwmb-select" name="child_' . esc_attr($char_slug) . '">'; foreach ($values as $value) { if ($spec_value == $value['imic_plugin_specification_values']) { $child_vals = $value['imic_plugin_specification_values_child']; $child_vals = explode(',', $child_vals); break; } } foreach ($child_vals as $val) { $selected = $current_value == $val || $current_value == " " . $val ? 'selected' : ''; echo '<option ' . $selected . ' value="' . $val . '">' . $val . '</option>'; } echo '</select>'; } ?> </div> </div> <?php } ?> </div> <div class="clear" /></div> </div> <?php //} // endif $i++; } // endforeach foreach ($ints as $in) { $values = get_post_meta($in, 'specifications_value', true); $integer = get_post_meta($in, 'imic_plugin_spec_char_type', true); $post_id = get_post($in); $spec_slug = $post_id->post_name; ?> <div class="field_row"> <div class="rwmb-meta-box"> <div class="rwmb-field rwmb-select-wrapper"><div class="rwmb-label"> <label><?php echo get_the_title($in); ?> </label></div> <div class="rwmb-input"><input type="text" class="meta_feat_title" name="int_<?php echo esc_attr($spec_slug); ?> " value="<?php echo get_post_meta($car_id, 'int_' . $spec_slug, true); ?> "/></div> </div> </div> <div class="clear" /></div> </div> <?php } //$ids[]=get_the_ID(); //} wp_reset_postdata(); ?> </div></div> <?php }
echo $get_child_filter; ?> " href="#"><?php echo esc_attr($prefix . $tab['imic_plugin_specification_values']); ?> </a></li> <?php } } ?> </ul> </div> </div> </div> <?php if (imic_get_child_values_status($tabs) == 1) { $child_label = get_post_meta($filter, 'imic_plugin_sub_field_label', true); echo '<div id="fieldfltr-' . ($filter * 111 + 2648) . '">'; echo '<div class="accordion-group panel"> <div class="accordion-heading togglize"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#" href="#collapseTwo-sub' . esc_attr($series) . '">' . $child_label . '<i class="fa fa-angle-down"></i> </a> </div> <div id="collapseTwo-sub' . esc_attr($series) . '" class="accordion-body collapse"> <div class="accordion-inner"> <ul id="sub-' . esc_attr($slug) . '" class="filter-options-list list-group search-fields">'; echo '<li>' . __('Select ', 'framework') . get_the_title($filter) . '</li>'; echo '</ul> </div> </div> </div>'; echo '</div>'; } ?>
function imic_create_vehicle() { //echo "sainath"; global $imic_options; $post_id = $_POST['post_id']; $steps = $_POST['steps']; $updating_values = ''; $phone = $_POST['phone']; $email = $_POST['email']; $listing_view = isset($_POST['listing_view']) ? $_POST['listing_view'] : ''; $fields = isset($_POST['values']) ? $_POST['values'] : ''; $tags = isset($_POST['tags']) ? $_POST['tags'] : array(); $val = $id = $mids = ''; $data = isset($_POST['matched']) ? $_POST['matched'] : ''; $mids = isset($_POST['mids']) ? $_POST['mids'] : ''; $category = isset($_POST['category']) ? $_POST['category'] : ''; $category = $category != "none" ? $category : ''; $remain = isset($_POST['remain']) ? $_POST['remain'] : ''; $plans = isset($_POST['plan']) ? $_POST['plan'] : ''; $user_id = get_current_user_id(); $user_info_id = get_user_meta($user_id, 'imic_user_info_id', true); $user_remaining_listings = get_post_meta($user_info_id, 'imic_allowed_listings_' . $plans, true); if (!empty($mids)) { foreach ($mids as $mid) { $spec_ids = explode('-', $mid); $spec_id[] = $spec_ids[1]; } $new_array = array(); foreach ($spec_id as $specs) { $new_array[] = $specs - 2648; } $updating_values = array_combine($new_array, $fields); } $listing_status = isset($imic_options['opt_listing_status']) ? $imic_options['opt_listing_status'] : 'draft'; $my_post = array('post_title' => 'listing', 'post_type' => 'yachts', 'post_status' => $listing_status); if (empty($post_id)) { $post_id = wp_insert_post($my_post); update_post_meta($user_info_id, 'imic_allowed_listings_' . $plans, $user_remaining_listings - 1); $user_plan_summary = get_post_meta($user_info_id, 'imic_user_plan_' . $plans, true); if (!empty($user_plan_summary)) { foreach ($user_plan_summary as $key => $value) { $new_value[$key] = $value . ',' . $post_id; } update_post_meta($user_info_id, 'imic_user_plan_' . $plans, $new_value); } update_post_meta($post_id, 'imic_pages_Choose_slider_display', '1'); update_post_meta($post_id, 'imic_browse_by_specification_switch', '2'); $valid_with_plan = get_post_meta($plans, 'imic_plan_validity_expire_listing', true); //Listing not showing in front end if user doesn't set any plan $listing_end_date = get_post_meta($post_id, 'imic_plugin_listing_end_dt', true); if ($listing_end_date == '' && $valid_with_plan != 1) { update_post_meta($post_id, 'imic_plugin_listing_end_dt', '2020-01-01'); } } if ($category != '') { $cat_slug = $category; $category_id = get_term_by('slug', $cat_slug, 'listing-category'); $term_id = $category_id->term_id; $parents = get_ancestors($term_id, 'listing-category'); $list_terms = array(); foreach ($parents as $parent) { $list_term = get_term_by('id', $parent, 'listing-category'); $list_terms[] = $list_term->slug; } $list_terms[] = $cat_slug; wp_set_object_terms($post_id, $list_terms, 'listing-category'); } if ($data != '') { $id = explode('-', $data); if (!empty($id)) { $id = $id[1] - 2648; $val = get_post_meta($id, 'feat_data', true); $int_specs = imic_get_all_integer_specifications(1); $char_specs = imic_get_all_integer_specifications(2); foreach ($int_specs as $int_spec) { $pre_val = get_post_meta($id, 'int_' . $int_spec, true); update_post_meta($post_id, 'int_' . $int_spec, $pre_val); } foreach ($char_specs as $char_spec) { $pre_val = get_post_meta($id, 'char_' . $char_spec, true); update_post_meta($post_id, 'char_' . $char_spec, $pre_val); } } } if (!empty($mids)) { $spec_in = array(); $int_count = 0; foreach ($mids as $mid) { $specs_int = explode('-', $mid); if ($specs_int[0] == "int") { $post_data = get_post($specs_int[1]); $spec_slug = $post_data->post_name; update_post_meta($post_id, 'int_' . $spec_slug, $fields[$int_count]); } elseif ($specs_int[0] == "char") { $spec_id = $specs_int[1] - 2648; if (get_post_type($specs_int[1]) == "specification") { $post_data = get_post($specs_int[1]); $spec_slug = $post_data->post_name; update_post_meta($post_id, 'char_' . $spec_slug, $fields[$int_count]); } elseif (get_post_type($spec_id) == "specification") { $post_data = get_post($spec_id); $spec_slug = $post_data->post_name; update_post_meta($post_id, 'char_' . $spec_slug, $fields[$int_count]); } } elseif ($specs_int[0] == "child") { $spec_id = $specs_int[1] - 2648; $spec_id = $spec_id / 111; $post_data = get_post($spec_id); $spec_slug = $post_data->post_name; update_post_meta($post_id, 'child_' . $spec_slug, $fields[$int_count]); } $spec_in[] = $specs_int[1]; $int_count++; } $int_val_array = array_combine($spec_in, $fields); } $tags = array_map('intval', $tags); $tags = array_unique($tags); wp_set_object_terms($post_id, $tags, 'yachts-tag'); if (!empty($tags)) { foreach ($tags as $tag) { //wp_set_object_terms($post_id, $tag, 'cars-tag'); } } $step = ''; if ($steps == "listing-add-form-one") { $step = 1; } elseif ($steps == "listing-add-form-two") { $step = 2; } elseif ($steps == "listing-add-form-three") { $step = 3; } elseif ($steps == "listing-add-form-four") { $step = 4; } elseif ($steps == "listing-add-form-five") { $step = 5; } $already_step = get_post_meta($post_id, 'imic_plugin_ads_steps', true); if ($already_step < $step) { update_post_meta($post_id, 'imic_plugin_ads_steps', $step); } update_post_meta($post_id, 'imic_plugin_contact_phone', $phone); update_post_meta($post_id, 'imic_plugin_contact_email', $email); update_post_meta($post_id, 'imic_plugin_listing_view', $listing_view); $specs_ids = array(); $ints = array(); $args_specification = array('post_type' => 'specification', 'posts_per_page' => '-1', 'post_status' => 'publish'); $specification_listing = new WP_Query($args_specification); if ($specification_listing->have_posts()) { while ($specification_listing->have_posts()) { $specification_listing->the_post(); $int = get_post_meta(get_the_ID(), 'imic_plugin_spec_char_type', true); if ($int == 0) { $specs_ids[] = get_the_ID(); } else { $ints[] = get_the_ID(); } } } wp_reset_postdata(); foreach ($ints as $in) { } $specification_values = get_post_meta($post_id, 'feat_data', true); if (empty($specification_values['start_time'])) { for ($i = 0; $i < count($specs_ids); $i++) { $id = $specs_ids[$i]; $vals = get_post_meta($id, 'specifications_value', true); if (imic_get_child_values_status($vals) == 1) { $feat_data['start_time'][] = ''; $feat_data['sch_title'][] = $id * 111; } $feat_data['start_time'][] = 'select'; $feat_data['sch_title'][] = $id; } if ($feat_data) { update_post_meta($post_id, 'feat_data', $feat_data); } } $specification_values = get_post_meta($post_id, 'feat_data', true); if (!empty($specification_values['start_time'])) { for ($i = 0; $i < count($specification_values['start_time']); $i++) { $value = $specification_values['start_time'][$i]; $id = $specification_values['sch_title'][$i]; if (!empty($updating_values)) { if ($i == 0) { foreach ($updating_values as $key => $values) { $key_id = array_search($key, $specification_values['sch_title']); if (!is_int($key_id)) { if (get_post_type($key) == 'specification') { $vals = get_post_meta($key, 'specifications_value', true); if (imic_get_child_values_status($vals) == 1) { $new_feat_data['start_time'][] = $values; $new_feat_data['sch_title'][] = $key * 111; } $new_feat_data['start_time'][] = $values; $new_feat_data['sch_title'][] = $key; } } } } if (isset($updating_values[$id])) { $value = $updating_values[$id]; } } $new_feat_data['start_time'][] = $value; $new_feat_data['sch_title'][] = $id; } } if (!empty($new_feat_data)) { update_post_meta($post_id, 'feat_data', $new_feat_data); } $title = isset($imic_options['highlighted_specs']) ? $imic_options['highlighted_specs'] : array(); $specifications = get_post_meta($post_id, 'feat_data', true); $new_highlighted_specs = imic_filter_lang_specs_admin($title, $post_id); $title = $new_highlighted_specs; $new_title = imic_vehicle_title($post_id, $title, $specifications); $new_slug = sanitize_title($new_title); $this_slug = imic_the_slug($post_id); if ($this_slug != $new_slug) { $update_title = array('ID' => $post_id, 'post_title' => $new_title, 'post_name' => $new_slug); wp_update_post($update_title); } if ($val != '') { update_post_meta($post_id, 'feat_data', $val); } echo esc_attr($post_id); die; }