public static function generate_sitemap_for_year_month($args)
{
$is_partial_or_running = get_option('msm_days_to_process');
$year = $args['year'];
$month = $args['month'];
// cal_days_in_month doesn't exist on WP.com so set it to a possible max. Will skip invalid dates as no posts will be found
if (!function_exists('cal_days_in_month')) {
$max_days = 31;
} else {
$max_days = cal_days_in_month(CAL_GREGORIAN, (int) $month, (int) $year);
}
if (date('Y') == $year && $month == date('n')) {
$max_days = date('j');
}
if (empty($is_partial_or_running)) {
$days = range(1, $max_days);
update_option('msm_days_to_process', $days);
} else {
$days = $is_partial_or_running;
}
$next_day = end($days);
$time = time();
wp_schedule_single_event($time, 'msm_cron_generate_sitemap_for_year_month_day', array(array('year' => (int) $year, 'month' => (int) $month, 'day' => (int) $next_day)));
}