Created
March 14, 2019 19:39
-
-
Save ingliths/61250d18e51a22441b452a406539457a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <?php | |
| get_header(); | |
| $id_form = opt('FORMULARIO_INTERESSE'); | |
| ?> | |
| <?php | |
| if ( have_posts() ) : | |
| while ( have_posts() ) : the_post(); | |
| setPostViews($post->ID); | |
| #Nome do Modal | |
| $nmModal = "modal-contactar-anunciante-id-" . get_the_ID() ; | |
| $nmModalDenunicar = "modal-denunciar-anunciante"; | |
| $allData = get_fields($post->ID); | |
| # Galeria de Fotos | |
| $galeria = get_field('galeria_de_fotos', $post->ID); | |
| # Outros dados | |
| $tipo_de_anuncio = get_field('tipo_de_anuncio', $post->ID); | |
| $grupo_info = get_field("grupo_de_informacoes_de_$tipo_de_anuncio", $post->ID); | |
| $resumo = get_field('resumo', $post->ID); | |
| $preco = get_field('preco', $post->ID); | |
| $informacoesAdicionais = get_field('informacoes_adicionais', $post->ID); | |
| $videos = get_field('videos', $post->ID); | |
| $categorias = wp_get_post_terms($post->ID, array('tipos_classificados')); | |
| $terms = wp_get_post_terms( $post->ID, 'caracteristicas_classificados'); | |
| $categorias_txt = ""; | |
| $categorias_count = count($categorias); | |
| foreach($categorias as $key => $categoria) { | |
| if($key == ($categorias_count - 1)) { | |
| $categorias_txt .= $categoria->name; | |
| } else { | |
| if($categorias_count > 1) { | |
| $categorias_txt .= $categoria->name . " - "; | |
| } else { | |
| $categorias_txt .= $categoria->name; | |
| } | |
| } | |
| } | |
| //echo "<!--" . $categorias_txt . "-->"; | |
| $set_novo_usado = null; | |
| // Resgata e separa | |
| $NovoUsadoTerms = get_terms_terms_itens_arr($tipo_de_anuncio); | |
| $idsNovoUsado = array(); | |
| foreach($NovoUsadoTerms['itens'] as $n): | |
| $idsNovoUsado[] = $n->term_id; | |
| endforeach; | |
| // Separa se é novo, usado... | |
| foreach($terms as $key => $term): | |
| if(in_array($term->term_id, $idsNovoUsado)) { | |
| $set_novo_usado = $term; | |
| unset($terms[$key]); | |
| } | |
| endforeach; | |
| ?> | |
| <div id="classificado" class="mb-5 mt-5 <?php echo $tipo_de_anuncio ;?>"> | |
| <div class="container"> | |
| <div class="row"> | |
| <div class="col-md-12 mb-5"> | |
| <?php get_template_part('template-parts/breadcrumbs') ?> | |
| </div> | |
| <div class="col-md-9"> | |
| <div id="classificado-conteudo"> | |
| <div class="row"> | |
| <div class="col-md-6 classificado-imagem"> | |
| <?php if (has_post_thumbnail( $post->ID ) ): ?> | |
| <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?> | |
| <?php $imageTumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) ); ?> | |
| <img class="img-fluid" src="<?php echo $image[0]; ?>" alt="<?php the_title() ?>"> | |
| <?php else: ?> | |
| <img class="img-fluid" src="https://placehold.it/600x600&text=Sem+Imagem" alt="<?php the_title() ?>"> | |
| <?php endif; ?> | |
| <?php if(!empty($galeria)): ?> | |
| <div class="classificado-galeria"> | |
| <div class="row mt-4"> | |
| <div class="col-lg-3 col-4 img-galeria ativo"> | |
| <img | |
| class="img-fluid" | |
| width="150" | |
| height="150" | |
| data-src="<?php echo $image[0]; ?>" | |
| src="<?php echo $imageTumb[0]; ?>" | |
| alt="<?php the_title() ?>"> | |
| </div> | |
| <?php foreach($galeria as $imagem): ?> | |
| <div class="col-lg-3 col-4 img-galeria"> | |
| <img | |
| class="img-fluid" | |
| width="150" | |
| height="150" | |
| data-src="<?php echo $imagem['url'] ?>" | |
| src="<?php echo $imagem['sizes']['thumbnail'] ?>" | |
| alt=" <?php echo $imagem['title'] ?>"> | |
| </div> | |
| <?php endforeach; ?> | |
| </div> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| <div class="col-md-6"> | |
| <div class="denunciar"> | |
| <button | |
| data-toggle="modal" | |
| data-target="#<?php echo $nmModalDenunicar ?>"> | |
| ... | |
| </button> | |
| </div> | |
| <h1 class="classificado-titulo"> | |
| <?php the_title() ?> | |
| </h1> | |
| <div class="staring"> | |
| <?php if(function_exists("kk_star_ratings")) : echo kk_star_ratings($post->ID); endif; ?> | |
| </div> | |
| <p class="classificado-resumo mt-3"> | |
| <?php echo $resumo ?> | |
| </p> | |
| <?php if(!empty($set_novo_usado)): ?> | |
| <p class="classificado-resumo uppercase bold mt-3"> | |
| <?php echo $set_novo_usado->name ?> | |
| </p> | |
| <?php endif; ?> | |
| <?php if( isset($allData['grupo_de_informacoes_de_veiculos']) && $tipo_de_anuncio === 'veiculos'): ?> | |
| <?php $tmp = $allData['grupo_de_informacoes_de_veiculos']; ?> | |
| <ul class="ul-caract"> | |
| <li><?php echo $tmp['km']; ?> KM</li> | |
| <!-- <?php print_r($tmp['aceita_troca']) ?> --> | |
| <li>Aceita troca: <?php echo $tmp['aceita_troca'] ? 'Sim' : 'Não'; ?></li> | |
| <li>Horas de uso: <?php echo $tmp['horas_de_uso']; ?></li> | |
| </ul> | |
| <?php endif; ?> | |
| <?php if( isset($allData['grupo_de_informacoes_de_servicos']) && $tipo_de_anuncio === 'servicos'): ?> | |
| <?php | |
| $tmp = $allData['grupo_de_informacoes_de_servicos']; | |
| $tpServico = get_term($tmp['tipo_de_servico']); | |
| if($tpServico): ?> | |
| <ul class="ul-caract"> | |
| <li>Tipo do serviço: <?php echo $tpServico->name ; ?></li> | |
| </ul> | |
| <?php endif; ?> | |
| <?php endif; ?> | |
| <?php if( isset($allData['grupo_de_informacoes_de_acessorios']) && $tipo_de_anuncio === 'acessorios'): ?> | |
| <?php $tmp = $allData['grupo_de_informacoes_de_acessorios']; ?> | |
| <ul class="ul-caract"> | |
| <li>Ano: <?php echo $tmp['ano']; ?></li> | |
| </ul> | |
| <?php endif; ?> | |
| <?php if(!empty($terms)): ?> | |
| <ul class="ul-caract"> | |
| <?php foreach($terms as $term): ?> | |
| <li><?php echo $term->name ?></li> | |
| <?php endforeach; ?> | |
| </ul> | |
| <?php endif; ?> | |
| <p class="classificado-preco"> | |
| R$ <?php echo $preco ?> | |
| </p> | |
| <?php if(trim(@$allData['telefone_01']) !== ''): ?> | |
| <p class="classificado-telefone orange show-number" | |
| data-phone-acao="ga" | |
| data-phone-exibir="<?php echo base64_encode(formataTelefone($allData['telefone_01'])) ?>" | |
| data-phone-discar="<?php echo base64_encode(formataDiscaTelefone($allData['telefone_01'])) ?>"> | |
| <a href="javascript:;"> | |
| <i class="fa fa-phone"></i> | |
| <?php echo substr(formataTelefone($allData['telefone_01']), 0, 9); ?>... <small>Clique para exibir</small> | |
| </a> | |
| </p> | |
| <?php endif; ?> | |
| <?php if(trim(@$allData['telefone_02']) !== ''): ?> | |
| <p class="classificado-telefone orange show-number" | |
| data-phone-acao="ga" | |
| data-phone-exibir="<?php echo base64_encode(formataTelefone($allData['telefone_02'])) ?>" | |
| data-phone-discar="<?php echo base64_encode(formataDiscaTelefone($allData['telefone_02'])) ?>"> | |
| <a href="javascript:;"> | |
| <i class="fa fa-phone"></i> | |
| <?php echo substr(formataTelefone($allData['telefone_02']), 0, 9); ?>... <small>Clique para exibir</small> | |
| </a> | |
| </p> | |
| <?php endif; ?> | |
| <?php /* | |
| <!--p class="classificado-interesse"> | |
| <button | |
| class="btn btn-interesse" | |
| data-toggle="modal" | |
| data-target="#<?php echo $nmModal ?>"> | |
| Estou interessado no produto | |
| </button> | |
| </p--> | |
| */ ?> | |
| <p class="classificado-publicado mt-5"> | |
| Publicado por: <?php the_author_posts_link(); ?> | |
| </p> | |
| <div class="classificado-interesse"> | |
| <div class="titulo-interesse">Converse com o Vendedor</div> | |
| <?php if(!empty($id_form)): ?> | |
| <?php echo do_shortcode("[contact-form-7 id='$id_form']"); ?> | |
| <?php else: ?> | |
| <p class="alert alert-info">Selecione pelo Painel de Controle o formulário a ser exibido neste item.</p> | |
| <?php endif ?> | |
| </div> | |
| </div> | |
| <div class="col-md-12 mt-5"> | |
| <div class="classificado-item-adicional"> | |
| <h3 class="classificado-descricao aberto"> | |
| <img src="<?php echo get_template_directory_uri() ?>/assets/images/descricao.png" alt="Descrição <?php the_title() ?>"> | |
| Descrição | |
| </h3> | |
| <div> | |
| <?php the_content() ?> | |
| </div> | |
| </div> | |
| <div class="classificado-item-adicional"> | |
| <h3 class="classificado-descricao"> | |
| <img src="<?php echo get_template_directory_uri() ?>/assets/images/informacoes-adicionais.png" alt="Informações adicionais <?php the_title() ?>"> | |
| Informações adicionais | |
| </h3> | |
| <div style="display: none"> | |
| <?php if(!empty($informacoesAdicionais)): ?> | |
| <?php echo $informacoesAdicionais; ?> | |
| <?php else: ?> | |
| Nenhuma informação adicional enviada | |
| <?php endif; ?> | |
| </div> | |
| </div> | |
| <div class="classificado-item-adicional"> | |
| <h3 class="classificado-descricao"> | |
| <img src="<?php echo get_template_directory_uri() ?>/assets/images/videos.png" alt="Vídeos <?php the_title() ?>"> | |
| Vídeo | |
| </h3> | |
| <div style="display: none"> | |
| <?php if(!empty($videos)): foreach($videos as $video): ?> | |
| <?php if(!empty($video['video_links'])): ?> | |
| <?php if(preg_match('/youtube/im', $video['video_links'])): ?> | |
| <?php $url_video = explode('=', $video['video_links']); ?> | |
| <iframe | |
| width="100%" | |
| height="400" | |
| src="https://www.youtube.com/embed/<?php echo $url_video[1]; ?>" | |
| frameborder="0" | |
| allow="autoplay; encrypted-media" | |
| allowfullscreen></iframe> | |
| <?php endif; ?> | |
| <?php if(preg_match('/vimeo/im', $video['video_links'])): ?> | |
| <?php $url_video = explode('/', $video['video_links']); ?> | |
| <iframe | |
| src="https://player.vimeo.com/video/<?php echo $url_video[count($url_video) - 1]; ?>" | |
| width="100%" | |
| height="400" | |
| frameborder="0" | |
| webkitallowfullscreen | |
| mozallowfullscreen | |
| allowfullscreen></iframe> | |
| <?php endif; ?> | |
| <?php else: ?> | |
| Nenhum vídeo enviado | |
| <?php endif; ?> | |
| <?php endforeach; ?> | |
| <?php else: ?> | |
| Nenhum vídeo enviado | |
| <?php endif; ?> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="col-md-3"> | |
| <?php get_sidebar() ?> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <?php /* | |
| <!-- Modal --> | |
| <!--div class="modal fade modal-contactar-anunciante" id="<?php echo $nmModal ?>" tabindex="-1" role="dialog" aria-labelledby="Modal Interesse" aria-hidden="true"> | |
| <div class="modal-dialog" role="document"> | |
| <div class="modal-content"> | |
| <div class="modal-header"> | |
| <h5 class="modal-title" id="modal-title-interesse">Estou interessado</h5> | |
| <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
| <span aria-hidden="true">×</span> | |
| </button> | |
| </div> | |
| <div class="modal-body"> | |
| <?php if(!empty($id_form)): ?> | |
| <?php echo do_shortcode("[contact-form-7 id='$id_form']"); ?> | |
| <?php else: ?> | |
| <p class="alert alert-info">Selecione pelo Painel de Controle o formulário a ser exibido neste item.</p> | |
| <?php endif ?> | |
| </div> | |
| </div> | |
| </div> | |
| </div--> | |
| */ ?> | |
| <!-- Modal Denúncia --> | |
| <div class="modal fade <?php echo $nmModalDenunicar ?>" id="<?php echo $nmModalDenunicar ?>" tabindex="-1" role="dialog" aria-labelledby="Modal Denunciar" aria-hidden="true"> | |
| <div class="modal-dialog" role="document"> | |
| <div class="modal-content"> | |
| <div class="modal-header"> | |
| <h5 class="modal-title" id="modal-title-denunciar">Quero denunciar este anúncio</h5> | |
| <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
| <span aria-hidden="true">×</span> | |
| </button> | |
| </div> | |
| <div class="modal-body"> | |
| <p class="mb-0"><span class="laranja">Anúncio:</span> <span class="uppercase"><?php the_title() ?></span></p> | |
| <p><span class="laranja">Publicado por:</span> <?php the_author_posts_link(); ?></p> | |
| <?php echo do_shortcode('[contact-form-7 id="493"]'); ?> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener( 'wpcf7mailsent', function( event ) { | |
| if ( '493' == event.detail.contactFormId ) { | |
| $('#<?php echo $nmModalDenunicar ?>').modal('hide'); | |
| ga('send', 'event','Detalhe do Anuncio','Clique - Enviar Mensagem', '<?php echo get_the_title() ?>' + ' - ' + '<?php echo $categorias_txt; ?>'); | |
| alert('Formulário enviado com sucesso!'); | |
| } | |
| if ( '<?php echo $id_form ?>' == event.detail.contactFormId ) { | |
| /*$('#<?php echo $nmModal ?>').modal('hide');*/ | |
| alert('Formulário enviado com sucesso!'); | |
| } | |
| }, false ); | |
| </script> | |
| <?php | |
| endwhile; | |
| endif; | |
| ?> | |
| <?php //get_template_part('template-parts/banners-retangulares') ?> | |
| <?php get_footer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment