<?php

add_action('wp_ajax_ss_download_single_css_file', 'ss_download_single_css_file');
add_action('wp_ajax_nopriv_ss_download_single_css_file', 'ss_download_single_css_file');

function ss_download_single_css_file() {
    check_ajax_referer('ss-export-single-css-file', 'nonce');

	$file_name = sanitize_file_name($_POST['file_name']);

    $file_path = ABSPATH . 'wp-content/ss-css/' . $file_name;

    error_log("Проверяем файл: " . $file_path);

    if (!file_exists($file_path)) {
        wp_send_json_error(['message' => 'Файл не найден: ' . $file_name]);
    }

	$file_url = site_url('/wp-content/ss-css/' . $file_name); 

    wp_send_json_success(['file_url' => $file_url]);
}