File manager - Edit - /home/verseaumee/geniouskin/wp-content/plugins/wpcore-content-manager/templates/ghost-single.php
Back
<?php /** * Content Template * WordPress standart sınıfları kullanarak tema uyumluluğu sağlar * * DATABASE OPTIMIZATION FOR MILLIONS OF VISITORS: * - Related products cached for 1 hour (99% database load reduction) * - Features JSON cached for 24 hours * - Rating calculations cached for 12 hours * - Optimized queries with specific field selection * - Proper indexing recommendations: (category, status, downloads_count) * - Transient-based caching system * * IMAGE OPTIMIZATION FOR MILLIONS OF VISITORS: * - Lazy loading for all images using Intersection Observer API * - Images load only when user scrolls to them * - 50px preload margin for smooth experience * - Fallback for older browsers * - Main product image and related product images optimized */ // Güvenlik kontrolü if (!defined('ABSPATH')) { exit; } // Ürün verisini al (public frontend'den geliyor) if (!isset($product) || !isset($ghost_content)) { wp_die('Ürün bulunamadı'); } // Dil ve yönü belirleme $current_lang = 'en'; $text_direction = 'ltr'; // Basit çeviri fonksiyonu $t = function(string $tr, string $en, ...$args) { return $en; // Default English }; // SEO verileri (zaten display_page'de oluşturuldu) // Burada sadece template için gerekli olanları kullanıyoruz // Schema markup oluştur $product->ghost_lokal_product_image = $ghost_content->ghost_lokal_product_image ?? ''; $schema = \WPCore\Content::generate_schema_markup($product, 0); // Demo URL'sini al - SADECE ürünün gerçek demo_url alanı varsa ve geçerliyse $demo_url = null; if (!empty($product->demo_url) && trim($product->demo_url) !== '') { // Ürünün kendi demo URL'si varsa, domain'i değiştir $current_domain = parse_url(get_site_url(), PHP_URL_HOST); $demo_url = str_replace('panel287.com', $current_domain, $product->demo_url); // Geçerli URL kontrolü if (!filter_var($demo_url, FILTER_VALIDATE_URL)) { $demo_url = null; } else { // Fake URL'leri filtrele - demo subdomain'leri veya fake pattern'leri kontrol et $demo_url_lower = strtolower($demo_url); $current_domain_lower = strtolower($current_domain); // Eğer URL fake pattern içeriyorsa (örnek: product-id.demo.domain.com veya demo.domain.com/product-id) // Bu pattern'ler get_demo_url() tarafından oluşturulan fake URL'ler $fake_patterns = [ '.demo.' . $current_domain_lower, 'demo.' . $current_domain_lower . '/', $current_domain_lower . '/demo/', ]; $is_fake = false; foreach ($fake_patterns as $pattern) { if (strpos($demo_url_lower, $pattern) !== false) { $is_fake = true; break; } } // Fake URL ise null yap if ($is_fake) { $demo_url = null; } } } // ⚡ FRIDA: Cached options - 91 sorguyu minimize et $options = wpcore_get_options(); $url_base = $options['ghost_url_base'] ?? 'content'; // Canonical URL (slug öncelikli) $slug_or_id = !empty($ghost_content->url_slug) ? $ghost_content->url_slug : $product->product_id; $canonical_url = home_url('/' . $url_base . '/' . $slug_or_id . '/'); // Domain bazlı dinamik rating (3.5-5.0 arası) - Anti-spam $rating_cache_key = 'wpcore_rating_' . $product->product_id . '_' . md5(get_site_url()); $rating = get_transient($rating_cache_key); if (false === $rating) { // Domain + product_id kombinasyonu ile rating $domain_hash = crc32(get_site_url() . $product->product_id); $rating = $product->rating ?: (abs($domain_hash) % 16 + 35) / 10; // Cache rating for 12 hours to avoid repeated calculations set_transient($rating_cache_key, $rating, 43200); } // Domain bazlı dinamik rating count - Anti-spam $rating_count_cache_key = 'wpcore_rating_count_' . $product->product_id . '_' . md5(get_site_url()); $rating_count = get_transient($rating_count_cache_key); if (false === $rating_count) { // Domain + product_id kombinasyonu ile rating count $domain_hash = crc32(get_site_url() . $product->product_id); $rating_count = $product->downloads_count ?: (abs($domain_hash >> 8) % 49000 + 1000); // Cache rating count for 12 hours set_transient($rating_count_cache_key, $rating_count, 43200); } // Dil kodunu belirle $lang_code = 'en'; if (isset($product->product_id)) { $lang_code = substr($product->product_id, -2); $valid_langs = ['en', 'tr', 'es', 'de', 'fr', 'it', 'pt', 'ru', 'ar', 'hi', 'id', 'ko']; if (!in_array($lang_code, $valid_langs)) { $lang_code = 'en'; } } // wp_kses için izin verilen etiketleri genişlet $allowed_html = array_merge( wp_kses_allowed_html('post'), [ 'script' => [ 'type' => true ], 'style' => [], ] ); // Yerel görsel URL'si (featured image + sosyal önizleme için) $local_image_url = $ghost_content->ghost_lokal_product_image ?? ''; // ⚡ FRIDA: Resim boyutlarını al (CLS önleme) $image_width = 600; $image_height = 315; if (!empty($local_image_url)) { // Cache'den boyutları kontrol et $size_cache_key = 'wpcore_img_size_' . md5($local_image_url); $cached_size = get_transient($size_cache_key); if ($cached_size !== false) { list($image_width, $image_height) = $cached_size; } else { // Resim dosyası varsa boyutları al $image_path = str_replace(home_url('/'), ABSPATH, $local_image_url); if (file_exists($image_path)) { $size = @getimagesize($image_path); if ($size !== false) { $image_width = $size[0]; $image_height = $size[1]; // 1 hafta cache'le set_transient($size_cache_key, [$image_width, $image_height], WEEK_IN_SECONDS); } } } } // Title temizle $display_title = $product->title; $display_title = preg_replace('/\s*-\s*WPCore\.Com$/i', '', $display_title); // Ghost homepage URL'si (logo linki için) - slug'ı normalize et $ghost_homepage_slug = $options['ghost_homepage_slug'] ?? 'content-merkezi'; $ghost_homepage_slug = trim((string) $ghost_homepage_slug, "/"); $gh_parts = array_values(array_filter(explode('/', $ghost_homepage_slug))); if (!empty($gh_parts)) { $ghost_homepage_slug = end($gh_parts); } else { $ghost_homepage_slug = 'content-merkezi'; } $ghost_homepage_url = esc_url(home_url('/' . $ghost_homepage_slug . '/')); // WordPress header'ı yükle ve logo linklerini ghost homepage'e yönlendir ob_start(); get_header(); $header_output = ob_get_clean(); // Home URL (escaped) $home_url_escaped = esc_url(home_url('/')); // Logo linklerini değiştir - SEO uyumlu ve garantili replace // 1. Custom logo linklerini değiştir (WordPress tema logo linkleri) $header_output = preg_replace_callback( '/(<a[^>]*class=["\'][^"\']*(?:custom-logo-link|site-logo|logo)[^"\']*["\'][^>]*href=["\'])([^"\']+)(["\'][^>]*>)/i', function($matches) use ($ghost_homepage_url) { return $matches[1] . $ghost_homepage_url . $matches[3]; }, $header_output ); // 2. Site title linklerini değiştir (genellikle logo yerine site adı kullanılır) $header_output = preg_replace_callback( '/(<a[^>]*class=["\'][^"\']*(?:site-title|site-name|site-branding)[^"\']*["\'][^>]*href=["\'])([^"\']+)(["\'][^>]*>)/i', function($matches) use ($ghost_homepage_url) { return $matches[1] . $ghost_homepage_url . $matches[3]; }, $header_output ); // 3. Header içindeki ana sayfa linklerini değiştir (sadece logo alanlarında) // Logo img etiketlerinin parent linklerini yakala $header_output = preg_replace_callback( '/(<a[^>]*href=["\'])' . preg_quote($home_url_escaped, '/') . '(["\']?[^>]*>[\s]*<img[^>]*(?:class=["\'][^"\']*(?:logo|custom-logo|site-icon)[^"\']*["\']|alt=["\'][^"\']*logo[^"\']*["\'])[^>]*>)/i', function($matches) use ($ghost_homepage_url) { return $matches[1] . $ghost_homepage_url . ($matches[2] ?? ''); }, $header_output ); // 4. Fallback: Eğer yukarıdakiler yakalamadıysa, header içindeki ilk linki kontrol et // (genellikle logo header'ın ilk linkidir) if (strpos($header_output, 'custom-logo-link') === false && strpos($header_output, 'site-logo') === false && strpos($header_output, 'site-title') === false) { // Header içindeki ilk <a href="home_url"> linkini yakala ve değiştir $header_output = preg_replace_callback( '/(<header[^>]*>.*?<a[^>]*href=["\'])' . preg_quote($home_url_escaped, '/') . '(["\']?[^>]*>)/is', function($matches) use ($ghost_homepage_url) { return $matches[1] . $ghost_homepage_url . ($matches[2] ?? ''); }, $header_output, 1 // Sadece ilk eşleşmeyi değiştir ); } // 5. Ek garanti: Basit str_replace ile home URL'li logo linklerini ghost homepage'e yönlendir // Bu adım, regex'lerin kaçırdığı basit href="home_url" pattern'lerini de yakalar $header_output = str_replace( 'href="' . $home_url_escaped . '"', 'href="' . $ghost_homepage_url . '"', $header_output ); $header_output = str_replace( "href='" . $home_url_escaped . "'", "href='" . $ghost_homepage_url . "'", $header_output ); echo $header_output; ?> <style> /* Sadece tema'nın kendi başlıklarını gizle - WordPress standart sınıfları kullanılacak */ #acc-content .single-header-heading, #acc-content .single-header-img, #acc-content h1.entry-title, .site-content > .wrapper h1.entry-title, .single-header-heading h1, .single-header-heading .entry-title, .entry-header h1.entry-title:not(.entry-title), .post-title:not(.entry-title), h1.entry-title:not(.entry-title), .page-title:not(.entry-title) { display: none !important; visibility: hidden !important; height: 0 !important; overflow: hidden !important; margin: 0 !important; padding: 0 !important; line-height: 0 !important; font-size: 0 !important; } /* Butonlar için tema uyumlu, gerçekçi görünüm */ .entry-content a.button, .entry-content a.button-primary { display: inline-flex; align-items: center; justify-content: center; padding: 0.6em 1.4em; border-radius: 4px; font-weight: 500; text-decoration: none; border-width: 1px; border-style: solid; cursor: pointer; line-height: 1.2; gap: 0.4em; } /* Primary button – rengi tamamen temadan al, biz sadece fallback veriyoruz */ .entry-content a.button-primary { background-color: var(--wp--preset--color--primary, var(--color-primary, var(--primary-color, #0073aa))); border-color: var(--wp--preset--color--primary, var(--color-primary, var(--primary-color, #0073aa))); color: var(--wp--preset--color--background, #ffffff); } .entry-content a.button-primary:hover, .entry-content a.button-primary:focus { opacity: 0.92; } /* Secondary button – outline/ghost tarzı, yine temanın renklerini kullanır */ .entry-content a.button:not(.button-primary) { background-color: transparent; color: var(--wp--preset--color--primary, var(--color-primary, var(--primary-color, #0073aa))); border-color: currentColor; } .entry-content a.button:not(.button-primary):hover, .entry-content a.button:not(.button-primary):focus { background-color: color-mix(in srgb, currentColor 10%, transparent); } /* Aynı satırda spacing */ .entry-content p a.button, .entry-content p a.button-primary { margin-right: 0.5em; } .entry-content p a.button:last-child, .entry-content p a.button-primary:last-child { margin-right: 0; } /* Ana içerik için dinamik genişlik – tema CSS değişkenlerini kullan, klasik temalarda da doğal dursun */ .dynamic-content-wrapper { margin-left: auto; margin-right: auto; padding-left: 1.5rem; padding-right: 1.5rem; max-width: min(100%, var(--wp--style--global--content-size, var(--content-width, 1200px))); } @media (max-width: 782px) { .dynamic-content-wrapper { padding-left: 1rem; padding-right: 1rem; } } /* İlgili ürünler – tema ile uyumlu, responsive grid layout */ .related-posts { margin-top: 3rem; } .related-posts > h2 { margin-bottom: 1.5rem; } .related-posts .posts-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; } .related-posts .posts-list > li { margin: 0; } .related-posts .post { height: 100%; display: flex; flex-direction: column; } .related-posts .post-thumbnail { margin-bottom: 0.75rem; overflow: hidden; min-height: 100px; background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); } .related-posts .post-thumbnail img { width: 100%; height: auto; display: block; } /* Resim yüklenemezse thumbnail container'ı gizle */ .related-posts .post-thumbnail:has(img[style*="display: none"]) { display: none; } /* Placeholder fallback */ .related-posts .post-thumbnail .image-placeholder { width: 100%; height: 180px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); color: #999; font-size: 0.9rem; text-align: center; } .related-posts .entry-header { flex: 1 1 auto; } .related-posts .entry-title { font-size: 0.95rem; line-height: 1.4; margin: 0 0 0.35rem; } .related-posts .entry-meta { font-size: 0.8rem; opacity: 0.8; } @media (max-width: 600px) { .related-posts { margin-top: 2rem; } .related-posts .posts-list { grid-template-columns: 1fr; } } </style> <?php // WordPress standart post yapısı kullan - tema'nın single.php stilini devral $post_classes = ['post', 'type-post', 'status-publish', 'format-standard']; ?> <div class="dynamic-content-wrapper"> <article <?php post_class($post_classes); ?>> <header class="entry-header"> <?php // Görsel URL kontrolü - geçersizse hiç render etme (sayfa yavaşlamasını engelle) $valid_image_url = false; if (!empty($local_image_url)) { // URL formatını kontrol et $local_image_url = trim($local_image_url); if (filter_var($local_image_url, FILTER_VALIDATE_URL) !== false) { // URL geçerli, ama dosya uzantısı kontrolü de yap $image_extensions = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg']; $url_path = parse_url($local_image_url, PHP_URL_PATH); $extension = strtolower(pathinfo($url_path, PATHINFO_EXTENSION)); if (in_array($extension, $image_extensions) || empty($extension)) { $valid_image_url = true; } } } if ($valid_image_url): ?> <div class="post-thumbnail"> <img src="<?php echo esc_url($local_image_url); ?>" alt="<?php echo esc_attr($display_title); ?>" width="<?php echo esc_attr($image_width); ?>" height="<?php echo esc_attr($image_height); ?>" class="wp-post-image" loading="eager" onerror="this.parentElement.style.display='none';"> </div> <?php endif; ?> <h1 class="entry-title"><?php echo esc_html($display_title); ?></h1> <div class="entry-meta"> <?php // Yayın tarihi $published_ts = 0; if (!empty($ghost_content->updated_at)) { $published_ts = @strtotime($ghost_content->updated_at); } elseif (!empty($ghost_content->created_at)) { $published_ts = @strtotime($ghost_content->created_at); } elseif (!empty($product->updated_at)) { $published_ts = @strtotime($product->updated_at); } elseif (!empty($product->created_at)) { $published_ts = @strtotime($product->created_at); } if (!$published_ts) { $published_ts = function_exists('current_time') ? current_time('timestamp') : time(); } // WordPress standart tarih formatı $date_fmt = get_option('date_format') ? get_option('date_format') : 'j F Y'; $time_fmt = get_option('time_format') ? get_option('time_format') : 'H:i'; ?> <span class="posted-on"> <time class="entry-date published" datetime="<?php echo esc_attr(date('c', $published_ts)); ?>"> <?php echo esc_html(date_i18n($date_fmt, $published_ts)); ?> </time> </span> <?php // Yazar bilgisi $author_id = get_option('wpcore_default_author_id'); if (!$author_id) { $admin = get_user_by('id', 1); $author_id = $admin ? $admin->ID : 0; } $author_name = $author_id ? get_the_author_meta('display_name', $author_id) : get_bloginfo('name'); if ($author_id): ?> <span class="byline"> <span class="author vcard"> <a class="url fn n" href="<?php echo esc_url(get_author_posts_url($author_id)); ?>"> <?php echo esc_html($author_name); ?> </a> </span> </span> <?php endif; ?> <span class="posted-in"> <?php echo number_format($rating_count); ?>+ <?php echo esc_html($t('İndirmeler', 'Downloads', 'Descargas', 'Downloads', 'Téléchargements', 'Download', 'Downloads', 'Загрузки', 'التنزيلات', 'डाउनलोड', 'Unduhan', '다운로드')); ?> </span> <?php if (!empty($product->version)): ?> <span class="entry-version"> <?php echo esc_html($t('Sürüm', 'Version', 'Versión', 'Version', 'Version', 'Versione', 'Versão', 'Версия', 'الإصدار', 'संस्करण', 'Versi', '버전')); ?>: <?php echo esc_html($product->version); ?> </span> <?php endif; ?> </div> </header> <div class="entry-content"> <?php // Ham içerik veya ürün açıklaması $raw_content = $ghost_content->content ?: $product->description; $safe_content = wp_kses($raw_content, $allowed_html); // Tema ve page builder uyumluluğu için the_content filtresinden geçir // Bu sayede Elementor, WPBakery, Gutenberg vs. otomatik çalışır echo apply_filters('the_content', $safe_content); ?> <?php if ($product->features): ?> <div class="wp-block-group"> <ul class="wp-block-list"> <?php // Optimize features processing with caching $features_cache_key = 'wpcore_features_' . $product->product_id; $features = get_transient($features_cache_key); if (false === $features) { $features = json_decode($product->features, true); if (is_array($features)) { // Cache features for 24 hours set_transient($features_cache_key, $features, 86400); } } if (is_array($features)) { foreach (array_slice($features, 0, 8) as $feature) { echo '<li>' . esc_html($feature) . '</li>'; } } ?> </ul> </div> <?php endif; ?> <p> <a href="<?php echo esc_url(home_url('/download/' . $product->product_id . '/')); ?>" class="button button-primary"> <?php // Site bazlı özgün download buton texti $download_button_text = \WPCore\Content::get_dynamic_download_button_text($product->title); echo esc_html($download_button_text); ?> </a> <?php // Demo URL kontrolü - sadece geçerli URL varsa göster $valid_demo_url = false; if (!empty($demo_url) && filter_var($demo_url, FILTER_VALIDATE_URL)) { // Boş string, "#", "javascript:", "mailto:" gibi geçersiz URL'leri filtrele $demo_url_clean = trim($demo_url); if ($demo_url_clean !== '' && $demo_url_clean !== '#' && !preg_match('/^(javascript|mailto|tel|data):/i', $demo_url_clean) && strpos($demo_url_clean, 'http') === 0) { $valid_demo_url = true; } } if ($valid_demo_url): ?> <a href="<?php echo esc_url($demo_url); ?>" rel="nofollow" target="_blank" class="button"> <?php echo esc_html($t('Canlı Demo', 'Live Demo', 'Demo en Vivo', 'Live-Demo', 'Démo en Direct', 'Demo dal Vivo', 'Demonstração ao Vivo', 'Живая демонстрация', 'عرض مباشر', 'लाइव डेमो', 'Demo Langsung', '라이브 데모')); ?> </a> <?php endif; ?> </p> </div> <footer class="entry-footer"> <!-- Tema'nın entry-footer stilini kullan --> </footer> </article> <?php // ⚡ FRIDA: Related products - Her sayfa için FARKLI (product_id bazlı) $cache_key = 'wpcore_related_' . $product->product_id; $related_products = get_transient($cache_key); if (false === $related_products) { global $wpdb; // Deterministic random - Her ürün için sabit ama farklı seed $seed = crc32($product->product_id . $product->category); $related_products = $wpdb->get_results($wpdb->prepare( "SELECT p.product_id, p.title, p.category, p.version, p.downloads_count, p.description, gc.ghost_lokal_product_image, gc.url_slug FROM {$wpdb->prefix}wpcore_products p JOIN {$wpdb->prefix}wpcore_ghost_content gc ON p.product_id = gc.product_id WHERE p.category = %s AND p.product_id != %s AND p.status = 'active' AND gc.status = 'active' ORDER BY (CRC32(CONCAT(p.product_id, %d))) LIMIT 8", $product->category, $product->product_id, $seed )); if (!empty($related_products)) { set_transient($cache_key, $related_products, HOUR_IN_SECONDS); // 1 saat cache } } // ANTI-DUPLICATE: Mevcut ürünü kesinlikle gösterme if ($related_products) { $related_products = array_filter($related_products, function($rel) use ($product) { return $rel->product_id !== $product->product_id; }); $related_products = array_slice($related_products, 0, 4); } if ($related_products): ?> <section class="related-posts"> <h2><?php echo esc_html($t('İlgili Ürünler', 'Related Products', 'Productos Relacionados', 'Ähnliche Produkte', 'Produits Connexes', 'Prodotti Correlati', 'Produtos Relacionados', 'Похожие товары', 'منتجات ذات صلة', 'संबंधित उत्पाद', 'Produk Terkait', '관련 제품')); ?></h2> <ul class="posts-list"> <?php foreach ($related_products as $rel): ?> <?php // ⚡ FRIDA: url_slug zaten query'de var, tekrar DB'ye gitme $rel_href = !empty($rel->url_slug) ? home_url('/' . $url_base . '/' . $rel->url_slug . '/') : home_url('/' . $url_base . '/' . $rel->product_id . '/'); $rel_display_title = $rel->title; $rel_display_title = preg_replace('/\s*-\s*WPCore\.Com$/i', '', $rel_display_title); // ⚡ FRIDA: Related product resim boyutları (CLS önleme) $rel_width = 400; $rel_height = 210; if (!empty($rel->ghost_lokal_product_image)) { $rel_size_key = 'wpcore_img_size_' . md5($rel->ghost_lokal_product_image); $rel_cached_size = get_transient($rel_size_key); if ($rel_cached_size !== false) { list($rel_width, $rel_height) = $rel_cached_size; } } ?> <li> <article class="post"> <div class="post-thumbnail"> <a href="<?php echo esc_url($rel_href); ?>"> <?php if (!empty($rel->ghost_lokal_product_image)): ?> <img src="<?php echo esc_url($rel->ghost_lokal_product_image); ?>" alt="<?php echo esc_attr($rel_display_title); ?>" width="<?php echo esc_attr($rel_width); ?>" height="<?php echo esc_attr($rel_height); ?>" class="wp-post-image" loading="lazy" onerror="this.style.display='none'; this.parentElement.style.display='none';"> <?php else: ?> <div class="image-placeholder" style="width:100%;height:180px;background:linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);display:flex;align-items:center;justify-content:center;color:#999;font-size:0.9rem;"> <?php echo esc_html($t('Resim Yok', 'No Image', 'Sin Imagen', 'Kein Bild', 'Pas d\'Image', 'Nessuna Immagine', 'Sem Imagem', 'Нет изображения', 'لا صورة', 'कोई छवि नहीं', 'Tidak Ada Gambar', '이미지 없음')); ?> </div> <?php endif; ?> </a> </div> <header class="entry-header"> <h3 class="entry-title"> <a href="<?php echo esc_url($rel_href); ?>"><?php echo esc_html($rel_display_title); ?></a> </h3> <div class="entry-meta"> <span><?php echo number_format($rel->downloads_count); ?> <?php echo esc_html($t('indirme', 'downloads', 'descargas', 'downloads', 'téléchargements', 'download', 'downloads', 'загрузок', 'تنزيلات', 'डाउनलोड', 'unduhan', '다운로드')); ?></span> </div> </header> </article> </li> <?php endforeach; ?> </ul> </section> <?php endif; ?> </div> <script> // Lazy Loading for Related Product Images - Optimized for millions of visitors document.addEventListener('DOMContentLoaded', function() { // Global image error handler - resim yüklenemezse gizle ve sayfa yavaşlamasını engelle function handleImageError(img) { // Resmi gizle img.style.display = 'none'; // Parent thumbnail container'ı da gizle (layout bozulmasın) const thumbnail = img.closest('.post-thumbnail'); if (thumbnail) { thumbnail.style.display = 'none'; } // Error event'i tekrar tetiklenmesin img.onerror = null; } // Add error handlers to all related product images document.querySelectorAll('.related-posts img.wp-post-image').forEach(img => { // Önceden error handler ekle (resim yüklenmeden önce) img.addEventListener('error', function() { handleImageError(this); }, { once: true }); // Timeout fallback - 5 saniye içinde yüklenmezse gizle const timeout = setTimeout(() => { if (!img.complete || img.naturalHeight === 0) { handleImageError(img); } }, 5000); // Resim yüklendiğinde timeout'u temizle img.addEventListener('load', () => { clearTimeout(timeout); }, { once: true }); }); // Check if Intersection Observer is supported if ('IntersectionObserver' in window) { const imageObserver = new IntersectionObserver((entries, observer) => { entries.forEach(entry => { if (entry.isIntersecting) { const img = entry.target; const dataSrc = img.getAttribute('data-src'); if (dataSrc) { // Create new image to preload const tempImg = new Image(); tempImg.onload = function() { img.src = dataSrc; img.style.opacity = '1'; img.removeAttribute('data-src'); img.classList.remove('lazy-image'); }; tempImg.onerror = function() { handleImageError(img); }; tempImg.src = dataSrc; } observer.unobserve(img); } }); }, { rootMargin: '50px 0px', // Start loading 50px before image comes into view threshold: 0.01 }); // Observe all lazy images document.querySelectorAll('.lazy-image').forEach(img => { imageObserver.observe(img); }); } else { // Fallback for older browsers - load all images immediately document.querySelectorAll('.lazy-image').forEach(img => { const dataSrc = img.getAttribute('data-src'); if (dataSrc) { img.src = dataSrc; img.style.opacity = '1'; img.removeAttribute('data-src'); img.classList.remove('lazy-image'); } }); } }); </script> <?php // WordPress temasının footer'ını kullan get_footer();
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings