https://github.com/anthonybudd/wp_cron
A better API into the WordPress Cron System
https://github.com/anthonybudd/wp_cron
Last synced: over 1 year ago
JSON representation
A better API into the WordPress Cron System
- Host: GitHub
- URL: https://github.com/anthonybudd/wp_cron
- Owner: anthonybudd
- Created: 2018-01-25T15:10:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-07-28T18:03:16.000Z (almost 4 years ago)
- Last Synced: 2025-03-26T15:43:09.531Z (over 1 year ago)
- Language: PHP
- Size: 7.81 KB
- Stars: 17
- Watchers: 0
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# WP_Cron
### Clean API into WordPress's Cron System
WP_Cron is a simple and easy to use class for defining cron events in WordPress. Simply, define a class extending WP_Cron, set the frequency of the cron event using the $every property and then write the code you want to execute in the handle() method.
```php
30,
'minutes' => 15,
'hours' => 1,
];
public function handle(){
$response = file_get_contents('http://api.openweathermap.org/data/2.5/weather?id=2172797');
$json = json_decode($response);
if($json === NULL && json_last_error() !== JSON_ERROR_NONE){
return;
}
if(isset($json->weather[0]->description)){
update_option('london_weather', $json->weather[0]->description);
}
}
}
UpdateLondonWeather::register();
```