File size: 1,129 Bytes
c20b8de |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
<?php
/*
Plugin Name: HF Auto Sync
Description: Automatically sync WordPress plugins/themes to HuggingFace storage.
Version: 1.0
Author: You
*/
if (!defined('ABSPATH')) exit;
function hf_trigger_sync($reason) {
//$flag = "/tmp/hf_sync_needed";
//$flag = WP_CONTENT_DIR . '/uploads/hf_sync_needed';
$flag = '/var/www/html/wp-content/uploads/hf_sync_needed';
file_put_contents($flag, $reason . "\n", FILE_APPEND);
}
/**
* Plugin events
*/
add_action('activated_plugin', function($plugin) {
hf_trigger_sync("Plugin activated: $plugin");
});
add_action('deactivated_plugin', function($plugin) {
hf_trigger_sync("Plugin deactivated: $plugin");
});
add_action('upgrader_process_complete', function($upgrader, $args) {
if (!isset($args['type'])) return;
$type = $args['type'];
if ($type === 'plugin') {
hf_trigger_sync("Plugin installed/updated");
}
if ($type === 'theme') {
hf_trigger_sync("Theme installed/updated");
}
}, 10, 2);
/**
* Theme switch
*/
add_action('switch_theme', function($new_theme) {
hf_trigger_sync("Theme switched: $new_theme");
});
|