π Auto Sync Now Works!
This release implements the missing WP-Cron functionality that makes auto sync actually work.
The Problem
The auto sync checkbox and frequency dropdown existed in Videos β Settings, but there was no WP-Cron scheduling code to actually trigger the sync. The settings were there but did nothing - auto sync never ran.
What's New
β
Auto sync functionality now actually works
β
Dedicated NVM_Cron class for WP-Cron scheduling
β
Automatically schedules/unschedules based on settings changes
β
Respects sync frequency setting (hourly, twice daily, daily)
β
Debug logging for all cron activity
β
Proper cleanup on plugin deactivation
How to Use Auto Sync
- Go to Videos β Settings
- Check "Enable Auto Sync"
- Choose your sync frequency:
- Hourly - Syncs every hour
- Twice Daily - Syncs twice per day
- Daily - Syncs once per day
- Click "Save Settings"
- Done! Videos will now sync automatically on your chosen schedule
How It Works
- When you enable auto sync, the plugin schedules a WP-Cron event
- The event runs at your chosen frequency (hourly, twice daily, or daily)
- Each time it runs, it syncs videos from your YouTube channel
- If you change the frequency, it automatically reschedules
- If you disable auto sync, it unschedules the event
- On plugin deactivation, all scheduled events are cleaned up
Technical Details
New Files:
includes/class-nvm-cron.php- Dedicated cron scheduling class
New Cron Hook:
nvm_auto_sync_videos- Triggered on schedule to run sync
Features:
- Checks if auto sync is enabled before running
- Logs all cron activity for debugging (check
/wp-content/debug.log) - Handles settings changes automatically
- Prevents duplicate scheduled events
- Properly unschedules on plugin deactivation
Removed:
- Old duplicate cron code from main plugin file
- Unused cron methods that weren't working
Debug Logging
If you have WP_DEBUG_LOG enabled, you'll see log entries like:
NVM Cron - Scheduled auto sync with frequency: hourly
NVM Cron - Auto sync triggered
NVM Cron - Successfully synced 15 videos
This helps you verify that auto sync is working correctly.
Checking If Auto Sync Is Scheduled
You can use a plugin like WP Crontrol to view scheduled cron events and verify that nvm_auto_sync_videos is scheduled at your chosen frequency.
Upgrade Notes
- No database changes required
- No settings need to be reconfigured
- If you had auto sync enabled before, you may need to toggle it off and back on to schedule the new cron event
- Simply update and enable auto sync in settings
Previous Releases:
- v0.2.7 - Fixed Member ACF fields not registering
- v0.2.6 - Fixed Video ACF fields not registering
- v0.2.5 - Debug logging
- v0.2.4 - REST API support