Advertisement
campusboy

rs_cron_rebuild_meta_products

Feb 27th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. // Регистрируем период времени для перегенерации мета-данных
  2. function rs_cron_time_period( $schedules ) {
  3.     $schedules['rs_time_period'] = array(
  4.         'interval' => 1,
  5.         'display' => 'Задаётся в настройках плагина RS'
  6.     );
  7.     return $schedules;
  8. }
  9. add_filter( 'cron_schedules', 'rs_cron_time_period' );
  10.  
  11. // Добавляем запланированный хук
  12. function rs_cron_rebuild_meta_products() {
  13.     if( ! wp_next_scheduled( 'rs_cron_event' ) ) {
  14.         wp_schedule_event( time(), 'rs_time_period', 'rs_cron_event');
  15.     }
  16. }
  17. add_action('wp', 'rs_cron_rebuild_meta_products');
  18.  
  19. // добавляем функцию к указанному хуку
  20. function rs_do_time_period() {
  21.  
  22.     $headers = 'From: My Name <myname@mydomain.com>' . "\r\n";
  23.     wp_mail('test@test.com', 'Тема', 'Содержание', $headers);
  24.    
  25.     die('111111');
  26.    
  27. }
  28. add_action('rs_cron_event', 'rs_do_time_period');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement