Skip to content

Instantly share code, notes, and snippets.

@eto4detak
Last active October 19, 2019 06:50
Show Gist options
  • Save eto4detak/fc2f3d3ea9f2aaf4121a4e6e4e0603fe to your computer and use it in GitHub Desktop.
Save eto4detak/fc2f3d3ea9f2aaf4121a4e6e4e0603fe to your computer and use it in GitHub Desktop.
wp php cron
* * * * * php /var/www/project/yii mailer/send
<?php
// регистрируем пятиминутный интервал
add_filter( 'cron_schedules', 'cron_add_five_min2234124124124' );
function cron_add_five_min2234124124124( $schedules ) {
$schedules['twenty_min_аaa'] = array(
'interval' => 60 * 20,
'display' => 'Раз в 20 минут'
);
return $schedules;
}
// регистрируем событие
add_action('wp', 'price_all_fdsfasf_fsdfasfas');
function price_all_fdsfasf_fsdfasfas() {
if ( ! wp_next_scheduled( 'sdfdsf_fsddfasf2_event' ) ) {
wp_schedule_event( time(), 'twenty_min_аaa', 'sdfdsf_fsddfasf2_event');
// wp_schedule_event( time(), 'hourly', 'sdfdsf_fsddfasf2_event');
// wp_schedule_event( time(), 'daily', 'sdfdsf_fsddfasf2_event');
}
}
// добавляем функцию к указанному хуку
add_action('sdfdsf_fsddfasf2_event', 'do_every_five_mindfgfasfasfagd');
function do_every_five_mindfgfasfasfagd() {
// делаем что-либо каждые 5 минут
}
add_action('wp', 'add_action_cron_callback');
add_action('action_cron_callback', 'update_all_status_np');
function add_action_cron_callback() {
if ( ! wp_next_scheduled( 'action_cron_callback' ) ) {
wp_schedule_event( time(), 'daily', 'action_cron_callback');
// wp_schedule_event( time(), 'hourly', 'sdfdsf_fsddfasf2_event');
}
}
function update_all_status_np() {
}
///////////////////////////////////////////////////////////////////////////////////////////
/////// class
///////////////////////////////////////////////////////////////////////////////////////////
add_action('wp', 'add_action_cron_NP_Package_Status');
add_action('action_cron_NP_Package_Status', array('NP_Package_Status' , 'update_all_status_np'));
function add_action_cron_NP_Package_Status() {
if ( ! wp_next_scheduled( 'action_cron_NP_Package_Status' ) ) {
wp_schedule_event( time(), 'daily', 'action_cron_NP_Package_Status');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment