/** * Details page tab custom fields. * * @since 1.0.0 * @package GeoDirectory * @global object $post The current post object. * @param array $tabs_arr Tabs array {@see geodir_detail_page_tab_headings_change()}. * @return array Modified tabs array. */ function geodir_detail_page_custom_field_tab($tabs_arr) { global $post; $post_type = geodir_get_current_posttype(); $all_postypes = geodir_get_posttypes(); if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) { $package_info = array(); $package_info = geodir_post_package_info($package_info, $post); $post_package_id = $package_info->pid; $fields_location = 'detail'; $custom_fields = geodir_post_custom_fields($post_package_id, 'default', $post_type, $fields_location); if (!empty($custom_fields)) { $parse_custom_fields = array(); foreach ($custom_fields as $field) { $field = stripslashes_deep($field); // strip slashes $type = $field; $field_name = $field['htmlvar_name']; if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { $post->{$field_name} = $_REQUEST[$field_name]; } if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && (isset($post->{$field_name}) && $post->{$field_name} != '' || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) { if ($type['type'] == 'datepicker' && ($post->{$type}['htmlvar_name'] == '' || $post->{$type}['htmlvar_name'] == '0000-00-00')) { continue; } $parse_custom_fields[] = $field; } } $custom_fields = $parse_custom_fields; } if (!empty($custom_fields)) { $field_set_start = 0; $fieldset_count = 0; $fieldset = ''; $total_fields = count($custom_fields); $count_field = 0; $fieldset_arr = array(); $i = 0; $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL; foreach ($custom_fields as $field) { $count_field++; $field_name = $field['htmlvar_name']; if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { $post->{$field_name} = $_REQUEST[$field_name]; } if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && (isset($post->{$field_name}) && $post->{$field_name} != '' || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) { $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title']; $site_title = trim($field['site_title']); $type = $field; $html = ''; $html_var = $field_name; $field_icon = ''; $variables_array = array(); if ($type['type'] == 'datepicker' && ($post->{$type}['htmlvar_name'] == '' || $post->{$type}['htmlvar_name'] == '0000-00-00')) { continue; } if ($type['type'] != 'fieldset') { $i++; $variables_array['post_id'] = $post->ID; $variables_array['label'] = __($type['site_title'], 'geodirectory'); $variables_array['value'] = ''; $variables_array['value'] = $post->{$type}['htmlvar_name']; } if (strpos($type['field_icon'], 'http') !== false) { $field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;'; } elseif (strpos($type['field_icon'], 'fa fa-') !== false) { $field_icon = '<i class="' . $type['field_icon'] . '"></i>'; } switch ($type['type']) { case 'fieldset': $i = 0; $fieldset_count++; $field_set_start = 1; $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count; $fieldset_arr[$fieldset_count]['label'] = $label; break; case 'url': if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { if ($type['name'] == 'geodir_facebook') { $field_icon_af = '<i class="fa fa-facebook-square"></i>'; } elseif ($type['name'] == 'geodir_twitter') { $field_icon_af = '<i class="fa fa-twitter-square"></i>'; } else { $field_icon_af = '<i class="fa fa-link"></i>'; } } else { $field_icon_af = $field_icon; $field_icon = ''; } if (!strstr($post->{$type}['htmlvar_name'], 'http')) { $website = 'http://' . $post->{$type}['htmlvar_name']; } else { $website = $post->{$type}['htmlvar_name']; } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; // all search engines that use the nofollow value exclude links that use it from their ranking calculation $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . ' <a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', stripslashes(__($type['site_title'], 'geodirectory')), $website, $post->ID) . '</strong></a></span></div>'; break; case 'phone': if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-phone"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; break; case 'time': $value = ''; if ($post->{$type}['htmlvar_name'] != '') { //$value = date('h:i',strtotime($post->$type['htmlvar_name'])); $value = date(get_option('time_format'), strtotime($post->{$type}['htmlvar_name'])); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-clock-o"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . stripslashes($value) . '</div>'; break; case 'datepicker': $date_format = geodir_default_date_format(); if ($type['extra_fields'] != '') { $date_format = unserialize($type['extra_fields']); $date_format = $date_format['date_format']; } $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format $date_format = str_replace($search, $replace, $date_format); $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type}['htmlvar_name']) : $post->{$type}['htmlvar_name']; // PHP doesn't work well with dd/mm/yyyy format $value = ''; if ($post->{$type}['htmlvar_name'] != '') { $value = date($date_format, strtotime($post_htmlvar_value)); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-calendar"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . $value . '</div>'; break; case 'text': if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; break; case 'radio': if ($post->{$type}['htmlvar_name'] != '') { if ($post->{$type}['htmlvar_name'] == 'f' || $post->{$type}['htmlvar_name'] == '0') { $html_val = __('No', 'geodirectory'); } else { if ($post->{$type}['htmlvar_name'] == 't' || $post->{$type}['htmlvar_name'] == '1') { $html_val = __('Yes', 'geodirectory'); } } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } else { if ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . $html_val . '</div>'; } break; case 'checkbox': $html_var = $type['htmlvar_name']; $html_val = $type['htmlvar_name']; if ((int) $post->{$html_var} == 1) { if ($post->{$type}['htmlvar_name'] == '1') { $html_val = __('Yes', 'geodirectory'); } else { $html_val = __('No', 'geodirectory'); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } else { if ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . $html_val . '</div>'; } break; case 'select': if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; break; case 'multiselect': if (is_array($post->{$type}['htmlvar_name'])) { $post->{$type}['htmlvar_name'] = implode(', ', $post->{$type}['htmlvar_name']); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $option_values = explode(',', $post->{$type}['htmlvar_name']); if ($type['option_values']) { if (strstr($type['option_values'], "/")) { $option_values = array(); $field_values = explode(',', $type['option_values']); foreach ($field_values as $data) { $val = explode('/', $data); if (isset($val[1]) && in_array($val[1], explode(',', $post->{$type}['htmlvar_name']))) { $option_values[] = $val[0]; } } } } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>'; if (count($option_values) > 1) { $html .= '<ul>'; foreach ($option_values as $val) { $html .= '<li>' . stripslashes($val) . '</li>'; } $html .= '</ul>'; } else { $html .= stripslashes(trim($post->{$type}['htmlvar_name'], ',')); } $html .= '</div>'; break; case 'email': if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-envelope"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; break; case 'textarea': if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= '</span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>'; break; case 'html': if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>'; break; case 'file': $html_var = $type['htmlvar_name']; if (!empty($post->{$type}['htmlvar_name'])) { $files = explode(",", $post->{$type}['htmlvar_name']); if (!empty($files)) { $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : ''; $file_paths = ''; foreach ($files as $file) { if (!empty($file)) { $filetype = wp_check_filetype($file); $image_name_arr = explode('/', $file); $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; $filename = end($image_name_arr); $img_name_arr = explode('.', $filename); $arr_file_type = wp_check_filetype($filename); if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { continue; } $uploaded_file_type = $arr_file_type['type']; $uploaded_file_ext = $arr_file_type['ext']; if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { continue; // Invalid file type. } //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain'); $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon'); // If the uploaded file is image if (in_array($uploaded_file_type, $image_file_types)) { $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; $file_paths .= '<a href="' . $file . '">'; $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false); $file_paths .= '</a>'; $file_paths .= '</div>'; } else { $ext_path = '_' . $html_var . '_'; $filename = explode($ext_path, $filename); $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; } } } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } else { if ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } } $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . ' geodir-custom-file-box" style="clear:both;"><span class="geodir-i-file" style="display:inline-block;vertical-align:top;padding-right:14px;' . $field_icon . '">' . $field_icon_af; if ($field_set_start == 1 && $site_title != '') { $html .= ' ' . __($site_title, 'geodirectory') . ': '; } $html .= ' </span>' . $file_paths . '</div>'; } } break; } if ($field_set_start == 1) { $add_html = false; if ($type['type'] == 'fieldset' && $fieldset_count > 1) { if ($fieldset != '') { $add_html = true; $label = $fieldset_arr[$fieldset_count - 1]['label']; $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name']; } $fieldset_html = $fieldset; $fieldset = ''; } else { $fieldset .= $html; if ($total_fields == $count_field && $fieldset != '') { $add_html = true; $label = $fieldset_arr[$fieldset_count]['label']; $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name']; $fieldset_html = $fieldset; } } if ($add_html) { $tabs_arr[$htmlvar_name] = array('heading_text' => __($label, 'geodirectory'), 'is_active_tab' => false, 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name), 'tab_content' => '<div class="geodir-company_info field-group">' . $fieldset_html . '</html>'); } } else { if ($html != '') { $tabs_arr[$field['htmlvar_name']] = array('heading_text' => __($label, 'geodirectory'), 'is_active_tab' => false, 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']), 'tab_content' => $html); } } } } } } return $tabs_arr; }
/** * Gets the post featured image. * * @since 1.0.0 * @package GeoDirectory * @param int|string $post_id The post ID. * @param string $size Optional. Thumbnail size. Default: thumbnail. * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false. * @return bool|string Returns image html. */ function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false) { $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage); $html = geodir_show_image($image, $size, $no_image, false); if (!empty($html) && $echo) { echo $html; } elseif (!empty($html)) { return $html; } else { return false; } }
/** * The main function responsible for displaying tabs in frontend detail page. * * @since 1.0.0 * @package GeoDirectory * @global object $post The current post object. * @global array $post_images List of images attached to the post. * @global string $video The video embed content. * @global string $special_offers Special offers content. * @global string $related_listing Related listing html. * @global string $geodir_post_detail_fields Detail field html. */ function geodir_show_detail_page_tabs() { global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; $post_id = !empty($post) && isset($post->ID) ? (int) $post->ID : 0; $request_post_id = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; $is_backend_preview = is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p']) && is_super_admin() ? true : false; // skip if preview from backend if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) { $post = geodir_get_post_info($request_post_id); setup_postdata($post); } $geodir_post_detail_fields = geodir_show_listing_info('detail'); if (geodir_is_page('detail')) { $video = geodir_get_video($post->ID); $special_offers = geodir_get_special_offers($post->ID); $related_listing_array = array(); if (get_option('geodir_add_related_listing_posttypes')) { $related_listing_array = get_option('geodir_add_related_listing_posttypes'); } $related_listing = ''; if (in_array($post->post_type, $related_listing_array)) { $request = array('post_number' => get_option('geodir_related_post_count'), 'relate_to' => get_option('geodir_related_post_relate_to'), 'layout' => get_option('geodir_related_post_listing_view'), 'add_location_filter' => get_option('geodir_related_post_location_filter'), 'list_sort' => get_option('geodir_related_post_sortby'), 'character_count' => get_option('geodir_related_post_excerpt')); $related_listing = geodir_related_posts_display($request); } $post_images = geodir_get_images($post->ID, 'thumbnail'); $thumb_image = ''; if (!empty($post_images)) { foreach ($post_images as $image) { $caption = !empty($image->caption) ? $image->caption : ''; $thumb_image .= '<a href="' . $image->src . '" title="' . $caption . '">'; $thumb_image .= geodir_show_image($image, 'thumbnail', true, false); $thumb_image .= '</a>'; } } $map_args = array(); $map_args['map_canvas_name'] = 'detail_page_map_canvas'; $map_args['width'] = '600'; $map_args['height'] = '300'; if ($post->post_mapzoom) { $map_args['zoom'] = '' . $post->post_mapzoom . ''; } $map_args['autozoom'] = false; $map_args['child_collapse'] = '0'; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; $map_args['map_class_name'] = 'geodir-map-detail-page'; $map_args['maptype'] = !empty($post->post_mapview) ? $post->post_mapview : 'ROADMAP'; } elseif (geodir_is_page('preview')) { $video = isset($post->geodir_video) ? $post->geodir_video : ''; $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : ''; if (isset($post->post_images)) { $post->post_images = trim($post->post_images, ","); } if (isset($post->post_images) && !empty($post->post_images)) { $post_images = explode(",", $post->post_images); } $thumb_image = ''; if (!empty($post_images)) { foreach ($post_images as $image) { if ($image != '') { $thumb_image .= '<a href="' . $image . '">'; $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false); $thumb_image .= '</a>'; } } } global $map_jason; $map_jason[] = $post->marker_json; $address_latitude = isset($post->post_latitude) ? $post->post_latitude : ''; $address_longitude = isset($post->post_longitude) ? $post->post_longitude : ''; $mapview = isset($post->post_mapview) ? $post->post_mapview : ''; $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : ''; if (!$mapzoom) { $mapzoom = 12; } $map_args = array(); $map_args['map_canvas_name'] = 'preview_map_canvas'; $map_args['width'] = '950'; $map_args['height'] = '300'; $map_args['child_collapse'] = '0'; $map_args['maptype'] = $mapview; $map_args['autozoom'] = false; $map_args['zoom'] = "{$mapzoom}"; $map_args['latitude'] = $address_latitude; $map_args['longitude'] = $address_longitude; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; $map_args['map_class_name'] = 'geodir-map-preview-page'; } $arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user $active_tab_name = ''; foreach ($arr_detail_page_tabs as $tabs) { if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && isset($tabs['heading_text']) && $tabs['heading_text']) { $active_tab_name = __($tabs['heading_text'], 'geodirectory'); } } ?> <div class="geodir-tabs" id="gd-tabs" style="position:relative;"> <div id="geodir-tab-mobile-menu" > <i class="fa fa-bars"></i> <span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?> </span> <i class="fa fa-sort-desc"></i> </div> <dl class="geodir-tab-head"> <?php /** * Called before the details page tab list headings, inside the `dl` tag. * * @since 1.0.0 * @see 'geodir_after_tab_list' */ do_action('geodir_before_tab_list'); ?> <?php foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) { if ($detail_page_tab['is_display']) { ?> <dt></dt> <!-- added to comply with validation --> <dd <?php if ($detail_page_tab['is_active_tab']) { ?> class="geodir-tab-active"<?php } ?> > <a data-tab="#<?php echo $tab_index; ?> " data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?> </a> </dd> <?php ob_start(); ?> <li id="<?php echo $tab_index; ?> Tab" <?php if ($tab_index == 'post_profile') { //echo 'itemprop="description"'; } ?> > <div id="<?php echo $tab_index; ?> " class="hash-offset"></div> <?php /** * Called before the details tab content is output per tab. * * @since 1.0.0 * @param string $tab_index The tab name ID. */ do_action('geodir_before_tab_content', $tab_index); /** * Called before the details tab content is output per tab. * * Uses dynamic hook name: geodir_before_$tab_index_tab_content * * @since 1.0.0 * @todo do we need this if we have the hook above? 'geodir_before_tab_content' */ do_action('geodir_before_' . $tab_index . '_tab_content'); /// write a code to generate content of each tab switch ($tab_index) { case 'post_profile': /** * Called before the listing description content on the details page tab. * * @since 1.0.0 */ do_action('geodir_before_description_on_listing_detail'); if (geodir_is_page('detail')) { the_content(); } else { /** This action is documented in geodirectory_template_actions.php */ echo apply_filters('the_content', stripslashes($post->post_desc)); } /** * Called after the listing description content on the details page tab. * * @since 1.0.0 */ do_action('geodir_after_description_on_listing_detail'); break; case 'post_info': echo $geodir_post_detail_fields; break; case 'post_images': echo $thumb_image; break; case 'post_video': /** This action is documented in geodirectory_template_actions.php */ echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also; break; case 'special_offers': echo wpautop(stripslashes($special_offers)); break; case 'post_map': geodir_draw_map($map_args); break; case 'reviews': comments_template(); break; case 'related_listing': echo $related_listing; break; default: if ((isset($post->{$tab_index}) || !isset($post->{$tab_index}) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business')) && !empty($detail_page_tab['tab_content'])) { echo $detail_page_tab['tab_content']; } break; } /** * Called after the details tab content is output per tab. * * @since 1.0.0 */ do_action('geodir_after_tab_content', $tab_index); /** * Called after the details tab content is output per tab. * * Uses dynamic hook name: geodir_after_$tab_index_tab_content * * @since 1.0.0 * @todo do we need this if we have the hook above? 'geodir_after_tab_content' */ do_action('geodir_after_' . $tab_index . '_tab_content'); ?> </li> <?php /** * Filter the current tab content. * * @since 1.0.0 */ $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean()); } // end of if for is_display } // end of foreach /** * Called after the details page tab list headings, inside the `dl` tag. * * @since 1.0.0 * @see 'geodir_before_tab_list' */ do_action('geodir_after_tab_list'); ?> </dl> <ul class="geodir-tabs-content entry-content" style="position:relative;"> <?php foreach ($arr_detail_page_tabs as $detail_page_tab) { if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) { echo $detail_page_tab['tab_content']; } // end of if } // end of foreach /** * Called after all the tab content is output in `li` tags, called before the closing `ul` tag. * * @since 1.0.0 */ do_action('geodir_add_tab_content'); ?> </ul> <!--gd-tabs-content ul end--> </div> <script> if (window.location.hash && window.location.hash.indexOf('&') === -1 && jQuery(window.location.hash + 'Tab').length) { hashVal = window.location.hash; } else { hashVal = jQuery('dl.geodir-tab-head dd.geodir-tab-active').find('a').attr('data-tab'); } jQuery('dl.geodir-tab-head dd').each(function () { //Get all tabs var tabs = jQuery(this).children('dd'); var tab = ''; tab = jQuery(this).find('a').attr('data-tab'); if (hashVal != tab) { jQuery(tab + 'Tab').hide(); } }); </script> <?php }
/** * Show listing info depending on field location. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global object $post The current post object. * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. * @return string Returns listing info html. */ function geodir_show_listing_info($fields_location = '') { global $post, $preview, $wpdb; $payment_info = array(); $package_info = array(); $package_info = geodir_post_package_info($package_info, $post); //return; $post_package_id = $package_info->pid; $p_type = geodir_get_current_posttype() ? geodir_get_current_posttype() : $post->post_type; ob_start(); $fields_info = geodir_post_custom_fields($post_package_id, 'default', $p_type, $fields_location); if (!empty($fields_info)) { //echo '<div class="geodir-company_info field-group">'; $field_set_start = 0; if ($fields_location == 'detail') { $i = 1; } foreach ($fields_info as $type) { $type = stripslashes_deep($type); // strip slashes $html = ''; $html_var = ''; $field_icon = ''; $variables_array = array(); if ($fields_location == 'detail' && isset($type['show_as_tab']) && (int) $type['show_as_tab'] == 1 && in_array($type['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) { continue; } if ($type['type'] != 'fieldset') { $variables_array['post_id'] = $post->ID; $variables_array['label'] = __($type['site_title'], 'geodirectory'); $variables_array['value'] = ''; if (isset($post->{$type}['htmlvar_name'])) { $variables_array['value'] = $post->{$type}['htmlvar_name']; } } //if($type['field_icon']) if (strpos($type['field_icon'], 'http') !== false) { $field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;'; } elseif (strpos($type['field_icon'], 'fa fa-') !== false) { $field_icon = '<i class="' . $type['field_icon'] . '"></i>'; } //else{$field_icon = $type['field_icon'];} switch ($type['type']) { case 'fieldset': if ($field_set_start == 1) { echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2>' . __($type['site_title'], 'geodirectory') . '</h2>'; } else { echo '<h2>' . __($type['site_title'], 'geodirectory') . '</h2>'; $field_set_start = 1; } break; case 'address': $html_var = $type['htmlvar_name'] . '_address'; if ($type['extra_fields']) { $extra_fields = unserialize($type['extra_fields']); $addition_fields = ''; if (!empty($extra_fields)) { /** * Filter "show city in address" value. * * @since 1.0.0 */ $show_city_in_address = apply_filters('geodir_show_city_in_address', false); if (isset($extra_fields['show_city']) && $extra_fields['show_city'] && $show_city_in_address) { $field = $type['htmlvar_name'] . '_city'; if ($post->{$field}) { $addition_fields .= ', ' . $post->{$field}; } } if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { $field = $type['htmlvar_name'] . '_zip'; if ($post->{$field}) { $addition_fields .= ', ' . $post->{$field}; } } } } /*if($type['extra_fields']) { $extra_fields = unserialize($type['extra_fields']); $addition_fields = ''; if(!empty($extra_fields)) { if($extra_fields['show_city']) { $field = $type['htmlvar_name'].'_city'; if($post->$field) { $addition_fields .= ', '.$post->$field; } } if($extra_fields['show_region']) { $field = $type['htmlvar_name'].'_region'; if($post->$field) { $addition_fields .= ', '.$post->$field; } } if($extra_fields['show_country']) { $field = $type['htmlvar_name'].'_country'; if($post->$field) { $addition_fields .= ', '.$post->$field; } } if($extra_fields['show_zip']) { $field = $type['htmlvar_name'].'_zip'; if($post->$field) { $addition_fields .= ', '.$post->$field; } } } }*/ if ($post->{$html_var}) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-home"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;" itemscope itemtype="http://schema.org/PostalAddress">'; $html .= '<span class="geodir-i-location" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; $html .= '</span>'; //print_r($_POST); if ($preview) { $html .= stripslashes($post->{$html_var}) . $addition_fields . '</p>'; } else { if ($post->post_address) { $html .= '<span itemprop="streetAddress">' . $post->post_address . '</span><br>'; } if ($post->post_city) { $html .= '<span itemprop="addressLocality">' . $post->post_city . '</span><br>'; } if ($post->post_region) { $html .= '<span itemprop="addressRegion">' . $post->post_region . '</span><br>'; } if ($post->post_zip) { $html .= '<span itemprop="postalCode">' . $post->post_zip . '</span><br>'; } if ($post->post_country) { $html .= '<span itemprop="addressCountry">' . __($post->post_country, 'geodirectory') . '</span><br>'; } $html .= '</div>'; } } $variables_array['value'] = $post->{$html_var}; break; case 'url': $html_var = $type['htmlvar_name']; if ($post->{$type}['htmlvar_name']) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { if ($type['name'] == 'geodir_facebook') { $field_icon_af = '<i class="fa fa-facebook-square"></i>'; } elseif ($type['name'] == 'geodir_twitter') { $field_icon_af = '<i class="fa fa-twitter-square"></i>'; } else { $field_icon_af = '<i class="fa fa-link"></i>'; } } else { $field_icon_af = $field_icon; $field_icon = ''; } if (!strstr($post->{$type}['htmlvar_name'], 'http')) { $website = 'http://' . $post->{$type}['htmlvar_name']; } else { $website = $post->{$type}['htmlvar_name']; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } // all search engines that use the nofollow value exclude links that use it from their ranking calculation $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"'; /** * Filter custom field website name. * * @since 1.0.0 * * @param string $type['site_title'] Website Title. * @param string $website Website URL. * @param int $post->ID Post ID. */ $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . '<a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', stripslashes(__($type['site_title'], 'geodirectory')), $website, $post->ID) . '</strong></a></span></div>'; } break; case 'phone': $html_var = $type['htmlvar_name']; if ($post->{$type}['htmlvar_name']) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-phone"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af . ($html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ' '); $html .= '</span><a href="tel:' . stripslashes($post->{$type}['htmlvar_name']) . '">' . stripslashes($post->{$type}['htmlvar_name']) . '</a></div>'; } break; case 'time': $html_var = $type['htmlvar_name']; if ($post->{$type}['htmlvar_name']) { $value = ''; if ($post->{$type}['htmlvar_name'] != '') { //$value = date('h:i',strtotime($post->$type['htmlvar_name'])); $value = date(get_option('time_format'), strtotime($post->{$type}['htmlvar_name'])); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-clock-o"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; $html .= '</span>' . stripslashes($value) . '</div>'; } break; case 'datepicker': if ($post->{$type}['htmlvar_name']) { $date_format = geodir_default_date_format(); if ($type['extra_fields'] != '') { $date_format = unserialize($type['extra_fields']); $date_format = $date_format['date_format']; } $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format $date_format = str_replace($search, $replace, $date_format); $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type}['htmlvar_name']) : $post->{$type}['htmlvar_name']; // PHP doesn't work well with dd/mm/yyyy format $value = ''; if ($post->{$type}['htmlvar_name'] != '' && $post->{$type}['htmlvar_name'] != "0000-00-00") { $value = date($date_format, strtotime($post_htmlvar_value)); } else { continue; } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-calendar"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . $value . '</div>'; } break; case 'text': $html_var = $type['htmlvar_name']; if (isset($post->{$type}['htmlvar_name']) && $post->{$type}['htmlvar_name'] != '' && $type['htmlvar_name'] == 'geodir_timing') { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-clock-o"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ' '; $html .= '</span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; } elseif (isset($post->{$type}['htmlvar_name']) && $post->{$type}['htmlvar_name']) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; } break; case 'radio': $html_var = $type['htmlvar_name']; $html_val = $post->{$type}['htmlvar_name']; if ($post->{$type}['htmlvar_name'] != '') { if ($post->{$type}['htmlvar_name'] == 'f' || $post->{$type}['htmlvar_name'] == '0') { $html_val = __('No', 'geodirectory'); } elseif ($post->{$type}['htmlvar_name'] == 't' || $post->{$type}['htmlvar_name'] == '1') { $html_val = __('Yes', 'geodirectory'); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . $html_val . '</div>'; } break; case 'checkbox': $html_var = $type['htmlvar_name']; $html_val = $type['htmlvar_name']; if ((int) $post->{$html_var} == 1) { if ($post->{$type}['htmlvar_name'] == '1') { $html_val = __('Yes', 'geodirectory'); } else { $html_val = __('No', 'geodirectory'); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . $html_val . '</div>'; } break; case 'select': $html_var = $type['htmlvar_name']; if ($post->{$type}['htmlvar_name']) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; } break; case 'multiselect': $html_var = $type['htmlvar_name']; if (!empty($post->{$type}['htmlvar_name'])) { if (is_array($post->{$type}['htmlvar_name'])) { $post->{$type}['htmlvar_name'] = implode(', ', $post->{$type}['htmlvar_name']); } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $option_values = explode(',', $post->{$type}['htmlvar_name']); if ($type['option_values']) { if (strstr($type['option_values'], "/")) { $option_values = array(); $field_values = explode(',', $type['option_values']); foreach ($field_values as $data) { $val = explode('/', $data); if (isset($val[1]) && in_array($val[1], explode(',', $post->{$type}['htmlvar_name']))) { $option_values[] = $val[0]; } } } } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>'; if (count($option_values) > 1) { $html .= '<ul>'; foreach ($option_values as $val) { $html .= '<li>' . stripslashes($val) . '</li>'; } $html .= '</ul>'; } else { $html .= stripslashes(trim($post->{$type}['htmlvar_name'], ',')); } $html .= '</div>'; } break; case 'email': if ($type['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) { continue; // Remove Send Enquiry | Send To Friend from listings page } if ($type['htmlvar_name'] == 'geodir_email' && (isset($package_info->sendtofriend) && $package_info->sendtofriend || $post->{$type}['htmlvar_name'])) { $b_send_inquiry = ''; $b_sendtofriend = ''; $html = ''; if (!$preview) { $b_send_inquiry = 'b_send_inquiry'; $b_sendtofriend = 'b_sendtofriend'; $html = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div>'; } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-envelope"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html .= '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; $seperator = ''; if ($post->{$type}['htmlvar_name']) { $html .= '<a href="javascript:void(0);" class="' . $b_send_inquiry . '" >' . SEND_INQUIRY . '</a>'; $seperator = ' | '; } if (isset($package_info->sendtofriend) && $package_info->sendtofriend) { $html .= $seperator . '<a href="javascript:void(0);" class="' . $b_sendtofriend . '">' . SEND_TO_FRIEND . '</a>'; } $html .= '</span></div>'; if (isset($_REQUEST['send_inquiry']) && $_REQUEST['send_inquiry'] == 'success') { $html .= '<p class="sucess_msg">' . SEND_INQUIRY_SUCCESS . '</p>'; } elseif (isset($_REQUEST['sendtofrnd']) && $_REQUEST['sendtofrnd'] == 'success') { $html .= '<p class="sucess_msg">' . SEND_FRIEND_SUCCESS . '</p>'; } elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') { $html .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>'; } /*if(!$preview){require_once (geodir_plugin_path().'/geodirectory-templates/popup-forms.php');}*/ } else { if ($post->{$type}['htmlvar_name']) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = '<i class="fa fa-envelope"></i>'; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>'; } } break; case 'file': $html_var = $type['htmlvar_name']; if (!empty($post->{$type}['htmlvar_name'])) { $files = explode(",", $post->{$type}['htmlvar_name']); if (!empty($files)) { $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : ''; $file_paths = ''; foreach ($files as $file) { if (!empty($file)) { $filetype = wp_check_filetype($file); $image_name_arr = explode('/', $file); $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; $filename = end($image_name_arr); $img_name_arr = explode('.', $filename); $arr_file_type = wp_check_filetype($filename); if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { continue; } $uploaded_file_type = $arr_file_type['type']; $uploaded_file_ext = $arr_file_type['ext']; if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { continue; // Invalid file type. } //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain'); $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon'); // If the uploaded file is image if (in_array($uploaded_file_type, $image_file_types)) { $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; $file_paths .= '<a href="' . $file . '">'; $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false); $file_paths .= '</a>'; //$file_paths .= '<img src="'.$file.'" />'; $file_paths .= '</div>'; } else { $ext_path = '_' . $html_var . '_'; $filename = explode($ext_path, $filename); $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; } } } if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' geodir-custom-file-box ' . $type['htmlvar_name'] . '"><div class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; $html .= '<span style="display: inline-block; vertical-align: top; padding-right: 14px;">'; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>'; $html .= $file_paths . '</div></div>'; } } break; case 'textarea': if (!empty($post->{$type}['htmlvar_name'])) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>'; } break; case 'html': if (!empty($post->{$type}['htmlvar_name'])) { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } elseif ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>'; } break; case 'taxonomy': $html_var = $type['htmlvar_name']; if ($html_var == $post->post_type . 'category' && !empty($post->{$html_var})) { $post_taxonomy = $post->post_type . 'category'; $field_value = $post->{$html_var}; $links = array(); $terms = array(); $termsOrdered = array(); if (!is_array($field_value)) { $field_value = explode(",", trim($field_value, ",")); } $field_value = array_unique($field_value); if (!empty($field_value)) { foreach ($field_value as $term) { $term = trim($term); if ($term != '') { $term = get_term_by('id', $term, $html_var); if (is_object($term)) { $links[] = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>" . $term->name . "</a>"; $terms[] = $term; } } } if (!empty($links)) { // order alphabetically asort($links); foreach (array_keys($links) as $key) { $termsOrdered[$key] = $terms[$key]; } $terms = $termsOrdered; } } $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object) $terms) : ''; if ($html_value != '') { if (strpos($field_icon, 'http') !== false) { $field_icon_af = ''; } else { if ($field_icon == '') { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } } $geodir_odd_even = ''; if ($fields_location == 'detail') { $geodir_odd_even = 'geodir_more_info_odd'; if ($i % 2 == 0) { $geodir_odd_even = 'geodir_more_info_even'; } $i++; } $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $html_var . '" style="clear:both;"><span class="geodir-i-taxonomy geodir-i-category" style="' . $field_icon . '">' . $field_icon_af; $html .= trim($type['site_title']) ? __($type['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span> ' . $html_value . '</div>'; } } break; } if ($html) { /** * Called before a custom fields is output on the frontend. * * @since 1.0.0 * @param string $html_var The HTML variable name for the field. */ do_action("geodir_before_show_{$html_var}"); /** * Filter custom field output. * * @since 1.0.0 * * @param string $html_var The HTML variable name for the field. * @param string $html Custom field unfiltered HTML. * @param array $variables_array Custom field variables array. */ if ($html) { echo apply_filters("geodir_show_{$html_var}", $html, $variables_array); } /** * Called after a custom fields is output on the frontend. * * @since 1.0.0 * @param string $html_var The HTML variable name for the field. */ do_action("geodir_after_show_{$html_var}"); } } //echo '</div>'; } return $html = ob_get_clean(); }