Twenty Fourteen: updates all PHP files to meet new brace style in WP coding standards. Props rickalee for initial patch, fixes #26093.

Built from https://develop.svn.wordpress.org/trunk@26260


git-svn-id: http://core.svn.wordpress.org/trunk@26166 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Lance Willett 2013-11-18 23:11:10 +00:00
parent 4a5e64e682
commit 9e201fadff
14 changed files with 142 additions and 75 deletions

View File

@ -13,8 +13,9 @@
* If the current post is protected by a password and the visitor has not yet
* entered the password we will return early without loading the comments.
*/
if ( post_password_required() )
if ( post_password_required() ) {
return;
}
?>
<div id="comments" class="comments-area">

View File

@ -12,10 +12,11 @@
<a class="post-thumbnail" href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>">
<?php
if ( has_post_thumbnail() ) :
if ( 'grid' == get_theme_mod( 'featured_content_layout' ) )
if ( 'grid' == get_theme_mod( 'featured_content_layout' ) ) {
the_post_thumbnail();
else
} else {
the_post_thumbnail( 'twentyfourteen-full-width' );
}
endif;
?>
</a>

View File

@ -31,14 +31,16 @@
*
* @since Twenty Fourteen 1.0
*/
if ( ! isset( $content_width ) )
if ( ! isset( $content_width ) ) {
$content_width = 474;
}
/**
* Twenty Fourteen only works in WordPress 3.6 or later.
*/
if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) )
if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
}
if ( ! function_exists( 'twentyfourteen_setup' ) ) :
/**
@ -122,9 +124,10 @@ add_action( 'after_setup_theme', 'twentyfourteen_setup' );
* @return void
*/
function twentyfourteen_content_width() {
if ( is_attachment() && wp_attachment_is_image() )
if ( is_attachment() && wp_attachment_is_image() ) {
$GLOBALS['content_width'] = 810;
}
}
add_action( 'template_redirect', 'twentyfourteen_content_width' );
/**
@ -203,8 +206,9 @@ function twentyfourteen_font_url() {
* Translators: If there are characters in your language that are not supported
* by Lato, translate this to 'off'. Do not translate into your own language.
*/
if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) )
if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ), "//fonts.googleapis.com/css" );
}
return $font_url;
}
@ -230,14 +234,17 @@ function twentyfourteen_scripts() {
wp_enqueue_style( 'twentyfourteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfourteen-style' ), '20131110' );
wp_style_add_data( 'twentyfourteen-ie', 'conditional', 'lt IE 9' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() )
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'twentyfourteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20130402' );
}
if ( is_active_sidebar( 'sidebar-3' ) )
if ( is_active_sidebar( 'sidebar-3' ) ) {
wp_enqueue_script( 'jquery-masonry' );
}
if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) {
wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20131109', true );
@ -303,13 +310,15 @@ function twentyfourteen_the_attached_image() {
}
// get the URL of the next image attachment...
if ( $next_id )
if ( $next_id ) {
$next_attachment_url = get_attachment_link( $next_id );
}
// or get the URL of the first image attachment.
else
else {
$next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) );
}
}
printf( '<a href="%1$s" rel="attachment">%2$s</a>',
esc_url( $next_attachment_url ),
@ -337,8 +346,9 @@ function twentyfourteen_list_authors() {
$post_count = count_user_posts( $contributor_id );
// Move on if user has not published a post (yet).
if ( ! $post_count )
if ( ! $post_count ) {
continue;
}
?>
<div class="contributor">
@ -379,33 +389,40 @@ endif;
* @return array The filtered body class list.
*/
function twentyfourteen_body_classes( $classes ) {
if ( is_multi_author() )
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
if ( get_header_image() )
if ( get_header_image() ) {
$classes[] = 'header-image';
else
} else {
$classes[] = 'masthead-fixed';
}
if ( is_archive() || is_search() || is_home() )
if ( is_archive() || is_search() || is_home() ) {
$classes[] = 'list-view';
}
if ( ( ! is_active_sidebar( 'sidebar-2' ) )
|| is_page_template( 'page-templates/full-width.php' )
|| is_page_template( 'page-templates/contributors.php' )
|| is_attachment() )
|| is_attachment() ) {
$classes[] = 'full-width';
}
if ( is_active_sidebar( 'sidebar-3' ) )
if ( is_active_sidebar( 'sidebar-3' ) ) {
$classes[] = 'footer-widgets';
}
if ( is_singular() && ! is_front_page() )
if ( is_singular() && ! is_front_page() ) {
$classes[] = 'singular';
}
if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) )
if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) {
$classes[] = 'slider';
elseif ( is_front_page() )
} elseif ( is_front_page() ) {
$classes[] = 'grid';
}
return $classes;
}
@ -423,8 +440,9 @@ add_filter( 'body_class', 'twentyfourteen_body_classes' );
* @return array The filtered post class list.
*/
function twentyfourteen_post_classes( $classes ) {
if ( ! post_password_required() && has_post_thumbnail() )
if ( ! post_password_required() && has_post_thumbnail() ) {
$classes[] = 'has-post-thumbnail';
}
return $classes;
}
@ -443,20 +461,23 @@ add_filter( 'post_class', 'twentyfourteen_post_classes' );
function twentyfourteen_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() )
if ( is_feed() ) {
return $title;
}
// Add the site name.
$title .= get_bloginfo( 'name' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title = "$title $sep $site_description";
}
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 )
if ( $paged >= 2 || $page >= 2 ) {
$title = "$title $sep " . sprintf( __( 'Page %s', 'twentyfourteen' ), max( $paged, $page ) );
}
return $title;
}
@ -477,5 +498,6 @@ require get_template_directory() . '/inc/customizer.php';
* To overwrite in a plugin, define your own Featured_Content class on or
* before the 'setup_theme' hook.
*/
if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] )
if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
require get_template_directory() . '/inc/featured-content.php';
}

View File

@ -97,10 +97,11 @@ function twentyfourteen_adjust_color( $color, $steps ) {
$hex = '#';
foreach ( $rgb as $value ) {
$value += $steps;
if ( $value > 255 )
if ( $value > 255 ) {
$value = 255;
elseif ( $value < 0 )
} elseif ( $value < 0 ) {
$value = 0;
}
$hex .= str_pad( dechex( $value ), 2, '0', STR_PAD_LEFT);
}
@ -154,8 +155,9 @@ function twentyfourteen_customizer_styles() {
$accent_color = get_theme_mod( 'accent_color', '#24890d' );
// Don't do anything if the current color is the default.
if ( '#24890d' === $accent_color )
if ( '#24890d' === $accent_color ) {
return;
}
$accent_mid = get_theme_mod( 'accent_mid' );
$accent_light = get_theme_mod( 'accent_light' );

View File

@ -46,25 +46,29 @@ class Featured_Content {
$theme_support = get_theme_support( 'featured-content' );
// Return early if theme does not support Featured Content.
if ( ! $theme_support )
if ( ! $theme_support ) {
return;
}
/*
* An array of named arguments must be passed as the second parameter
* of add_theme_support().
*/
if ( ! isset( $theme_support[0] ) )
if ( ! isset( $theme_support[0] ) ) {
return;
}
// Return early if "featured_content_filter" has not been defined.
if ( ! isset( $theme_support[0]['featured_content_filter'] ) )
if ( ! isset( $theme_support[0]['featured_content_filter'] ) ) {
return;
}
$filter = $theme_support[0]['featured_content_filter'];
// Theme can override the number of max posts.
if ( isset( $theme_support[0]['max_posts'] ) )
if ( isset( $theme_support[0]['max_posts'] ) ) {
self::$max_posts = absint( $theme_support[0]['max_posts'] );
}
add_filter( $filter, array( __CLASS__, 'get_featured_posts' ) );
add_action( 'customize_register', array( __CLASS__, 'customize_register' ), 9 );
@ -100,8 +104,9 @@ class Featured_Content {
$post_ids = self::get_featured_post_ids();
// No need to query if there is are no featured posts.
if ( empty( $post_ids ) )
if ( empty( $post_ids ) ) {
return array();
}
$featured_posts = get_posts( array(
'include' => $post_ids,
@ -124,17 +129,19 @@ class Featured_Content {
public static function get_featured_post_ids() {
// Return array of cached results if they exist.
$featured_ids = get_transient( 'featured_content_ids' );
if ( ! empty( $featured_ids ) )
if ( ! empty( $featured_ids ) ) {
return array_map( 'absint', (array) $featured_ids );
}
$settings = self::get_setting();
// Return sticky post ids if no tag name is set.
$term = get_term_by( 'name', $settings['tag-name'], 'post_tag' );
if ( $term )
if ( $term ) {
$tag = $term->term_id;
else
} else {
return self::get_sticky_posts();
}
// Query for featured posts.
$featured = get_posts( array(
@ -149,8 +156,9 @@ class Featured_Content {
) );
// Return array with sticky posts if no Featured Content exists.
if ( ! $featured )
if ( ! $featured ) {
return self::get_sticky_posts();
}
// Ensure correct format before save/return.
$featured_ids = wp_list_pluck( (array) $featured, 'ID' );
@ -195,20 +203,23 @@ class Featured_Content {
public static function pre_get_posts( $query ) {
// Bail if not home or not main query.
if ( ! $query->is_home() || ! $query->is_main_query() )
if ( ! $query->is_home() || ! $query->is_main_query() ) {
return;
}
$page_on_front = get_option( 'page_on_front' );
// Bail if the blog page is not the front page.
if ( ! empty( $page_on_front ) )
if ( ! empty( $page_on_front ) ) {
return;
}
$featured = self::get_featured_post_ids();
// Bail if no featured posts.
if ( ! $featured )
if ( ! $featured ) {
return;
}
// We need to respect post ids already in the blacklist.
$post__not_in = $query->get( 'post__not_in' );
@ -237,8 +248,9 @@ class Featured_Content {
public static function delete_post_tag( $tag_id ) {
$settings = self::get_setting();
if ( empty( $settings['tag-id'] ) || $tag_id != $settings['tag-id'] )
if ( empty( $settings['tag-id'] ) || $tag_id != $settings['tag-id'] ) {
return;
}
$settings['tag-id'] = 0;
$settings = self::validate_settings( $settings );
@ -259,21 +271,25 @@ class Featured_Content {
public static function hide_featured_term( $terms, $taxonomies ) {
// This filter is only appropriate on the front-end.
if ( is_admin() )
if ( is_admin() ) {
return $terms;
}
// We only want to hide the featured tag.
if ( ! in_array( 'post_tag', $taxonomies ) )
if ( ! in_array( 'post_tag', $taxonomies ) ) {
return $terms;
}
// Bail if no terms were returned.
if ( empty( $terms ) )
if ( empty( $terms ) ) {
return $terms;
}
foreach( $terms as $order => $term ) {
if ( self::get_setting( 'tag-id' ) == $term->term_id && 'post_tag' == $term->taxonomy )
if ( self::get_setting( 'tag-id' ) == $term->term_id && 'post_tag' == $term->taxonomy ) {
unset( $terms[ $order ] );
}
}
return $terms;
}
@ -293,21 +309,25 @@ class Featured_Content {
public static function hide_the_featured_term( $terms, $id, $taxonomy ) {
// This filter is only appropriate on the front-end.
if ( is_admin() )
if ( is_admin() ) {
return $terms;
}
// Make sure we are in the correct taxonomy.
if ( 'post_tag' != $taxonomy )
if ( 'post_tag' != $taxonomy ) {
return $terms;
}
// No terms? Return early!
if ( empty( $terms ) )
if ( empty( $terms ) ) {
return $terms;
}
foreach( $terms as $order => $term ) {
if ( self::get_setting( 'tag-id' ) == $term->term_id )
if ( self::get_setting( 'tag-id' ) == $term->term_id ) {
unset( $terms[ $term->term_id ] );
}
}
return $terms;
}
@ -401,8 +421,9 @@ class Featured_Content {
$options = array_intersect_key( $options, $defaults );
$options['quantity'] = self::sanitize_quantity( $options['quantity'] );
if ( 'all' != $key )
if ( 'all' != $key ) {
return isset( $options[ $key ] ) ? $options[ $key ] : false;
}
return $options;
}
@ -437,8 +458,9 @@ class Featured_Content {
$output['tag-name'] = $input['tag-name'];
}
if ( isset( $input['quantity'] ) )
if ( isset( $input['quantity'] ) ) {
$output['quantity'] = self::sanitize_quantity( $input['quantity'] );
}
$output['hide-tag'] = isset( $input['hide-tag'] ) && $input['hide-tag'] ? 1 : 0;
@ -458,10 +480,11 @@ class Featured_Content {
public static function sanitize_quantity( $input ) {
$quantity = absint( $input );
if ( $quantity > self::$max_posts )
if ( $quantity > self::$max_posts ) {
$quantity = self::$max_posts;
else if ( 1 > $quantity )
} else if ( 1 > $quantity ) {
$quantity = 1;
}
return $quantity;
}

View File

@ -17,16 +17,18 @@ if ( ! function_exists( 'twentyfourteen_paging_nav' ) ) :
*/
function twentyfourteen_paging_nav() {
// Don't print empty markup if there's only one page.
if ( $GLOBALS['wp_query']->max_num_pages < 2 )
if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
return;
}
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
$pagenum_link = html_entity_decode( get_pagenum_link() );
$query_args = array();
$url_parts = explode( '?', $pagenum_link );
if ( isset( $url_parts[1] ) )
if ( isset( $url_parts[1] ) ) {
wp_parse_str( $url_parts[1], $query_args );
}
$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
@ -72,8 +74,9 @@ function twentyfourteen_post_nav() {
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous )
if ( ! $next && ! $previous ) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
@ -102,8 +105,9 @@ if ( ! function_exists( 'twentyfourteen_posted_on' ) ) :
* @return void
*/
function twentyfourteen_posted_on() {
if ( is_sticky() && is_home() && ! is_paged() )
if ( is_sticky() && is_home() && ! is_paged() ) {
echo '<span class="featured-post">' . __( 'Sticky', 'twentyfourteen' ) . '</span>';
}
printf( __( '<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="%4$s" rel="author">%5$s</a></span></span>', 'twentyfourteen' ),
esc_url( get_permalink() ),
@ -167,18 +171,20 @@ add_action( 'save_post', 'twentyfourteen_category_transient_flusher' );
* @return void
*/
function twentyfourteen_post_thumbnail() {
if ( post_password_required() || ! has_post_thumbnail() )
if ( post_password_required() || ! has_post_thumbnail() ) {
return;
}
if ( is_singular() ) :
?>
<div class="post-thumbnail">
<?php
if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) && ! wp_is_mobile() )
if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) && ! wp_is_mobile() ) {
the_post_thumbnail( 'twentyfourteen-full-width' );
else
} else {
the_post_thumbnail();
}
?>
</div>
@ -186,10 +192,11 @@ function twentyfourteen_post_thumbnail() {
<a class="post-thumbnail" href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>">
<?php
if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) && ! wp_is_mobile() )
if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) && ! wp_is_mobile() ) {
the_post_thumbnail( 'twentyfourteen-full-width' );
else
} else {
the_post_thumbnail();
}
?>
</a>

View File

@ -231,8 +231,9 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
function update( $new_instance, $instance ) {
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['number'] = empty( $new_instance['number'] ) ? 2 : absint( $new_instance['number'] );
if ( in_array( $new_instance['format'], $this->formats ) )
if ( in_array( $new_instance['format'], $this->formats ) ) {
$instance['format'] = $new_instance['format'];
}
$this->flush_widget_cache();

View File

@ -18,8 +18,9 @@ get_header(); ?>
<div id="main-content" class="main-content">
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() )
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
get_template_part( 'featured-content' );
}
?>
<div id="primary" class="content-area">

View File

@ -12,8 +12,9 @@ get_header(); ?>
<div id="main-content" class="main-content">
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() )
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
get_template_part( 'featured-content' );
}
?>
<div id="primary" class="content-area">
@ -35,8 +36,9 @@ get_header(); ?>
<?php
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() )
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>
</div><!-- #content -->

View File

@ -12,8 +12,9 @@ get_header(); ?>
<div id="main-content" class="main-content">
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() )
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
get_template_part( 'featured-content' );
}
?>
<div id="primary" class="content-area">
@ -25,8 +26,9 @@ get_header(); ?>
get_template_part( 'content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() )
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>
</div><!-- #content -->

View File

@ -16,8 +16,9 @@ get_header(); ?>
<div id="main-content" class="main-content">
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() )
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
get_template_part( 'featured-content' );
}
?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
@ -29,8 +30,9 @@ get_header(); ?>
get_template_part( 'content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() )
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>

View File

@ -7,8 +7,9 @@
* @since Twenty Fourteen 1.0
*/
if ( ! is_active_sidebar( 'sidebar-2' ) )
if ( ! is_active_sidebar( 'sidebar-2' ) ) {
return;
}
?>
<div id="content-sidebar" class="content-sidebar widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-2' ); ?>

View File

@ -7,8 +7,9 @@
* @since Twenty Fourteen 1.0
*/
if ( ! is_active_sidebar( 'sidebar-3' ) )
if ( ! is_active_sidebar( 'sidebar-3' ) ) {
return;
}
?>
<div id="supplementary">

View File

@ -20,8 +20,9 @@ get_header(); ?>
twentyfourteen_post_nav();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() )
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>
</div><!-- #content -->