Skip to content

Commit

Permalink
Merge pull request #136 from Automattic/kraftbj-patch-1
Browse files Browse the repository at this point in the history
CLI: Use cal_days_in_month when available
  • Loading branch information
kraftbj authored May 3, 2018
2 parents 4b4935c + 6e05b3e commit f0d233c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion includes/wp-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ function generate_sitemap_for_year_month( $args, $assoc_args ) {
WP_CLI::line( sprintf( 'Generating sitemap for %s-%s', $year, $month ) );

// Calculate actual number of days in the month since we don't have cal_days_in_month available
$max_days = 31;
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 && date( 'n' ) == $month ) {
$max_days = date( 'j' );
Expand Down

0 comments on commit f0d233c

Please sign in to comment.