Skip to content

Commit

Permalink
Restore generate_sitemap_for_year_month_day
Browse files Browse the repository at this point in the history
We need something to actually trigger the scheduled cron events
  • Loading branch information
mjangda committed Jan 9, 2017
1 parent c9fda86 commit 25ffc54
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions includes/msm-sitemap-builder-cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class MSM_Sitemap_Builder_Cron {

public static function setup() {
add_action( 'msm_update_sitemap_for_year_month_date', array( __CLASS__, 'schedule_sitemap_update_for_year_month_date' ), 10, 2 );
add_action( 'msm_cron_generate_sitemap_for_year_month_day', array( __CLASS__, 'generate_sitemap_for_year_month_day' ) );
}

public static function schedule_sitemap_update_for_year_month_date( $date, $time ) {
Expand All @@ -21,4 +22,21 @@ public static function schedule_sitemap_update_for_year_month_date( $date, $time
)
);
}

/**
* Generate sitemap for a given year, month, day
* @param mixed[] $args
*/
public static function generate_sitemap_for_year_month_day( $args ) {
$year = $args['year'];
$month = $args['month'];
$day = $args['day'];

$date_stamp = Metro_Sitemap::get_date_stamp( $year, $month, $day );
if ( Metro_Sitemap::date_range_has_posts( $date_stamp, $date_stamp ) ) {
Metro_Sitemap::generate_sitemap_for_date( $date_stamp );
} else {
Metro_Sitemap::delete_sitemap_for_date( $date_stamp );
}
}
}

0 comments on commit 25ffc54

Please sign in to comment.