Skip to content

Instantly share code, notes, and snippets.

@chrdesigner
Last active January 5, 2023 19:15
Show Gist options
  • Save chrdesigner/f7f16006260fff56b93b8de005f6de5c to your computer and use it in GitHub Desktop.
Save chrdesigner/f7f16006260fff56b93b8de005f6de5c to your computer and use it in GitHub Desktop.
[
{
"key": "group_63b5c82e80cd6",
"title": "Localização",
"fields": [
{
"key": "field_63b5d064ffe62",
"label": "ATENÇÃO!!!",
"name": "",
"aria-label": "",
"type": "message",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"message": "Acesse o site abaixo para gerar as coordenadas corretas da sua localização:\r\n\r\n<a href=\"https:\/\/gps-coordinates.org\/coordinate-converter.php\" title=\"Gerar Coordenadas.\" target=\"_blank\">Gerar Coordenadas<\/a>\r\n\r\n<sub>* Procure pelo campo <strong>ADRESS<\/strong> e depois clique em <strong>Get GPS Coordinates<\/strong>.<\/sub>",
"new_lines": "br",
"esc_html": 0
},
{
"key": "field_63b5d4ca316a9",
"label": "Latitude",
"name": "latitude",
"aria-label": "",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "50",
"class": "",
"id": ""
},
"default_value": "",
"maxlength": "",
"placeholder": "",
"prepend": "",
"append": ""
},
{
"key": "field_63b5d4e7316aa",
"label": "Longitude",
"name": "longitude",
"aria-label": "",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "50",
"class": "",
"id": ""
},
"default_value": "",
"maxlength": "",
"placeholder": "",
"prepend": "",
"append": ""
}
],
"location": [
[
{
"param": "page_template",
"operator": "==",
"value": "page-localizacao.php"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": "",
"show_in_rest": 0
}
]
<?php
// pega os nossos campos personalizados
$latitude = get_field('latitude');
$longitude = get_field('longitude');
// inicio da verificação
// verifica se os dois campos estão cadastrados
if ($latitude && $longitude ) : ?>
<div class="map-responsive">
<iframe src ="https://maps.google.com/maps?q=<?php echo esc_attr($latitude); ?>,<?php echo esc_attr($longitude); ?>&hl=es;z=14&amp;output=embed" loading="lazy"></iframe>
</div>
<!-- Inicio do CSS para deixar o Mapa Responsivo -->
<style type="text/css">
.map-responsive{
overflow:hidden;
padding-bottom:50%;
position:relative;
height:0;
}
.map-responsive iframe{
left:0;
top:0;
height:100%;
width:100%;
position:absolute;
}
</style>
<!-- Fim do CSS -->
<?php endif;
// fim da verificação
?>
<?php
/*
* Template Name: Localização
* Template Post Type: page
*/
get_header();
?>
<div id="content" class="site-content container py-5 mt-5">
<div id="primary" class="content-area">
<div class="row">
<div class="col-12">
<main id="main" class="site-main">
<header class="entry-header">
<?php the_title('<h1>', '</h1>'); ?>
</header>
<div class="entry-content">
<?php the_content(); ?>
<!-- Adicione aqui o loop de localização -->
</div>
</main>
</div>
</div>
</div>
</div>
<?php
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment