An open API service indexing awesome lists of open source software.

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

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();
```