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