Subversion Repositories ZenDark

Rev

Rev 25 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25 Rev 27
Line 1... Line 1...
1
<?php
1
<?php
2
// Add localisation support
2
// Add localisation support
3
load_theme_textdomain( 'sdt', TEMPLATEPATH . '/languages' );
-
 
-
 
3
load_theme_textdomain( 'zendark', TEMPLATEPATH . '/languages' );
4
$locale = get_locale();
4
$locale = get_locale();
5
$locale_file = TEMPLATEPATH ."/languages/$locale.php";
5
$locale_file = TEMPLATEPATH ."/languages/$locale.php";
6
if (is_readable($locale_file)) require_once($locale_file);
6
if (is_readable($locale_file)) require_once($locale_file);
7
7
8
// Register theme options page
8
// Register theme options page
Line 13... Line 13...
13
13
14
// Set the content width based on the theme's design and stylesheet.
14
// Set the content width based on the theme's design and stylesheet.
15
if (!isset($content_width))     $content_width = 700;
15
if (!isset($content_width))     $content_width = 700;
16
16
17
// This theme uses wp_nav_menu() in one location.
17
// This theme uses wp_nav_menu() in one location.
18
function sdt_register_nav_menu() {
-
 
19
  register_nav_menu('primary', __('Primary Menu', 'sdt'));
-
 
-
 
18
function zendark_register_nav_menu() {
-
 
19
  register_nav_menu('primary', __('Primary Menu', 'zendark'));
20
}
20
}
21
add_action('init', 'sdt_register_nav_menu');
-
 
-
 
21
add_action('init', 'zendark_register_nav_menu');
22
22
23
// Sets the post excerpt length to 40 words.
23
// Sets the post excerpt length to 40 words.
24
function sdt_excerpt_length($length) {
-
 
-
 
24
function zendark_excerpt_length($length) {
25
        return 40;
25
        return 40;
26
}
26
}
27
add_filter('excerpt_length', 'sdt_excerpt_length');
-
 
-
 
27
add_filter('excerpt_length', 'zendark_excerpt_length');
28
28
29
// Returns a "Continue Reading" link for excerpts
29
// Returns a "Continue Reading" link for excerpts
30
function sdt_continue_reading_link() {
-
 
31
        return '<a href="'.esc_url(get_permalink()).'">'.__('Continue reading ⇾', 'sdt').'</a>';
-
 
-
 
30
function zendark_continue_reading_link() {
-
 
31
        return '<a href="'.esc_url(get_permalink()).'">'.__('Continue reading ⇾', 'zendark').'</a>';
32
}
32
}
33
33
34
// Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and sdt_continue_reading_link().
-
 
35
function sdt_auto_excerpt_more($more) {
-
 
36
        return '&hellip;<br />'.sdt_continue_reading_link();
-
 
-
 
34
// Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and zendark_continue_reading_link().
-
 
35
function zendark_auto_excerpt_more($more) {
-
 
36
        return '&hellip;<br />'.zendark_continue_reading_link();
37
}
37
}
38
add_filter('excerpt_more', 'sdt_auto_excerpt_more');
-
 
-
 
38
add_filter('excerpt_more', 'zendark_auto_excerpt_more');
39
39
40
// Display navigation to next/previous pages when applicable
40
// Display navigation to next/previous pages when applicable
41
function sdt_content_nav( $nav_id ) {
-
 
-
 
41
function zendark_content_nav( $nav_id ) {
42
        global $wp_query;
42
        global $wp_query;
43
43
44
        if ( $wp_query->max_num_pages > 1 ) : ?>
44
        if ( $wp_query->max_num_pages > 1 ) : ?>
45
                <nav id="<?php echo $nav_id; ?>">
45
                <nav id="<?php echo $nav_id; ?>">
46
                        <div class="nav-next"><?php previous_posts_link( __('⇽ Newer posts', 'sdt')); ?></div>
-
 
47
                        <div class="nav-previous"><?php next_posts_link( __('Older posts ⇾', 'sdt')); ?></div>
-
 
-
 
46
                        <div class="nav-next"><?php previous_posts_link( __('⇽ Newer posts', 'zendark')); ?></div>
-
 
47
                        <div class="nav-previous"><?php next_posts_link( __('Older posts ⇾', 'zendark')); ?></div>
48
                </nav><!-- #<?php echo $nav_id; ?> -->
48
                </nav><!-- #<?php echo $nav_id; ?> -->
49
        <?php endif;
49
        <?php endif;
50
}
50
}
51
51
52
// Count authors number (users with writing rights)
52
// Count authors number (users with writing rights)
53
function sdt_count_authors(){
-
 
-
 
53
function zendark_count_authors(){
54
  $number = 0;
54
  $number = 0;
55
  $result = count_users();
55
  $result = count_users();
56
  foreach($result['avail_roles'] as $role => $count)
56
  foreach($result['avail_roles'] as $role => $count)
57
    if($role != "subscriber") { $number = $number + $count; }
57
    if($role != "subscriber") { $number = $number + $count; }
58
  return $number;
58
  return $number;
59
}
59
}
60
60
61
// Register sidebars
61
// Register sidebars
62
function sdt_widgets_init() {
-
 
-
 
62
function zendark_widgets_init() {
63
63
64
        register_sidebar( array(
64
        register_sidebar( array(
65
                'name' => __( 'Main Sidebar', 'sdt' ),
-
 
-
 
65
                'name' => __( 'Main Sidebar', 'zendark' ),
66
                'id' => 'sidebar-1',
66
                'id' => 'sidebar-1',
67
                'before_widget' => '<aside id="%1$s" class="widget %2$s">',
67
                'before_widget' => '<aside id="%1$s" class="widget %2$s">',
68
                'after_widget' => "</aside>",
68
                'after_widget' => "</aside>",
69
                'before_title' => '<h3 class="widget-title">',
69
                'before_title' => '<h3 class="widget-title">',
70
                'after_title' => '</h3>',
70
                'after_title' => '</h3>',
71
        ) );
71
        ) );
72
}
72
}
73
add_action('widgets_init', 'sdt_widgets_init');
-
 
-
 
73
add_action('widgets_init', 'zendark_widgets_init');
74
74
75
/*
75
/*
76
 * Adds two classes to the array of body classes.
76
 * Adds two classes to the array of body classes.
77
 * The first is if the site has only had one author with published posts.
77
 * The first is if the site has only had one author with published posts.
78
 * The second is if a singular post being displayed
78
 * The second is if a singular post being displayed
79
 */
79
 */
80
function sdt_body_classes($classes) {
-
 
-
 
80
function zendark_body_classes($classes) {
81
        if (!is_multi_author()) { $classes[] = 'single-author'; }
81
        if (!is_multi_author()) { $classes[] = 'single-author'; }
82
        if (is_singular() && !is_home()) $classes[] = 'singular';
82
        if (is_singular() && !is_home()) $classes[] = 'singular';
83
        return $classes;
83
        return $classes;
84
}
84
}
85
add_filter('body_class', 'sdt_body_classes');
-
 
-
 
85
add_filter('body_class', 'zendark_body_classes');
86
86
87
// Get the first parent of a page
87
// Get the first parent of a page
88
function sdt_get_root_parent($page_id) {
-
 
-
 
88
function zendark_get_root_parent($page_id) {
89
  global $wpdb;
89
  global $wpdb;
90
        $parent = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE post_type='page' AND ID = '$page_id'");
90
        $parent = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE post_type='page' AND ID = '$page_id'");
91
        if ($parent == 0) return $page_id;
91
        if ($parent == 0) return $page_id;
92
        else return sdt_get_root_parent($parent);
-
 
-
 
92
        else return zendark_get_root_parent($parent);
93
}
93
}
94
94
95
95
96
// Add class to menu <li> for first parent page
96
// Add class to menu <li> for first parent page
97
add_filter('nav_menu_css_class', 'sdt_special_nav_class', 10, 2);
-
 
98
function sdt_special_nav_class($classes, $item){
-
 
99
  if($item->object_id == sdt_get_root_parent(get_the_ID())){
-
 
-
 
97
add_filter('nav_menu_css_class', 'zendark_special_nav_class', 10, 2);
-
 
98
function zendark_special_nav_class($classes, $item){
-
 
99
  if($item->object_id == zendark_get_root_parent(get_the_ID())){
100
    $classes[] = "current_page_parent_function";
100
    $classes[] = "current_page_parent_function";
101
  }
101
  }
102
  return $classes;
102
  return $classes;
103
}
103
}
104
104
Line 122... Line 122...
122
}
122
}
123
123
124
/* Function to generate comments, I believe it's
124
/* Function to generate comments, I believe it's
125
 * necessary if you want paged comments.
125
 * necessary if you want paged comments.
126
 */
126
 */
127
 function sdt_comment($comment, $args, $depth) {
-
 
-
 
127
 function zendark_comment($comment, $args, $depth) {
128
        $GLOBALS['comment'] = $comment;
128
        $GLOBALS['comment'] = $comment;
129
129
130
  if ($comment->comment_type != "trackback" && $comment->comment_type != "pingback") : ?>
130
  if ($comment->comment_type != "trackback" && $comment->comment_type != "pingback") : ?>
131
  <div id="comment-<?php comment_ID() ?>" <?php comment_class(); ?>>
131
  <div id="comment-<?php comment_ID() ?>" <?php comment_class(); ?>>
132
    <header class="comment-header">
132
    <header class="comment-header">
Line 134... Line 134...
134
        if (validate_gravatar(get_comment_author_email()))
134
        if (validate_gravatar(get_comment_author_email()))
135
          echo '<div class="comment-avatar">'.get_avatar($comment, 40).'</div>';
135
          echo '<div class="comment-avatar">'.get_avatar($comment, 40).'</div>';
136
      ?>
136
      ?>
137
      <div>
137
      <div>
138
        <div class="comment-meta">
138
        <div class="comment-meta">
139
          <span class="comment-author"><?php comment_author_link() ?></span> <?php edit_comment_link( __( 'Edit', 'sdt' ), ' &bull; ', '' ); ?><br />
-
 
-
 
139
          <span class="comment-author"><?php comment_author_link() ?></span> <?php edit_comment_link( __( 'Edit', 'zendark' ), ' &bull; ', '' ); ?><br />
140
          <?php printf('<span class="comment-datetime"><a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a></span>',
140
          <?php printf('<span class="comment-datetime"><a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a></span>',
141
                        esc_url(get_comment_link($comment->comment_ID)),
141
                        esc_url(get_comment_link($comment->comment_ID)),
142
                        get_comment_time('c'),
142
                        get_comment_time('c'),
143
                        /* translators: 1: date, 2: time */
143
                        /* translators: 1: date, 2: time */
144
                        sprintf(__('%1$s %2$s', 'sdt'), get_comment_date(), get_comment_time())
-
 
-
 
144
                        sprintf(__('%1$s %2$s', 'zendark'), get_comment_date(), get_comment_time())
145
                ); ?>
145
                ); ?>
146
        </div>
146
        </div>
147
        <?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']))); ?>
-
 
-
 
147
        <?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']))); ?>
148
      </div>
148
      </div>
149
    </header>
149
    </header>
150
    <div class="comment-content">
150
    <div class="comment-content">
151
      <?php if ($comment->comment_approved == '0') : ?>
151
      <?php if ($comment->comment_approved == '0') : ?>
152
        <div class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation', 'sdt'); ?></div>
-
 
-
 
152
        <div class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation', 'zendark'); ?></div>
153
                        <?php endif; ?>
153
                        <?php endif; ?>
154
      <?php comment_text(); ?>
154
      <?php comment_text(); ?>
155
    </div>
155
    </div>
156
  </div>
156
  </div>
157
  <?php
157
  <?php
158
  endif;
158
  endif;
159
}
159
}
160
160
161
// Function to generate trackback/pingback
161
// Function to generate trackback/pingback
162
function sdt_trackback($comment, $args, $depth) {
-
 
-
 
162
function zendark_trackback($comment, $args, $depth) {
163
        $GLOBALS['comment'] = $comment;
163
        $GLOBALS['comment'] = $comment;
164
164
165
  if ($comment->comment_type == "trackback" || $comment->comment_type == "pingback") : ?>
165
  if ($comment->comment_type == "trackback" || $comment->comment_type == "pingback") : ?>
166
    <div id="comment-<?php comment_ID() ?>" <?php comment_class(); ?>>
166
    <div id="comment-<?php comment_ID() ?>" <?php comment_class(); ?>>
167
      <span class="comment-author"><?php comment_author_link() ?></span><br />
167
      <span class="comment-author"><?php comment_author_link() ?></span><br />
Line 170... Line 170...
170
  <?php
170
  <?php
171
        endif;
171
        endif;
172
}
172
}
173
173
174
// Function to count trackback/pingback
174
// Function to count trackback/pingback
175
function sdt_trackback_number($comments) {
-
 
-
 
175
function zendark_trackback_number($comments) {
176
  $numero_trackback = 0;
176
  $numero_trackback = 0;
177
        foreach ($comments as $comment) :
177
        foreach ($comments as $comment) :
178
    if ($comment->comment_type == "trackback" || $comment->comment_type == "pingback") $numero_trackback++;
178
    if ($comment->comment_type == "trackback" || $comment->comment_type == "pingback") $numero_trackback++;
179
  endforeach;
179
  endforeach;
180
        return $numero_trackback;
180
        return $numero_trackback;
Line 182... Line 182...
182
182
183
/* Function to generate both comments and trackbacks/pingbacks together,
183
/* Function to generate both comments and trackbacks/pingbacks together,
184
 * in case of paged comments. If you find a way to nicely separate comments
184
 * in case of paged comments. If you find a way to nicely separate comments
185
 * and pingbacks/trackbacks in paged comments, please tell me.
185
 * and pingbacks/trackbacks in paged comments, please tell me.
186
 */
186
 */
187
function sdt_all_comment($comment, $args, $depth) {
-
 
-
 
187
function zendark_all_comment($comment, $args, $depth) {
188
        $GLOBALS['comment'] = $comment;
188
        $GLOBALS['comment'] = $comment;
189
189
190
  if ($comment->comment_type != "trackback" && $comment->comment_type != "pingback") : ?>
190
  if ($comment->comment_type != "trackback" && $comment->comment_type != "pingback") : ?>
191
  <div id="comment-<?php comment_ID() ?>" <?php comment_class(); ?>>
191
  <div id="comment-<?php comment_ID() ?>" <?php comment_class(); ?>>
192
    <header class="comment-header">
192
    <header class="comment-header">
Line 194... Line 194...
194
        if (validate_gravatar(get_comment_author_email()))
194
        if (validate_gravatar(get_comment_author_email()))
195
          echo '<div class="comment-avatar">'.get_avatar($comment, 40).'</div>';
195
          echo '<div class="comment-avatar">'.get_avatar($comment, 40).'</div>';
196
      ?>
196
      ?>
197
      <div>
197
      <div>
198
        <div class="comment-meta">
198
        <div class="comment-meta">
199
          <span class="comment-author"><?php comment_author_link() ?></span> <?php edit_comment_link( __( 'Edit', 'sdt' ), ' &bull; ', '' ); ?><br />
-
 
-
 
199
          <span class="comment-author"><?php comment_author_link() ?></span> <?php edit_comment_link( __( 'Edit', 'zendark' ), ' &bull; ', '' ); ?><br />
200
          <?php printf('<span class="comment-datetime"><a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a></span>',
200
          <?php printf('<span class="comment-datetime"><a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a></span>',
201
                        esc_url(get_comment_link($comment->comment_ID)),
201
                        esc_url(get_comment_link($comment->comment_ID)),
202
                        get_comment_time('c'),
202
                        get_comment_time('c'),
203
                        /* translators: 1: date, 2: time */
203
                        /* translators: 1: date, 2: time */
204
                        sprintf(__('%1$s %2$s', 'sdt'), get_comment_date(), get_comment_time())
-
 
-
 
204
                        sprintf(__('%1$s %2$s', 'zendark'), get_comment_date(), get_comment_time())
205
                ); ?>
205
                ); ?>
206
        </div>
206
        </div>
207
        <?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']))); ?>
-
 
-
 
207
        <?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']))); ?>
208
      </div>
208
      </div>
209
    </header>
209
    </header>
210
    <div class="comment-content">
210
    <div class="comment-content">
211
      <?php if ($comment->comment_approved == '0') : ?>
211
      <?php if ($comment->comment_approved == '0') : ?>
212
        <div class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation', 'sdt'); ?></div>
-
 
-
 
212
        <div class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation', 'zendark'); ?></div>
213
                        <?php endif; ?>
213
                        <?php endif; ?>
214
      <?php comment_text(); ?>
214
      <?php comment_text(); ?>
215
    </div>
215
    </div>
216
  </div>
216
  </div>
217
  <?php
217
  <?php