- Timestamp:
- 11/18/2013 11:11:01 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfourteen/functions.php
r26249 r26260 32 32 * @since Twenty Fourteen 1.0 33 33 */ 34 if ( ! isset( $content_width ) ) 34 if ( ! isset( $content_width ) ) { 35 35 $content_width = 474; 36 } 36 37 37 38 /** 38 39 * Twenty Fourteen only works in WordPress 3.6 or later. 39 40 */ 40 if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) ) 41 if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) ) { 41 42 require get_template_directory() . '/inc/back-compat.php'; 43 } 42 44 43 45 if ( ! function_exists( 'twentyfourteen_setup' ) ) : … … 123 125 */ 124 126 function twentyfourteen_content_width() { 125 if ( is_attachment() && wp_attachment_is_image() ) 127 if ( is_attachment() && wp_attachment_is_image() ) { 126 128 $GLOBALS['content_width'] = 810; 129 } 127 130 } 128 131 add_action( 'template_redirect', 'twentyfourteen_content_width' ); … … 204 207 * by Lato, translate this to 'off'. Do not translate into your own language. 205 208 */ 206 if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) 209 if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) { 207 210 $font_url = add_query_arg( 'family', urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ), "//fonts.googleapis.com/css" ); 211 } 208 212 209 213 return $font_url; … … 231 235 wp_style_add_data( 'twentyfourteen-ie', 'conditional', 'lt IE 9' ); 232 236 233 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) 237 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { 234 238 wp_enqueue_script( 'comment-reply' ); 235 236 if ( is_singular() && wp_attachment_is_image() ) 239 } 240 241 if ( is_singular() && wp_attachment_is_image() ) { 237 242 wp_enqueue_script( 'twentyfourteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20130402' ); 238 239 if ( is_active_sidebar( 'sidebar-3' ) ) 243 } 244 245 if ( is_active_sidebar( 'sidebar-3' ) ) { 240 246 wp_enqueue_script( 'jquery-masonry' ); 247 } 241 248 242 249 if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) { … … 304 311 305 312 // get the URL of the next image attachment... 306 if ( $next_id ) 313 if ( $next_id ) { 307 314 $next_attachment_url = get_attachment_link( $next_id ); 315 } 308 316 309 317 // or get the URL of the first image attachment. 310 else 318 else { 311 319 $next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) ); 320 } 312 321 } 313 322 … … 338 347 339 348 // Move on if user has not published a post (yet). 340 if ( ! $post_count ) 349 if ( ! $post_count ) { 341 350 continue; 351 } 342 352 ?> 343 353 … … 380 390 */ 381 391 function twentyfourteen_body_classes( $classes ) { 382 if ( is_multi_author() ) 392 if ( is_multi_author() ) { 383 393 $classes[] = 'group-blog'; 384 385 if ( get_header_image() ) 394 } 395 396 if ( get_header_image() ) { 386 397 $classes[] = 'header-image'; 387 else398 } else { 388 399 $classes[] = 'masthead-fixed'; 389 390 if ( is_archive() || is_search() || is_home() ) 400 } 401 402 if ( is_archive() || is_search() || is_home() ) { 391 403 $classes[] = 'list-view'; 404 } 392 405 393 406 if ( ( ! is_active_sidebar( 'sidebar-2' ) ) 394 407 || is_page_template( 'page-templates/full-width.php' ) 395 408 || is_page_template( 'page-templates/contributors.php' ) 396 || is_attachment() ) 409 || is_attachment() ) { 397 410 $classes[] = 'full-width'; 398 399 if ( is_active_sidebar( 'sidebar-3' ) ) 411 } 412 413 if ( is_active_sidebar( 'sidebar-3' ) ) { 400 414 $classes[] = 'footer-widgets'; 401 402 if ( is_singular() && ! is_front_page() ) 415 } 416 417 if ( is_singular() && ! is_front_page() ) { 403 418 $classes[] = 'singular'; 404 405 if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) 419 } 420 421 if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) { 406 422 $classes[] = 'slider'; 407 elseif ( is_front_page() )423 } elseif ( is_front_page() ) { 408 424 $classes[] = 'grid'; 425 } 409 426 410 427 return $classes; … … 424 441 */ 425 442 function twentyfourteen_post_classes( $classes ) { 426 if ( ! post_password_required() && has_post_thumbnail() ) 443 if ( ! post_password_required() && has_post_thumbnail() ) { 427 444 $classes[] = 'has-post-thumbnail'; 445 } 428 446 429 447 return $classes; … … 444 462 global $paged, $page; 445 463 446 if ( is_feed() ) 464 if ( is_feed() ) { 447 465 return $title; 466 } 448 467 449 468 // Add the site name. … … 452 471 // Add the site description for the home/front page. 453 472 $site_description = get_bloginfo( 'description', 'display' ); 454 if ( $site_description && ( is_home() || is_front_page() ) ) 473 if ( $site_description && ( is_home() || is_front_page() ) ) { 455 474 $title = "$title $sep $site_description"; 475 } 456 476 457 477 // Add a page number if necessary. 458 if ( $paged >= 2 || $page >= 2 ) 478 if ( $paged >= 2 || $page >= 2 ) { 459 479 $title = "$title $sep " . sprintf( __( 'Page %s', 'twentyfourteen' ), max( $paged, $page ) ); 480 } 460 481 461 482 return $title; … … 478 499 * before the 'setup_theme' hook. 479 500 */ 480 if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] ) 501 if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] ) { 481 502 require get_template_directory() . '/inc/featured-content.php'; 503 }
Note: See TracChangeset
for help on using the changeset viewer.