function vipgo_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); } }
/** * 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); } self::find_next_day_to_process($year, $month, $day); }
/** * @subcommand generate-sitemap-for-year-month-day */ function generate_sitemap_for_year_month_day($args, $assoc_args) { if (empty($this->command)) { $this->command = 'day'; } $assoc_args = wp_parse_args($assoc_args, array('year' => false, 'month' => false, 'day' => false)); $year = intval($assoc_args['year']); $month = intval($assoc_args['month']); $day = intval($assoc_args['day']); $valid = $this->validate_year_month_day($year, $month, $day); if (is_wp_error($valid)) { WP_CLI::error($valid->get_error_message()); } WP_CLI::line(sprintf('Generating sitemap for %s-%s-%s', $year, $month, $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); // TODO: simplify; this function should accept the year, month, day and translate accordingly } }