Download wp-hf-sync.php from sohom004/another: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/sohom004/another/resolve/main/wp-hf-sync.php
- Command line
-
hf download hf://spaces/sohom004/another/wp-hf-sync.php
-
curl -L -o wp-hf-sync.php https://huggingface.co/spaces/sohom004/another/resolve/main/wp-hf-sync.php
1.13 kB
| /* | |
| 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"); | |
| }); | |