/**
 * Return the daily archive URL for the post type.
 *
 * @see get_post_type_date_link()
 */
function get_post_type_day_link($post_type, $year = '', $month = '', $day = '')
{
    return get_post_type_date_link($post_type, $year, $month, $day);
}
function cfs_lfq_calendar($args)
{
    if (CFS_LFQ_POST_TYPE) {
        $defaults = array('dates' => array(), 'months' => array(), 'weekdayLabel' => 'default', 'weekdayBase' => 0, 'element' => 'div', 'class' => '');
        $d = wp_parse_args($args, $defaults);
        extract($d, EXTR_SKIP);
        $locale = new WP_Locale();
        if ($weekdayLabel == 'en') {
            $wd = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
        } else {
            $wd = array_values($locale->weekday_abbrev);
        }
        $wd_en = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
        $today = date_i18n('Ymd');
        $factory = new CalendR\Calendar();
        $num = 1;
        foreach ($months as $month) {
            $month = $month . "01";
            $month = $factory->getMonth(date('Y', strtotime($month)), date('m', strtotime($month)));
            ?>
	<<?php 
            echo esc_html($element);
            ?>
 class="calendar-<?php 
            echo $num;
            ?>
 calendar-<?php 
            echo date('Y', strtotime($month)) . "-" . date('m', strtotime($month));
            if ($class) {
                ?>
 <?php 
                echo esc_html($class);
            }
            ?>
">
        <header>
        	<h4><?php 
            echo $month->format('M');
            ?>
</h4>
        </header>
        <table cellspacing="0" cellpadding="0" border="0">
            <thead>
				<tr>
					<?php 
            for ($i = 0; $i < 7; ++$i) {
                $weekday = ($weekdayBase + $i) % 7;
                $weekdayText = $wd[$weekday];
                $weekdayEn = $wd_en[$weekday];
                echo '<th class="dayweek ' . $weekdayEn . '">' . $weekdayText . '</th>';
            }
            ?>
				</tr>
        	</thead>
        	<tbody>
                <?php 
            foreach ($month as $week) {
                ?>
                    <tr>
                        <?php 
                foreach ($week as $day) {
                    ?>
                            <td class="<?php 
                    echo mb_strtolower($day->format('D'));
                    if ($day->format('Ymd') === $today) {
                        ?>
 today<?php 
                    }
                    if (!$month->includes($day)) {
                        ?>
 out-of-month<?php 
                    }
                    ?>
">
                                <?php 
                    if ($month->includes($day) && in_array($day->format('Ymd'), $dates)) {
                        $href = get_post_type_date_link(CFS_LFQ_POST_TYPE, $day->format('Y'), $day->format('m'), $day->format('d'));
                        $dayText = '<a href="' . $href . '"><span>' . $day->format('j') . '</span></a>';
                    } else {
                        $dayText = $day->format('j');
                    }
                    echo $dayText;
                    ?>
                            </td>
                        <?php 
                }
                ?>
                    </tr>
                <?php 
            }
            ?>
            </tbody>
        </table>
	</<?php 
            echo esc_html($element);
            ?>
>
<?php 
            $num++;
        }
    }
}