Project

General

Profile

Feature #8987 » cavalcade-migrate.php

Boone Gorges, 2018-06-05 05:23 PM

 
1
<?php
2

    
3
remove_filter( 'pre_update_option_cron', 'HM\\Cavalcade\\Plugin\\Connector\\update_cron_array', 10, 2 );
4
remove_filter( 'pre_option_cron', 'HM\\Cavalcade\\Plugin\\Connector\\get_cron_array', 10, 2 );
5

    
6
$crons = _get_cron_array();
7

    
8
add_filter( 'pre_update_option_cron', 'HM\\Cavalcade\\Plugin\\Connector\\update_cron_array', 10, 2 );
9
add_filter( 'pre_option_cron', 'HM\\Cavalcade\\Plugin\\Connector\\get_cron_array', 10, 2 );
10

    
11
$job_count = 0;
12
foreach ( $crons as $timestamp => $hooks ) {
13
	foreach ( $hooks as $hook => $jobs ) {
14
		foreach ( $jobs as $key => $args ) {
15
			$job_count++;
16
			if ( ! empty( $args['schedule'] ) ) {
17
				wp_schedule_event( $timestamp, $args['schedule'], $hook, $args );
18
			} else {
19
				wp_schedule_single_event( $timestamp, $hook, $args );
20
			}
21
		}
22
	}
23
}
24

    
25
echo "Migrated $job_count jobs for " . home_url() . "\n";
26

    
27

    
(2-2/2)