<?php
function actualiza_posicion(){
$centros = array('punteggio_borgaro','punteggio_leini','punteggio_settimo');
$campos = array('posizione_borgaro','posizione_leini','posizione_settimo');
for($l=0; $l< sizeof($campos); $l++){
$args = array(
'post_type' => 'prova_classifica',
'orderby' => 'meta_value_num',
'meta_key' => $centros[$l],
'order' => 'DESC',
'posts_per_page' => -1,
);
$the_query = new WP_Query($args);
$punteggio = array();
$laID = array();
if ($the_query->have_posts()) {
while ($the_query->have_posts()) {
$the_query->the_post();
$punteggio[] = get_field($centros[$l]);
$posicion[] = get_field($campos[$l]);
$laID[] = get_the_ID();
}
}
$a = 1;
for ($i = 0; $i < sizeof($punteggio); $i++) {
if ($punteggio[$i] > 0) {
$a = ($i > 0 && $punteggio[$i] < $punteggio[$i - 1]) ? ++$a : $a;
update_field($campos[$l], $a, $laID[$i]);
}
}
wp_reset_postdata();
}
}
add_action( 'save_post', 'actualiza_posicion' );
jQuery(document).ready(function() {
const mapa = document.querySelector('#mapaGoogle')
calculaTamano = ()=>{
switch(true){
case window.innerWidth > 1400:
divisor = 2
padding = 30
break
default:
divisor = 1
padding = 40
break
}
anchoMapa = (window.innerWidth/divisor) - padding
altoMapa = anchoMapa/1.45
mapa.width= anchoMapa
mapa.height= altoMapa
console.log(divisor)
}
calculaTamano()
window.addEventListener('resize', calculaTamano)
})
/**** Caso de mas de un mapa y ajusta margen
* según tamaño pantalla
* ***/
jQuery(document).ready(function() {
const mapa = document.querySelectorAll('.mapaGoogle')
let margenLateral = 0, anchoTotal = 0
calculaTamano = ()=>{
mapa.forEach((n)=>{
anchoTotal = window.innerWidth
switch(true){
case (anchoTotal >1000):
margenLateral = 600
break
case (anchoTotal < 1000 && anchoTotal > 600):
margenLateral = 400
break
case (anchoTotal < 600 && anchoTotal > 400):
margenLateral = 50
break
default:
margenLateral = 10
break
}
n.width= window.innerWidth - margenLateral
n.height= n.width/1.45
})
}
calculaTamano()
window.addEventListener('resize', calculaTamano)
})
const busqueda = "Palazzina di Caccia di Stupinigi" //String to find for background color changed
const colorFondo_modal = "#e8c812" //New Color for background color changed
const chrome_nav = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
const URLactual = window.location.href;
/**** Variables de Posicionado ****/
let hora_pos_top, la_hora, title_pos_top, el_alto, top_hora, pos_hora, diferencia, mas_alto, mas_bajo = 1000000
/**** Variables de Modal ****/
let a = 0, diaOut, mesOut, diaTxtOut, yearOut, horaOut, pos
/**** Control Modal ****/
termina = () =>
{
/*** Background Color ***/
cambiaFondo = false
if (subHeaderPagina.includes(busqueda)) cambiaFondo = true
elFondo_modal = document.querySelectorAll('.wcs-modal.wcs-modal-container')
if (cambiaFondo) elFondo_modal[0].style = "background-color: " + colorFondo_modal + "!important"
/*** Sub Heading ***/
headingModal = document.querySelectorAll('.wcs-modal__title')
headingModal[0].children[0].innerText = subHeaderPagina
/*** Boton ***/
boton = document.querySelectorAll('.wcs-modal__action')[0].outerHTML
/*** Datos Fecha ***/
fechaModal = document.querySelectorAll('.wcs-modal__meta')
fechaDatos = fechaModal[0].firstChild.innerText
diaOut = fechaDatos.substring(0, 2)
for (let i = 0; i < fechaDatos.length; i++) {
if (fechaDatos[i] === " ") {
a = a + 1;
switch (a) {
case 2:
mesOut = fechaDatos.substring(3, i)
pos = i
break
case 3:
diaTxtOut = fechaDatos.substring(pos + 1, i)
pos = i
break
case 4:
yearOut = fechaDatos.substring(pos + 1, i)
pos = i
break
case 5:
horaOut = fechaDatos.substring(pos + 1, i - 4)
break
}
}
}
/*** Imprimir y formatear ***/
datosHora = '<span class="hora-evento">ore ' + horaOut + '</span>' //Hora
datosFecha = '<div class="datado-modal"><span class="date-day">' + diaOut + '</span> <span class="date-short">' + mesOut + ' ' + diaTxtOut + ' ' + yearOut + '</span></div>'
fechaModal[0].innerHTML = '<div class="datado-principal"><div class="cuadro_tiempo">' + datosFecha + datosHora + '</div>' + boton
}
laBusqueda = () =>
{
containerModal = document.querySelectorAll('.wcs-modal__meta')
if (containerModal.length > 0) {
termina()
clearInterval(interval)
}
}
/************************************************ ******************************/
window.addEventListener('load', () =>
{
/****** Control Modal *****/
document.addEventListener('click', (e) =>
{
if (e.target.closest('.wcs-class')) {
contenedorPagina = e.target.closest('.wcs-class')
subHeader = contenedorPagina.querySelectorAll('.wcs-class__excerpt')
subHeaderPagina = subHeader[0].children[1].innerText
interval = setInterval(function () { laBusqueda() }, 1)
}
})
/****** Size and posittion adjustement for cards ****/
const titulos_slider = document.querySelectorAll('.titolo-evento.wcs-modal-call')
titulos_slider.forEach((v) =>
{
top_hora = v.nextElementSibling.offsetTop
if (top_hora > mas_alto) mas_alto = top_hora
if (top_hora < mas_bajo) mas_bajo = top_hora
diferencia = (mas_alto - mas_bajo)
})
if (chrome_nav) diferencia = diferencia + 40
titulos_slider.forEach((n) =>
{
la_hora = n.nextElementSibling
hora_pos_top = n.nextElementSibling.offsetTop
title_pos_top = n.offsetTop
el_alto = hora_pos_top - title_pos_top
n.nextElementSibling.nextElementSibling.style.marginTop = diferencia + (diferencia - el_alto) + "px"
})
})
/*If you need more control and flexibility, add a div inside the 'Row Center', set it 100% width, and add any number of divs inside it for your header columns.
To hide the rows that are empty (Row Left and Row Right in this case)
add the following CSS (I use this in my boilerplate). This will only apply if there's nothing inside the Rows.*/
/*remove min width from empty header row*/
:is(.oxy-header-left, .oxy-header-right):empty{
min-width: 0; /* or display: none */
max-width: 0; /* or display: none */
}
/*If you use ACSS, it adds a padding to the header, I'm not sure why but I always remove it.*/
/*ACSS adds padding to header, this removes it*/
#header .oxy-header-container {
padding-left: 0;
padding-right: 0;
}
if( function_exists('oxygen_vsb_register_condition') ) {
global $oxy_condition_operators;
oxygen_vsb_register_condition('Has Password', array('options'=>array('true', 'false'), 'custom'=>false), array('=='), 'has_password_callback', 'Post');
function has_password_callback($value, $operator) {
if( $value == "true" && post_password_required( get_the_ID() ) ) {
return true;
} else if( $value == "false" && !post_password_required( get_the_ID() ) ) {
return true;
} else {
return false;
}
}
}