/home/sylamedg/www/wp-content/themes/skt-nurse/inc/customizer.php
<?php
/**
* SKT Nurse Theme Customizer
*
* @package SKT Nurse
*/
function skt_nurse_custom_header_setup() {
add_theme_support( 'custom-header', apply_filters( 'skt_nurse_custom_header_args', array(
'default-text-color' => '949494',
'width' => 1600,
'height' => 230,
'wp-head-callback' => 'skt_nurse_header_style',
'default-text-color' => false,
'header-text' => false,
) ) );
}
add_action( 'after_setup_theme', 'skt_nurse_custom_header_setup' );
if ( ! function_exists( 'skt_nurse_header_style' ) ) :
/**
* Styles the header image and text displayed on the blog
*
* @see skt_nurse_custom_header_setup().
*/
function skt_nurse_header_style() {
?>
<style type="text/css">
<?php
//Check if user has defined any header image.
if ( get_header_image() ) :
?>
.header{
background: url(<?php echo esc_url(get_header_image()); ?>) no-repeat;
background-position: center top;
background-size:cover;
}
<?php endif; ?>
</style>
<?php
}
endif; // skt_nurse_header_style
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function skt_nurse_customize_register( $wp_customize ) {
//Add a class for titles
class skt_nurse_Info extends WP_Customize_Control {
public $type = 'info';
public $label = '';
public function render_content() {
?>
<h3 style="text-decoration: underline; color: #DA4141; text-transform: uppercase;"><?php echo esc_html( $this->label ); ?></h3>
<?php
}
}
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->add_setting('color_scheme',array(
'default' => '#33aabf',
'sanitize_callback' => 'sanitize_hex_color'
));
$wp_customize->add_control(
new WP_Customize_Color_Control($wp_customize,'color_scheme',array(
'label' => esc_html__('Color Scheme','skt-nurse'),
'section' => 'colors',
'settings' => 'color_scheme'
))
);
$wp_customize->add_setting('header_bg_color',array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color'
));
$wp_customize->add_control(
new WP_Customize_Color_Control($wp_customize,'header_bg_color',array(
'label' => esc_html__('Header Background Color','skt-nurse'),
'section' => 'colors',
'settings' => 'header_bg_color'
))
);
$wp_customize->add_section('header_phone_number',array(
'title' => esc_html__('Header Phone Number','skt-nurse'),
'priority' => null
));
$wp_customize->add_setting('header_phonenumbertext',array(
'default' => null,
'sanitize_callback' => 'sanitize_text_field'
));
$wp_customize->add_control('header_phonenumbertext',array(
'label' => esc_html__('Add Phone Number','skt-nurse'),
'section' => 'header_phone_number',
'setting' => 'header_phonenumbertext'
));
// Hide Header Phone Number
$wp_customize->add_setting('hide_header_phonenumber',array(
'sanitize_callback' => 'skt_nurse_sanitize_checkbox',
'default' => true,
));
$wp_customize->add_control( 'hide_header_phonenumber', array(
'section' => 'header_phone_number',
'label' => esc_html__('Uncheck To Show Phone Number In Header','skt-nurse'),
'type' => 'checkbox'
));
// Hide Header Phone Number
$wp_customize->add_setting('footer_text_color',array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color'
));
$wp_customize->add_control(
new WP_Customize_Color_Control($wp_customize,'footer_text_color',array(
'label' => esc_html__('Copyright Text Color','skt-nurse'),
'section' => 'colors',
'settings' => 'footer_text_color'
))
);
// Inner Page Banner Settings
$wp_customize->add_section('inner_page_banner',array(
'title' => esc_html__('Inner Page Banner Settings','skt-nurse'),
'priority' => null
));
$wp_customize->add_setting('inner_page_banner_thumb',array(
'default' => null,
'sanitize_callback' => 'esc_url_raw'
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'inner_page_banner_thumb', array(
'section' => 'inner_page_banner',
'label' => esc_html__('Upload Default Banner Image','skt-nurse'),
'settings' => 'inner_page_banner_thumb',
'button_labels' => array(// All These labels are optional
'select' => 'Select Image',
'remove' => 'Remove Image',
'change' => 'Change Image',
)
)));
$wp_customize->add_setting('inner_page_banner_option',array(
'sanitize_callback' => 'skt_nurse_sanitize_checkbox',
'default' => true,
));
$wp_customize->add_control( 'inner_page_banner_option', array(
'section' => 'inner_page_banner',
'label' => esc_html__('Uncheck To Show Inner Page Banner On All Inner Pages. For Display Different Banner Image On Each Page Set Page Featured Image. Set Image Size (1400 X 300) For Better Resolution.','skt-nurse'),
'type' => 'checkbox'
));
// Inner Page Banner Settings
// Inner Post Banner Settings
$wp_customize->add_section('inner_post_banner',array(
'title' => esc_html__('Category / Archive And Single Post Banner Settings','skt-nurse'),
'priority' => null
));
$wp_customize->add_setting('inner_post_banner_thumb',array(
'default' => null,
'sanitize_callback' => 'esc_url_raw'
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'inner_post_banner_thumb', array(
'section' => 'inner_post_banner',
'label' => esc_html__('Upload Default Banner Image','skt-nurse'),
'settings' => 'inner_post_banner_thumb',
'button_labels' => array(// All These labels are optional
'select' => 'Select Image',
'remove' => 'Remove Image',
'change' => 'Change Image',
)
)));
$wp_customize->add_setting('inner_post_banner_option',array(
'sanitize_callback' => 'skt_nurse_sanitize_checkbox',
'default' => true,
));
$wp_customize->add_control( 'inner_post_banner_option', array(
'section' => 'inner_post_banner',
'label' => esc_html__('Uncheck To Show Inner Post Banner On Category / Archive And Single Post. For Display Different Banner Image On Each Post Set Post Featured Image. Set Image Size (1400 X 300) For Better Resolution.','skt-nurse'),
'type' => 'checkbox'
));
// Inner Page Banner Settings
$wp_customize->add_section('footer_text_copyright',array(
'title' => esc_html__('Footer Copyright Text','skt-nurse'),
'priority' => null
));
$wp_customize->add_setting('footer_text',array(
'default' => null,
'sanitize_callback' => 'sanitize_text_field'
));
$wp_customize->add_control('footer_text',array(
'label' => esc_html__('Add Copyright Text Here','skt-nurse'),
'section' => 'footer_text_copyright',
'setting' => 'footer_text'
));
}
add_action( 'customize_register', 'skt_nurse_customize_register' );
//Integer
function skt_nurse_sanitize_integer( $input ) {
if( is_numeric( $input ) ) {
return intval( $input );
}
}
function skt_nurse_sanitize_checkbox( $checked ) {
// Boolean check.
return ( ( isset( $checked ) && true == $checked ) ? true : false );
}
//setting inline css.
function skt_nurse_custom_css() {
wp_enqueue_style(
'skt-nurse-custom-style',
get_stylesheet_directory_uri() . '/css/skt-nurse-custom-style.css'
);
$color = esc_html(get_theme_mod( 'color_scheme' ));
$headerbgcolor = esc_html(get_theme_mod( 'header_bg_color' ));
$footertextcolor = esc_html(get_theme_mod( 'footer_text_color' ));
$custom_css = "
#sidebar ul li a:hover,
.blog_lists h4 a:hover,
.recent-post h6 a:hover,
.recent-post a:hover,
.design-by a,
.postmeta a:hover,
.tagcloud a,
.header-phone-number,
#sidebar li a:hover,
.main-navigation ul li ul li a,
.footer-row .cols-3 ul li a:hover,
.footer-row .cols-3 ul li.current_page_item a,
.footer-row .cols-3 ul li.current-menu-item a
{
color: {$color} !important;
}
#sidebar h2::after, #sidebar h3::after, #sidebar h4::after, #sidebar h5::after, #sidebar h6::after, #sidebar h6 #sidebar label::after, #sidebar .wp-block-search__label::after{background: {$color} !important;}
#commentform input#submit:hover,
.wpcf7 input[type='submit'],
input.search-submit,
.recent-post .morebtn:hover,
.read-more-btn,
.woocommerce-product-search button[type='submit'],
.view-all-btn a:hover,
.social-icons a:hover
{
background-color: {$color} !important;
}
.titleborder span:after, .sticky{border-bottom-color: {$color} !important;}
.header{background-color:{$headerbgcolor} !important;}
.copyright-txt{color: {$footertextcolor} !important;}
.main-navigation ul ul li a:hover, .main-navigation ul ul li a:focus {background-color: {$color} !important;}
";
wp_add_inline_style( 'skt-nurse-custom-style', $custom_css );
}
add_action( 'wp_enqueue_scripts', 'skt_nurse_custom_css' );
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function skt_nurse_customize_preview_js() {
wp_enqueue_script( 'skt_nurse_customizer', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '20130508', true );
}
add_action( 'customize_preview_init', 'skt_nurse_customize_preview_js' );