'',
'default-text-color' => $header_color,
'width' => 900,
'height' => 200,
'flex-height' => true,
'wp-head-callback' => 'cleanhome_header_style',
'admin-head-callback' => 'cleanhome_admin_header_style',
'admin-preview-callback' => 'cleanhome_admin_header_image',
) ) );
add_action( 'init', 'cleanhome_register_menus' );
add_action( 'widgets_init', 'cleanhome_widgets_init' );
add_action( 'wp_enqueue_scripts', 'cleanhome_color_registrar' );
load_theme_textdomain( 'cleanhome', get_template_directory() . '/languages' );
}
/**
* Enqueue scripts and styles
*/
function cleanhome_scripts() {
global $wp_styles;
wp_enqueue_style( 'cleanhome', get_stylesheet_uri() );
wp_enqueue_style( 'cleanhome-ie', get_template_directory_uri() . '/ie.css', array( 'cleanhome' ) );
$wp_styles->add_data( 'cleanhome-ie', 'conditional', 'IE' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
}
add_action( 'wp_enqueue_scripts', 'cleanhome_scripts' );
function cleanhome_header_style() {
// If no custom options for text are set, let's bail
// get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value
if ( HEADER_TEXTCOLOR == get_header_textcolor() )
return;
// If we get this far, we have custom styles. Let's do this.
?>
>
__( 'Primary Navigation', 'cleanhome' ),
) );
}
// Menu Fallback
function cleanhome_page_menu() { // fallback for primary navigation ?>
__( 'Sidebar', 'cleanhome' ),
'id' => 'primary-widget-area',
'description' => __( 'The primary widget area', 'cleanhome' ),
'before_widget' => '',
'before_title' => '',
'after_title' => '
'
));
register_sidebar( array(
'name' => __( 'Header', 'cleanhome' ),
'id' => 'header',
'description' => __( 'Header widget area with big font size.', 'cleanhome' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
));
}
// Returns the current Clean Home theme options, with default values for fallback
function cleanhome_get_theme_options() {
$defaults = array(
'color_scheme' => 'light',
);
$options = get_option( 'cleanhome_theme_options', $defaults );
return $options;
}
// Register our color schemes and add them to the queue
function cleanhome_color_registrar() {
$options = cleanhome_get_theme_options();
$color_scheme = $options['color_scheme'];
if ( 'dark' == $color_scheme ) {
wp_register_style( 'dark', get_template_directory_uri() . '/colors/dark.css', null, null );
wp_enqueue_style( 'dark' );
}
if ( 'snowy' == $color_scheme ) {
wp_register_style( 'snowy', get_template_directory_uri() . '/colors/snowy.css', null, null );
wp_enqueue_style( 'snowy' );
}
if ( 'sunny' == $color_scheme ) {
wp_register_style( 'sunny', get_template_directory_uri() . '/colors/sunny.css', null, null );
wp_enqueue_style( 'sunny' );
}
}
/**
* Adds custom classes to the array of body classes.
*/
function cleanhome_body_classes( $classes ) {
$options = cleanhome_get_theme_options();
$color_scheme = $options['color_scheme'];
// Add color scheme class.
switch ( $color_scheme ) {
case 'dark' :
$classes[] = 'color-dark';
break;
case 'snowy' :
$classes[] = 'color-snowy';
break;
case 'sunny' :
$classes[] = 'color-sunny';
break;
default :
$classes[] = 'color-light';
break;
}
return $classes;
}
add_filter( 'body_class', 'cleanhome_body_classes' );
/**
* Filters wp_title to print a neat tag based on what is being viewed.
*
* @since Clean Home 1.2.0
*/
function cleanhome_wp_title( $title, $sep ) {
global $page, $paged;
if ( is_feed() )
return $title;
// Add the blog name
$title .= get_bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title .= " $sep $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
$title .= " $sep " . sprintf( __( 'Page %s', 'cleanhome' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'cleanhome_wp_title', 10, 2 );
/**
* Load Jetpack compatibility file.
*/
if ( file_exists( get_template_directory() . '/inc/jetpack.php' ) )
require get_template_directory() . '/inc/jetpack.php';