<?php 
/**
 * swiftpress Theme Customizer.
 *
 * @package swiftpress
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function swiftpress_customize_register( $wp_customize ) {
  $wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
  $wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
  $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
  //$wp_customize->get_setting( 'swiftpress_header_logo_image' )->transport = 'postMessage';
}
add_action( 'customize_register', 'swiftpress_customize_register' );

add_action('after_setup_theme','twentyelevenchild_customize_appearance_header_options');
function twentyelevenchild_customize_appearance_header_options () {


add_theme_support( 'custom-logo', array(
  'height'      => 45,
  'width'       => 200,
  'flex-height' => true,
  'flex-width'  => true,
  'default'   =>get_template_directory_uri().'/images/logo.png',
 ) );

}



/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function swiftpress_customize_preview_js() {
  wp_enqueue_script( 'swiftpress_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'swiftpress_customize_preview_js' );


function swiftpress_theme_sanitize_category($input){
  $output=intval($input);
  return $output;
}

function swiftpress_theme_sanitize_text( $input ) {
    return wp_kses_post( force_balance_tags( $input ) );
}

if ( ! function_exists( 'swiftpress_sanitize_post' ) ) :
    /**
     * Function to sanitize post/page/post type
     *
     * @access public
     * @since 1.1
     *
     * @param int $swiftpress_post_id
     * @param object $swiftpress_setting
     * @return int || float
     *
     */
    function swiftpress_sanitize_post( $swiftpress_post_id, $swiftpress_setting ) {
        // Ensure $swiftpress_post_id is an absolute integer.
        $swiftpress_post_id = absint( $swiftpress_post_id );

        // If $swiftpress_post_id is an ID of a published page, return it; otherwise, return the default.
        return ( 'publish' == get_post_status( $swiftpress_post_id ) ? $swiftpress_post_id : $swiftpress_setting->default );
    }

endif;
