104 /* translators: To add an additional Open Sans character subset specific to your language, |
110 /* translators: To add an additional Open Sans character subset specific to your language, |
105 * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. |
111 * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. |
106 */ |
112 */ |
107 $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'twentytwelve' ); |
113 $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'twentytwelve' ); |
108 |
114 |
109 if ( 'cyrillic' == $subset ) |
115 if ( 'cyrillic' == $subset ) { |
110 $subsets .= ',cyrillic,cyrillic-ext'; |
116 $subsets .= ',cyrillic,cyrillic-ext'; |
111 elseif ( 'greek' == $subset ) |
117 } elseif ( 'greek' == $subset ) { |
112 $subsets .= ',greek,greek-ext'; |
118 $subsets .= ',greek,greek-ext'; |
113 elseif ( 'vietnamese' == $subset ) |
119 } elseif ( 'vietnamese' == $subset ) { |
114 $subsets .= ',vietnamese'; |
120 $subsets .= ',vietnamese'; |
115 |
121 } |
116 $protocol = is_ssl() ? 'https' : 'http'; |
122 |
117 $query_args = array( |
123 $query_args = array( |
118 'family' => 'Open+Sans:400italic,700italic,400,700', |
124 'family' => 'Open+Sans:400italic,700italic,400,700', |
119 'subset' => $subsets, |
125 'subset' => $subsets, |
120 ); |
126 ); |
121 $font_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ); |
127 $font_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); |
122 } |
128 } |
123 |
129 |
124 return $font_url; |
130 return $font_url; |
125 } |
131 } |
126 |
132 |
127 /** |
133 /** |
128 * Enqueue scripts and styles for front-end. |
134 * Enqueue scripts and styles for front end. |
129 * |
135 * |
130 * @since Twenty Twelve 1.0 |
136 * @since Twenty Twelve 1.0 |
131 */ |
137 */ |
132 function twentytwelve_scripts_styles() { |
138 function twentytwelve_scripts_styles() { |
133 global $wp_styles; |
139 global $wp_styles; |
134 |
140 |
135 /* |
141 /* |
136 * Adds JavaScript to pages with the comment form to support |
142 * Adds JavaScript to pages with the comment form to support |
137 * sites with threaded comments (when in use). |
143 * sites with threaded comments (when in use). |
138 */ |
144 */ |
139 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) |
145 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { |
140 wp_enqueue_script( 'comment-reply' ); |
146 wp_enqueue_script( 'comment-reply' ); |
|
147 } |
141 |
148 |
142 // Adds JavaScript for handling the navigation menu hide-and-show behavior. |
149 // Adds JavaScript for handling the navigation menu hide-and-show behavior. |
143 wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'jquery' ), '20140711', true ); |
150 wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'jquery' ), '20140711', true ); |
144 |
151 |
145 $font_url = twentytwelve_get_font_url(); |
152 $font_url = twentytwelve_get_font_url(); |
146 if ( ! empty( $font_url ) ) |
153 if ( ! empty( $font_url ) ) { |
147 wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), null ); |
154 wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), null ); |
|
155 } |
148 |
156 |
149 // Loads our main stylesheet. |
157 // Loads our main stylesheet. |
150 wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() ); |
158 wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() ); |
151 |
159 |
152 // Loads the Internet Explorer specific stylesheet. |
160 // Loads the Internet Explorer specific stylesheet. |
236 * Registers our main widget area and the front page widget areas. |
275 * Registers our main widget area and the front page widget areas. |
237 * |
276 * |
238 * @since Twenty Twelve 1.0 |
277 * @since Twenty Twelve 1.0 |
239 */ |
278 */ |
240 function twentytwelve_widgets_init() { |
279 function twentytwelve_widgets_init() { |
241 register_sidebar( array( |
280 register_sidebar( |
242 'name' => __( 'Main Sidebar', 'twentytwelve' ), |
281 array( |
243 'id' => 'sidebar-1', |
282 'name' => __( 'Main Sidebar', 'twentytwelve' ), |
244 'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ), |
283 'id' => 'sidebar-1', |
245 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
284 'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ), |
246 'after_widget' => '</aside>', |
285 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
247 'before_title' => '<h3 class="widget-title">', |
286 'after_widget' => '</aside>', |
248 'after_title' => '</h3>', |
287 'before_title' => '<h3 class="widget-title">', |
249 ) ); |
288 'after_title' => '</h3>', |
250 |
289 ) |
251 register_sidebar( array( |
290 ); |
252 'name' => __( 'First Front Page Widget Area', 'twentytwelve' ), |
291 |
253 'id' => 'sidebar-2', |
292 register_sidebar( |
254 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ), |
293 array( |
255 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
294 'name' => __( 'First Front Page Widget Area', 'twentytwelve' ), |
256 'after_widget' => '</aside>', |
295 'id' => 'sidebar-2', |
257 'before_title' => '<h3 class="widget-title">', |
296 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ), |
258 'after_title' => '</h3>', |
297 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
259 ) ); |
298 'after_widget' => '</aside>', |
260 |
299 'before_title' => '<h3 class="widget-title">', |
261 register_sidebar( array( |
300 'after_title' => '</h3>', |
262 'name' => __( 'Second Front Page Widget Area', 'twentytwelve' ), |
301 ) |
263 'id' => 'sidebar-3', |
302 ); |
264 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ), |
303 |
265 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
304 register_sidebar( |
266 'after_widget' => '</aside>', |
305 array( |
267 'before_title' => '<h3 class="widget-title">', |
306 'name' => __( 'Second Front Page Widget Area', 'twentytwelve' ), |
268 'after_title' => '</h3>', |
307 'id' => 'sidebar-3', |
269 ) ); |
308 'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ), |
|
309 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
|
310 'after_widget' => '</aside>', |
|
311 'before_title' => '<h3 class="widget-title">', |
|
312 'after_title' => '</h3>', |
|
313 ) |
|
314 ); |
270 } |
315 } |
271 add_action( 'widgets_init', 'twentytwelve_widgets_init' ); |
316 add_action( 'widgets_init', 'twentytwelve_widgets_init' ); |
272 |
317 |
273 if ( ! function_exists( 'twentytwelve_content_nav' ) ) : |
318 if ( ! function_exists( 'twentytwelve_content_nav' ) ) : |
274 /** |
319 /** |
275 * Displays navigation to next/previous pages when applicable. |
320 * Displays navigation to next/previous pages when applicable. |
276 * |
321 * |
277 * @since Twenty Twelve 1.0 |
322 * @since Twenty Twelve 1.0 |
278 */ |
323 */ |
279 function twentytwelve_content_nav( $html_id ) { |
324 function twentytwelve_content_nav( $html_id ) { |
280 global $wp_query; |
325 global $wp_query; |
281 |
326 |
282 if ( $wp_query->max_num_pages > 1 ) : ?> |
327 if ( $wp_query->max_num_pages > 1 ) : ?> |
283 <nav id="<?php echo esc_attr( $html_id ); ?>" class="navigation" role="navigation"> |
328 <nav id="<?php echo esc_attr( $html_id ); ?>" class="navigation" role="navigation"> |
284 <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3> |
329 <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3> |
285 <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentytwelve' ) ); ?></div> |
330 <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentytwelve' ) ); ?></div> |
286 <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?></div> |
331 <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?></div> |
287 </nav><!-- .navigation --> |
332 </nav><!-- .navigation --> |
288 <?php endif; |
333 <?php |
289 } |
334 endif; |
|
335 } |
290 endif; |
336 endif; |
291 |
337 |
292 if ( ! function_exists( 'twentytwelve_comment' ) ) : |
338 if ( ! function_exists( 'twentytwelve_comment' ) ) : |
293 /** |
339 /** |
294 * Template for comments and pingbacks. |
340 * Template for comments and pingbacks. |
295 * |
341 * |
296 * To override this walker in a child theme without modifying the comments template |
342 * To override this walker in a child theme without modifying the comments template |
297 * simply create your own twentytwelve_comment(), and that function will be used instead. |
343 * simply create your own twentytwelve_comment(), and that function will be used instead. |
298 * |
344 * |
299 * Used as a callback by wp_list_comments() for displaying the comments. |
345 * Used as a callback by wp_list_comments() for displaying the comments. |
300 * |
346 * |
301 * @since Twenty Twelve 1.0 |
347 * @since Twenty Twelve 1.0 |
302 */ |
348 */ |
303 function twentytwelve_comment( $comment, $args, $depth ) { |
349 function twentytwelve_comment( $comment, $args, $depth ) { |
304 $GLOBALS['comment'] = $comment; |
350 $GLOBALS['comment'] = $comment; |
305 switch ( $comment->comment_type ) : |
351 switch ( $comment->comment_type ) : |
306 case 'pingback' : |
352 case 'pingback': |
307 case 'trackback' : |
353 case 'trackback': |
308 // Display trackbacks differently than normal comments. |
354 // Display trackbacks differently than normal comments. |
309 ?> |
355 ?> |
310 <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>"> |
356 <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>"> |
311 <p><?php _e( 'Pingback:', 'twentytwelve' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?></p> |
357 <p><?php _e( 'Pingback:', 'twentytwelve' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?></p> |
312 <?php |
358 <?php |
313 break; |
359 break; |
314 default : |
360 default: |
315 // Proceed with normal comments. |
361 // Proceed with normal comments. |
316 global $post; |
362 global $post; |
317 ?> |
363 ?> |
318 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> |
364 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> |
319 <article id="comment-<?php comment_ID(); ?>" class="comment"> |
365 <article id="comment-<?php comment_ID(); ?>" class="comment"> |
320 <header class="comment-meta comment-author vcard"> |
366 <header class="comment-meta comment-author vcard"> |
321 <?php |
367 <?php |
322 echo get_avatar( $comment, 44 ); |
368 echo get_avatar( $comment, 44 ); |
323 printf( '<cite><b class="fn">%1$s</b> %2$s</cite>', |
369 printf( |
|
370 '<cite><b class="fn">%1$s</b> %2$s</cite>', |
324 get_comment_author_link(), |
371 get_comment_author_link(), |
325 // If current post author is also comment author, make it known visually. |
372 // If current post author is also comment author, make it known visually. |
326 ( $comment->user_id === $post->post_author ) ? '<span>' . __( 'Post author', 'twentytwelve' ) . '</span>' : '' |
373 ( $comment->user_id === $post->post_author ) ? '<span>' . __( 'Post author', 'twentytwelve' ) . '</span>' : '' |
327 ); |
374 ); |
328 printf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>', |
375 printf( |
|
376 '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>', |
329 esc_url( get_comment_link( $comment->comment_ID ) ), |
377 esc_url( get_comment_link( $comment->comment_ID ) ), |
330 get_comment_time( 'c' ), |
378 get_comment_time( 'c' ), |
331 /* translators: 1: date, 2: time */ |
379 /* translators: 1: date, 2: time */ |
332 sprintf( __( '%1$s at %2$s', 'twentytwelve' ), get_comment_date(), get_comment_time() ) |
380 sprintf( __( '%1$s at %2$s', 'twentytwelve' ), get_comment_date(), get_comment_time() ) |
333 ); |
381 ); |
334 ?> |
382 ?> |
335 </header><!-- .comment-meta --> |
383 </header><!-- .comment-meta --> |
336 |
384 |
337 <?php if ( '0' == $comment->comment_approved ) : ?> |
385 <?php if ( '0' == $comment->comment_approved ) : ?> |
338 <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentytwelve' ); ?></p> |
386 <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentytwelve' ); ?></p> |
339 <?php endif; ?> |
387 <?php endif; ?> |
340 |
388 |
341 <section class="comment-content comment"> |
389 <section class="comment-content comment"> |
342 <?php comment_text(); ?> |
390 <?php comment_text(); ?> |
343 <?php edit_comment_link( __( 'Edit', 'twentytwelve' ), '<p class="edit-link">', '</p>' ); ?> |
391 <?php edit_comment_link( __( 'Edit', 'twentytwelve' ), '<p class="edit-link">', '</p>' ); ?> |
344 </section><!-- .comment-content --> |
392 </section><!-- .comment-content --> |
345 |
393 |
346 <div class="reply"> |
394 <div class="reply"> |
347 <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'twentytwelve' ), 'after' => ' <span>↓</span>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> |
395 <?php |
348 </div><!-- .reply --> |
396 comment_reply_link( |
349 </article><!-- #comment-## --> |
397 array_merge( |
350 <?php |
398 $args, array( |
351 break; |
399 'reply_text' => __( 'Reply', 'twentytwelve' ), |
352 endswitch; // end comment_type check |
400 'after' => ' <span>↓</span>', |
353 } |
401 'depth' => $depth, |
|
402 'max_depth' => $args['max_depth'], |
|
403 ) |
|
404 ) |
|
405 ); |
|
406 ?> |
|
407 </div><!-- .reply --> |
|
408 </article><!-- #comment-## --> |
|
409 <?php |
|
410 break; |
|
411 endswitch; // end comment_type check |
|
412 } |
354 endif; |
413 endif; |
355 |
414 |
356 if ( ! function_exists( 'twentytwelve_entry_meta' ) ) : |
415 if ( ! function_exists( 'twentytwelve_entry_meta' ) ) : |
357 /** |
416 /** |
358 * Set up post entry meta. |
417 * Set up post entry meta. |
359 * |
418 * |
360 * Prints HTML with meta information for current post: categories, tags, permalink, author, and date. |
419 * Prints HTML with meta information for current post: categories, tags, permalink, author, and date. |
361 * |
420 * |
362 * Create your own twentytwelve_entry_meta() to override in a child theme. |
421 * Create your own twentytwelve_entry_meta() to override in a child theme. |
363 * |
422 * |
364 * @since Twenty Twelve 1.0 |
423 * @since Twenty Twelve 1.0 |
365 */ |
424 */ |
366 function twentytwelve_entry_meta() { |
425 function twentytwelve_entry_meta() { |
367 // Translators: used between list items, there is a space after the comma. |
426 // Translators: used between list items, there is a space after the comma. |
368 $categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) ); |
427 $categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) ); |
369 |
428 |
370 // Translators: used between list items, there is a space after the comma. |
429 // Translators: used between list items, there is a space after the comma. |
371 $tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) ); |
430 $tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) ); |
372 |
431 |
373 $date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', |
432 $date = sprintf( |
374 esc_url( get_permalink() ), |
433 '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', |
375 esc_attr( get_the_time() ), |
434 esc_url( get_permalink() ), |
376 esc_attr( get_the_date( 'c' ) ), |
435 esc_attr( get_the_time() ), |
377 esc_html( get_the_date() ) |
436 esc_attr( get_the_date( 'c' ) ), |
378 ); |
437 esc_html( get_the_date() ) |
379 |
438 ); |
380 $author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', |
439 |
381 esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), |
440 $author = sprintf( |
382 esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ), |
441 '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', |
383 get_the_author() |
442 esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), |
384 ); |
443 esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ), |
385 |
444 get_the_author() |
386 // Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name. |
445 ); |
387 if ( $tag_list ) { |
446 |
388 $utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); |
447 // Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name. |
389 } elseif ( $categories_list ) { |
448 if ( $tag_list ) { |
390 $utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); |
449 $utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); |
391 } else { |
450 } elseif ( $categories_list ) { |
392 $utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); |
451 $utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); |
393 } |
452 } else { |
394 |
453 $utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); |
395 printf( |
454 } |
396 $utility_text, |
455 |
397 $categories_list, |
456 printf( |
398 $tag_list, |
457 $utility_text, |
399 $date, |
458 $categories_list, |
400 $author |
459 $tag_list, |
401 ); |
460 $date, |
402 } |
461 $author |
|
462 ); |
|
463 } |
403 endif; |
464 endif; |
404 |
465 |
405 /** |
466 /** |
406 * Extend the default WordPress body classes. |
467 * Extend the default WordPress body classes. |
407 * |
468 * |