PageRenderTime 57ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

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

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