PageRenderTime 52ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/twentyeleven/functions.php

https://bitbucket.org/crafttheweb/wordpress-fold
PHP | 613 lines | 346 code | 62 blank | 205 comment | 43 complexity | 99e3c356c2a36c029642ee835d6bd6a6 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Twenty Eleven functions and definitions
  4. *
  5. * Sets up the theme and provides some helper functions. Some helper functions
  6. * are used in the theme as custom template tags. Others are attached to action and
  7. * filter hooks in WordPress to change core functionality.
  8. *
  9. * The first function, twentyeleven_setup(), sets up the theme by registering support
  10. * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
  11. *
  12. * When using a child theme (see http://codex.wordpress.org/Theme_Development and
  13. * http://codex.wordpress.org/Child_Themes), you can override certain functions
  14. * (those wrapped in a function_exists() call) by defining them first in your child theme's
  15. * functions.php file. The child theme's functions.php file is included before the parent
  16. * theme's file, so the child theme functions would be used.
  17. *
  18. * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  19. * to a filter or action hook. The hook can be removed by using remove_action() or
  20. * remove_filter() and you can attach your own function to the hook.
  21. *
  22. * We can remove the parent theme's hook only after it is attached, which means we need to
  23. * wait until setting up the child theme:
  24. *
  25. * <code>
  26. * add_action( 'after_setup_theme', 'my_child_theme_setup' );
  27. * function my_child_theme_setup() {
  28. * // We are providing our own filter for excerpt_length (or using the unfiltered value)
  29. * remove_filter( 'excerpt_length', 'twentyeleven_excerpt_length' );
  30. * ...
  31. * }
  32. * </code>
  33. *
  34. * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
  35. *
  36. * @package WordPress
  37. * @subpackage Twenty_Eleven
  38. * @since Twenty Eleven 1.0
  39. */
  40. /**
  41. * Set the content width based on the theme's design and stylesheet.
  42. */
  43. if ( ! isset( $content_width ) )
  44. $content_width = 584;
  45. /**
  46. * Tell WordPress to run twentyeleven_setup() when the 'after_setup_theme' hook is run.
  47. */
  48. add_action( 'after_setup_theme', 'twentyeleven_setup' );
  49. if ( ! function_exists( 'twentyeleven_setup' ) ):
  50. /**
  51. * Sets up theme defaults and registers support for various WordPress features.
  52. *
  53. * Note that this function is hooked into the after_setup_theme hook, which runs
  54. * before the init hook. The init hook is too late for some features, such as indicating
  55. * support post thumbnails.
  56. *
  57. * To override twentyeleven_setup() in a child theme, add your own twentyeleven_setup to your child theme's
  58. * functions.php file.
  59. *
  60. * @uses load_theme_textdomain() For translation/localization support.
  61. * @uses add_editor_style() To style the visual editor.
  62. * @uses add_theme_support() To add support for post thumbnails, automatic feed links, custom headers
  63. * and backgrounds, and post formats.
  64. * @uses register_nav_menus() To add support for navigation menus.
  65. * @uses register_default_headers() To register the default custom header images provided with the theme.
  66. * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  67. *
  68. * @since Twenty Eleven 1.0
  69. */
  70. function twentyeleven_setup() {
  71. /* Make Twenty Eleven available for translation.
  72. * Translations can be added to the /languages/ directory.
  73. * If you're building a theme based on Twenty Eleven, use a find and replace
  74. * to change 'twentyeleven' to the name of your theme in all the template files.
  75. */
  76. load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' );
  77. // This theme styles the visual editor with editor-style.css to match the theme style.
  78. add_editor_style();
  79. // Load up our theme options page and related code.
  80. require( get_template_directory() . '/inc/theme-options.php' );
  81. // Grab Twenty Eleven's Ephemera widget.
  82. require( get_template_directory() . '/inc/widgets.php' );
  83. // Add default posts and comments RSS feed links to <head>.
  84. add_theme_support( 'automatic-feed-links' );
  85. // This theme uses wp_nav_menu() in one location.
  86. register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );
  87. // Add support for a variety of post formats
  88. add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
  89. $theme_options = twentyeleven_get_theme_options();
  90. if ( 'dark' == $theme_options['color_scheme'] )
  91. $default_background_color = '1d1d1d';
  92. else
  93. $default_background_color = 'f1f1f1';
  94. // Add support for custom backgrounds.
  95. add_theme_support( 'custom-background', array(
  96. // Let WordPress know what our default background color is.
  97. // This is dependent on our current color scheme.
  98. 'default-color' => $default_background_color,
  99. ) );
  100. // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
  101. add_theme_support( 'post-thumbnails' );
  102. // Add support for custom headers.
  103. $custom_header_support = array(
  104. // The default header text color.
  105. 'default-text-color' => '000',
  106. // The height and width of our custom header.
  107. 'width' => apply_filters( 'twentyeleven_header_image_width', 1000 ),
  108. 'height' => apply_filters( 'twentyeleven_header_image_height', 288 ),
  109. // Support flexible heights.
  110. 'flex-height' => true,
  111. // Random image rotation by default.
  112. 'random-default' => true,
  113. // Callback for styling the header.
  114. 'wp-head-callback' => 'twentyeleven_header_style',
  115. // Callback for styling the header preview in the admin.
  116. 'admin-head-callback' => 'twentyeleven_admin_header_style',
  117. // Callback used to display the header preview in the admin.
  118. 'admin-preview-callback' => 'twentyeleven_admin_header_image',
  119. );
  120. add_theme_support( 'custom-header', $custom_header_support );
  121. if ( ! function_exists( 'get_custom_header' ) ) {
  122. // This is all for compatibility with versions of WordPress prior to 3.4.
  123. define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
  124. define( 'HEADER_IMAGE', '' );
  125. define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
  126. define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
  127. add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] );
  128. add_custom_background();
  129. }
  130. // We'll be using post thumbnails for custom header images on posts and pages.
  131. // We want them to be the size of the header image that we just defined
  132. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
  133. set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
  134. // Add Twenty Eleven's custom image sizes.
  135. // Used for large feature (header) images.
  136. add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true );
  137. // Used for featured posts if a large-feature doesn't exist.
  138. add_image_size( 'small-feature', 500, 300 );
  139. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  140. register_default_headers( array(
  141. 'wheel' => array(
  142. 'url' => '%s/images/headers/wheel.jpg',
  143. 'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
  144. /* translators: header image description */
  145. 'description' => __( 'Wheel', 'twentyeleven' )
  146. ),
  147. 'shore' => array(
  148. 'url' => '%s/images/headers/shore.jpg',
  149. 'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg',
  150. /* translators: header image description */
  151. 'description' => __( 'Shore', 'twentyeleven' )
  152. ),
  153. 'trolley' => array(
  154. 'url' => '%s/images/headers/trolley.jpg',
  155. 'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg',
  156. /* translators: header image description */
  157. 'description' => __( 'Trolley', 'twentyeleven' )
  158. ),
  159. 'pine-cone' => array(
  160. 'url' => '%s/images/headers/pine-cone.jpg',
  161. 'thumbnail_url' => '%s/images/headers/pine-cone-thumbnail.jpg',
  162. /* translators: header image description */
  163. 'description' => __( 'Pine Cone', 'twentyeleven' )
  164. ),
  165. 'chessboard' => array(
  166. 'url' => '%s/images/headers/chessboard.jpg',
  167. 'thumbnail_url' => '%s/images/headers/chessboard-thumbnail.jpg',
  168. /* translators: header image description */
  169. 'description' => __( 'Chessboard', 'twentyeleven' )
  170. ),
  171. 'lanterns' => array(
  172. 'url' => '%s/images/headers/lanterns.jpg',
  173. 'thumbnail_url' => '%s/images/headers/lanterns-thumbnail.jpg',
  174. /* translators: header image description */
  175. 'description' => __( 'Lanterns', 'twentyeleven' )
  176. ),
  177. 'willow' => array(
  178. 'url' => '%s/images/headers/willow.jpg',
  179. 'thumbnail_url' => '%s/images/headers/willow-thumbnail.jpg',
  180. /* translators: header image description */
  181. 'description' => __( 'Willow', 'twentyeleven' )
  182. ),
  183. 'hanoi' => array(
  184. 'url' => '%s/images/headers/hanoi.jpg',
  185. 'thumbnail_url' => '%s/images/headers/hanoi-thumbnail.jpg',
  186. /* translators: header image description */
  187. 'description' => __( 'Hanoi Plant', 'twentyeleven' )
  188. )
  189. ) );
  190. }
  191. endif; // twentyeleven_setup
  192. if ( ! function_exists( 'twentyeleven_header_style' ) ) :
  193. /**
  194. * Styles the header image and text displayed on the blog
  195. *
  196. * @since Twenty Eleven 1.0
  197. */
  198. function twentyeleven_header_style() {
  199. $text_color = get_header_textcolor();
  200. // If no custom options for text are set, let's bail.
  201. if ( $text_color == HEADER_TEXTCOLOR )
  202. return;
  203. // If we get this far, we have custom styles. Let's do this.
  204. ?>
  205. <style type="text/css">
  206. <?php
  207. // Has the text been hidden?
  208. if ( 'blank' == $text_color ) :
  209. ?>
  210. #site-title,
  211. #site-description {
  212. position: absolute !important;
  213. clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
  214. clip: rect(1px, 1px, 1px, 1px);
  215. }
  216. <?php
  217. // If the user has set a custom color for the text use that
  218. else :
  219. ?>
  220. #site-title a,
  221. #site-description {
  222. color: #<?php echo $text_color; ?> !important;
  223. }
  224. <?php endif; ?>
  225. </style>
  226. <?php
  227. }
  228. endif; // twentyeleven_header_style
  229. if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) :
  230. /**
  231. * Styles the header image displayed on the Appearance > Header admin panel.
  232. *
  233. * Referenced via add_theme_support('custom-header') in twentyeleven_setup().
  234. *
  235. * @since Twenty Eleven 1.0
  236. */
  237. function twentyeleven_admin_header_style() {
  238. ?>
  239. <style type="text/css">
  240. .appearance_page_custom-header #headimg {
  241. border: none;
  242. }
  243. #headimg h1,
  244. #desc {
  245. font-family: "Helvetica Neue", Arial, Helvetica, "Nimbus Sans L", sans-serif;
  246. }
  247. #headimg h1 {
  248. margin: 0;
  249. }
  250. #headimg h1 a {
  251. font-size: 32px;
  252. line-height: 36px;
  253. text-decoration: none;
  254. }
  255. #desc {
  256. font-size: 14px;
  257. line-height: 23px;
  258. padding: 0 0 3em;
  259. }
  260. <?php
  261. // If the user has set a custom color for the text use that
  262. if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
  263. ?>
  264. #site-title a,
  265. #site-description {
  266. color: #<?php echo get_header_textcolor(); ?>;
  267. }
  268. <?php endif; ?>
  269. #headimg img {
  270. max-width: 1000px;
  271. height: auto;
  272. width: 100%;
  273. }
  274. </style>
  275. <?php
  276. }
  277. endif; // twentyeleven_admin_header_style
  278. if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) :
  279. /**
  280. * Custom header image markup displayed on the Appearance > Header admin panel.
  281. *
  282. * Referenced via add_theme_support('custom-header') in twentyeleven_setup().
  283. *
  284. * @since Twenty Eleven 1.0
  285. */
  286. function twentyeleven_admin_header_image() { ?>
  287. <div id="headimg">
  288. <?php
  289. $color = get_header_textcolor();
  290. $image = get_header_image();
  291. if ( $color && $color != 'blank' )
  292. $style = ' style="color:#' . $color . '"';
  293. else
  294. $style = ' style="display:none"';
  295. ?>
  296. <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
  297. <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>
  298. <?php if ( $image ) : ?>
  299. <img src="<?php echo esc_url( $image ); ?>" alt="" />
  300. <?php endif; ?>
  301. </div>
  302. <?php }
  303. endif; // twentyeleven_admin_header_image
  304. /**
  305. * Sets the post excerpt length to 40 words.
  306. *
  307. * To override this length in a child theme, remove the filter and add your own
  308. * function tied to the excerpt_length filter hook.
  309. */
  310. function twentyeleven_excerpt_length( $length ) {
  311. return 40;
  312. }
  313. add_filter( 'excerpt_length', 'twentyeleven_excerpt_length' );
  314. if ( ! function_exists( 'twentyeleven_continue_reading_link' ) ) :
  315. /**
  316. * Returns a "Continue Reading" link for excerpts
  317. */
  318. function twentyeleven_continue_reading_link() {
  319. return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) . '</a>';
  320. }
  321. endif; // twentyeleven_continue_reading_link
  322. /**
  323. * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyeleven_continue_reading_link().
  324. *
  325. * To override this in a child theme, remove the filter and add your own
  326. * function tied to the excerpt_more filter hook.
  327. */
  328. function twentyeleven_auto_excerpt_more( $more ) {
  329. return ' &hellip;' . twentyeleven_continue_reading_link();
  330. }
  331. add_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' );
  332. /**
  333. * Adds a pretty "Continue Reading" link to custom post excerpts.
  334. *
  335. * To override this link in a child theme, remove the filter and add your own
  336. * function tied to the get_the_excerpt filter hook.
  337. */
  338. function twentyeleven_custom_excerpt_more( $output ) {
  339. if ( has_excerpt() && ! is_attachment() ) {
  340. $output .= twentyeleven_continue_reading_link();
  341. }
  342. return $output;
  343. }
  344. add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
  345. /**
  346. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  347. */
  348. function twentyeleven_page_menu_args( $args ) {
  349. $args['show_home'] = true;
  350. return $args;
  351. }
  352. add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' );
  353. /**
  354. * Register our sidebars and widgetized areas. Also register the default Epherma widget.
  355. *
  356. * @since Twenty Eleven 1.0
  357. */
  358. function twentyeleven_widgets_init() {
  359. register_widget( 'Twenty_Eleven_Ephemera_Widget' );
  360. register_sidebar( array(
  361. 'name' => __( 'Main Sidebar', 'twentyeleven' ),
  362. 'id' => 'sidebar-1',
  363. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  364. 'after_widget' => "</aside>",
  365. 'before_title' => '<h3 class="widget-title">',
  366. 'after_title' => '</h3>',
  367. ) );
  368. register_sidebar( array(
  369. 'name' => __( 'Showcase Sidebar', 'twentyeleven' ),
  370. 'id' => 'sidebar-2',
  371. 'description' => __( 'The sidebar for the optional Showcase Template', 'twentyeleven' ),
  372. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  373. 'after_widget' => "</aside>",
  374. 'before_title' => '<h3 class="widget-title">',
  375. 'after_title' => '</h3>',
  376. ) );
  377. register_sidebar( array(
  378. 'name' => __( 'Footer Area One', 'twentyeleven' ),
  379. 'id' => 'sidebar-3',
  380. 'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
  381. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  382. 'after_widget' => "</aside>",
  383. 'before_title' => '<h3 class="widget-title">',
  384. 'after_title' => '</h3>',
  385. ) );
  386. register_sidebar( array(
  387. 'name' => __( 'Footer Area Two', 'twentyeleven' ),
  388. 'id' => 'sidebar-4',
  389. 'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
  390. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  391. 'after_widget' => "</aside>",
  392. 'before_title' => '<h3 class="widget-title">',
  393. 'after_title' => '</h3>',
  394. ) );
  395. register_sidebar( array(
  396. 'name' => __( 'Footer Area Three', 'twentyeleven' ),
  397. 'id' => 'sidebar-5',
  398. 'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
  399. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  400. 'after_widget' => "</aside>",
  401. 'before_title' => '<h3 class="widget-title">',
  402. 'after_title' => '</h3>',
  403. ) );
  404. }
  405. add_action( 'widgets_init', 'twentyeleven_widgets_init' );
  406. if ( ! function_exists( 'twentyeleven_content_nav' ) ) :
  407. /**
  408. * Display navigation to next/previous pages when applicable
  409. */
  410. function twentyeleven_content_nav( $nav_id ) {
  411. global $wp_query;
  412. if ( $wp_query->max_num_pages > 1 ) : ?>
  413. <nav id="<?php echo $nav_id; ?>">
  414. <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
  415. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
  416. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
  417. </nav><!-- #nav-above -->
  418. <?php endif;
  419. }
  420. endif; // twentyeleven_content_nav
  421. /**
  422. * Return the URL for the first link found in the post content.
  423. *
  424. * @since Twenty Eleven 1.0
  425. * @return string|bool URL or false when no link is present.
  426. */
  427. function twentyeleven_url_grabber() {
  428. if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
  429. return false;
  430. return esc_url_raw( $matches[1] );
  431. }
  432. /**
  433. * Count the number of footer sidebars to enable dynamic classes for the footer
  434. */
  435. function twentyeleven_footer_sidebar_class() {
  436. $count = 0;
  437. if ( is_active_sidebar( 'sidebar-3' ) )
  438. $count++;
  439. if ( is_active_sidebar( 'sidebar-4' ) )
  440. $count++;
  441. if ( is_active_sidebar( 'sidebar-5' ) )
  442. $count++;
  443. $class = '';
  444. switch ( $count ) {
  445. case '1':
  446. $class = 'one';
  447. break;
  448. case '2':
  449. $class = 'two';
  450. break;
  451. case '3':
  452. $class = 'three';
  453. break;
  454. }
  455. if ( $class )
  456. echo 'class="' . $class . '"';
  457. }
  458. if ( ! function_exists( 'twentyeleven_comment' ) ) :
  459. /**
  460. * Template for comments and pingbacks.
  461. *
  462. * To override this walker in a child theme without modifying the comments template
  463. * simply create your own twentyeleven_comment(), and that function will be used instead.
  464. *
  465. * Used as a callback by wp_list_comments() for displaying the comments.
  466. *
  467. * @since Twenty Eleven 1.0
  468. */
  469. function twentyeleven_comment( $comment, $args, $depth ) {
  470. $GLOBALS['comment'] = $comment;
  471. switch ( $comment->comment_type ) :
  472. case 'pingback' :
  473. case 'trackback' :
  474. ?>
  475. <li class="post pingback">
  476. <p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>
  477. <?php
  478. break;
  479. default :
  480. ?>
  481. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  482. <article id="comment-<?php comment_ID(); ?>" class="comment">
  483. <footer class="comment-meta">
  484. <div class="comment-author vcard">
  485. <?php
  486. $avatar_size = 68;
  487. if ( '0' != $comment->comment_parent )
  488. $avatar_size = 39;
  489. echo get_avatar( $comment, $avatar_size );
  490. /* translators: 1: comment author, 2: date and time */
  491. printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
  492. sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
  493. sprintf( '<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>',
  494. esc_url( get_comment_link( $comment->comment_ID ) ),
  495. get_comment_time( 'c' ),
  496. /* translators: 1: date, 2: time */
  497. sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )
  498. )
  499. );
  500. ?>
  501. <?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
  502. </div><!-- .comment-author .vcard -->
  503. <?php if ( $comment->comment_approved == '0' ) : ?>
  504. <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyeleven' ); ?></em>
  505. <br />
  506. <?php endif; ?>
  507. </footer>
  508. <div class="comment-content"><?php comment_text(); ?></div>
  509. <div class="reply">
  510. <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  511. </div><!-- .reply -->
  512. </article><!-- #comment-## -->
  513. <?php
  514. break;
  515. endswitch;
  516. }
  517. endif; // ends check for twentyeleven_comment()
  518. if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
  519. /**
  520. * Prints HTML with meta information for the current post-date/time and author.
  521. * Create your own twentyeleven_posted_on to override in a child theme
  522. *
  523. * @since Twenty Eleven 1.0
  524. */
  525. function twentyeleven_posted_on() {
  526. printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
  527. esc_url( get_permalink() ),
  528. esc_attr( get_the_time() ),
  529. esc_attr( get_the_date( 'c' ) ),
  530. esc_html( get_the_date() ),
  531. esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
  532. esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
  533. get_the_author()
  534. );
  535. }
  536. endif;
  537. /**
  538. * Adds two classes to the array of body classes.
  539. * The first is if the site has only had one author with published posts.
  540. * The second is if a singular post being displayed
  541. *
  542. * @since Twenty Eleven 1.0
  543. */
  544. function twentyeleven_body_classes( $classes ) {
  545. if ( function_exists( 'is_multi_author' ) && ! is_multi_author() )
  546. $classes[] = 'single-author';
  547. if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
  548. $classes[] = 'singular';
  549. return $classes;
  550. }
  551. add_filter( 'body_class', 'twentyeleven_body_classes' );