__( 'Primary Menu', 'fresh-and-clean' ),
) );
// This theme allows users to set a custom background.
add_custom_background();
// This theme allows users to upload a custom header.
define( 'HEADER_TEXTCOLOR', '000000' );
define( 'HEADER_IMAGE', '' );
define( 'HEADER_IMAGE_WIDTH', 920 ); // use width and height appropriate for your theme
define( 'HEADER_IMAGE_HEIGHT', 116 );
// Add a way for the custom header to be styled in the admin panel that controls
// custom headers. See fresh_and_clean_admin_header_style(), below.
add_custom_image_header( 'fresh_and_clean_header_style', 'fresh_and_clean_admin_header_style' );
// This theme uses Featured Images
add_theme_support( 'post-thumbnails' );
// Set thumbnail size.
add_image_size( 'fresh-and-clean-thumbnail', 160, 120, true );
add_image_size( 'large-feature', 840, 280, true );
// Define the minimum image width for the featured slider
define ( 'FEATURED_IMAGE_WIDTH', 840 );
}
endif; // fresh-and-clean_setup
// Tell WordPress to run fresh-and-clean_setup() when the 'after_setup_theme' hook is run.
add_action( 'after_setup_theme', 'fresh_and_clean_setup' );
/**
* Enqueue scripts and styles
*/
function fresh_and_clean_scripts() {
wp_enqueue_style( 'fresh-and-clean', get_stylesheet_uri() );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
}
add_action( 'wp_enqueue_scripts', 'fresh_and_clean_scripts' );
/**
* Add custom header support
*/
if ( ! function_exists( 'fresh_and_clean_header_style' ) ) :
/**
* Styles the header image and text displayed on the blog
*
*/
function fresh_and_clean_header_style() {
// If no custom options for text are set, let's bail
if ( HEADER_TEXTCOLOR == get_header_textcolor() && '' == get_header_image() )
return;
// If we get this far, we have custom styles. Let's do this.
?>
Header admin panel.
*
* Referenced via add_custom_image_header() in fresh_and_clean_setup().
*
*/
function fresh_and_clean_admin_header_style() {
?>
__( 'Sidebar 1', 'fresh-and-clean' ),
'id' => 'sidebar-1',
'description' => __( 'Drag widgets here to activate the sidebar.', 'fresh-and-clean' ),
'before_widget' => '",
'before_title' => '
',
'after_title' => '
',
) );
}
add_action( 'init', 'fresh_and_clean_widgets_init' );
if ( ! function_exists( 'fresh_and_clean_content_nav' ) ):
// Display navigation to next/previous pages when applicable
function fresh_and_clean_content_nav( $nav_id ) {
global $wp_query;
?>
comment_type ) :
case 'pingback' :
case 'trackback' :
?>
permalink.', 'fresh-and-clean' );
} else {
$meta_text = __( 'This entry was posted on %5$s%6$s. Bookmark the permalink.', 'fresh-and-clean' );
}
} else {
// But this blog has loads of categories so we should probably display them here
if ( '' != $tag_list && ! is_wp_error( $tags_list ) ) {
$meta_text = __( 'This entry was posted on %5$s%6$s, in %1$s and tagged %2$s. Bookmark the permalink.', 'fresh-and-clean' );
} else {
$meta_text = __( 'This entry was posted on %5$s%6$s, in %1$s. Bookmark the permalink.', 'fresh-and-clean' );
}
} // end check for categories on this blog
// Only display author link if blog has multiple authors
if ( ! is_multi_author() ) {
$author = '';
}
else {
$author = ' by ' . esc_html( get_the_author() ) . '';
}
printf(
$meta_text,
$category_list,
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' ),
esc_attr( get_the_date() ),
$author
);
else :
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', 'fresh-and-clean' ) );
$tags_list = get_the_tag_list( '', __( ', ', 'fresh-and-clean' ) );
if ( $categories_list && fresh_and_clean_categorized_blog() ) {
$meta_text = __( 'Posted on %1$s, in %2$s.', 'fresh-and-clean' );
} // End if $categories_list
if ( $tags_list && ! is_wp_error( $tags_list ) ) {
$meta_text = __( 'Posted on %1$s, and tagged %3$s.', 'fresh-and-clean' );
} // End if $tags_list
printf(
$meta_text,
esc_attr( get_the_date() ),
$categories_list,
$tags_list
);
endif;
}
/**
* Add special classes to the WordPress body class.
*/
function fresh_and_clean_body_classes( $classes ) {
// If we have one sidebar active we have secondary content
if ( ! is_active_sidebar( 'sidebar-1' ) )
$classes[] = 'one-column';
return $classes;
}
add_filter( 'body_class', 'fresh_and_clean_body_classes' );
/**
* Returns a "Continue Reading" link for excerpts
*/
function fresh_and_clean_reading_link() {
return ' ' . __( 'Continue reading →', 'fresh-and-clean' ) . '';
}
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and fresh_and_clean_reading_link().
*
* To override this in a child theme, remove the filter and add your own
* function tied to the excerpt_more filter hook.
*/
function fresh_and_clean_auto_excerpt_more( $more ) {
return ' …' . fresh_and_clean_reading_link();
}
add_filter( 'excerpt_more', 'fresh_and_clean_auto_excerpt_more' );
/**
* Adds a pretty "Continue Reading" link to custom post excerpts.
*
* To override this link in a child theme, remove the filter and add your own
* function tied to the get_the_excerpt filter hook.
*/
function fresh_and_clean_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= fresh_and_clean_reading_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'fresh_and_clean_custom_excerpt_more' );
// Returns true if a blog has more than 1 category
function fresh_and_clean_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) {
// Create an array of all the categories that are attached to posts
$all_the_cool_cats = get_categories( array(
'hide_empty' => 1,
) );
// Count the number of categories that are attached to the posts
$all_the_cool_cats = is_countable( $all_the_cool_cats ) ? count( $all_the_cool_cats ) : 0;
set_transient( 'all_the_cool_cats', $all_the_cool_cats );
}
if ( '1' != $all_the_cool_cats ) {
// This blog has more than 1 category so fresh-and-clean_categorized_blog should return true
return true;
} else {
// This blog has only 1 category so fresh-and-clean_categorized_blog should return false
return false;
}
}
// Flush out the transients used in fresh-and-clean_categorized_blog
function fresh_and_clean_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'all_the_cool_cats' );
}
add_action( 'edit_category', 'fresh_and_clean_transient_flusher' );
add_action( 'save_post', 'fresh_and_clean_transient_flusher' );
// Filter in a link to a content ID attribute for the next/previous image links on image attachment pages
function fresh_and_clean_enhanced_image_navigation( $url ) {
global $post, $wp_rewrite;
$id = null;
if ( isset( $post->ID ) ) {
$id = (int) $post->ID;
}
$object = get_post( $id );
if ( ( isset( $post->ID ) && wp_attachment_is_image( $post->ID ) ) && ( $wp_rewrite->using_permalinks() && ( $object->post_parent > 0 ) && ( $object->post_parent != $id ) ) )
$url = $url . '#main';
return $url;
}
add_filter( 'attachment_link', 'fresh_and_clean_enhanced_image_navigation' );
// Enqueue font styles
function fresh_and_clean_fonts() {
wp_enqueue_style( 'pacifico', "https://fonts.googleapis.com/css?family=Pacifico" );
wp_enqueue_style( 'droid sans', "https://fonts.googleapis.com/css?family=Droid+Sans:400" );
wp_enqueue_style( 'droid serif', "https://fonts.googleapis.com/css?family=Droid+Serif:400" );
}
add_action( 'wp_enqueue_scripts', 'fresh_and_clean_fonts' );
/**
* Enqueue font style for the custom header admin page.
*/
function fresh_and_clean_admin_fonts( $hook_suffix ) {
if ( 'appearance_page_custom-header' != $hook_suffix )
return;
wp_enqueue_style( 'pacifico', "https://fonts.googleapis.com/css?family=Pacifico" );
wp_enqueue_style( 'droid sans', "https://fonts.googleapis.com/css?family=Droid+Sans:400" );
}
add_action( 'admin_enqueue_scripts', 'fresh_and_clean_admin_fonts' );
function fresh_and_clean_header_css() {
// Make #branding tall enough to fit the header image if the user adds a custom header image
if ( '' != get_header_image() ) : ?>
tag based on what is being viewed.
*
* @since Fresh and Clean 1.3
*/
function fresh_and_clean_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', 'fresh-and-clean' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'fresh_and_clean_wp_title', 10, 2 );