<?php
/**
 * For store widget hook action/filter.
 * 
 * @package bootstrap-basic
 */


if (!function_exists('bootstrapBasicWidgetHooksGetCalendar')) {
    /**
     * Change WordPress calendar widget table to add bootstrap class into it.
     * 
     * @todo change code in this function when WordPress allowed to hook into that widget.
     * @param string $calendar Calendar HTML string.
     * @return string
     */
    function bootstrapBasicWidgetHooksGetCalendar($calendar) 
    {
        $new_calendar = preg_replace('#(<table*\s)(id="wp-calendar")#i', '$1 id="wp-calendar" class="table"', $calendar);
        $new_calendar = '<div class="table-responsive">' . $new_calendar . '</div>';

        return $new_calendar;
    }// bootstrapBasicWidgetHooksGetCalendar
}
add_filter('get_calendar', 'bootstrapBasicWidgetHooksGetCalendar', 10, 1);
