Advertisement
Guest User

Untitled

a guest
Jan 12th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.84 KB | None | 0 0
  1. <?php
  2.  
  3. if ( ! isset( $content_width ) )
  4. $content_width = 1024;
  5.  
  6. add_action( 'after_setup_theme', 'twentyeleven_setup' );
  7.  
  8. if ( ! function_exists( 'twentyeleven_setup' ) ):
  9.  
  10. function twentyeleven_setup() {
  11.  
  12.  
  13. load_theme_textdomain( 'twentyeleven', get_template_directory() . '/languages' );
  14.  
  15. add_editor_style();
  16.  
  17. require( get_template_directory() . '/inc/theme-options.php' );
  18.  
  19. require( get_template_directory() . '/inc/widgets.php' );
  20.  
  21. add_theme_support( 'post-thumbnails' );
  22.  
  23. set_post_thumbnail_size( 150, 150, true );
  24.  
  25. register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) );
  26.  
  27. add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );
  28.  
  29. $theme_options = twentyeleven_get_theme_options();
  30. if ( 'dark' == $theme_options['color_scheme'] )
  31. $default_background_color = '1d1d1d';
  32. else
  33. $default_background_color = 'e2e2e2';
  34.  
  35. add_theme_support( 'custom-background', array('default-color' => $default_background_color,)
  36. );
  37.  
  38. if ( function_exists( 'add_theme_support' ) ) {
  39. add_theme_support( 'post-thumbnails' );
  40. set_post_thumbnail_size( 150, 150, true );
  41. }
  42.  
  43. add_theme_support( 'post-thumbnails' );
  44.  
  45. $custom_header_support = array(
  46.  
  47. 'default-text-color' => '000',
  48. 'width' => apply_filters( 'twentyeleven_header_image_width', 1024 ),
  49. 'height' => apply_filters( 'twentyeleven_header_image_height', 200 ),
  50. 'flex-height' => true,
  51. 'random-default' => true,
  52. 'wp-head-callback' => 'twentyeleven_header_style',
  53. 'admin-head-callback' => 'twentyeleven_admin_header_style',
  54. 'admin-preview-callback' => 'twentyeleven_admin_header_image',
  55. );
  56.  
  57. add_theme_support( 'custom-header', $custom_header_support );
  58.  
  59. if ( ! function_exists( 'get_custom_header' ) ) {
  60. define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
  61. define( 'HEADER_IMAGE', '' );
  62. define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
  63. define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
  64. add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] );
  65. add_custom_background();
  66. }
  67.  
  68. set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true);
  69.  
  70. add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true );
  71. add_image_size( 'small-feature', 500, 300 );
  72. add_image_size('excerpt-thumbnail', 200, 200, true);
  73. register_default_headers( array(
  74. 'wheel' => array(
  75. 'url' => '%s/images/headers/wheel.jpg',
  76. 'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg',
  77. /* translators: header image description */
  78. 'description' => __( 'Wheel', 'twentyeleven' )
  79. ),
  80. 'shore' => array(
  81. 'url' => '%s/images/headers/shore.jpg',
  82. 'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg',
  83. /* translators: header image description */
  84. 'description' => __( 'Shore', 'twentyeleven' )
  85. ),
  86. 'trolley' => array(
  87. 'url' => '%s/images/headers/trolley.jpg',
  88. 'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg',
  89. /* translators: header image description */
  90. 'description' => __( 'Trolley', 'twentyeleven' )
  91. ),
  92. 'pine-cone' => array(
  93. 'url' => '%s/images/headers/pine-cone.jpg',
  94. 'thumbnail_url' => '%s/images/headers/pine-cone-thumbnail.jpg',
  95. /* translators: header image description */
  96. 'description' => __( 'Pine Cone', 'twentyeleven' )
  97. ),
  98. 'chessboard' => array(
  99. 'url' => '%s/images/headers/chessboard.jpg',
  100. 'thumbnail_url' => '%s/images/headers/chessboard-thumbnail.jpg',
  101. /* translators: header image description */
  102. 'description' => __( 'Chessboard', 'twentyeleven' )
  103. ),
  104. 'lanterns' => array(
  105. 'url' => '%s/images/headers/lanterns.jpg',
  106. 'thumbnail_url' => '%s/images/headers/lanterns-thumbnail.jpg',
  107. /* translators: header image description */
  108. 'description' => __( 'Lanterns', 'twentyeleven' )
  109. ),
  110. 'willow' => array(
  111. 'url' => '%s/images/headers/willow.jpg',
  112. 'thumbnail_url' => '%s/images/headers/willow-thumbnail.jpg',
  113. /* translators: header image description */
  114. 'description' => __( 'Willow', 'twentyeleven' )
  115. ),
  116. 'hanoi' => array(
  117. 'url' => '%s/images/headers/hanoi.jpg',
  118. 'thumbnail_url' => '%s/images/headers/hanoi-thumbnail.jpg',
  119. /* translators: header image description */
  120. 'description' => __( 'Hanoi Plant', 'twentyeleven' )
  121. )
  122. ) );
  123. }
  124. endif; // twentyeleven_setup
  125.  
  126. if ( ! function_exists( 'twentyeleven_header_style' ) ) :
  127.  
  128. function twentyeleven_header_style() {
  129. $text_color = get_header_textcolor();
  130.  
  131. // If no custom options for text are set, let's bail.
  132. if ( $text_color == HEADER_TEXTCOLOR )
  133. return;
  134.  
  135. // If we get this far, we have custom styles. Let's do this.
  136. ?>
  137. <style type="text/css">
  138. <?php
  139. // Has the text been hidden?
  140. if ( 'blank' == $text_color ) :
  141. ?>
  142. #site-title,
  143. #site-description {
  144. position: absolute !important;
  145. clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
  146. clip: rect(1px, 1px, 1px, 1px);
  147. }
  148. <?php
  149. // If the user has set a custom color for the text use that
  150. else :
  151. ?>
  152. #site-title a,
  153. #site-description {
  154. color: #<?php echo $text_color; ?> !important;
  155. }
  156. <?php endif; ?>
  157. </style>
  158. <?php
  159. }
  160. endif; // twentyeleven_header_style
  161.  
  162. if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) :
  163.  
  164. function twentyeleven_admin_header_style() {
  165. ?>
  166. <style type="text/css">
  167. .appearance_page_custom-header #headimg {
  168. border: none;
  169. }
  170. #headimg h1,
  171. #desc {
  172. font-family: "Helvetica Neue", Arial, Helvetica, "Nimbus Sans L", sans-serif;
  173. }
  174. #headimg h1 {
  175. margin: 0;
  176. }
  177. #headimg h1 a {
  178. font-size: 32px;
  179. line-height: 36px;
  180. text-decoration: none;
  181. }
  182. #desc {
  183. font-size: 14px;
  184. line-height: 23px;
  185. padding: 0 0 3em;
  186. }
  187. <?php
  188. // If the user has set a custom color for the text use that
  189. if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
  190. ?>
  191. #site-title a,
  192. #site-description {
  193. color: #<?php echo get_header_textcolor(); ?>;
  194. }
  195. <?php endif; ?>
  196. #headimg img {
  197. max-width: 1000px;
  198. height: auto;
  199. width: 100%;
  200. }
  201. </style>
  202. <?php
  203. }
  204. endif; // twentyeleven_admin_header_style
  205.  
  206. if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) :
  207.  
  208. function twentyeleven_admin_header_image() { ?>
  209. <div id="headimg">
  210. <?php
  211. $color = get_header_textcolor();
  212. $image = get_header_image();
  213. if ( $color && $color != 'blank' )
  214. $style = ' style="color:#' . $color . '"';
  215. else
  216. $style = ' style="display:none"';
  217. ?>
  218. <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
  219. <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>
  220. <?php if ( $image ) : ?>
  221. <img src="<?php echo esc_url( $image ); ?>" alt="" />
  222. <?php endif; ?>
  223. </div>
  224. <?php }
  225. endif; // twentyeleven_admin_header_image
  226.  
  227.  
  228. function twentyeleven_excerpt_length( $length ) {
  229. return 0;
  230. }
  231. add_filter( 'excerpt_length', 'twentyeleven_excerpt_length' );
  232.  
  233. if ( ! function_exists( 'twentyeleven_continue_reading_link' ) ) :
  234. /**
  235. * Returns a "Continue Reading" link for excerpts
  236. */
  237. function twentyeleven_continue_reading_link() {
  238. return ' <a href="'. esc_url( get_permalink() ) . '">' . __( ' <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) . '</a>';
  239. }
  240. endif; // twentyeleven_continue_reading_link
  241.  
  242.  
  243. function twentyeleven_auto_excerpt_more( $more ) {
  244. return ' &hellip;' . twentyeleven_continue_reading_link();
  245. }
  246.  
  247. remove_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' );
  248.  
  249.  
  250. function twentyeleven_custom_excerpt_more( $output ) {
  251. if ( has_excerpt() && ! is_attachment() ) {
  252. $output .= twentyeleven_continue_reading_link();
  253. }
  254. return $output;
  255. }
  256. remove_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
  257.  
  258.  
  259. function trim_excerpt($text) {
  260. return rtrim($text,'[...]');
  261. }
  262. add_filter('get_the_excerpt', 'trim_excerpt');
  263.  
  264.  
  265.  
  266. function twentyeleven_page_menu_args( $args ) {
  267. if ( ! isset( $args['show_home'] ) )
  268. $args['show_home'] = true;
  269. return $args;
  270. }
  271.  
  272.  
  273.  
  274. add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' );
  275.  
  276.  
  277. function twentyeleven_widgets_init() {
  278.  
  279. register_widget( 'Twenty_Eleven_Ephemera_Widget' );
  280.  
  281. register_sidebar( array(
  282. 'name' => __( 'Main Sidebar', 'twentyeleven' ),
  283. 'id' => 'sidebar-1',
  284. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  285. 'after_widget' => "</aside>",
  286. 'before_title' => '<h3 class="widget-title">',
  287. 'after_title' => '</h3>',
  288. ) );
  289.  
  290. register_sidebar( array(
  291. 'name' => __( 'Showcase Sidebar', 'twentyeleven' ),
  292. 'id' => 'sidebar-2',
  293. 'description' => __( 'The sidebar for the optional Showcase Template', 'twentyeleven' ),
  294. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  295. 'after_widget' => "</aside>",
  296. 'before_title' => '<h3 class="widget-title">',
  297. 'after_title' => '</h3>',
  298. ) );
  299.  
  300. register_sidebar( array(
  301. 'name' => __( 'Footer Area One', 'twentyeleven' ),
  302. 'id' => 'sidebar-3',
  303. 'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
  304. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  305. 'after_widget' => "</aside>",
  306. 'before_title' => '<h3 class="widget-title">',
  307. 'after_title' => '</h3>',
  308. ) );
  309.  
  310. register_sidebar( array(
  311. 'name' => __( 'Footer Area Two', 'twentyeleven' ),
  312. 'id' => 'sidebar-4',
  313. 'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
  314. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  315. 'after_widget' => "</aside>",
  316. 'before_title' => '<h3 class="widget-title">',
  317. 'after_title' => '</h3>',
  318. ) );
  319.  
  320. register_sidebar( array(
  321. 'name' => __( 'Footer Area Three', 'twentyeleven' ),
  322. 'id' => 'sidebar-5',
  323. 'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
  324. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  325. 'after_widget' => "</aside>",
  326. 'before_title' => '<h3 class="widget-title">',
  327. 'after_title' => '</h3>',
  328. ) );
  329. }
  330. add_action( 'widgets_init', 'twentyeleven_widgets_init' );
  331.  
  332. if ( ! function_exists( 'twentyeleven_content_nav' ) ) :
  333.  
  334. function twentyeleven_content_nav( $html_id ) {
  335. global $wp_query;
  336.  
  337. if ( $wp_query->max_num_pages > 1 ) : ?>
  338. <nav id="<?php echo esc_attr( $html_id ); ?>">
  339. <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
  340. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
  341. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
  342. </nav><!-- #nav-above -->
  343. <?php endif;
  344. }
  345. endif; // twentyeleven_content_nav
  346.  
  347.  
  348. function twentyeleven_url_grabber() {
  349. if ( ! preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
  350. return false;
  351.  
  352. return esc_url_raw( $matches[1] );
  353. }
  354.  
  355.  
  356.  
  357.  
  358. function twentyeleven_footer_sidebar_class() {
  359. $count = 0;
  360.  
  361. if ( is_active_sidebar( 'sidebar-3' ) )
  362. $count++;
  363.  
  364. if ( is_active_sidebar( 'sidebar-4' ) )
  365. $count++;
  366.  
  367. if ( is_active_sidebar( 'sidebar-5' ) )
  368. $count++;
  369.  
  370. $class = '';
  371.  
  372. switch ( $count ) {
  373. case '1':
  374. $class = 'one';
  375. break;
  376. case '2':
  377. $class = 'two';
  378. break;
  379. case '3':
  380. $class = 'three';
  381. break;
  382. }
  383.  
  384. if ( $class )
  385. echo 'class="' . $class . '"';
  386. }
  387.  
  388. if ( ! function_exists( 'twentyeleven_comment' ) ) :
  389.  
  390. function twentyeleven_comment( $comment, $args, $depth ) {
  391. $GLOBALS['comment'] = $comment;
  392. switch ( $comment->comment_type ) :
  393. case 'pingback' :
  394. case 'trackback' :
  395. ?>
  396. <li class="post pingback">
  397. <p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?></p>
  398. <?php
  399. break;
  400. default :
  401. ?>
  402. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  403. <article id="comment-<?php comment_ID(); ?>" class="comment">
  404. <footer class="comment-meta">
  405. <div class="comment-author vcard">
  406. <?php
  407. $avatar_size = 68;
  408. if ( '0' != $comment->comment_parent )
  409. $avatar_size = 39;
  410.  
  411. echo get_avatar( $comment, $avatar_size );
  412.  
  413. /* translators: 1: comment author, 2: date and time */
  414. printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
  415. sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
  416. sprintf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
  417. esc_url( get_comment_link( $comment->comment_ID ) ),
  418. get_comment_time( 'c' ),
  419. /* translators: 1: date, 2: time */
  420. sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )
  421. )
  422. );
  423. ?>
  424.  
  425. <?php edit_comment_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
  426. </div><!-- .comment-author .vcard -->
  427.  
  428. <?php if ( $comment->comment_approved == '0' ) : ?>
  429. <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyeleven' ); ?></em>
  430. <br />
  431. <?php endif; ?>
  432.  
  433. </footer>
  434.  
  435. <div class="comment-content"><?php comment_text(); ?></div>
  436.  
  437. <div class="reply">
  438. <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  439. </div><!-- .reply -->
  440. </article><!-- #comment-## -->
  441.  
  442. <?php
  443. break;
  444. endswitch;
  445. }
  446. endif; // ends check for twentyeleven_comment()
  447.  
  448. if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
  449.  
  450. function twentyeleven_posted_on() {
  451. 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' ),
  452. esc_url( get_permalink() ),
  453. esc_attr( get_the_time() ),
  454. esc_attr( get_the_date( 'c' ) ),
  455. esc_html( get_the_date() ),
  456. esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
  457. esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
  458. get_the_author()
  459. );
  460. }
  461. endif;
  462.  
  463.  
  464. function twentyeleven_body_classes( $classes ) {
  465.  
  466. if ( function_exists( 'is_multi_author' ) && ! is_multi_author() )
  467. $classes[] = 'single-author';
  468.  
  469. if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
  470. $classes[] = 'singular';
  471.  
  472. return $classes;
  473. }
  474. add_filter( 'body_class', 'twentyeleven_body_classes' );
  475.  
  476.  
  477. register_nav_menus( array(
  478. 'primary' => __( 'Primary Menu', 'Wild at Art' ),
  479. 'secondary' => __( 'Secondary Menu', 'Wild at Art'),
  480. ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement