/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously for catchresponsive.
 * And flushes out all transient data on preview
 *
 * @since Catch Responsive 1.0
 */
function catchresponsive_customize_preview()
{
    wp_enqueue_script('catchresponsive_customizer', get_template_directory_uri() . '/js/catchresponsive-customizer.min.js', array('customize-preview'), '20120827', true);
    //Flush transients on preview
    catchresponsive_flush_transients();
}
/**
 * Reset all settings to default
 * @param  $input entered value
 * @return sanitized output
 *
 * @since Catch Responsive 1.8
 */
function catchresponsive_reset_all_settings($input)
{
    if ($input == 1) {
        // Set default values
        set_theme_mod('catchresponsive_theme_options', catchresponsive_get_default_theme_options());
        // Flush out all transients	on reset
        catchresponsive_flush_transients();
    } else {
        return '';
    }
}
    /**
    * Add Featured content.
    *
    * @uses action hook catchresponsive_before_content.
    *
    * @since Catch Responsive 1.0
    */
    function catchresponsive_featured_content_display()
    {
        catchresponsive_flush_transients();
        global $post, $wp_query;
        // get data value from options
        $options = catchresponsive_get_theme_options();
        $enablecontent = $options['featured_content_option'];
        $contentselect = $options['featured_content_type'];
        // Front page displays in Reading Settings
        $page_on_front = get_option('page_on_front');
        $page_for_posts = get_option('page_for_posts');
        // Get Page ID outside Loop
        $page_id = $wp_query->get_queried_object_id();
        if ($enablecontent == 'entire-site' || (is_front_page() || is_home() && $page_for_posts != $page_id) && $enablecontent == 'homepage') {
            if (!($catchresponsive_featured_content = get_transient('catchresponsive_featured_content_display'))) {
                $layouts = $options['featured_content_layout'];
                $headline = $options['featured_content_headline'];
                $subheadline = $options['featured_content_subheadline'];
                echo '<!-- refreshing cache -->';
                if (!empty($layouts)) {
                    $classes = $layouts;
                }
                if ($contentselect == 'demo-featured-content') {
                    $classes .= ' demo-featured-content';
                    $headline = __('Featured Content', 'catch-responsive');
                    $subheadline = __('Here you can showcase the x number of Featured Content. You can edit this Headline, Subheadline and Feaured Content from "Appearance -> Customize -> Featured Content Options".', 'catch-responsive');
                } elseif ($contentselect == 'featured-page-content') {
                    $classes .= ' featured-page-content';
                }
                //Check Featured Content Position
                $featured_content_position = $options['featured_content_position'];
                if ('1' == $featured_content_position) {
                    $classes .= ' border-top';
                }
                $catchresponsive_featured_content = '
				<section id="featured-content" class="' . $classes . '">
					<div class="wrapper">';
                if (!empty($headline) || !empty($subheadline)) {
                    $catchresponsive_featured_content .= '<div class="featured-heading-wrap">';
                    if (!empty($headline)) {
                        $catchresponsive_featured_content .= '<h1 id="featured-heading" class="entry-title">' . $headline . '</h1>';
                    }
                    if (!empty($subheadline)) {
                        $catchresponsive_featured_content .= '<p>' . $subheadline . '</p>';
                    }
                    $catchresponsive_featured_content .= '</div><!-- .featured-heading-wrap -->';
                }
                $catchresponsive_featured_content .= '
						<div class="featured-content-wrap">';
                // Select content
                if ($contentselect == 'demo-featured-content' && function_exists('catchresponsive_demo_content')) {
                    $catchresponsive_featured_content .= catchresponsive_demo_content($options);
                } elseif ($contentselect == 'featured-page-content' && function_exists('catchresponsive_page_content')) {
                    $catchresponsive_featured_content .= catchresponsive_page_content($options);
                }
                $catchresponsive_featured_content .= '
						</div><!-- .featured-content-wrap -->
					</div><!-- .wrapper -->
				</section><!-- #featured-content -->';
                set_transient('catchresponsive_featured_content', $catchresponsive_featured_content, 86940);
            }
            echo $catchresponsive_featured_content;
        }
    }