��<?php /** * Generate child theme functions and definitions * * @package Generate */ // Encolamiento // General get_template_part('template-parts/custom', 'load-functions'); // Resource Loading get_template_part('template-parts/custom', 'load-resources'); // Footer get_template_part('template-parts/settings', 'footer'); // Dashboard get_template_part('template-parts/settings', 'dashboard'); //Mega Menu get_template_part('template-parts/settings', 'mega-menu'); // Flexible Content get_template_part('template-parts/flexible-content/init'); //Traducciones function change_multiple_texts( $translated ) { $text = array( 'Quiero mi plan!' => 'Quiero mi plan', 'Quiero mi plan!!' => 'Quiero mi plan', ); $translated = str_ireplace( array_keys( $text ), $text, $translated ); return $translated; } add_filter( 'gettext', 'change_multiple_texts', 20 ); function elimina_cabeceiras() { remove_action('wp-head', 'wp_generator'); remove_action('wp-head', 'wlwmanifest_link'); remove_action('wp-head', 'rsd_link'); } /* Bloques custom */ add_action('hacce_blocks', function () { include_once('blocks/comentarios/settings.php'); include_once('blocks/comentarios-lista/settings.php'); include_once('blocks/consejo-expertos/settings.php'); include_once('blocks/icono-texto/settings.php'); include_once('blocks/imagen-texto/settings.php'); include_once('blocks/logos/settings.php'); include_once('blocks/ofertas/settings.php'); include_once('blocks/ventajas/settings.php'); }); /*** **** FUNCI��� ��� �� NS FRONT ***/ /* Permitir subida de SVG */ function subir_svg($file_types) { $novo_tipo = array(); $novo_tipo['svg'] = 'image/svg+xml'; $file_types = array_merge($file_types, $novo_tipo); return $file_types; } /* Cargar scripts/estilos */ function dom_enqueue_scripts_styles() { // REMOVED-ORPHANED: wp_enqueue_script('isotope-script', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/3.0.6/isotope.pkgd.min.js'); wp_enqueue_script('slick-js', get_stylesheet_directory_uri() . '/js/slick/slick.min.js', array('jquery'), false, true); wp_enqueue_script('arenatours-script', get_stylesheet_directory_uri() . '/js/arenatours.js', array('jquery'), false, true); wp_enqueue_style('slick-css', get_stylesheet_directory_uri() . '/js/slick/slick.css'); wp_enqueue_style('slick-theme', get_stylesheet_directory_uri() . '/js/slick/slick-theme.css'); wp_enqueue_script( 'gsap-js', get_stylesheet_directory_uri() . '/assets/js/gsap/gsap.min.js', array(), false, true ); wp_enqueue_script( 'gsap-st', get_stylesheet_directory_uri() . '/assets/js/gsap/ScrollTrigger.min.js', array('gsap-js'), false, true ); // FIX Feb2026: app.js only needed on single tours (GSAP parallax for .bg-parallaxY-img) if ( is_singular('tours') ) { wp_enqueue_script('gsap-js2', get_stylesheet_directory_uri() . '/assets/js/app.js', array('gsap-js'), false, true); } // FIX Feb2026: ScrollToPlugin, CSSRulePlugin + slider-full only on pages/page-templates if ( is_page_template() || is_page() ) { wp_enqueue_script( 'gsap-stp', get_stylesheet_directory_uri() . '/assets/js/gsap/ScrollToPlugin.min.js', array('gsap-js'), false, true ); wp_enqueue_script( 'gsap-crp', get_stylesheet_directory_uri() . '/assets/js/gsap/CSSRulePlugin.min.js', array('gsap-js'), false, true ); wp_enqueue_script('slider-gsap-js2', get_stylesheet_directory_uri() . '/assets/js/script-slider-full.js', array('gsap-js', "gsap-st", "gsap-stp", "gsap-crp"), false, true); } // REMOVED: wp_enqueue_script( 'lodash-js', get_stylesheet_directory_uri() . '/assets/js/lodash/lodash.min.js', array(), false, true ); // wp_enqueue_script( 'init-scripts', get_stylesheet_directory_uri() . '/assets/js/init-script.js', array(), false, true ); // wp_enqueue_style( 'font-awesome', '//use.fontawesome.com/releases/v5.5.0/css/all.css', array(), '5.5.0' ); // wp_enqueue_style( 'dashicons' ); // wp_enqueue_style('bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'); } /* Devolver cadena vac��� � ��a */ function return_empty_string() { return ''; } /* Sliders para p��� � ��ginas de detalles (Hotel, Tour, Habitaci��� � ��n, Restaurante) */ function dom_prepara_slider() { global $post; if (is_singular('hoteles') || is_singular('tours')) { if (has_shortcode($post->post_content, 'gallery')) { $images = get_post_gallery(get_the_ID(), false); $idsImagenes = explode(",", $images["ids"]); $image_gallery = '<div class="galeria-slick galeria-slick-imagenes">'; $image_thumbnails = '<div class="galeria-slick galeria-slick-thumbnails">'; for ($i = 0; $i < count($images["src"]); $i++) { $image_gallery .= '<div><img src="' . wp_get_attachment_image_src($idsImagenes[$i], 'main-carousel')[0] . '" /></div>'; $image_thumbnails .= '<div><img src="' . wp_get_attachment_image_src($idsImagenes[$i], 'medium')[0] . '" /></div>'; } $image_gallery .= '</div>'; $image_thumbnails .= '</div>'; remove_shortcode('gallery'); add_shortcode('gallery', 'return_empty_string'); echo $image_gallery; echo $image_thumbnails; } } elseif (is_singular('habitaciones') || is_singular('restaurantes') || is_singular('servicios')) { if (has_shortcode($post->post_content, 'gallery')) { $images = get_post_gallery(get_the_ID(), false); $idsImagenes = explode(",", $images["ids"]); $image_gallery = '<div class="gallery-box showMouseTracking slider-full-width"><div class="galery-content galeria-slick-hyr galeria-slick-imagenes">'; for ($i = 0; $i < count($images["src"]); $i++) { $image_gallery .= '<div><img src="' . wp_get_attachment_image_src($idsImagenes[$i], 'main-carousel')[0] . '" /></div>'; } $image_gallery .= '</div></div>'; remove_shortcode('gallery'); add_shortcode('gallery', 'return_empty_string'); echo $image_gallery; } } } /* Quitar imagen en p��� � ��gina de detalles (Hotel, Tour, Habitaci��� � ��n, Restaurante) */ function dom_quita_imagen($options) { if (is_singular('hoteles') || is_singular('tours') || is_singular('habitaciones') || is_singular('restaurantes')) { $options['single_post_image'] = false; } return $options; } /* Cargar d��� � ��as del Tour */ function carga_dias_tour() { function dom_acf_carga_valores_dia_tour($field) { $field['choices'] = array(); $args = array( 'numberposts' => -1, 'post_type' => 'dias' ); $the_query = new WP_Query($args); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); $value = get_post_field('post_name', get_the_ID()); $label = get_the_title(); $field['choices'][$value] = $label; } wp_reset_postdata(); } return $field; } for ($i = 1; $i <= 20; $i++) { add_filter('acf/load_field/name=tour_dia_' . $i, 'dom_acf_carga_valores_dia_tour'); } } /* Para las estrellas de calificaci��� � ��n de productos */ function print_stars($numStars) { $stars = '<span class="ratings">'; for ($i = 1; $i <= $numStars; $i++) { if ($i == 6) $stars .= '<span class="glyphicon glyphicon-star extra-star"></span>'; else $stars .= '<span class="glyphicon glyphicon-star"></span>'; } $stars .= '</span>'; return $stars; } /* Barra lateral de Gu��� � ��as */ add_filter('generate_sidebar_layout', function ($layout) { if (is_singular('guias')) { return 'right-sidebar'; } return $layout; }); /* Barra lateral de Contacto */ function dom_engade_sidebar() { register_sidebar(array( 'name' => 'Sidebar de Contacto', 'id' => 'contacto_sidebar', 'class' => 'info-contacto', 'before_widget' => '<div>', 'after_widget' => '</div>', 'before_title' => '<h2>', 'after_title' => '</h2>', )); } add_action('widgets_init', 'dom_engade_sidebar'); // Obtener categor��� � ��a principal de post function get_post_primary_category($post_id, $term = 'category', $return_all_categories = false) { $return = array(); if (class_exists('WPSEO_Primary_Term')) { $wpseo_primary_term = new WPSEO_Primary_Term($term, $post_id); $primary_term = get_term($wpseo_primary_term->get_primary_term()); if (!is_wp_error($primary_term)) { $return['primary_category'] = $primary_term; } } if (empty($return['primary_category']) || $return_all_categories) { $categories_list = get_the_terms($post_id, $term); if (empty($return['primary_category']) && !empty($categories_list)) { if( ! is_wp_error($categories_list) ) { $return['primary_category'] = $categories_list[0]; } } if ($return_all_categories) { $return['all_categories'] = array(); if (!empty($categories_list)) { foreach ($categories_list as &$category) { $return['all_categories'][] = $category->term_id; } } } } return $return; } /* Sentencias */ elimina_cabeceiras(); add_action('upload_mimes', 'subir_svg'); add_action('wp_enqueue_scripts', 'dom_enqueue_scripts_styles'); add_action('generate_before_main_content', 'dom_prepara_slider'); add_filter('option_generate_blog_settings', 'dom_quita_imagen'); /*** **** FUNCI��� ��� �� NS ADMIN ***/ // Quita meta_box de GP function dom_remove_meta_boxes() { remove_meta_box('generate_layout_options_meta_box', 'hoteles', 'side'); } add_action('add_meta_boxes', 'dom_remove_meta_boxes', 999); // Orden del men��� � �� function dom_orden_menu($menu_ord) { if (!$menu_ord) return true; return array( 'index.php', // escritorio 'edit.php', // entradas 'edit.php?post_type=noticias-externas', // Entradas externas 'upload.php', //medios 'edit.php?post_type=page', // paginas 'edit-comments.php', //comentarios 'edit.php?post_type=hoteles', // Entradas Hoteles 'edit.php?post_type=habitaciones', //Entradas Habitaciones 'edit.php?post_type=restaurantes', // Entradas Restaurantes 'edit.php?post_type=servicios', //Entradas Servicios 'edit.php?post_type=actividades', // Entradas Actividades 'edit.php?post_type=tours', // Entradas Tours 'edit.php?post_type=dias', // Entradas D��� � ��as 'edit.php?post_type=guias', // Entradas Gu��� � ��as 'themes.php', //apariencia 'plugins.php', //plugins 'users.php', //usuarios 'tools.php', //herrramientas 'options-general.php', //ajustes ); } add_filter('custom_menu_order', 'dom_orden_menu'); add_filter('menu_order', 'dom_orden_menu'); // Iconos CPTs function custom_post_types_css() { echo '<style type="text/css" media="screen"> #adminmenu #menu-posts-hoteles .menu-icon-hoteles div.wp-menu-image::before { font-family: "Font Awesome 5 Free" !important; content: "\\f594"; color: #8CBF2F; font-weight: 900; } #adminmenu #menu-posts-habitaciones .menu-icon-habitaciones div.wp-menu-image::before { font-family: "Font Awesome 5 Free" !important; content: "\\f236"; color: #8CBF2F; font-weight: 900; } #adminmenu #menu-posts-restaurantes .menu-icon-restaurantes div.wp-menu-image::before { font-family: "Font Awesome 5 Free" !important; content: "\\f2e7"; color: #8CBF2F; font-weight: 900; } #adminmenu #menu-posts-servicios .menu-icon-servicios div.wp-menu-image::before { font-family: FontAwesome !important; content: "\\f5c5"; color: #8CBF2F; font-weight: 900; } #adminmenu #menu-posts-actividades .menu-icon-actividades div.wp-menu-image::before { font-family: FontAwesome !important; content: "\\f45d"; color: #8CBF2F; font-weight: 900; } #adminmenu #menu-posts-tours .menu-icon-tours div.wp-menu-image::before { font-family: FontAwesome !important; content: "\\f072"; color: #FFD700; font-weight: 900; } #adminmenu #menu-posts-dias .menu-icon-dias div.wp-menu-image::before { font-family: FontAwesome !important; content: "\\f073"; color: #FFD700; font-weight: 900; } #adminmenu #menu-posts-guias .menu-icon-guias div.wp-menu-image::before { font-family: FontAwesome !important; content: "\\f5a0"; color: #6EA028; font-weight: 900; } </style>'; } add_action('admin_head', 'custom_post_types_css'); // Quitar descripci��� � ��n en Pa��� � ��s function pais_remove_taxonomy_description($columns) { if (!isset($_GET['taxonomy']) || $_GET['taxonomy'] != 'pais') return $columns; if ($posts = $columns['description']) { unset($columns['description']); } return $columns; } add_filter('manage_edit-pais_columns', 'pais_remove_taxonomy_description'); // Mostrar imagen en Paises add_filter('manage_edit-pais_columns', function ($defaults) { $defaults['imagen'] = ''; return $defaults; }, 1); add_filter('manage_pais_custom_column', function ($content, $column_name, $term_id) { $ter = get_term($term_id, 'pais'); $img = get_field('pais_imagen', $ter); if ($column_name === 'imagen') { $content = '<img src="' . $img['url'] . '" style="height:40px;width:auto;float:right;">'; } return $content; }, 1, 3); // Mostrar Hotel en Servicios add_filter('manage_servicios_posts_columns', 'servicios_columns', 5); add_action('manage_servicios_posts_custom_column', 'servicios_custom_columns', 5, 2); function servicios_columns($columns) { $columns['hotel'] = 'Hotel'; return $columns; } function servicios_custom_columns($column_name, $id) { if ($column_name === 'hotel') { $hotel = get_field('engadir_a_hotel', $id); if ($hotel) echo '<a href="' . get_the_permalink($hotel) . '">' . get_the_title($hotel) . '</a>'; } } // Mostrar Hotel en Actividades add_filter('manage_actividades_posts_columns', 'actividades_columns', 5); add_action('manage_actividades_posts_custom_column', 'actividades_custom_columns', 5, 2); function actividades_columns($columns) { $columns['hotel'] = 'Hotel'; return $columns; } function actividades_custom_columns($column_name, $id) { if ($column_name === 'hotel') { $hotel = get_field('engadir_a_hotel', $id); if ($hotel) echo '<a href="' . get_the_permalink($hotel) . '">' . get_the_title($hotel) . '</a>'; } } // Mostrar Hotel en Restaurantes add_filter('manage_restaurantes_posts_columns', 'restaurantes_columns', 5); add_action('manage_restaurantes_posts_custom_column', 'restaurantes_custom_columns', 5, 2); function restaurantes_columns($columns) { $columns['hotel'] = 'Hotel'; return $columns; } function restaurantes_custom_columns($column_name, $id) { if ($column_name === 'hotel') { $hotel = get_field('engadir_a_hotel', $id); if ($hotel) echo '<a href="' . get_the_permalink($hotel) . '">' . get_the_title($hotel) . '</a>'; } } // Mostrar Hotel en Habitaciones add_filter('manage_habitaciones_posts_columns', 'habitaciones_columns', 5); add_action('manage_habitaciones_posts_custom_column', 'habitaciones_custom_columns', 5, 2); function habitaciones_columns($columns) { $columns['hotel'] = 'Hotel'; return $columns; } function habitaciones_custom_columns($column_name, $id) { if ($column_name === 'hotel') { $hotel = get_field('engadir_a_hotel', $id); if ($hotel) echo '<a href="' . get_the_permalink($hotel) . '">' . get_the_title($hotel) . '</a>'; } } /** * Font Awesome Kit Setup * * This will add your Font Awesome Kit to the front-end, the admin back-end, * and the login screen area. */ if (!function_exists('fa_custom_setup_kit')) { function fa_custom_setup_kit($kit_url = '') { foreach (['wp_enqueue_scripts', 'admin_enqueue_scripts', 'login_enqueue_scripts'] as $action) { add_action( $action, function () use ($kit_url) { wp_enqueue_script('font-awesome-kit', $kit_url, [], null); } ); } } } //fa_custom_setup_kit('https://kit.fontawesome.com/d6780efd75.js'); //function webp_upload_mimes( $existing_mimes ) {// add webp to the list of mime types$existing_mimes['webp'] = 'image/webp';// return the array back to the function with our added mime typereturn $existing_mimes;}add_filter( 'mime_types', 'webp_upload_mimes' ); //funcines de JADR //breadcrums banner verde function custom_breadcrumbs() { // Configuraci��� � ��n b��� � ��sica $separator = ' &raquo; '; // Separador entre los niveles // Detectar idioma seg��� � ��n la URL $current_url = $_SERVER['REQUEST_URI']; if (strpos($current_url, '/es/') !== false) { $home_text = 'Inicio'; } elseif (strpos($current_url, '/en/') !== false) { $home_text = 'Home'; } elseif (strpos($current_url, '/fr/') !== false) { $home_text = 'Accueil'; } elseif (strpos($current_url, '/de/') !== false) { $home_text = 'StartSeite'; } elseif (strpos($current_url, '/it/') !== false) { $home_text = 'Home'; } elseif (strpos($current_url, '/pt-pt/') !== false) { $home_text = 'In��� � ��cio'; } else { $home_text = 'Inicio'; // Por defecto en espa��� � ��ol } $home_link = home_url('/'); // URL de la p��� � ��gina de inicio // No mostrar breadcrumbs en la portada if (is_front_page()) { return; } // Inicio del breadcrumb echo '<nav class="breadcrumb">'; echo '<a href="' . $home_link . '">' . $home_text . '</a><span class="breadcrumb-separator">' . $separator . '</span>'; global $post; if (is_singular('post')) { // Para entradas de blog $category = get_the_category(); if ($category) { foreach ($category as $cat) { if (strtolower($cat->slug) !== 'hoteles') { // Evitar mostrar la categor��� � ��a "hoteles" $category_link = get_category_link($cat->term_id); echo '<a href="' . esc_url($category_link) . '">' . esc_html($cat->name) . '</a><span class="breadcrumb-separator">' . $separator . '</span>'; break; // Mostrar solo la primera categor��� � ��a no excluida } } } echo '<span>' . get_the_title() . '</span>'; } elseif (is_page() && !is_front_page()) { // Para p��� � ��ginas if ($post->post_parent) { $ancestors = array_reverse(get_post_ancestors($post->ID)); foreach ($ancestors as $ancestor) { $ancestor_link = get_permalink($ancestor); echo '<a href="' . $ancestor_link . '">' . get_the_title($ancestor) . '</a><span class="breadcrumb-separator">' . $separator . '</span>'; } } echo '<span>' . get_the_title() . '</span>'; } elseif (is_category()) { // Para categor��� � ��as $category_name = strtolower(single_cat_title('', false)); if ($category_name !== 'hoteles') { // Evitar mostrar la categor��� � ��a "hoteles" echo '<span>' . single_cat_title('', false) . '</span>'; } } elseif (is_archive()) { // Para archivos echo '<span>' . post_type_archive_title('', false) . '</span>'; } elseif (is_search()) { // Para resultados de b��� � ��squeda echo '<span>Resultados de b��� � ��squeda para "' . get_search_query() . '"</span>'; } elseif (is_404()) { // Para p��� � ��ginas de error 404 echo '<span>Error 404</span>'; } elseif (is_singular()) { // Para Custom Post Types (CPT) $taxonomy = 'category'; // Cambia esto si tus t��� � ��rminos de ACF usan una taxonom��� � ��a personalizada $terms = get_the_terms($post->ID, $taxonomy); if ($terms && !is_wp_error($terms)) { foreach ($terms as $term) { if ($term->slug !== 'hoteles') { // Excluir el t��� � ��rmino "hoteles" $term_link = get_term_link($term); echo '<a href="' . esc_url($term_link) . '">' . esc_html($term->name) . '</a><span class="breadcrumb-separator">' . $separator . '</span>'; } } } $post_type = get_post_type_object(get_post_type()); if ($post_type && !is_wp_error($post_type)) { $post_type_link = get_post_type_archive_link($post_type->name); echo '<a href="' . esc_url($post_type_link) . '">' . esc_html($post_type->labels->singular_name) . '</a><span class="breadcrumb-separator">' . $separator . '</span>'; } echo '<span>' . get_the_title() . '</span>'; } // Fin del breadcrumb echo '</nav>'; } /* Estilo general del breadcrumb */ add_action('wp_head', function() { echo '<style> .breadcrumb { background-color: #ffffff; /* Color de fondo por defecto */ color: #000000; /* Color del texto por defecto */ font-family: "Raleway", sans-serif; /* Familia de fuente por defecto */ font-weight: 400; /* Peso de la fuente */ font-size: 16px; /* Tama��� � ��o del texto */ padding: 10px; /* Espaciado interno */ text-align: center; /* Alineaci��� � ��n inicial (puede cambiarse) */ margin-left: 0; /* Margen izquierdo por defecto */ margin-bottom: 0; /* Margen inferior */ display: block; } /* Espaciado entre migas (secciones del breadcrumb) */ .breadcrumb a { color: inherit; /* Heredar color del texto */ text-decoration: none; /* Sin subrayado */ margin-right: 8px; /* Espacio entre migas */ } .breadcrumb a:last-child { margin-right: 0; /* Eliminar margen del ��� � ��ltimo elemento */ } /* Estilo del separador */ .breadcrumb-separator { margin: 0 5px; /* Espaciado alrededor del separador */ color: #000000; /* Color del separador */ } /* Alineaci��� � ��n del breadcrumb */ .breadcrumb.align-left { text-align: left; } .breadcrumb.align-right { text-align: right; } .breadcrumb.align-center { text-align: center; } /* Margen izquierdo para empezar el breadcrumb */ .breadcrumb.margin-left { margin-left: 20px; /* Ajusta el valor seg��� � ��n sea necesario */ } /* Cambiar espaciado entre migas con una clase adicional */ .breadcrumb.spacing-wide a { margin-right: 16px; /* M��� � ��s espacio entre migas */ } </style>'; }); /* fin funcion breadcrums*/ // Ofuscar enlaces function ofuscar_enlaces($content) { $enlaces = [ 'https://arenatours.pro/aviso-legal/' => 'avisoLegal', 'https://arenatours.pro/condiciones-generales/' => 'condicionesGenerales', 'https://arenatours.pro/politica-de-privacidad/' => 'politicaPrivacidad', 'https://arenatours.pro/politica-de-cookies/' => 'politicaCookies', 'https://arenatours.pro/media-kit/' => 'mediaKit', 'https://arenatours.pro/trabaja-con-nosotros/' => 'trabajaConNosotros', ]; foreach ($enlaces as $url => $id) { $ofuscado = '<span class="link-ofuscado" data-id="' . esc_attr($id) . '">[Clic aqu��� � ��]</span>'; $content = str_replace($url, $ofuscado, $content); } return $content; } add_filter('the_content', 'ofuscar_enlaces'); function script_para_revelar_enlaces() { ?> <script> document.addEventListener('DOMContentLoaded', function() { const enlaces = { avisoLegal: "https://arenatours.com/aviso-legal/", condicionesGenerales: "https://arenatours.com/condiciones-generales/", politicaPrivacidad: "https://arenatours.com/politica-de-privacidad/", politicaCookies: "https://arenatours.com/politica-de-cookies/", mediaKit: "https://arenatours.com/media-kit/", trabajaConNosotros: "https://arenatours.com/trabaja-con-nosotros/" }; document.querySelectorAll('.link-ofuscado').forEach(function(el) { const id = el.getAttribute('data-id'); if (id && enlaces[id]) { el.innerHTML = `<a href="${enlaces[id]}" target="_blank">${el.textContent}</a>`; } }); }); </script> <?php } add_action('wp_footer', 'script_para_revelar_enlaces'); // Fin de ofuscar enlaces // Agregar etiquetas hreflang y x-default add_action('wp_head', 'add_hreflang_to_pagination'); function add_hreflang_to_pagination() { if (is_paged()) { global $wp_query; $current_page = max(1, get_query_var('paged')); $languages = apply_filters('wpml_active_languages', NULL); if (!empty($languages)) { foreach ($languages as $lang_code => $language) { $url = get_pagenum_link($current_page); $translated_url = apply_filters('wpml_permalink', $url, $lang_code); echo '<link rel="alternate" hreflang="' . esc_attr($lang_code) . '" href="' . esc_url($translated_url) . '" />' . PHP_EOL; } // A��� � ��adir etiqueta x-default $default_url = get_pagenum_link($current_page); echo '<link rel="alternate" hreflang="x-default" href="' . esc_url($default_url) . '" />' . PHP_EOL; } } } // Fin etiquetas hreflang y x-default // Ocultar imagen destacada en entradas add_action( 'after_setup_theme', function() { remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single', 10 ); } ); // Fin ocultar imagen destacada en entradas //Mostrar letras en color verde o blanco seg��� � ��n la p��� � ��gina que se est��� � �� visitando function obtener_clase_css_menu() { // Definir los slugs de las p��� � ��ginas en las que cambiar��� � �� la clase $excluded_pages = ['magazine', 'guias']; // Obtener el slug de la p��� � ��gina actual $current_page_slug = get_queried_object() ? get_queried_object()->post_name : ''; // Retornar la clase correspondiente return in_array($current_page_slug, $excluded_pages) ? 'text-at-green' : 'text-at-white'; } //Clase para recorrer las opciones de un men��� � �� y a��� � ��ade la clase css "text-at-white" a los enlaces del primer nivel del men��� � �� class Custom_Walker_White_link_Nav_Menu extends Walker_Nav_Menu { function start_el(&$output, $item, $depth = 0, $args = null, $id = 0) { $classes = empty($item->classes) ? array() : (array) $item->classes; $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args)); $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; $output .= '<li' . $class_names . '>'; $atts = array(); $atts['title'] = !empty($item->title) ? $item->title : ''; $atts['target'] = !empty($item->target) ? $item->target : ''; $atts['rel'] = !empty($item->xfn) ? $item->xfn : ''; $atts['href'] = !empty($item->url) ? $item->url : ''; // Agregar la clase "text-at-white" solo a los enlaces de primer nivel $link_classes = ($depth === 0) ? obtener_clase_css_menu() : ''; $attributes = ''; foreach ($atts as $attr => $value) { if (!empty($value)) { $attributes .= ' ' . $attr . '="' . esc_attr($value) . '"'; } } $title = apply_filters('the_title', $item->title, $item->ID); $item_output = $args->before; $item_output .= '<a class="' . esc_attr($link_classes) . '"' . $attributes . '>'; $item_output .= $args->link_before . $title . $args->link_after; $item_output .= '</a>'; $item_output .= $args->after; $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args); } } // DISABLED: // Cargar scripts para el AI Agent de Botpress (Norberto) // DISABLED: function cargar_scripts_ai_agent_arenatours() { // DISABLED: // Scripts de Botpress ORIGINALES (los que funcionaban) // DISABLED: wp_enqueue_script('botpress-inject', 'https://cdn.botpress.cloud/webchat/v2.4/inject.js', array(), null, true); // DISABLED: wp_enqueue_script('botpress-config', 'https://files.bpcontent.cloud/2025/05/19/21/20250519213605-Q86ZKXOM.js', array('botpress-inject'), null, true); // DISABLED: // DISABLED: // Nuestro script con la l��� � ��gica personalizada // DISABLED: wp_enqueue_script( // DISABLED: 'ai-agent-logic', // DISABLED: get_stylesheet_directory_uri() . '/js/ai-agent-react.js', // DISABLED: array('botpress-config'), // DISABLED: '1.1.2', // Nueva versi��� � ��n // DISABLED: true // DISABLED: ); // DISABLED: } // DISABLED: add_action('wp_enqueue_scripts', 'cargar_scripts_ai_agent_arenatours'); // DISABLED: // Estilo para el bot��� � ��n de Botpress // DISABLED: function estilo_ai_agent_arenatours() { // DISABLED: echo '<style> // DISABLED: .bpWebchat { bottom: 100px !important; right: 20px !important; z-index: 2147483647 !important; } // DISABLED: .bpFab { bottom: 20px !important; right: 20px !important; z-index: 2147483647 !important; background-color: #6D813B !important; } // DISABLED: /*@media screen and (max-width: 1024px) { // DISABLED: .bpFab, .bpWebchat { // DISABLED: display: none !important; // DISABLED: } // DISABLED: }*/ // DISABLED: </style>'; // DISABLED: } // DISABLED: add_action('wp_head', 'estilo_ai_agent_arenatours'); // Evitamos que WPML reescriba .htaccess evitando asi el error 500 de redireccion add_filter( 'xmlrpc_enabled', '__return_false' ); // Ahorra recursos de validaci��� � ��n add_filter( 'wpml_setting', function( $value, $key ) { if ( $key === 'language_negotiation_type' ) { // Forzamos que siempre crea que est��� � �� en modo directorio sin re-validar return 1; } return $value; }, 10, 2 ); // Optimizaci��� � ��n: Diferir inicializaci��� � ��n de Swiper // Optimizaci��� � ��n: font-display swap para GeneratePress icons function arenatours_font_display_swap() { $font_css = ' @font-face { font-family: "GeneratePress"; src: url("' . get_template_directory_uri() . '/assets/fonts/generatepress.woff2") format("woff2"); font-weight: normal; font-style: normal; font-display: swap; }'; wp_add_inline_style('generate-style', $font_css); } add_action('wp_enqueue_scripts', 'arenatours_font_display_swap', 20); // Optimizaci��� � ��n: Preload de fuentes cr��� � ��ticas function arenatours_preload_fonts() { echo '<link rel="preload" href="' . get_template_directory_uri() . '/assets/fonts/generatepress.woff2" as="font" type="font/woff2" crossorigin>' . "\n"; echo '<link rel="preload" href="' . get_stylesheet_directory_uri() . '/assets/fonts/icoArenaTours-v1.0/fonts/icoArenaTours.woff?7s2hwn" as="font" type="font/woff" crossorigin>' . "\n"; } add_action('wp_head', 'arenatours_preload_fonts', 1); /** * FIX Feb2026: Preload hero cover image for LCP improvement. * Outputs <link rel="preload"> in <head> for the banner cover image on * destination pages that use template_4 (video banner with cover). * This eliminates the ~5s resource load delay reported by Lighthouse. */ function arenatours_preload_hero_image() { // Only on singular pages that have the 'destino' flexible content field if ( ! is_singular() ) return; $post_id = get_the_ID(); if ( ! $post_id ) return; // Get the flexible content rows $rows = get_field('destino', $post_id); if ( ! $rows || ! is_array($rows) ) return; // Look for the first banners_destino row with template_4 foreach ( $rows as $row ) { if ( isset($row['acf_fc_layout']) && $row['acf_fc_layout'] === 'banners_destino' ) { // Check if it's template_4 (video banner) if ( isset($row['plantilla_destiny']) && $row['plantilla_destiny'] === 'template_4' ) { if ( isset($row['cover_del_video']) && is_array($row['cover_del_video']) && ! empty($row['cover_del_video']['url']) ) { $url = esc_url($row['cover_del_video']['url']); echo '<link rel="preload" as="image" href="' . $url . '" fetchpriority="high">' . "\n"; } } // Also handle templates 1-3 which use the featured image elseif ( has_post_thumbnail($post_id) ) { $thumb_url = get_the_post_thumbnail_url($post_id, 'full'); if ( $thumb_url ) { echo '<link rel="preload" as="image" href="' . esc_url($thumb_url) . '" fetchpriority="high">' . "\n"; } } break; // Only need the first banner } } } add_action('wp_head', 'arenatours_preload_hero_image', 2); /** * FIX Feb2026: Remove duplicate Google Fonts Raleway. * The child theme loads Raleway locally via assets/fonts/raleway/stylesheet.css, * so the Google Fonts CDN version from GeneratePress is an unnecessary extra request. */ function arenatours_dequeue_google_fonts() { wp_dequeue_style('generate-fonts'); wp_deregister_style('generate-fonts'); } add_action('wp_enqueue_scripts', 'arenatours_dequeue_google_fonts', 99); // ======================================== // OPTIMIZACI��� ��� �� N: Eliminar CSS innecesarios // A��� � ��adido: 2026-02-22 // ======================================== function arenatours_remove_unnecessary_css() { // Solo en frontend, no en admin if (is_admin()) { return; } // 1. Eliminar svg-with-js.css de FontAwesome (ya usamos webfonts) wp_dequeue_style('font-awesome-svg-styles'); wp_deregister_style('font-awesome-svg-styles'); // 2. Mantener dashicons para usuarios logueados (toolbar/frontend admin UX) // y desactivarlo para visitantes. if (!is_user_logged_in()) { wp_dequeue_style('dashicons'); wp_deregister_style('dashicons'); } } add_action('wp_enqueue_scripts', 'arenatours_remove_unnecessary_css', 100); // ======================================== // OPTIMIZACI��� ��� �� N: Desencolar dflip (no se usa) // A��� � ��adido: 2026-02-22 // ======================================== // ======================================== // OPTIMIZACI�N: Desencolar dflip (excepto en p�gina de cat�logos) // A�adido: 2026-02-22 | Modificado: 2026-02-26 (fix cat�logos) // ======================================== function arenatours_remove_dflip() { // Solo en frontend if (is_admin()) { return; } // NO desencolar en la p�gina de cat�logos if (is_page("catalogos") || is_singular("dflip")) { return; } // Desencolar flipbook JS y CSS en otras p�ginas wp_dequeue_script("dflip-script"); wp_dequeue_style("dflip-style"); } add_action("wp_enqueue_scripts", "arenatours_remove_dflip", 100); // ======================================== // OPTIMIZACI��� ��� �� N: A��� � ��adir dimensiones a im��� � ��genes (CLS fix) // A��� � ��adido: 2026-02-22 // ======================================== function arenatours_add_image_dimensions($content) { if (is_admin() || empty($content)) { return $content; } // Buscar im��� � ��genes sin width o height return preg_replace_callback( '/<img([^>]*?)src=["\']([^"\']+)["\']([^>]*?)>/i', function($matches) { $before = $matches[1]; $src = $matches[2]; $after = $matches[3]; $full_tag = $matches[0]; // Si ya tiene width Y height, no hacer nada if (preg_match('/width\s*=/i', $before . $after) && preg_match('/height\s*=/i', $before . $after)) { return $full_tag; } // Intentar obtener dimensiones del archivo local $upload_dir = wp_upload_dir(); $base_url = $upload_dir['baseurl']; $base_path = $upload_dir['basedir']; // Si es una imagen de uploads if (strpos($src, $base_url) !== false || strpos($src, '/wp-content/uploads/') !== false) { $file_path = str_replace($base_url, $base_path, $src); // Fallback para URLs relativas if (strpos($src, '/wp-content/uploads/') === 0) { $file_path = ABSPATH . ltrim($src, '/'); } if (file_exists($file_path)) { $size = @getimagesize($file_path); if ($size) { $width = $size[0]; $height = $size[1]; // A��� � ��adir dimensiones si faltan $attrs = ''; if (!preg_match('/width\s*=/i', $before . $after)) { $attrs .= ' width="' . $width . '"'; } if (!preg_match('/height\s*=/i', $before . $after)) { $attrs .= ' height="' . $height . '"'; } return '<img' . $before . 'src="' . $src . '"' . $after . $attrs . '>'; } } } return $full_tag; }, $content ); } add_filter('the_content', 'arenatours_add_image_dimensions', 20); add_filter('widget_text', 'arenatours_add_image_dimensions', 20); /** * FIX Feb2026: Inline critical CSS for LCP improvement. * Outputs minimal above-the-fold CSS inline in <head> so the hero image * can render without waiting for external stylesheets. * This eliminates ~5.3s Element Render Delay caused by 37 render-blocking CSS files. */ function arenatours_critical_css_inline() { ?> <style id="critical-css"> @font-face{font-family:'Raleway';src:url('/wp-content/themes/generatepress-child/assets/fonts/raleway/Raleway-Regular.woff2') format('woff2');font-weight:400;font-style:normal;font-display:swap} @font-face{font-family:'Raleway';src:url('/wp-content/themes/generatepress-child/assets/fonts/raleway/Raleway-SemiBold.woff2') format('woff2');font-weight:600;font-style:normal;font-display:swap} @font-face{font-family:'Raleway';src:url('/wp-content/themes/generatepress-child/assets/fonts/raleway/Raleway-Bold.woff2') format('woff2');font-weight:700;font-style:normal;font-display:swap} </style> <?php } add_action('wp_head', 'arenatours_critical_css_inline', 0); /** * FIX Feb2026: Defer non-critical CSS (DENY-LIST approach). * Only defers specific large plugin CSS files known to be safe for async loading. * Theme and layout CSS stays synchronous to prevent CLS regressions. * Total deferred: ~60KB of plugin CSS that is 89-99% unused on most pages. */ function arenatours_defer_noncritical_css($html, $handle, $href, $media) { // DENY-LIST approach: Only defer specific LARGE CSS files known to be safe. // Everything else stays synchronous to prevent CLS regressions. // These files are either below-fold, plugin-only, or have 90%+ unused CSS. $defer_handles = array( // Large plugin CSS (60KB+ total, 89-99% unused) 'font-awesome-official', // 21KB, 99% unused 'font-awesome-official-v4shim',// 4.5KB - FA v4 shims 'wp-block-library', // 16KB, 99% unused 'wpforms-modern-full', // 16KB, 89% unused - forms below fold // Small plugin CSS (below fold, safe to defer) 'saswp-rf-style', // Schema plugin 'saswp-frontend-css', // Schema plugin 'jquery-rateyo-min-css', // Schema plugin rating 'doi-error-notification', // Double opt-in 'sib-front-css', // Sendinblue 'wpml-legacy-dropdown-0', // WPML language switcher // Below-fold template section CSS (0.3-1KB each, safe to defer) 'contenido_destino-style', // Content section 'carrusel_destino-style', // Carousel section 'actividades_destino-style', // Activities section 'contacto_destino-style', // Contact section 'clima_destino-style', // Weather section 'hoteles_destino-style', // Hotels section 'consejos_destino-style', // Tips section 'otros_destino-style', // Other destinations 'testimonios_destino-style', // Testimonials section 'cta_destino-style', // CTA section 'galeria_destiny-style', // Gallery section 'block_subscribe-style', // Subscribe block // Below-fold utility CSS 'aos-css', // AOS animations (scroll-triggered) 'slick-css', // Slick carousel 'slick-theme', // Slick theme 'style-travel-guide-css', // Travel guide section 'style-font-raleway', // Redundant: inlined in critical CSS ); // Only defer if handle is in our safe list if (!in_array($handle, $defer_handles)) { return $html; } // Don't touch inline styles or admin if (strpos($html, 'inline-css') !== false || is_admin()) { return $html; } // Convert to async: media="print" onload="this.media='all'" $deferred = str_replace( "media='all'", "media='print' onload=\"this.media='all';this.onload=null;\"", $html ); if ($deferred === $html) { $deferred = str_replace( 'media="all"', 'media="print" onload="this.media=\'all\';this.onload=null;"', $html ); } // Noscript fallback $noscript = preg_replace('/\s*onload="[^"]*"/', '', $html); $noscript = preg_replace("/\s*onload='[^']*'/", '', $noscript); return $deferred . '<noscript>' . trim($noscript) . "</noscript>\n"; } add_filter('style_loader_tag', 'arenatours_defer_noncritical_css', 999, 4); // ============================================================================= // PAGESPEED OPTIMIZATION - Feb 28 2026 // ============================================================================= /** * FIX #1: Lazy Load reCAPTCHA (WPForms) * Solo carga reCAPTCHA cuando el usuario interact�a con el formulario */ add_filter('wpforms_frontend_recaptcha_disable', '__return_true'); function arenatours_lazy_recaptcha() { ?> <script> (function() { var recaptchaLoaded = false; var forms = document.querySelectorAll('.wpforms-form, .wpcf7-form'); function loadRecaptcha() { if (recaptchaLoaded) return; recaptchaLoaded = true; var script = document.createElement('script'); script.src = 'https://www.google.com/recaptcha/api.js?render=explicit'; script.async = true; script.defer = true; document.head.appendChild(script); } forms.forEach(function(form) { form.addEventListener('focusin', loadRecaptcha, {once: true}); form.addEventListener('click', loadRecaptcha, {once: true}); }); // Fallback: cargar despu�s de 5 segundos si el usuario no interact�a setTimeout(loadRecaptcha, 5000); })(); </script> <?php } add_action('wp_footer', 'arenatours_lazy_recaptcha', 99); /** * FIX #2: Defer Google Tag Manager * Carga GTM despu�s del contenido principal */ function arenatours_defer_gtm() { ?> <script> window.addEventListener('load', function() { setTimeout(function() { var gtm = document.createElement('script'); gtm.src = 'https://www.googletagmanager.com/gtm.js?id=GTM-K9DT9W7'; gtm.async = true; document.head.appendChild(gtm); }, 2000); // 2 segundos despu�s del load }); </script> <?php } // Solo activar si GTM no est� ya en el header add_action('wp_footer', 'arenatours_defer_gtm', 1); /** * FIX #3: Lazy Load Video Hero * Usa poster image y carga video solo cuando est� visible */ function arenatours_lazy_video_script() { ?> <script> document.addEventListener('DOMContentLoaded', function() { var videos = document.querySelectorAll('video[data-src]'); if ('IntersectionObserver' in window) { var videoObserver = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { var video = entry.target; var source = video.querySelector('source'); if (source && source.dataset.src) { source.src = source.dataset.src; video.load(); video.play(); } else if (video.dataset.src) { video.src = video.dataset.src; video.load(); video.play(); } videoObserver.unobserve(video); } }); }, {rootMargin: '100px'}); videos.forEach(function(video) { videoObserver.observe(video); }); } }); </script> <?php } add_action('wp_footer', 'arenatours_lazy_video_script', 5); // END PAGESPEED OPTIMIZATION require_once get_stylesheet_directory() . '/catalogs.php'; require_once get_stylesheet_directory() . '/geo-schema.php'; 1.0Arenatours UKhttps://arenatours.com/en/Arenatours General Conditionsrich600338<blockquote class="wp-embedded-content" data-secret="d4pK312F1r"><a href="https://arenatours.com/en/general-conditions/">General Conditions</a></blockquote><iframe sandbox="allow-scripts" security="restricted" src="https://arenatours.com/en/general-conditions/embed/#?secret=d4pK312F1r" width="600" height="338" title="“General Conditions” — Arenatours UK" data-secret="d4pK312F1r" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe><script> /*! This file is auto-generated */ !function(d,l){"use strict";l.querySelector&&d.addEventListener&&"undefined"!=typeof URL&&(d.wp=d.wp||{},d.wp.receiveEmbedMessage||(d.wp.receiveEmbedMessage=function(e){var t=e.data;if((t||t.secret||t.message||t.value)&&!/[^a-zA-Z0-9]/.test(t.secret)){for(var s,r,n,a=l.querySelectorAll('iframe[data-secret="'+t.secret+'"]'),o=l.querySelectorAll('blockquote[data-secret="'+t.secret+'"]'),c=new RegExp("^https?:$","i"),i=0;i<o.length;i++)o[i].style.display="none";for(i=0;i<a.length;i++)s=a[i],e.source===s.contentWindow&&(s.removeAttribute("style"),"height"===t.message?(1e3<(r=parseInt(t.value,10))?r=1e3:~~r<200&&(r=200),s.height=r):"link"===t.message&&(r=new URL(s.getAttribute("src")),n=new URL(t.value),c.test(n.protocol))&&n.host===r.host&&l.activeElement===s&&(d.top.location.href=t.value))}},d.addEventListener("message",d.wp.receiveEmbedMessage,!1),l.addEventListener("DOMContentLoaded",function(){for(var e,t,s=l.querySelectorAll("iframe.wp-embedded-content"),r=0;r<s.length;r++)(t=(e=s[r]).getAttribute("data-secret"))||(t=Math.random().toString(36).substring(2,12),e.src+="#?secret="+t,e.setAttribute("data-secret",t)),e.contentWindow.postMessage({message:"ready",secret:t},"*")},!1)))}(window,document); //# sourceURL=https://arenatours.com/wp-includes/js/wp-embed.min.js </script> http://arenatours.com/wp-content/uploads/2020/05/viaje-maldivas-todo-incluido-vilamendhoo-island-resort-maldives-slider-hp.jpg1600774General terms and conditions of contracting combined trips Details of the Travel Planner and scope of the General Terms and Conditions The Travel Planner of the combined trips offered is the entity VIAJES ARENA TOURS SL with Tax ID number B-84916337 and domicile at Paseo de la Castellana 259-C, Floor 18, 28046 of Madrid . ... Read more