Guest User

twentyeleven funct.

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