| Server IP : 62.171.151.215 / Your IP : 216.73.217.53 Web Server : nginx/1.18.0 System : Linux vmi3128365 5.15.0-176-generic #186-Ubuntu SMP Fri Mar 13 11:01:42 UTC 2026 x86_64 User : alex ( 1000) PHP Version : 8.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/raptorseduction.com/wp-content/themes/wp-theme-raptor/ |
Upload File : |
<?php
function guidelondres_setup() {
// Add theme support
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
add_theme_support('menus');
add_theme_support('woocommerce');
add_theme_support('wc-product-gallery-zoom');
add_theme_support('wc-product-gallery-lightbox');
add_theme_support('wc-product-gallery-slider');
add_theme_support('custom-logo', array(
'height' => 120,
'width' => 320,
'flex-height' => true,
'flex-width' => true,
));
// Register Navigation Menus
register_nav_menus(array(
'primary' => __('Menu Principal', 'guidelondres'),
'footer' => __('Menu Footer', 'guidelondres'),
));
}
add_action('after_setup_theme', 'guidelondres_setup');
add_filter('woocommerce_single_product_zoom_enabled', '__return_true');
add_filter('woocommerce_single_product_photoswipe_enabled', '__return_true');
add_filter('woocommerce_single_product_flexslider_enabled', '__return_true');
function guidelondres_get_ga_tracking_id() {
$options = get_option( 'gap_options' );
if ( is_array( $options ) && ! empty( $options['gap_id'] ) ) {
return (string) $options['gap_id'];
}
return '';
}
/*
function guidelondres_disable_ga_google_analytics_sync_loader() {
if ( ! function_exists( 'ga_google_analytics_tracking_code' ) ) {
return;
}
remove_action( 'wp_head', 'ga_google_analytics_tracking_code' );
remove_action( 'wp_footer', 'ga_google_analytics_tracking_code' );
}
add_action( 'wp', 'guidelondres_disable_ga_google_analytics_sync_loader', 1 );
function guidelondres_deferred_ga_loader() {
if ( is_admin() ) {
return;
}
$tracking_id = guidelondres_get_ga_tracking_id();
if ( '' === $tracking_id ) {
return;
}
?>
<script>
(function () {
var loaded = false;
function loadGA() {
if (loaded) return;
loaded = true;
window.dataLayer = window.dataLayer || [];
window.gtag = function(){ dataLayer.push(arguments); };
window.gtag('js', new Date());
window.gtag('config', <?php echo wp_json_encode( $tracking_id ); ?>, { anonymize_ip: true });
var s = document.createElement('script');
s.src = <?php echo wp_json_encode( 'https://www.googletagmanager.com/gtag/js?id=' . rawurlencode( $tracking_id ) ); ?>;
s.async = true;
document.head.appendChild(s);
}
if ('requestIdleCallback' in window) {
requestIdleCallback(loadGA, { timeout: 4000 });
} else {
setTimeout(loadGA, 3000);
}
['scroll', 'click', 'keydown', 'touchstart'].forEach(function(evt){
window.addEventListener(evt, loadGA, { once: true, passive: true });
});
})();
</script>
<?php
}
add_action( 'wp_footer', 'guidelondres_deferred_ga_loader', 20 );
*/
function guidelondres_resource_hints( $urls, $relation_type ) {
$is_mobile_home = ! is_admin() && is_front_page() && wp_is_mobile();
if ( $is_mobile_home ) {
return $urls;
}
if ( 'preconnect' === $relation_type ) {
$urls[] = array(
'href' => 'https://fonts.googleapis.com',
'crossorigin' => '',
);
$urls[] = array(
'href' => 'https://fonts.gstatic.com',
'crossorigin' => '',
);
}
return $urls;
}
add_filter( 'wp_resource_hints', 'guidelondres_resource_hints', 10, 2 );
function guidelondres_non_blocking_google_fonts( $html, $handle, $href, $media ) {
if ( 'guidelondres-fonts' !== $handle ) {
return $html;
}
if ( ! is_admin() && is_front_page() && wp_is_mobile() ) {
return '';
}
return "<link rel='preload' href='" . esc_url( $href ) . "' as='style' onload=\"this.onload=null;this.rel='stylesheet'\" />\n"
. "<noscript><link rel='stylesheet' href='" . esc_url( $href ) . "' /></noscript>\n";
}
add_filter( 'style_loader_tag', 'guidelondres_non_blocking_google_fonts', 10, 4 );
function guidelondres_scripts() {
$is_mobile_home = is_front_page() && wp_is_mobile();
// Enqueue main theme stylesheet so WordPress always has a local CSS file to load.
wp_enqueue_style('guidelondres-style', get_stylesheet_uri(), array(), filemtime(get_stylesheet_directory() . '/style.css'));
wp_enqueue_style(
'guidelondres-tailwind',
get_template_directory_uri() . '/assets/css/tailwind.css',
array(),
filemtime(get_template_directory() . '/assets/css/tailwind.css')
);
if ( ! $is_mobile_home ) {
// Enqueue Google Fonts
wp_enqueue_style('guidelondres-fonts', 'https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;700;800&display=swap', array(), null);
}
wp_enqueue_script(
'guidelondres-header',
get_template_directory_uri() . '/assets/js/header.js',
array(),
filemtime(get_template_directory() . '/assets/js/header.js'),
true
);
if ( is_front_page() && ! $is_mobile_home ) {
wp_enqueue_script(
'guidelondres-front-page',
get_template_directory_uri() . '/assets/js/front-page.js',
array(),
filemtime(get_template_directory() . '/assets/js/front-page.js'),
true
);
}
if ( function_exists('is_product') && is_product() ) {
wp_enqueue_script(
'guidelondres-product',
get_template_directory_uri() . '/assets/js/product.js',
array(),
filemtime(get_template_directory() . '/assets/js/product.js'),
true
);
}
}
add_action('wp_enqueue_scripts', 'guidelondres_scripts');
function guidelondres_front_page_resource_hints() {
if ( ! is_front_page() ) {
return;
}
$is_mobile_home = wp_is_mobile();
$hero_lcp_480 = esc_url( home_url('/wp-content/uploads/2025/04/london-bg-3-480x320.webp') );
$hero_lcp_640 = esc_url( home_url('/wp-content/uploads/2025/04/london-bg-3-640x427.webp') );
$hero_lcp_768 = esc_url( home_url('/wp-content/uploads/2025/04/london-bg-3-768x512.webp') );
if ( $is_mobile_home ) {
$imagesrcset_mobile = $hero_lcp_480 . ' 480w, ' . $hero_lcp_640 . ' 640w';
echo '<link rel="preload" as="image" href="' . $hero_lcp_640 . '" imagesrcset="' . esc_attr( $imagesrcset_mobile ) . '" imagesizes="100vw" fetchpriority="high" />' . "\n";
return;
}
$imagesrcset_desktop = $hero_lcp_640 . ' 640w, ' . $hero_lcp_768 . ' 768w';
echo '<link rel="preload" as="image" href="' . $hero_lcp_768 . '" imagesrcset="' . esc_attr( $imagesrcset_desktop ) . '" imagesizes="100vw" fetchpriority="high" />' . "\n";
}
add_action('wp_head', 'guidelondres_front_page_resource_hints', 1);
function guidelondres_primary_menu_fallback() {
echo '<ul class="hidden md:flex gap-5 text-sm uppercase tracking-widest font-medium">';
if ( is_front_page() ) {
echo '<li><a href="#activites" class="text-offwhite hover:text-gold transition-colors">Activités</a></li>';
echo '<li><a href="#visites" class="text-offwhite hover:text-gold transition-colors">Visites</a></li>';
echo '<li><a href="#guide" class="text-offwhite hover:text-gold transition-colors">Guide</a></li>';
} else {
echo '<li><a href="' . esc_url( home_url('/#activites') ) . '" class="text-offwhite hover:text-gold transition-colors">Activités</a></li>';
echo '<li><a href="' . esc_url( home_url('/#visites') ) . '" class="text-offwhite hover:text-gold transition-colors">Visites</a></li>';
}
$blog_url = get_permalink( get_option('page_for_posts') ) ?: home_url('/blog');
echo '<li><a href="' . esc_url( $blog_url ) . '" class="text-offwhite hover:text-gold transition-colors">Blog</a></li>';
echo '</ul>';
}
function guidelondres_primary_menu_link_classes( $atts, $item, $args ) {
if ( empty( $args->theme_location ) || 'primary' !== $args->theme_location ) {
return $atts;
}
$is_sub_item = ! empty( $item->menu_item_parent );
$classes = $is_sub_item
? 'text-navy hover:text-gold transition-colors'
: 'text-offwhite hover:text-gold transition-colors';
if ( ! empty( $item->current ) || ! empty( $item->current_item_ancestor ) ) {
$classes = 'text-gold ' . $classes;
}
$atts['class'] = $classes;
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'guidelondres_primary_menu_link_classes', 10, 3 );
function affiliate_link() {
$affiliation = get_field("affiliation");
if ( ! empty($affiliation) ) {
?>
<div style="text-align:center;"><a href="<?php echo $affiliation; ?>" style="
font-size: 30px;
padding: 0px 20px 2px 20px;
background-color: #030303;
line-height: 1.1;
color: #fff;
font-weight: 400;
text-decoration: none;
border: 0;
border-radius: 5px;
margin-bottom:10px;
outline: 0;" target="_blank">Voir les Prix</a></div>
<?php
}
}
add_shortcode('subscribe', 'affiliate_link');
add_shortcode( 'product_description', 'display_product_description' );
function display_product_description( $atts ){
$atts = shortcode_atts( array(
'id' => get_the_id(),
), $atts, 'product_description' );
$product = wc_get_product( $atts['id'] );
if ( ! $product ) {
return '';
}
return $product->get_description();
}
function remove_add_to_cart_on_shop_category_page() {
if ( is_shop() || is_product_category() ) {
return;
}
}
add_filter( 'woocommerce_loop_add_to_cart_link', 'remove_add_to_cart_on_shop_category_page');
add_filter( 'get_avatar_url', 'custom_default_avatar_url', 10, 3 );
function custom_default_avatar_url( $url, $id_or_email, $args ) {
$local_file = get_template_directory() . '/images/default-avatar.jpg';
if ( file_exists( $local_file ) ) {
return get_template_directory_uri() . '/images/default-avatar.jpg';
}
return $url;
}
if ( ! function_exists("guidelondres_cleanup_head_assets") ) {
function guidelondres_cleanup_head_assets() {
if ( is_admin() ) {
return;
}
// Remove block/editor related front CSS for this classic theme.
wp_dequeue_style("wp-block-library");
wp_dequeue_style("wp-block-library-theme");
wp_dequeue_style("classic-theme-styles");
wp_dequeue_style("global-styles");
}
}
add_action("wp_enqueue_scripts", "guidelondres_cleanup_head_assets", 100);
if ( ! function_exists("guidelondres_optimize_front_page_woocommerce_assets") ) {
function guidelondres_optimize_front_page_woocommerce_assets() {
if ( is_admin() || ! is_front_page() ) {
return;
}
$is_mobile_home = wp_is_mobile();
wp_dequeue_style( 'woocommerce-layout' );
wp_dequeue_style( 'woocommerce-smallscreen' );
wp_dequeue_style( 'woocommerce-general' );
wp_dequeue_style( 'wc-blocks-style' );
wp_dequeue_style( 'woocommerce-inline' );
wp_deregister_style( 'wc-blocks-style' );
wp_deregister_style( 'woocommerce-inline' );
wp_dequeue_script( 'wc-add-to-cart' );
wp_dequeue_script( 'woocommerce' );
wp_dequeue_script( 'wc-cart-fragments' );
wp_dequeue_script( 'js-cookie' );
wp_dequeue_script( 'sourcebuster-js' );
wp_dequeue_script( 'wc-order-attribution' );
if ( $is_mobile_home ) {
wp_dequeue_style( 'universal-form' );
wp_dequeue_style( 'universal-form-css' );
wp_deregister_style( 'universal-form' );
wp_deregister_style( 'universal-form-css' );
}
}
}
add_action( 'wp_enqueue_scripts', 'guidelondres_optimize_front_page_woocommerce_assets', 9999 );
add_action( 'wp_print_styles', 'guidelondres_optimize_front_page_woocommerce_assets', 9999 );
add_action( 'wp_print_scripts', 'guidelondres_optimize_front_page_woocommerce_assets', 9999 );
if ( ! function_exists("guidelondres_disable_woo_front_css_on_home") ) {
function guidelondres_disable_woo_front_css_on_home( $styles ) {
if ( is_admin() || ! is_front_page() ) {
return $styles;
}
return array();
}
}
add_filter( 'woocommerce_enqueue_styles', 'guidelondres_disable_woo_front_css_on_home', 9999 );
if ( ! function_exists("guidelondres_strip_home_non_critical_style_tags") ) {
function guidelondres_strip_home_non_critical_style_tags( $html, $handle ) {
if ( is_admin() || ! is_front_page() ) {
return $html;
}
$blocked = array(
'wc-blocks-style',
'woocommerce-layout',
'woocommerce-smallscreen',
'woocommerce-general',
'woocommerce-inline',
);
if ( wp_is_mobile() ) {
$blocked[] = 'universal-form';
$blocked[] = 'universal-form-css';
}
if ( in_array( $handle, $blocked, true ) ) {
return '';
}
return $html;
}
}
add_filter( 'style_loader_tag', 'guidelondres_strip_home_non_critical_style_tags', 9999, 2 );
if ( ! function_exists("guidelondres_dynamic_style_version") ) {
function guidelondres_dynamic_style_version( $src, $handle ) {
$url_path = wp_parse_url( $src, PHP_URL_PATH );
if ( empty( $url_path ) ) {
return $src;
}
// Skip external hosts and keep only local styles.
$asset_host = wp_parse_url( $src, PHP_URL_HOST );
$site_host = wp_parse_url( home_url(), PHP_URL_HOST );
if ( ! empty( $asset_host ) && ! empty( $site_host ) && strtolower( $asset_host ) !== strtolower( $site_host ) ) {
return $src;
}
$file_path = ABSPATH . ltrim( $url_path, "/" );
if ( ! file_exists( $file_path ) || is_dir( $file_path ) ) {
return $src;
}
return add_query_arg(
"ver",
(string) filemtime( $file_path ),
remove_query_arg( "ver", $src )
);
}
}
add_filter( "style_loader_src", "guidelondres_dynamic_style_version", 9999, 2 );
if ( ! function_exists( 'guidelondres_get_public_url' ) ) {
function guidelondres_get_public_url( $path_candidates, $fallback = '' ) {
foreach ( (array) $path_candidates as $path ) {
$path = trim( (string) $path, '/' );
if ( '' === $path ) {
continue;
}
$page = get_page_by_path( $path );
if ( $page instanceof WP_Post && 'publish' === $page->post_status ) {
return get_permalink( $page );
}
$post = get_posts(
array(
'name' => $path,
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1,
)
);
if ( ! empty( $post ) ) {
return get_permalink( $post[0] );
}
}
return $fallback ? esc_url_raw( $fallback ) : home_url( '/' );
}
}
if ( ! function_exists( 'guidelondres_get_category_url' ) ) {
function guidelondres_get_category_url( $slug, $fallback = '' ) {
$term = get_term_by( 'slug', $slug, 'category' );
if ( $term && ! is_wp_error( $term ) ) {
return get_term_link( $term );
}
return $fallback ? esc_url_raw( $fallback ) : home_url( '/' );
}
}
if ( ! function_exists( 'guidelondres_should_noindex_current_view' ) ) {
function guidelondres_should_noindex_current_view() {
if ( is_search() || is_404() ) {
return true;
}
if ( is_page( array( 'vente', 'test-100' ) ) ) {
return true;
}
return false;
}
}
if ( ! function_exists( 'guidelondres_fallback_meta_description_text' ) ) {
function guidelondres_fallback_meta_description_text() {
if ( is_front_page() ) {
return 'Guide premium en francais pour organiser un voyage a Londres : attractions, quartiers, transports, billets, budget et conseils pratiques.';
}
if ( is_home() ) {
return 'Tous nos articles pour preparer un sejour a Londres : visites, transports, hotels, bons plans et idees d itineraires.';
}
if ( is_category() ) {
$term = get_queried_object();
if ( $term instanceof WP_Term ) {
return sprintf(
'Selection d articles utiles pour %s : conseils pratiques, idees de visites, budget, transport et bons plans a Londres.',
wp_strip_all_tags( $term->name )
);
}
}
if ( is_singular() ) {
$post = get_queried_object();
if ( ! ( $post instanceof WP_Post ) ) {
return '';
}
$manual_description = get_post_meta( $post->ID, 'rank_math_description', true );
if ( ! empty( $manual_description ) ) {
return '';
}
if ( has_excerpt( $post ) ) {
$description = wp_strip_all_tags( get_the_excerpt( $post ), true );
} else {
$description = wp_strip_all_tags( strip_shortcodes( $post->post_content ), true );
}
return wp_trim_words( preg_replace( '/\s+/', ' ', $description ), 28, '' );
}
return '';
}
}
if ( ! function_exists( 'guidelondres_rank_math_description_fallback' ) ) {
function guidelondres_rank_math_description_fallback( $description ) {
if ( ! empty( $description ) ) {
return $description;
}
return guidelondres_fallback_meta_description_text();
}
}
add_filter( 'rank_math/frontend/description', 'guidelondres_rank_math_description_fallback' );
if ( ! function_exists( 'guidelondres_rank_math_robots_override' ) ) {
function guidelondres_rank_math_robots_override( $robots ) {
if ( guidelondres_should_noindex_current_view() ) {
return array( 'noindex', 'nofollow' );
}
return $robots;
}
}
add_filter( 'rank_math/frontend/robots', 'guidelondres_rank_math_robots_override' );
if ( ! function_exists( 'guidelondres_limit_archive_posts_per_page' ) ) {
function guidelondres_limit_archive_posts_per_page( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( $query->is_search() || $query->is_author() ) {
$query->set( 'posts_per_page', 12 );
}
}
}
add_action( 'pre_get_posts', 'guidelondres_limit_archive_posts_per_page' );
if ( ! function_exists( 'guidelondres_meta_description_fallback_tag' ) ) {
function guidelondres_meta_description_fallback_tag() {
if ( defined( 'RANK_MATH_VERSION' ) ) {
return;
}
if ( ! empty( get_post_meta( get_queried_object_id(), 'rank_math_description', true ) ) ) {
return;
}
$description = guidelondres_fallback_meta_description_text();
if ( empty( $description ) ) {
return;
}
echo '<meta name="description" content="' . esc_attr( $description ) . "\" />\n";
}
}
add_action( 'wp_head', 'guidelondres_meta_description_fallback_tag', 8 );