Last active
March 10, 2017 10:55
-
-
Save MikeMnD/fa797fd15ad01ddc9073319a3b0315f7 to your computer and use it in GitHub Desktop.
Човек и добре да живее накрая пише плъгин за Wordpress!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* To display the custom fields on detail page */ | |
if(!function_exists('tmpl_fields_detail_informations')){ | |
function tmpl_fields_detail_informations($not_show = array('title'),$title_text = TMPL_HEADING_TITLE){ | |
global $post,$htmlvar_name,$heading_type,$used_heading; | |
$used_heading = array(); | |
$is_edit=''; | |
if(isset($_REQUEST['action']) && $_REQUEST['action']=='edit'){ | |
$is_edit=1; | |
} | |
$j=0; | |
if(!empty($htmlvar_name) && is_single()){ | |
echo '<div class="tevolution_custom_field listing_custom_field">'; | |
foreach($htmlvar_name as $key=>$value){ | |
$i=0; | |
if(!empty($value)){ | |
foreach($value as $k=>$val){ | |
if(isset($_REQUEST['page']) && $_REQUEST['page'] =='preview' && isset($_SESSION['custom_fields'][$k])){ | |
$field= $_SESSION['custom_fields'][$k]; | |
}else{ | |
$field= get_post_meta($post->ID,$k,true); | |
} | |
$tmpl_key = ( $key == 'basic_inf') ? $title_text: $heading_type[$key]; | |
/* Show other custom fields */ | |
if($k!='post_title' && $k!='category' && $k!='post_content' && $k!='post_excerpt' && $k!='post_images' && $k!='listing_timing' && $k!='address' && $k!='listing_logo' && $k!='video' && $k!='post_tags' && $k!='map_view' && $k!='proprty_feature' && $k!='phone' && $k!='email' && $k!='website' && $k!='twitter' && $k!='facebook' && $k!='google_plus' && $k!='contact_info' && !in_array($k,$not_show)){ | |
/* To display the title and Locations information on top */ | |
$key_value = get_post_meta($post->ID,$k,true); | |
if($is_edit ==1 && $i==0 && $key_value !=''){ | |
$used_heading[$key] = $tmpl_key; | |
echo '<h2 class="custom_field_headding">'.$tmpl_key.'</h2>'; | |
} | |
if($i==0 && $key_value !=''){ | |
if($is_edit ==''){ | |
if($tmpl_key){ | |
$used_heading[$key] = $tmpl_key; | |
echo apply_filters('tmpl_custom_fields_listtitle','<h2 class="custom_field_headding">'.$tmpl_key.'</h2>'); | |
} | |
$field= get_post_meta(get_the_ID(),$k,true); | |
if($i==0 && $field!='' && $key != 'field_label' && $heading_key){ | |
$used_heading[$key] = $heading_key; | |
echo apply_filters('tmpl_custom_fields_listtitle','<h2 class="custom_field_headding">'.$heading_key.'</h2>'); | |
$i++; | |
} | |
if($field!='' && $key == 'field_label' && $val['label']){ | |
$used_heading[$key] = $val['label']; | |
echo apply_filters('tmpl_custom_fields_listtitle','<h2 class="custom_field_headding">'.$val['label'].'</h2>');$i++; | |
} | |
} | |
/* Show locations informations - country/state/city */ | |
if($htmlvar_name['basic_inf']['post_city_id'] && $htmlvar_name['basic_inf']['post_city_id']['type'] =='multicity' && $k=='post_city_id'){ | |
global $wpdb,$country_table,$zones_table,$multicity_table; | |
if(isset($_REQUEST['page']) && $_REQUEST['page'] =='preview'){ | |
$city= $_SESSION['custom_fields']['post_city_id']; | |
$country_id= @$_SESSION['custom_fields']['country_id']; | |
$zones_id= @$_SESSION['custom_fields']['zones_id']; | |
}else{ | |
$city= get_post_meta($post->ID,'post_city_id',true); | |
$zones_id= get_post_meta($post->ID,'zones_id',true); | |
$country_id= get_post_meta($post->ID,'country_id',true); | |
} | |
$cityinfo = $wpdb->get_results($wpdb->prepare("select cityname from $multicity_table where city_id =%d",$city )); | |
if($country_id !='') | |
$countryinfo = $wpdb->get_results($wpdb->prepare("select country_name from $country_table where country_id =%d",$country_id )); | |
if($zones_id !='') | |
$zoneinfo = $wpdb->get_results($wpdb->prepare("select zone_name from $zones_table where zones_id =%d",$zones_id )); | |
if($countryinfo[0]->country_name){ | |
?><p class='<?php echo $val['style_class'];?>'><label><?php _e('Country','templatic'); ?>:</label> <strong><span><?php echo $countryinfo[0]->country_name; ?></span></strong></p> | |
<?php } | |
if($zoneinfo[0]->zone_name){ ?> | |
<p class='<?php echo $val['style_class'];?>'><label><?php _e('State','templatic'); ?>:</label> <strong><span><?php echo $zoneinfo[0]->zone_name; ?></span></strong></p> | |
<?php } | |
if($cityinfo[0]->cityname){ ?> | |
<p class='<?php echo $val['style_class'];?>'><label><?php _e('City','templatic'); ?>:</label> <strong><span><?php echo $cityinfo[0]->cityname; ?></span></strong></p> | |
<?php } | |
} | |
} | |
if($val['type'] == 'multicheckbox' && ($field!="" || $is_edit==1)): | |
$checkbox_value = ''; | |
$option_values = explode(",",$val['option_values']); | |
$option_titles = explode(",",$val['option_title']); | |
for($i=0;$i<count($option_values);$i++){ | |
if(isset($option_values[$i]) && $option_values[$i] !='' && count($field)>0){ | |
if($option_values[$i] !='' && is_array($field) && in_array($option_values[$i],$field)){ | |
if($option_titles[$i]!=""){ | |
$checkbox_value .= $option_titles[$i].', '; | |
}else{ | |
$checkbox_value .= $option_values[$i].', '; | |
} | |
} | |
} | |
} | |
?> | |
<p class='<?php echo $val['style_class']; ?>'><?php if($key != 'field_label') { ?><label><?php echo $val['label']; ?>: </label><?php }?> <strong><span <?php if($is_edit==1):?>id="frontend_multicheckbox_<?php echo $k;?>" <?php endif;?> class="multicheckbox"><?php echo substr($checkbox_value,0,-2);?></span></strong></p> | |
<?php | |
elseif(($val['type']=='radio' || $val['type']=='select') && ($field || $is_edit==1)): | |
$option_values = explode(",",$val['option_values']); | |
$option_titles = explode(",",$val['option_title']); | |
for($i=0;$i<count($option_values);$i++){ | |
if($field == $option_values[$i]){ | |
if($option_titles[$i]!=""){ | |
$rado_value = $option_titles[$i]; | |
}else{ | |
$rado_value = $option_values[$i]; | |
} | |
?> | |
<p class='<?php echo $val['style_class'];?>'><?php if($key != 'field_label' || $is_edit==1) { ?><label><?php echo $val['label']; ?>: </label><?php } ?><strong><span <?php if($is_edit==1):?>id="frontend_radio_<?php echo $k;?>" <?php endif;?>><?php echo $rado_value;?></span></strong></p> | |
<?php | |
} | |
} | |
elseif($val['type']=='oembed_video' && ($field || $is_edit==1)):?> | |
<p class='<?php echo $val['style_class'];?>'><?php if($key != 'field_label') { ?><label><?php echo $val['label']; ?>: </label><?php } ?> | |
<?php if($is_edit==1):?> | |
<span id="frontend_edit_<?php echo $k;?>" class="frontend_oembed_video button" ><?php _e('Edit Video','templatic');?></span> | |
<input type="hidden" class="frontend_<?php echo $k;?>" name="frontend_edit_<?php echo $k;?>" value='<?php echo $field;?>' /> | |
<?php endif;?> | |
<span class="frontend_edit_<?php echo $k;?>"><?php | |
$embed_video= wp_oembed_get( $field); | |
if($embed_video!=""){ | |
echo $embed_video; | |
}else{ | |
echo $field; | |
} | |
?></span></p> | |
<?php | |
endif; | |
if($val['type'] == 'upload' || ($is_edit==1 && $val['type'] == 'upload')) | |
{ | |
if($_SESSION['upload_file'][$name]){ | |
$upload_file=strtolower(substr(strrchr($_SESSION['upload_file'][$name],'.'),1)); | |
}else{ | |
$upload_file=strtolower(substr(strrchr($field,'.'),1)); | |
} | |
if($is_edit==1):?> | |
<p class="<?php echo $val['style_class'];?>"><?php if($key != 'field_label') { ?><label><?php echo $val['label']; ?>: </label><?php } ?> | |
<span class="entry-header-<?php echo $k;?> span_uploader" > | |
<span style="display:none;" class="frontend_<?php echo $k;?>"><?php echo $field?></span> | |
<span id="fronted_upload_<?php echo $k;?>" class="frontend_uploader button" data-src="<?php echo $field?>"> | |
<span><?php echo __( 'Upload ', 'templatic-admin' ).$val['label']; ?></span> | |
</span> | |
</span> | |
</p> | |
<?php elseif($upload_file=='jpg' || $upload_file=='jpeg' || $upload_file=='gif' || $upload_file=='png' || $upload_file=='jpg' ):?> | |
<p class="<?php echo $val['style_class'];?>"><img src="<?php echo $field; ?>" /></p> | |
<?php else: | |
if(!empty($field)) | |
{ | |
?> | |
<p class="<?php echo $val['style_class'];?>"><?php if($key != 'field_label') { ?><label><?php echo $val['label']; ?>: </label><?php } ?><a href="<?php echo $field; ?>" target="_blank"><?php echo basename($field); ?></a></p> | |
<?php | |
} | |
endif; | |
} | |
if(($val['type'] != 'multicheckbox' && $val['type'] != 'radio' && $val['type'] != 'select' && $val['type'] != 'multicity' && $val['type'] != 'upload' && $val['type'] !='oembed_video') && ($field!='' || $is_edit==1)): | |
?> | |
<p class='<?php echo $val['style_class'];?>'> | |
<?php if($key != 'field_label') { ?><label><?php echo $val['label']; ?>: </label><?php } ?> | |
<?php if($val['type']=='texteditor'):?> | |
<strong><span <?php if($is_edit==1):?>id="frontend_<?php echo $val['type'].'_'.$k;?>" class="frontend_<?php echo $k; if($val['type']=='texteditor'){ echo ' editblock';} ?>" <?php endif;?>> | |
<?php echo $field;?> | |
</span></strong> | |
<?php else: ?> | |
<strong><span <?php if($is_edit==1):?>id="frontend_<?php echo $val['type'].'_'.$k;?>" contenteditable="true" class="frontend_<?php echo $k;?>" <?php endif;?>> | |
<?php echo $field;?> | |
</span></strong> | |
<?php endif;?> | |
</p> | |
<?php | |
endif; | |
}/* End If condition*/ | |
$j++; | |
$i++; | |
}/* End second foreach*/ | |
} | |
}/* END First foreach*/ | |
echo '</div>'; | |
?> | |
<script> | |
jQuery(document).ready(function(){ | |
if(jQuery('.tevolution_custom_field.listing_custom_field').is(':empty')){ | |
jQuery('.tevolution_custom_field.listing_custom_field').remove(); | |
} | |
}); | |
</script> | |
<?php | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment