Last active
October 19, 2019 06:50
-
-
Save eto4detak/fc2f3d3ea9f2aaf4121a4e6e4e0603fe to your computer and use it in GitHub Desktop.
wp php cron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* * * * * 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