kumitheme/functions.php
2018-09-01 12:24:57 +02:00

204 lines
6.8 KiB
PHP

<?php
if(!function_exists('austria_setup')) :
function austria_setup() {
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
// Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'header' => __( 'Header Navigation', 'austria' ),
) );
// This theme allows users to set a custom background
add_custom_background();
// Your changeable header business starts here
if ( ! defined( 'HEADER_TEXTCOLOR' ) )
define( 'HEADER_TEXTCOLOR', '' );
// No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
if ( ! defined( 'HEADER_IMAGE' ) )
define( 'HEADER_IMAGE', '%s/images/headers/harald.jpg' );
// The height and width of your custom header. You can hook into the theme's own filters to change these values.
// Add a filter to austria_header_image_width and austria_header_image_height to change these values.
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'austria_header_image_width', 940 ) );
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'austria_header_image_height', 244 ) );
// We'll be using post thumbnails for custom header images on posts and pages.
// We want them to be 940 pixels wide by 244 pixels tall.
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
// Don't support text inside the header image.
if ( ! defined( 'NO_HEADER_TEXT' ) )
define( 'NO_HEADER_TEXT', true );
// Add a way for the custom header to be styled in the admin panel that controls
// custom headers. See austria_admin_header_style(), below.
add_custom_image_header( '', 'austria_admin_header_style' );
// ... and thus ends the changeable header business.
// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
register_default_headers( array(
'harald' => array(
'url' => '%s/images/headers/harald.jpg',
'thumbnail_url' => '%s/images/headers/harald-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Austria theme', 'austria' )
)
) );
}
endif;
add_action('after_setup_theme', 'austria_setup');
if ( ! function_exists( 'austria_admin_header_style' ) ) :
/**
* Styles the header image displayed on the Appearance > Header admin panel.
*
* Referenced via add_custom_image_header() in austria_setup().
*
* @since Twenty Ten 1.0
*/
function austria_admin_header_style() {
?>
<style type="text/css">
/* Shows the same border as on front end */
#headimg {
border-bottom: 1px solid #000;
border-top: 4px solid #000;
}
/* If NO_HEADER_TEXT is false, you would style the text with these selectors:
#headimg #name { }
#headimg #desc { }
*/
</style>
<?php
}
endif;
function my_austrian_sidebar() {
register_sidebar( array(
'name' => __( 'Austrian Widget Area', 'austria' ),
'id' => 'austrian-widget-area',
'description' => __( 'The Austrian widget area', 'austria' ),
'before_widget' => '<ul><li>',
'after_widget' => '</li></ul>',
'before_title' => '<h4>',
'after_title' => '</h4>',
) );
}
add_action('widgets_init', 'my_austrian_sidebar');
if ( ! function_exists( 'austria_content_nav' ) ) :
/**
* Display navigation to next/previous pages when applicable
*/
function austria_content_nav( $nav_id ) {
global $wp_query;
if ( $wp_query->max_num_pages > 1 ) : ?>
<nav id="<?php echo $nav_id; ?>">
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'austria' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'austria' ) ); ?></div>
</nav><!-- #nav-above -->
<?php endif;
}
endif; // austria_content_nav
if ( ! function_exists( 'austria_comment' ) ) :
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own austria_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
* @since Twenty Eleven 1.0
*/
function austria_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'austria' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'austria' ), '<span class="edit-link">', '</span>' ); ?></p>
<?php
break;
default :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<article id="comment-<?php comment_ID(); ?>" class="comment">
<footer class="comment-meta">
<div class="comment-author vcard">
<?php
$avatar_size = 68;
if ( '0' != $comment->comment_parent )
$avatar_size = 39;
echo get_avatar( $comment, $avatar_size );
/* translators: 1: comment author, 2: date and time */
printf( __( '%1$s on %2$s <span class="says">said:</span>', 'austria' ),
sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
sprintf( '<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>',
esc_url( get_comment_link( $comment->comment_ID ) ),
get_comment_time( 'c' ),
/* translators: 1: date, 2: time */
sprintf( __( '%1$s at %2$s', 'austria' ), get_comment_date(), get_comment_time() )
)
);
?>
<?php edit_comment_link( __( 'Edit', 'austria' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .comment-author .vcard -->
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'austria' ); ?></em>
<br />
<?php endif; ?>
</footer>
<div class="comment-content"><?php comment_text(); ?></div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'austria' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
</article><!-- #comment-## -->
<?php
break;
endswitch;
}
endif; // ends check for austria_comment()
?>