1. Go to this page and download the library: Download doiftrue/wp-kama-cron library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
doiftrue / wp-kama-cron example snippets
new \Kama\WP\Kama_Cron( [
'wpkama_core_data_check_update' => [
'callback' => 'wpkama_core_data_check_update',
'interval_name' => 'hourly',
]
] );
/**
* Cron callback (handler) function.
*/
function wpkama_core_data_check_update(){
// your code to do the cron job
}
new \Kama\WP\Kama_Cron( [
'wpkama_cron_hook' => [
'callback' => 'wpkama_cron_func',
'interval_name' => '10 minutes',
],
] );
function wpkama_cron_func(){
// your code to do the cron job
}
new \Kama\WP\Kama_Cron( [
'single_job' => [
'callback' => 'single_job_func',
// start event every day at 6am by site time
'start_time' => strtotime('tomorrow 6am') - (int) get_option('gmt_offset'),
],
] );
new \Kama\WP\Kama_Cron( [
'my_hook' => [
'callback' => 'my_cron_callback',
'interval_name' => 'hourly',
'args' => [ 123, 'abc' ],
],
] );
function my_cron_callback( $post_id, $mode ){
// do something
}