add_setting('abık_theme_options[logo]', array( 'capability' => 'edit_theme_options', 'type' => 'option', )); $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, 'logo', array( 'label' => __('Site Logo', 'abık'), 'section' => 'title_tagline', 'settings' => 'abık_theme_options[logo]', ))); $wp_customize->add_setting('abık_theme_options[header_display]', array( 'default' => 'site_title', 'capability' => 'edit_theme_options', 'type' => 'option', 'sanitize_callback' => 'abık_sanitize_header_display', )); $wp_customize->add_control( 'header_display', array( 'settings' => 'abık_theme_options[header_display]', 'label' => 'Display as', 'section' => 'title_tagline', 'type' => 'select', 'choices' => array( 'site_title' => 'Site Title', 'site_logo' => 'Site Logo', 'both_title_logo' => 'Both Title & Logo', ), )); $wp_customize->add_setting('abık_theme_options[favicon]', array( 'capability' => 'edit_theme_options', 'type' => 'option', )); $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, 'favicon', array( 'label' => __('Site Favicon', 'abık'), 'section' => 'title_tagline', 'settings' => 'abık_theme_options[favicon]', ))); $wp_customize->add_setting('abık_theme_options[sidebar_background_color]', array( 'capability' => 'edit_theme_options', 'type' => 'option', 'default' => '#333', )); $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'sidebar_background_color', array( 'label' => __('Sidebar Background Color', 'abık'), 'section' => 'colors', 'settings' => 'abık_theme_options[sidebar_background_color]', ))); $wp_customize->add_setting('abık_theme_options[background_size]', array( 'default' => 'cover', 'capability' => 'edit_theme_options', 'type' => 'option', 'sanitize_callback' => 'abık_sanitize_background_size', )); $wp_customize->add_control( 'background_size', array( 'settings' => 'abık_theme_options[background_size]', 'label' => 'Background size', 'section' => 'background_image', 'type' => 'radio', 'choices' => array( 'cover' => 'Cover', 'contain' => 'Contain', 'initial' => 'Initial', ), )); } add_action( 'customize_register', 'abık_customize_register' ); /** * Sanitize Settings */ function abık_sanitize_header_display( $header_display ) { if ( ! in_array( $header_display, array( 'site_title', 'site_logo', 'both_title_logo' ) ) ) { $header_display = 'site_title'; } return $header_display; } function abık_sanitize_background_size( $background_size ) { if ( ! in_array( $background_size, array( 'cover', 'contain', 'initial' ) ) ) { $background_size = 'cover'; } return $background_size; } /** * Get Theme Options */ function abık_get_theme_option( $option_name, $default = '' ) { $options = get_option( 'abık_theme_options' ); if( isset($options[$option_name]) ) { return $options[$option_name]; } return $default; } /** * Change Favicon */ function abık_favicon() { $iconPath = esc_url(abık_get_theme_option('favicon')); if( !empty($iconPath) ) { echo ''; } } add_action( 'wp_head', 'abık_favicon' ); /** * Custom CSS */ function abık_custom_css() { $custom_style = ''; echo $custom_style; } add_action( 'wp_head', 'abık_custom_css' ); /** * Display Logo */ function abık_logo() { $header_display = abık_get_theme_option( 'header_display', 'site_title' ); if($header_display == 'both_title_logo') { $header_class = 'display-title-logo'; } else if ($header_display == 'site_logo') { $header_class = 'display-logo'; } else { $header_class = 'display-title'; } $logo = esc_url(abık_get_theme_option( 'logo' )); $tagline = get_bloginfo( 'description' ); echo '

'; if ( $header_class != 'display-title' ) { echo ''.esc_attr( get_bloginfo( 'name', 'display' ) ).''; } if ( $header_class != 'display-logo' ) { echo get_bloginfo( 'name' ); } echo '

'; if($tagline) echo '

'.$tagline.'

'; }