Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hawkidoki/398f45f84ee2b7123b2688dac1450535 to your computer and use it in GitHub Desktop.
Save hawkidoki/398f45f84ee2b7123b2688dac1450535 to your computer and use it in GitHub Desktop.
<?php
add_action('acf/render_field/type=google_map', 'hwk_acf_google_map_render');
function hwk_acf_google_map_render($field){
echo '<div class="acf-fields -left hwk_google_map_wrapper">';
acf_render_field_wrap(array(
'key' => 'hwk_google_map_options',
'name' => 'hwk_google_map_options',
'label' => 'Options',
'type' => 'accordion',
'open' => false,
'multi_expand' => true
));
// Icons
$icons = array();
$icons = apply_filters('hwk/acf/google_map/icons', $icons);
if(!empty($icons)){
$choices = array();
foreach($icons as $icon){
$choices[$icon] = '<div><img src="'.$icon.'" /></div>';
}
acf_render_field_wrap(array(
'label' => 'Icône',
'instructions' => 'Sélectionnez un icône',
'type' => 'radio',
'name' => 'hwk_google_map_icon',
'prefix' => $field['name'],
'value' => (isset($field['value']['hwk_google_map_icon'])) ? $field['value']['hwk_google_map_icon'] : '',
'choices' => $choices,
'allow_null' => true,
'layout' => 'horizontal',
'class' => 'hwk_google_map_icon'
));
}
if($field['hwk_google_map_option_zoom'] == '1'){
acf_render_field_wrap(array(
'label' => 'Zoom utilisateur',
'instructions' => 'Définissez votre préférence',
'type' => 'range',
'name' => 'hwk_google_map_zoom',
'prefix' => $field['name'],
'value' => (isset($field['value']['hwk_google_map_zoom'])) ? $field['value']['hwk_google_map_zoom'] : 14,
'min' => 0,
'max' => 21,
'step' => 1,
'class' => 'hwk_google_map_zoom'
));
}
if($field['hwk_google_map_option_style_user'] == '1'){
acf_render_field_wrap(array(
'label' => 'Style personnalisé',
'instructions' => '<a href="https://snazzymaps.com/" target="_blank">Snazzy Maps</a>',
'type' => 'textarea',
'name' => 'hwk_google_map_style_user',
'prefix' => $field['name'],
'value' => (isset($field['value']['hwk_google_map_style_user'])) ? $field['value']['hwk_google_map_style_user'] : '',
'class' => 'hwk_google_map_style_user'
));
}
// Style: Default
if($field['hwk_google_map_option_style_switch'] == '1' && !empty($field['hwk_google_map_option_style_default'])){
acf_hidden_input(array(
'value' => $field['hwk_google_map_option_style_default'],
'class' => 'hwk_google_map_style_default'
));
}
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment