Advertisement
Guest User

Twenty Eleven functions.php

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