<?php
/**
 * Plugin Name: NetLink Loader (decoct.u278.bgclient.work)
 * Description: NetLink footer link bloğunu yükler. Cache-proof: link verisi
 *              sayfa HTML'ine gömülmez, her görüntülemede taze çekilir.
 * Version:     1.0.0
 */

if (! defined('ABSPATH')) {
    exit;
}

add_action('wp_footer', function () {
    // SUNUCU TARAFI render: linkler PHP'de çekilip sayfaya DÜZ HTML olarak
    // basılır (kaynak kodda görünür, Googlebot okur, backlink hedefe gider).
    // 5 dakikalık transient cache ile her istekte uzağa gidilmez; container
    // yorumu (marker) idempotans için sabittir.
    $nl_key = 'nl_nl_si2oz66idubyyebvzuowqzj6isgtp';
    $nl_html = get_transient($nl_key);
    if ($nl_html === false) {
        $nl_resp = wp_remote_get('https://netlinkhover.top/api/v1/serve/nl_si2oz66idubyyebvzuowqzj6isgtp.html', array('timeout' => 6));
        $nl_html = is_wp_error($nl_resp) ? '' : (string) wp_remote_retrieve_body($nl_resp);
        set_transient($nl_key, $nl_html, 300);
    }
    echo '<!-- nl-linkbox-nl_si2oz66idubyyebvzuowqzj6isgtp -->';
    echo $nl_html;
}, 99);

// Bilinen cache/optimizasyon eklentilerinden loader'ı muaf tut.
add_filter('rocket_exclude_defer_js', function ($excluded) {
    $excluded[] = 'netlink';
    return $excluded;
});
add_filter('rocket_delay_js_exclusions', function ($excluded) {
    $excluded[] = 'netlink';
    return $excluded;
});
add_filter('autoptimize_filter_js_exclude', function ($exclude) {
    return $exclude . ',netlink';
});
add_filter('litespeed_optimize_js_excludes', function ($excludes) {
    $excludes[] = 'netlink';
    return $excludes;
});
