Subversion Repositories ZenDark

Compare Revisions

Ignore whitespace Rev 26 → Rev 27

/functions.php
1,6 → 1,6
<?php
// Add localisation support
load_theme_textdomain( 'sdt', TEMPLATEPATH . '/languages' );
load_theme_textdomain( 'zendark', TEMPLATEPATH . '/languages' );
$locale = get_locale();
$locale_file = TEMPLATEPATH ."/languages/$locale.php";
if (is_readable($locale_file)) require_once($locale_file);
15,42 → 15,42
if (!isset($content_width)) $content_width = 700;
 
// This theme uses wp_nav_menu() in one location.
function sdt_register_nav_menu() {
register_nav_menu('primary', __('Primary Menu', 'sdt'));
function zendark_register_nav_menu() {
register_nav_menu('primary', __('Primary Menu', 'zendark'));
}
add_action('init', 'sdt_register_nav_menu');
add_action('init', 'zendark_register_nav_menu');
 
// Sets the post excerpt length to 40 words.
function sdt_excerpt_length($length) {
function zendark_excerpt_length($length) {
return 40;
}
add_filter('excerpt_length', 'sdt_excerpt_length');
add_filter('excerpt_length', 'zendark_excerpt_length');
 
// Returns a "Continue Reading" link for excerpts
function sdt_continue_reading_link() {
return '<a href="'.esc_url(get_permalink()).'">'.__('Continue reading ⇾', 'sdt').'</a>';
function zendark_continue_reading_link() {
return '<a href="'.esc_url(get_permalink()).'">'.__('Continue reading ⇾', 'zendark').'</a>';
}
 
// Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and sdt_continue_reading_link().
function sdt_auto_excerpt_more($more) {
return '&hellip;<br />'.sdt_continue_reading_link();
// Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and zendark_continue_reading_link().
function zendark_auto_excerpt_more($more) {
return '&hellip;<br />'.zendark_continue_reading_link();
}
add_filter('excerpt_more', 'sdt_auto_excerpt_more');
add_filter('excerpt_more', 'zendark_auto_excerpt_more');
 
// Display navigation to next/previous pages when applicable
function sdt_content_nav( $nav_id ) {
function zendark_content_nav( $nav_id ) {
global $wp_query;
 
if ( $wp_query->max_num_pages > 1 ) : ?>
<nav id="<?php echo $nav_id; ?>">
<div class="nav-next"><?php previous_posts_link( __('⇽ Newer posts', 'sdt')); ?></div>
<div class="nav-previous"><?php next_posts_link( __('Older posts ⇾', 'sdt')); ?></div>
<div class="nav-next"><?php previous_posts_link( __('⇽ Newer posts', 'zendark')); ?></div>
<div class="nav-previous"><?php next_posts_link( __('Older posts ⇾', 'zendark')); ?></div>
</nav><!-- #<?php echo $nav_id; ?> -->
<?php endif;
}
 
// Count authors number (users with writing rights)
function sdt_count_authors(){
function zendark_count_authors(){
$number = 0;
$result = count_users();
foreach($result['avail_roles'] as $role => $count)
59,10 → 59,10
}
 
// Register sidebars
function sdt_widgets_init() {
function zendark_widgets_init() {
 
register_sidebar( array(
'name' => __( 'Main Sidebar', 'sdt' ),
'name' => __( 'Main Sidebar', 'zendark' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
70,7 → 70,7
'after_title' => '</h3>',
) );
}
add_action('widgets_init', 'sdt_widgets_init');
add_action('widgets_init', 'zendark_widgets_init');
 
/*
* Adds two classes to the array of body classes.
77,26 → 77,26
* The first is if the site has only had one author with published posts.
* The second is if a singular post being displayed
*/
function sdt_body_classes($classes) {
function zendark_body_classes($classes) {
if (!is_multi_author()) { $classes[] = 'single-author'; }
if (is_singular() && !is_home()) $classes[] = 'singular';
return $classes;
}
add_filter('body_class', 'sdt_body_classes');
add_filter('body_class', 'zendark_body_classes');
 
// Get the first parent of a page
function sdt_get_root_parent($page_id) {
function zendark_get_root_parent($page_id) {
global $wpdb;
$parent = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE post_type='page' AND ID = '$page_id'");
if ($parent == 0) return $page_id;
else return sdt_get_root_parent($parent);
else return zendark_get_root_parent($parent);
}
 
 
// Add class to menu <li> for first parent page
add_filter('nav_menu_css_class', 'sdt_special_nav_class', 10, 2);
function sdt_special_nav_class($classes, $item){
if($item->object_id == sdt_get_root_parent(get_the_ID())){
add_filter('nav_menu_css_class', 'zendark_special_nav_class', 10, 2);
function zendark_special_nav_class($classes, $item){
if($item->object_id == zendark_get_root_parent(get_the_ID())){
$classes[] = "current_page_parent_function";
}
return $classes;
124,7 → 124,7
/* Function to generate comments, I believe it's
* necessary if you want paged comments.
*/
function sdt_comment($comment, $args, $depth) {
function zendark_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
 
if ($comment->comment_type != "trackback" && $comment->comment_type != "pingback") : ?>
136,20 → 136,20
?>
<div>
<div class="comment-meta">
<span class="comment-author"><?php comment_author_link() ?></span> <?php edit_comment_link( __( 'Edit', 'sdt' ), ' &bull; ', '' ); ?><br />
<span class="comment-author"><?php comment_author_link() ?></span> <?php edit_comment_link( __( 'Edit', 'zendark' ), ' &bull; ', '' ); ?><br />
<?php printf('<span class="comment-datetime"><a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a></span>',
esc_url(get_comment_link($comment->comment_ID)),
get_comment_time('c'),
/* translators: 1: date, 2: time */
sprintf(__('%1$s %2$s', 'sdt'), get_comment_date(), get_comment_time())
sprintf(__('%1$s %2$s', 'zendark'), get_comment_date(), get_comment_time())
); ?>
</div>
<?php comment_reply_link(array_merge($args, array('reply_text' => __( 'reply', 'sdt'), 'login_text' => __( 'login to reply', 'sdt'), 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
<?php comment_reply_link(array_merge($args, array('reply_text' => __( 'reply', 'zendark'), 'login_text' => __( 'login to reply', 'zendark'), 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
</div>
</header>
<div class="comment-content">
<?php if ($comment->comment_approved == '0') : ?>
<div class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation', 'sdt'); ?></div>
<div class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation', 'zendark'); ?></div>
<?php endif; ?>
<?php comment_text(); ?>
</div>
159,7 → 159,7
}
 
// Function to generate trackback/pingback
function sdt_trackback($comment, $args, $depth) {
function zendark_trackback($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
 
if ($comment->comment_type == "trackback" || $comment->comment_type == "pingback") : ?>
172,7 → 172,7
}
 
// Function to count trackback/pingback
function sdt_trackback_number($comments) {
function zendark_trackback_number($comments) {
$numero_trackback = 0;
foreach ($comments as $comment) :
if ($comment->comment_type == "trackback" || $comment->comment_type == "pingback") $numero_trackback++;
184,7 → 184,7
* in case of paged comments. If you find a way to nicely separate comments
* and pingbacks/trackbacks in paged comments, please tell me.
*/
function sdt_all_comment($comment, $args, $depth) {
function zendark_all_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
 
if ($comment->comment_type != "trackback" && $comment->comment_type != "pingback") : ?>
196,20 → 196,20
?>
<div>
<div class="comment-meta">
<span class="comment-author"><?php comment_author_link() ?></span> <?php edit_comment_link( __( 'Edit', 'sdt' ), ' &bull; ', '' ); ?><br />
<span class="comment-author"><?php comment_author_link() ?></span> <?php edit_comment_link( __( 'Edit', 'zendark' ), ' &bull; ', '' ); ?><br />
<?php printf('<span class="comment-datetime"><a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a></span>',
esc_url(get_comment_link($comment->comment_ID)),
get_comment_time('c'),
/* translators: 1: date, 2: time */
sprintf(__('%1$s %2$s', 'sdt'), get_comment_date(), get_comment_time())
sprintf(__('%1$s %2$s', 'zendark'), get_comment_date(), get_comment_time())
); ?>
</div>
<?php comment_reply_link(array_merge($args, array('reply_text' => __( 'reply', 'sdt'), 'login_text' => __( 'login to reply', 'sdt'), 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
<?php comment_reply_link(array_merge($args, array('reply_text' => __( 'reply', 'zendark'), 'login_text' => __( 'login to reply', 'zendark'), 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
</div>
</header>
<div class="comment-content">
<?php if ($comment->comment_approved == '0') : ?>
<div class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation', 'sdt'); ?></div>
<div class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation', 'zendark'); ?></div>
<?php endif; ?>
<?php comment_text(); ?>
</div>