.
add_theme_support( 'automatic-feed-links' );
// Add custom menus.
register_nav_menus( array(
'main_menu' => __( 'Main Menu', 'karakuri' ),
'footer_menu' => __( 'Footer Menu', 'karakuri' ),
) );
// Add support for custom backgrounds.
add_theme_support( 'custom-background', array(
'default-color' => 'f2f2f2',
) );
// Add support for custom headers.
$defaults = array(
'default-image' => get_template_directory_uri() . '/images/headers/nape-beauty.jpg',
'width' => apply_filters( 'karakuri_header_image_width', 980 ),
'height' => apply_filters( 'karakuri_header_image_height', 300 ),
'header-text' => true,
);
add_theme_support( 'custom-header', $defaults );
// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
register_default_headers( array(
'nape-beauty' => array(
'url' => '%s/images/headers/nape-beauty.jpg',
'thumbnail_url' => '%s/images/headers/nape-beauty-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Nape beauty', 'karakuri' )
),
'shukuba' => array(
'url' => '%s/images/headers/shukuba.jpg',
'thumbnail_url' => '%s/images/headers/shukuba-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Shukuba', 'karakuri' )
),
'water-wheel' => array(
'url' => '%s/images/headers/water-wheel.jpg',
'thumbnail_url' => '%s/images/headers/water-wheel-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Water wheel', 'karakuri' )
),
'chounai' => array(
'url' => '%s/images/headers/chounai.jpg',
'thumbnail_url' => '%s/images/headers/chounai-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Chounai', 'karakuri' )
),
'hei' => array(
'url' => '%s/images/headers/hei.jpg',
'thumbnail_url' => '%s/images/headers/hei-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Hei', 'karakuri' )
),
'noren' => array(
'url' => '%s/images/headers/noren.jpg',
'thumbnail_url' => '%s/images/headers/noren-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Noren', 'karakuri' )
),
) );
add_theme_support( 'post-thumbnails' );
add_image_size( 'archive-thumb', 184, 99999 );
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => 'page',
) );
}
endif;
/* karakuri_widgets_init */
if ( !function_exists( 'karakuri_widgets_init' ) ) :
add_action( 'widgets_init', 'karakuri_widgets_init' );
function karakuri_widgets_init() {
register_sidebar( array(
'name' => __( 'Footer Widget First', 'karakuri' ),
'id' => 'sidebar-1',
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Widget Second', 'karakuri' ),
'id' => 'sidebar-2',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer Widget Third', 'karakuri' ),
'id' => 'sidebar-3',
'before_widget' => '',
'before_title' => '',
) );
}
endif;
/* Head
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/**
* karakuri_wp_title
*
* @Filter to wp_title
* @Referring to Twenty Twelve 1.0
*/
add_filter( 'wp_title', 'karakuri_wp_title', 10, 2 );
function karakuri_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title = $site_description . $sep . $title;
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 )
$title = sprintf( __( 'Page %s', 'karakuri' ), max( $paged, $page ) ) . $sep . $title;
return $title;
}
/**
* karakuri_head_mobile_meta
*
* @Action to wp_head
*/
add_action( 'wp_head', 'karakuri_head_mobile_meta' );
function karakuri_head_mobile_meta() {
echo <<< EOT
EOT;
}
/**
* karakuri_head_script
*
* @Action to wp_head
*/
add_action( 'wp_head', 'karakuri_head_script' );
function karakuri_head_script() {
$template_directory_uri = get_template_directory_uri();
echo <<< EOT
EOT;
}
/**
* Enqueues scripts and styles for front-end.
*
* @Referring to Twenty Twelve 1.0
*/
add_action( 'wp_enqueue_scripts', 'karakuri_scripts_styles' );
function karakuri_scripts_styles() {
global $wp_styles;
/*
* Adds JavaScript to pages with the comment form to support
* sites with threaded comments (when in use).
*/
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
/*
* Loads our main theme common script.
*/
wp_enqueue_script( 'common-script', get_template_directory_uri() . '/js/common.min.js', array( 'jquery' ), get_file_time( 'js/common.min.js' ), true );
/*
* Loads our main stylesheet.
*/
wp_enqueue_style( 'karakuri-style', get_template_directory_uri() . '/style.css' , array(), get_file_time( 'style.css' ) );
}
/* Header
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* karakuri_main_nav */
function karakuri_main_nav() {
echo get_karakuri_main_nav();
}
/* get_karakuri_main_nav */
function get_karakuri_main_nav() {
$output = wp_nav_menu( array( 'container_id' => 'main-nav-box', 'echo' => false, 'theme_location' => 'main_menu' ) );
return $output;
}
/* karakuri_main_img */
function karakuri_main_img() {
echo get_karakuri_main_img();
}
/* get_karakuri_main_img */
function get_karakuri_main_img() {
$header_image = get_header_image();
if ( $header_image && (is_home() || is_front_page()) ) {
$output = '';
return $output;
}
}
/* Common
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
function entry_thumbnail() {
echo get_entry_thumbnail();
}
function get_entry_thumbnail() {
$id = get_the_ID();
$size = 'archive-thumb';
$width = 184;
$height = 104;
$output = '' . "\n";
return apply_filters( 'entry_thumbnail', $output, $size, $width, $height );
}
function entry_data() {
echo get_entry_data();
}
function get_entry_data() {
$output = '';
return apply_filters( 'entry_date', $output );
}
function entry_terms( $term_name = 'category' ) {
echo get_entry_terms( $term_name );
}
function get_entry_terms( $term_name = 'category' ) {
$id = get_the_ID();
if ( $term_name == 'post_tag' ) {
$terms = get_the_tags( $id );
$term_name = 'tags';
} else {
$terms = get_the_terms( $id, $term_name );
}
$separator = ', ';
$output = '';
$html = '';
if ( $terms ) {
$output .= '' . "\n";
foreach ( $terms as $term ) {
$html .= '' . esc_html( $term->name ) . '' . $separator;
}
$output .= trim( $html, $separator );
$output .= '
' . "\n";
return $output;
}
}
function entry_author() {
echo get_entry_author();
}
function get_entry_author() {
$output = '' . "\n";
$output .= '' . "\n";
$output .= get_the_author() . "\n";
$output .= '
' . "\n";
return apply_filters( 'entry_author', $output );
}
function entry_comments() {
if ( comments_open() ) {
echo '' . "\n";
}
}
function entry_more_link( $post_id = null ) {
echo get_entry_more_link( $post_id );
}
function get_entry_more_link( $post_id = null ) {
if ( ! $post_id )
$post_id = get_the_ID();
return '' . __( 'Read more »', 'themes' ) . '
';
}
function entry_edit_post_link() {
edit_post_link( __( 'Edit', 'karakuri' ), '', '
' );
}
function karakuri_content_nav() {
echo get_karakuri_content_nav();
}
function get_karakuri_content_nav() {
global $wp_query;
$output = '';
if ( $wp_query->max_num_pages > 1 ) {
$separator = ( get_next_posts_link() && get_previous_posts_link() ) ? ' / ' : '';
$output .= '' . "\n";
} elseif ( is_single() ) {
$next = get_adjacent_post();
$previous = get_adjacent_post( false, '', false );
$separator = ( $next && $previous ) ? ' / ' : '';
$output .= '' . "\n";
}
return $output;
}
/* Archive
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* archive_title */
function archive_title() {
echo get_archive_title();
}
/* get_archive_title */
function get_archive_title() {
global $wp_query;
$output = '';
if ( !is_home() || !is_front_page() ) {
$output .= '' . "\n";
}
return $output;
}
/* Single
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
function karakuri_link_pages() {
echo get_karakuri_link_pages();
}
function get_karakuri_link_pages() {
global $page, $numpages, $multipage, $more, $pagenow;
$output = '';
if ( $multipage ) {
$output .= '' ."\n";
$i = $page - 1;
if ( $i && $more ) {
$output .= _wp_link_page( $i );
$output .= ' «';
}
$i = $page + 1;
$output .= wp_link_pages( array( 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'echo' => 0 ) );
if ( $i <= $numpages && $more ) {
$output .= _wp_link_page( $i );
$output .= ' »';
}
$output .= '
' ."\n";
}
return $output;
}
/* Page
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Comment
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/**
* Comment Template
*
* @Referring to Twenty Twelve 1.0
*/
function karakuri_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
// Display trackbacks differently than normal comments.
?>
id="comment-">
', '' ); ?>
id="li-comment-">
'footer-nav-box', 'echo' => false, 'theme_location' => 'footer_menu' ) );
return $output;
}
/* copyright */
function copyright( $year = null ) {
echo get_copyright( $year );
}
/* get_copyright */
function get_copyright( $year = null ) {
$output = '© ' . get_copyright_year( $year ) . ' ' . esc_html( get_bloginfo( 'name', 'display' ) ) . '
' . "\n";
return $output;
}
/* copyright_year */
function copyright_year( $year = null ) {
echo get_copyright_year( $year );
}
/* get_copyright_year */
function get_copyright_year( $year = null ) {
$year = (int) apply_filters( 'copyright_year', $year );
if ( !$year )
$year = (int) date_i18n( 'Y' );
$get_year = (int) date_i18n( 'Y' );
if ( $get_year == $year ) {
$output = $year;
} else {
$output = $year . ' - ' . date_i18n( 'Y' );
}
return $output;
}
/* Other
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/**
* get_file_time
* Browser cache file protection.
*
* @since Karakuri 1.0
*/
function get_file_time( $file = null, $path = null, $child = false ) {
if ( !$path && $child )
$path = get_stylesheet_directory();
if ( !$path && !$child )
$path = get_template_directory();
$value = filemtime( $path . '/' . $file );
return $value;
}
/**
* Widget list filter
*
* @since Karakuri 1.0
*/
add_filter( 'wp_list_categories', 'wp_count_span_list' );
function wp_count_span_list( $links ) {
return preg_replace( '/($1', $links );
}
add_filter( 'widget_archives_args', 'widget_archives_count_span' );
function widget_archives_count_span( $args ) {
$args['before'] = '';
$args['after'] = '';
return $args;
}
add_filter( 'wp_list_bookmarks', 'wp_link_rating_span_list' );
function wp_link_rating_span_list( $output ) {
$output = str_replace('', '', $output);
$output = str_replace('', '', $output);
return $output;
}