-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·283 lines (256 loc) · 9.07 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<?php
/**
* Starkers functions and definitions
*
* @package WordPress
* @subpackage Starkers
* @since Starkers HTML5 3.0
*/
/** Tell WordPress to run starkers_setup() when the 'after_setup_theme' hook is run. */
add_action( 'after_setup_theme', 'starkers_setup' );
if ( ! function_exists( 'starkers_setup' ) ):
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* @since Starkers HTML5 3.0
*/
function starkers_setup() {
// 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' );
// Make theme available for translation
// Translations can be filed in the /languages/ directory
load_theme_textdomain( 'starkers', TEMPLATEPATH . '/languages' );
$locale = get_locale();
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
if ( is_readable( $locale_file ) )
require_once( $locale_file );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Primary Navigation', 'starkers' ),
) );
}
endif;
/**
* Set our wp_nav_menu() fallback, starkers_menu().
*
* @since Starkers HTML5 3.0
*/
function starkers_menu() {
echo '<nav><ul><li><a href="'.get_bloginfo('url').'">Home</a></li>';
wp_list_pages('title_li=');
echo '</ul></nav>';
}
/**
* Remove inline styles printed when the gallery shortcode is used.
*
* @since Starkers HTML5 3.2
*/
add_filter( 'use_default_gallery_style', '__return_false' );
/**
* @since Starkers HTML5 3.0
* @deprecated in Starkers HTML5 3.2 for WordPress 3.1
*
* @return string The gallery style filter, with the styles themselves removed.
*/
function starkers_remove_gallery_css( $css ) {
return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
}
// Backwards compatibility with WordPress 3.0.
if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
add_filter( 'gallery_style', 'starkers_remove_gallery_css' );
if ( ! function_exists( 'starkers_comment' ) ) :
/**
* Template for comments and pingbacks.
*
* @since Starkers HTML5 3.0
*/
function starkers_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '' :
?>
<article <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
<?php echo get_avatar( $comment, 40 ); ?>
<?php printf( __( '%s says:', 'starkers' ), sprintf( '%s', get_comment_author_link() ) ); ?>
<?php if ( $comment->comment_approved == '0' ) : ?>
<?php _e( 'Your comment is awaiting moderation.', 'starkers' ); ?>
<br />
<?php endif; ?>
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __( '%1$s at %2$s', 'starkers' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'starkers' ), ' ' );
?>
<?php comment_text(); ?>
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
<?php
break;
case 'pingback' :
case 'trackback' :
?>
<article <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
<p><?php _e( 'Pingback:', 'starkers' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'starkers'), ' ' ); ?></p>
<?php
break;
endswitch;
}
endif;
/**
* Closes comments and pingbacks with </article> instead of </li>.
*
* @since Starkers HTML5 3.0
*/
function starkers_comment_close() {
echo '</article>';
}
/**
* Adjusts the comment_form() input types for HTML5.
*
* @since Starkers HTML5 3.0
*/
function starkers_fields($fields) {
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields = array(
'author' => '<p><label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '*' : '' ) .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
'email' => '<p><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '*' : '' ) .
'<input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
'url' => '<p><label for="url">' . __( 'Website' ) . '</label>' .
'<input id="url" name="url" type="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
);
return $fields;
}
add_filter('comment_form_default_fields','starkers_fields');
/**
* Register widgetized areas.
*
* @since Starkers HTML5 3.0
*/
function starkers_widgets_init() {
// Area 1, located at the top of the sidebar.
register_sidebar( array(
'name' => __( 'Primary Widget Area', 'starkers' ),
'id' => 'primary-widget-area',
'description' => __( 'The primary widget area', 'starkers' ),
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
// Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
register_sidebar( array(
'name' => __( 'Secondary Widget Area', 'starkers' ),
'id' => 'secondary-widget-area',
'description' => __( 'The secondary widget area', 'starkers' ),
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
// Area 3, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'First Footer Widget Area', 'starkers' ),
'id' => 'first-footer-widget-area',
'description' => __( 'The first footer widget area', 'starkers' ),
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
// Area 4, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Second Footer Widget Area', 'starkers' ),
'id' => 'second-footer-widget-area',
'description' => __( 'The second footer widget area', 'starkers' ),
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
// Area 5, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Third Footer Widget Area', 'starkers' ),
'id' => 'third-footer-widget-area',
'description' => __( 'The third footer widget area', 'starkers' ),
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
// Area 6, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Fourth Footer Widget Area', 'starkers' ),
'id' => 'fourth-footer-widget-area',
'description' => __( 'The fourth footer widget area', 'starkers' ),
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
}
/** Register sidebars by running starkers_widgets_init() on the widgets_init hook. */
add_action( 'widgets_init', 'starkers_widgets_init' );
/**
* Removes the default styles that are packaged with the Recent Comments widget.
*
* @updated Starkers HTML5 3.2
*/
function starkers_remove_recent_comments_style() {
add_filter( 'show_recent_comments_widget_style', '__return_false' );
}
add_action( 'widgets_init', 'starkers_remove_recent_comments_style' );
if ( ! function_exists( 'starkers_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post—date/time and author.
*
* @since Starkers HTML5 3.0
*/
function starkers_posted_on() {
printf( __( 'Posted on %2$s by %3$s', 'starkers' ),
'meta-prep meta-prep-author',
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time datetime="%3$s" pubdate>%4$s</time></a>',
get_permalink(),
esc_attr( get_the_time() ),
get_the_date('Y-m-d'),
get_the_date()
),
sprintf( '<a href="%1$s" title="%2$s">%3$s</a>',
get_author_posts_url( get_the_author_meta( 'ID' ) ),
sprintf( esc_attr__( 'View all posts by %s', 'starkers' ), get_the_author() ),
get_the_author()
)
);
}
endif;
if ( ! function_exists( 'starkers_posted_in' ) ) :
/**
* Prints HTML with meta information for the current post (category, tags and permalink).
*
* @since Starkers HTML5 3.0
*/
function starkers_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) {
$posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'starkers' );
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
$posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'starkers' );
} else {
$posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'starkers' );
}
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
}
endif;