Function Reference: geodir_detail_page_custom_field_tab
Summary
Details page tab custom fields.
Global Values
- $post
- (object) (required) The current post object.
- Default: None
Package
GeoDirectory
Parameters
- $tabs_arr
- (array) (required) Tabs array {@see geodir_detail_page_tab_headings_change()}.
- Default: None
Return Values
- (array)
- Modified tabs array.
Change Log
Since: 1.0.0
1.5.7 Custom fields option values added to db translation.
Changes to display url fields title.
Filters
‘geodir_custom_field_output_{$filed_type}’ [Line: 2522]
‘geodir_tab_show_{$html_var}’ [Line: 2534]
Source File
geodir_detail_page_custom_field_tab() is located in geodirectory_hooks_actions.php [Line: 2402]
Source Code
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 = !empty($package_info->pid) ? $package_info->pid : ''; $fields_location = 'owntab'; $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location); //remove video and special offers if it is already set to show if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){ $unset_video = true; } if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){ $unset_special_offers = true; } if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){ foreach($custom_fields as $key => $custom_field){ if($custom_field['name']=='geodir_video' && isset($unset_video)){ unset($custom_fields[$key]); } if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){ unset($custom_fields[$key]); } } } 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_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { 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; } //print_r($custom_fields); if (!empty($custom_fields)) { global $field_set_start; $post = stripslashes_deep($post); // strip slashes $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_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title']; $site_title = trim($field['site_title']); $type = $field; $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'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : ''; }else{ $i = 0; $fieldset_count++; $field_set_start = 1; $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count; $fieldset_arr[$fieldset_count]['label'] = $label; } if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];} $type = stripslashes_deep($type); // strip slashes if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;} $html = ''; $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; if($html_var=='post'){$html_var='post_address';} $field_icon = geodir_field_icon_proccess($type); $filed_type = $type['type']; /** * Filter the output for custom fields. * * Here we can remove or add new functions depending on the field type. * * @param string $html The html to be filtered (blank). * @param string $fields_location The location the field is to be show. * @param array $type The array of field values. */ $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); /** * Filter custom field output in tab. * * @since 1.5.6 * * @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. */ $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array); $fieldset_html = ''; 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, /** * Filter if a custom field should be displayed on the details page tab. * * @since 1.0.0 * @param string $htmlvar_name The field HTML var name. */ 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name), 'tab_content' => '' . $fieldset_html . '' ); } } else { if ($html != '') { $tabs_arr[$html_var] = array( 'heading_text' => __($label, 'geodirectory'), 'is_active_tab' => false, /** This action is documented in geodirectory_hooks_actions.php */ 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']), 'tab_content' => $html ); } } } } } } return $tabs_arr; }