@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Implement Custom Header functionality for Twenty Fourteen |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Twenty_Fourteen |
|
7 | - * @since Twenty Fourteen 1.0 |
|
8 | - */ |
|
3 | + * Implement Custom Header functionality for Twenty Fourteen |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Twenty_Fourteen |
|
7 | + * @since Twenty Fourteen 1.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Set up the WordPress core custom header settings. |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * the Appearance > Header screen. |
36 | 36 | * } |
37 | 37 | */ |
38 | - add_theme_support( 'custom-header', apply_filters( 'twentyfourteen_custom_header_args', array( |
|
38 | + add_theme_support('custom-header', apply_filters('twentyfourteen_custom_header_args', array( |
|
39 | 39 | 'default-text-color' => 'fff', |
40 | 40 | 'width' => 1260, |
41 | 41 | 'height' => 240, |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | 'wp-head-callback' => 'twentyfourteen_header_style', |
44 | 44 | 'admin-head-callback' => 'twentyfourteen_admin_header_style', |
45 | 45 | 'admin-preview-callback' => 'twentyfourteen_admin_header_image', |
46 | - ) ) ); |
|
46 | + ))); |
|
47 | 47 | } |
48 | -add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' ); |
|
48 | +add_action('after_setup_theme', 'twentyfourteen_custom_header_setup'); |
|
49 | 49 | |
50 | -if ( ! function_exists( 'twentyfourteen_header_style' ) ) : |
|
50 | +if ( ! function_exists('twentyfourteen_header_style')) : |
|
51 | 51 | /** |
52 | 52 | * Styles the header image and text displayed on the blog |
53 | 53 | * |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $text_color = get_header_textcolor(); |
59 | 59 | |
60 | 60 | // If no custom color for text is set, let's bail. |
61 | - if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) ) |
|
61 | + if (display_header_text() && $text_color === get_theme_support('custom-header', 'default-text-color')) |
|
62 | 62 | return; |
63 | 63 | |
64 | 64 | // If we get this far, we have custom styles. |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | <style type="text/css" id="twentyfourteen-header-css"> |
67 | 67 | <?php |
68 | 68 | // Has the text been hidden? |
69 | - if ( ! display_header_text() ) : |
|
69 | + if ( ! display_header_text()) : |
|
70 | 70 | ?> |
71 | 71 | .site-title, |
72 | 72 | .site-description { |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | } |
77 | 77 | <?php |
78 | 78 | // If the user has set a custom color for the text, use that. |
79 | - elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) : |
|
79 | + elseif ($text_color != get_theme_support('custom-header', 'default-text-color')) : |
|
80 | 80 | ?> |
81 | 81 | .site-title a { |
82 | - color: #<?php echo esc_attr( $text_color ); ?>; |
|
82 | + color: #<?php echo esc_attr($text_color); ?>; |
|
83 | 83 | } |
84 | 84 | <?php endif; ?> |
85 | 85 | </style> |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | endif; // twentyfourteen_header_style |
89 | 89 | |
90 | 90 | |
91 | -if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) : |
|
91 | +if ( ! function_exists('twentyfourteen_admin_header_style')) : |
|
92 | 92 | /** |
93 | 93 | * Style the header image displayed on the Appearance > Header screen. |
94 | 94 | * |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | endif; // twentyfourteen_admin_header_style |
128 | 128 | |
129 | -if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) : |
|
129 | +if ( ! function_exists('twentyfourteen_admin_header_image')) : |
|
130 | 130 | /** |
131 | 131 | * Create the custom header image markup displayed on the Appearance > Header screen. |
132 | 132 | * |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | function twentyfourteen_admin_header_image() { |
138 | 138 | ?> |
139 | 139 | <div id="headimg"> |
140 | - <?php if ( get_header_image() ) : ?> |
|
140 | + <?php if (get_header_image()) : ?> |
|
141 | 141 | <img src="<?php header_image(); ?>" alt=""> |
142 | 142 | <?php endif; ?> |
143 | - <h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr( sprintf( 'color: #%s;', get_header_textcolor() ) ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> |
|
143 | + <h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr(sprintf('color: #%s;', get_header_textcolor())); ?>" onclick="return false;" href="<?php echo esc_url(home_url('/')); ?>" tabindex="-1"><?php bloginfo('name'); ?></a></h1> |
|
144 | 144 | </div> |
145 | 145 | <?php |
146 | 146 | } |
@@ -58,8 +58,9 @@ |
||
58 | 58 | $text_color = get_header_textcolor(); |
59 | 59 | |
60 | 60 | // If no custom color for text is set, let's bail. |
61 | - if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) ) |
|
62 | - return; |
|
61 | + if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) ) { |
|
62 | + return; |
|
63 | + } |
|
63 | 64 | |
64 | 65 | // If we get this far, we have custom styles. |
65 | 66 | ?> |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since Twenty Fourteen 1.0 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! function_exists( 'twentyfourteen_paging_nav' ) ) : |
|
10 | +if ( ! function_exists('twentyfourteen_paging_nav')) : |
|
11 | 11 | /** |
12 | 12 | * Display navigation to next/previous set of posts when applicable. |
13 | 13 | * |
@@ -20,42 +20,42 @@ discard block |
||
20 | 20 | global $wp_query, $wp_rewrite; |
21 | 21 | |
22 | 22 | // Don't print empty markup if there's only one page. |
23 | - if ( $wp_query->max_num_pages < 2 ) { |
|
23 | + if ($wp_query->max_num_pages < 2) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
27 | - $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; |
|
28 | - $pagenum_link = html_entity_decode( get_pagenum_link() ); |
|
27 | + $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; |
|
28 | + $pagenum_link = html_entity_decode(get_pagenum_link()); |
|
29 | 29 | $query_args = array(); |
30 | - $url_parts = explode( '?', $pagenum_link ); |
|
30 | + $url_parts = explode('?', $pagenum_link); |
|
31 | 31 | |
32 | - if ( isset( $url_parts[1] ) ) { |
|
33 | - wp_parse_str( $url_parts[1], $query_args ); |
|
32 | + if (isset($url_parts[1])) { |
|
33 | + wp_parse_str($url_parts[1], $query_args); |
|
34 | 34 | } |
35 | 35 | |
36 | - $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); |
|
37 | - $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; |
|
36 | + $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); |
|
37 | + $pagenum_link = trailingslashit($pagenum_link).'%_%'; |
|
38 | 38 | |
39 | - $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; |
|
40 | - $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; |
|
39 | + $format = $wp_rewrite->using_index_permalinks() && ! strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; |
|
40 | + $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit($wp_rewrite->pagination_base.'/%#%', 'paged') : '?paged=%#%'; |
|
41 | 41 | |
42 | 42 | // Set up paginated links. |
43 | - $links = paginate_links( array( |
|
43 | + $links = paginate_links(array( |
|
44 | 44 | 'base' => $pagenum_link, |
45 | 45 | 'format' => $format, |
46 | 46 | 'total' => $wp_query->max_num_pages, |
47 | 47 | 'current' => $paged, |
48 | 48 | 'mid_size' => 1, |
49 | - 'add_args' => array_map( 'urlencode', $query_args ), |
|
50 | - 'prev_text' => __( '← Previous', 'twentyfourteen' ), |
|
51 | - 'next_text' => __( 'Next →', 'twentyfourteen' ), |
|
52 | - ) ); |
|
49 | + 'add_args' => array_map('urlencode', $query_args), |
|
50 | + 'prev_text' => __('← Previous', 'twentyfourteen'), |
|
51 | + 'next_text' => __('Next →', 'twentyfourteen'), |
|
52 | + )); |
|
53 | 53 | |
54 | - if ( $links ) : |
|
54 | + if ($links) : |
|
55 | 55 | |
56 | 56 | ?> |
57 | 57 | <nav class="navigation paging-navigation" role="navigation"> |
58 | - <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentyfourteen' ); ?></h1> |
|
58 | + <h1 class="screen-reader-text"><?php _e('Posts navigation', 'twentyfourteen'); ?></h1> |
|
59 | 59 | <div class="pagination loop-pagination"> |
60 | 60 | <?php echo $links; ?> |
61 | 61 | </div><!-- .pagination --> |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | endif; |
67 | 67 | |
68 | -if ( ! function_exists( 'twentyfourteen_post_nav' ) ) : |
|
68 | +if ( ! function_exists('twentyfourteen_post_nav')) : |
|
69 | 69 | /** |
70 | 70 | * Display navigation to next/previous post when applicable. |
71 | 71 | * |
@@ -73,23 +73,23 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function twentyfourteen_post_nav() { |
75 | 75 | // Don't print empty markup if there's nowhere to navigate. |
76 | - $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); |
|
77 | - $next = get_adjacent_post( false, '', false ); |
|
76 | + $previous = (is_attachment()) ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); |
|
77 | + $next = get_adjacent_post(false, '', false); |
|
78 | 78 | |
79 | - if ( ! $next && ! $previous ) { |
|
79 | + if ( ! $next && ! $previous) { |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | |
83 | 83 | ?> |
84 | 84 | <nav class="navigation post-navigation" role="navigation"> |
85 | - <h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentyfourteen' ); ?></h1> |
|
85 | + <h1 class="screen-reader-text"><?php _e('Post navigation', 'twentyfourteen'); ?></h1> |
|
86 | 86 | <div class="nav-links"> |
87 | 87 | <?php |
88 | - if ( is_attachment() ) : |
|
89 | - previous_post_link( '%link', __( '<span class="meta-nav">Published In</span>%title', 'twentyfourteen' ) ); |
|
88 | + if (is_attachment()) : |
|
89 | + previous_post_link('%link', __('<span class="meta-nav">Published In</span>%title', 'twentyfourteen')); |
|
90 | 90 | else : |
91 | - previous_post_link( '%link', __( '<span class="meta-nav">Previous Post</span>%title', 'twentyfourteen' ) ); |
|
92 | - next_post_link( '%link', __( '<span class="meta-nav">Next Post</span>%title', 'twentyfourteen' ) ); |
|
91 | + previous_post_link('%link', __('<span class="meta-nav">Previous Post</span>%title', 'twentyfourteen')); |
|
92 | + next_post_link('%link', __('<span class="meta-nav">Next Post</span>%title', 'twentyfourteen')); |
|
93 | 93 | endif; |
94 | 94 | ?> |
95 | 95 | </div><!-- .nav-links --> |
@@ -98,23 +98,23 @@ discard block |
||
98 | 98 | } |
99 | 99 | endif; |
100 | 100 | |
101 | -if ( ! function_exists( 'twentyfourteen_posted_on' ) ) : |
|
101 | +if ( ! function_exists('twentyfourteen_posted_on')) : |
|
102 | 102 | /** |
103 | 103 | * Print HTML with meta information for the current post-date/time and author. |
104 | 104 | * |
105 | 105 | * @since Twenty Fourteen 1.0 |
106 | 106 | */ |
107 | 107 | function twentyfourteen_posted_on() { |
108 | - if ( is_sticky() && is_home() && ! is_paged() ) { |
|
109 | - echo '<span class="featured-post">' . __( 'Sticky', 'twentyfourteen' ) . '</span>'; |
|
108 | + if (is_sticky() && is_home() && ! is_paged()) { |
|
109 | + echo '<span class="featured-post">'.__('Sticky', 'twentyfourteen').'</span>'; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Set up and print post meta information. |
113 | - 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>', |
|
114 | - esc_url( get_permalink() ), |
|
115 | - esc_attr( get_the_date( 'c' ) ), |
|
116 | - esc_html( get_the_date() ), |
|
117 | - esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), |
|
113 | + 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>', |
|
114 | + esc_url(get_permalink()), |
|
115 | + esc_attr(get_the_date('c')), |
|
116 | + esc_html(get_the_date()), |
|
117 | + esc_url(get_author_posts_url(get_the_author_meta('ID'))), |
|
118 | 118 | get_the_author() |
119 | 119 | ); |
120 | 120 | } |
@@ -128,19 +128,19 @@ discard block |
||
128 | 128 | * @return boolean true if blog has more than 1 category |
129 | 129 | */ |
130 | 130 | function twentyfourteen_categorized_blog() { |
131 | - if ( false === ( $all_the_cool_cats = get_transient( 'twentyfourteen_category_count' ) ) ) { |
|
131 | + if (false === ($all_the_cool_cats = get_transient('twentyfourteen_category_count'))) { |
|
132 | 132 | // Create an array of all the categories that are attached to posts |
133 | - $all_the_cool_cats = get_categories( array( |
|
133 | + $all_the_cool_cats = get_categories(array( |
|
134 | 134 | 'hide_empty' => 1, |
135 | - ) ); |
|
135 | + )); |
|
136 | 136 | |
137 | 137 | // Count the number of categories that are attached to the posts |
138 | - $all_the_cool_cats = count( $all_the_cool_cats ); |
|
138 | + $all_the_cool_cats = count($all_the_cool_cats); |
|
139 | 139 | |
140 | - set_transient( 'twentyfourteen_category_count', $all_the_cool_cats ); |
|
140 | + set_transient('twentyfourteen_category_count', $all_the_cool_cats); |
|
141 | 141 | } |
142 | 142 | |
143 | - if ( 1 !== (int) $all_the_cool_cats ) { |
|
143 | + if (1 !== (int) $all_the_cool_cats) { |
|
144 | 144 | // This blog has more than 1 category so twentyfourteen_categorized_blog should return true |
145 | 145 | return true; |
146 | 146 | } else { |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | */ |
157 | 157 | function twentyfourteen_category_transient_flusher() { |
158 | 158 | // Like, beat it. Dig? |
159 | - delete_transient( 'twentyfourteen_category_count' ); |
|
159 | + delete_transient('twentyfourteen_category_count'); |
|
160 | 160 | } |
161 | -add_action( 'edit_category', 'twentyfourteen_category_transient_flusher' ); |
|
162 | -add_action( 'save_post', 'twentyfourteen_category_transient_flusher' ); |
|
161 | +add_action('edit_category', 'twentyfourteen_category_transient_flusher'); |
|
162 | +add_action('save_post', 'twentyfourteen_category_transient_flusher'); |
|
163 | 163 | |
164 | -if ( ! function_exists( 'twentyfourteen_post_thumbnail' ) ) : |
|
164 | +if ( ! function_exists('twentyfourteen_post_thumbnail')) : |
|
165 | 165 | /** |
166 | 166 | * Display an optional post thumbnail. |
167 | 167 | * |
@@ -172,17 +172,17 @@ discard block |
||
172 | 172 | * @since Twenty Fourteen 1.4 Was made 'pluggable', or overridable. |
173 | 173 | */ |
174 | 174 | function twentyfourteen_post_thumbnail() { |
175 | - if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { |
|
175 | + if (post_password_required() || is_attachment() || ! has_post_thumbnail()) { |
|
176 | 176 | return; |
177 | 177 | } |
178 | 178 | |
179 | - if ( is_singular() ) : |
|
179 | + if (is_singular()) : |
|
180 | 180 | ?> |
181 | 181 | |
182 | 182 | <div class="post-thumbnail"> |
183 | 183 | <?php |
184 | - if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) { |
|
185 | - the_post_thumbnail( 'twentyfourteen-full-width' ); |
|
184 | + if (( ! is_active_sidebar('sidebar-2') || is_page_template('page-templates/full-width.php'))) { |
|
185 | + the_post_thumbnail('twentyfourteen-full-width'); |
|
186 | 186 | } else { |
187 | 187 | the_post_thumbnail(); |
188 | 188 | } |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | |
194 | 194 | <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true"> |
195 | 195 | <?php |
196 | - if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) { |
|
197 | - the_post_thumbnail( 'twentyfourteen-full-width' ); |
|
196 | + if (( ! is_active_sidebar('sidebar-2') || is_page_template('page-templates/full-width.php'))) { |
|
197 | + the_post_thumbnail('twentyfourteen-full-width'); |
|
198 | 198 | } else { |
199 | - the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) ); |
|
199 | + the_post_thumbnail('post-thumbnail', array('alt' => get_the_title())); |
|
200 | 200 | } |
201 | 201 | ?> |
202 | 202 | </a> |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | endif; |
207 | 207 | |
208 | -if ( ! function_exists( 'twentyfourteen_excerpt_more' ) && ! is_admin() ) : |
|
208 | +if ( ! function_exists('twentyfourteen_excerpt_more') && ! is_admin()) : |
|
209 | 209 | /** |
210 | 210 | * Replaces "[...]" (appended to automatically generated excerpts) with ... |
211 | 211 | * and a Continue reading link. |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | * @param string $more Default Read More excerpt link. |
216 | 216 | * @return string Filtered Read More excerpt link. |
217 | 217 | */ |
218 | -function twentyfourteen_excerpt_more( $more ) { |
|
219 | - $link = sprintf( '<a href="%1$s" class="more-link">%2$s</a>', |
|
220 | - esc_url( get_permalink( get_the_ID() ) ), |
|
218 | +function twentyfourteen_excerpt_more($more) { |
|
219 | + $link = sprintf('<a href="%1$s" class="more-link">%2$s</a>', |
|
220 | + esc_url(get_permalink(get_the_ID())), |
|
221 | 221 | /* translators: %s: Name of current post */ |
222 | - sprintf( __( 'Continue reading %s <span class="meta-nav">→</span>', 'twentyfourteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' ) |
|
222 | + sprintf(__('Continue reading %s <span class="meta-nav">→</span>', 'twentyfourteen'), '<span class="screen-reader-text">'.get_the_title(get_the_ID()).'</span>') |
|
223 | 223 | ); |
224 | - return ' … ' . $link; |
|
224 | + return ' … '.$link; |
|
225 | 225 | } |
226 | -add_filter( 'excerpt_more', 'twentyfourteen_excerpt_more' ); |
|
226 | +add_filter('excerpt_more', 'twentyfourteen_excerpt_more'); |
|
227 | 227 | endif; |
@@ -87,8 +87,10 @@ discard block |
||
87 | 87 | <?php |
88 | 88 | if ( is_attachment() ) : |
89 | 89 | previous_post_link( '%link', __( '<span class="meta-nav">Published In</span>%title', 'twentyfourteen' ) ); |
90 | - else : |
|
90 | + else { |
|
91 | + : |
|
91 | 92 | previous_post_link( '%link', __( '<span class="meta-nav">Previous Post</span>%title', 'twentyfourteen' ) ); |
93 | + } |
|
92 | 94 | next_post_link( '%link', __( '<span class="meta-nav">Next Post</span>%title', 'twentyfourteen' ) ); |
93 | 95 | endif; |
94 | 96 | ?> |
@@ -189,9 +191,12 @@ discard block |
||
189 | 191 | ?> |
190 | 192 | </div> |
191 | 193 | |
192 | - <?php else : ?> |
|
194 | + <?php else { |
|
195 | + : ?> |
|
193 | 196 | |
194 | - <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true"> |
|
197 | + <a class="post-thumbnail" href="<?php the_permalink(); |
|
198 | +} |
|
199 | +?>" aria-hidden="true"> |
|
195 | 200 | <?php |
196 | 201 | if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) { |
197 | 202 | the_post_thumbnail( 'twentyfourteen-full-width' ); |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Custom Widget for displaying specific post formats |
|
4 | - * |
|
5 | - * Displays posts from Aside, Quote, Video, Audio, Image, Gallery, and Link formats. |
|
6 | - * |
|
7 | - * @link https://codex.wordpress.org/Widgets_API#Developing_Widgets |
|
8 | - * |
|
9 | - * @package WordPress |
|
10 | - * @subpackage Twenty_Fourteen |
|
11 | - * @since Twenty Fourteen 1.0 |
|
12 | - */ |
|
3 | + * Custom Widget for displaying specific post formats |
|
4 | + * |
|
5 | + * Displays posts from Aside, Quote, Video, Audio, Image, Gallery, and Link formats. |
|
6 | + * |
|
7 | + * @link https://codex.wordpress.org/Widgets_API#Developing_Widgets |
|
8 | + * |
|
9 | + * @package WordPress |
|
10 | + * @subpackage Twenty_Fourteen |
|
11 | + * @since Twenty Fourteen 1.0 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | class Twenty_Fourteen_Ephemera_Widget extends WP_Widget { |
15 | 15 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @var array |
23 | 23 | */ |
24 | - private $formats = array( 'aside', 'image', 'video', 'audio', 'quote', 'link', 'gallery' ); |
|
24 | + private $formats = array('aside', 'image', 'video', 'audio', 'quote', 'link', 'gallery'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Constructor. |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | * @return Twenty_Fourteen_Ephemera_Widget |
32 | 32 | */ |
33 | 33 | public function __construct() { |
34 | - parent::__construct( 'widget_twentyfourteen_ephemera', __( 'Twenty Fourteen Ephemera', 'twentyfourteen' ), array( |
|
34 | + parent::__construct('widget_twentyfourteen_ephemera', __('Twenty Fourteen Ephemera', 'twentyfourteen'), array( |
|
35 | 35 | 'classname' => 'widget_twentyfourteen_ephemera', |
36 | - 'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ), |
|
37 | - ) ); |
|
36 | + 'description' => __('Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen'), |
|
37 | + )); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -46,73 +46,73 @@ discard block |
||
46 | 46 | * @param array $args An array of standard parameters for widgets in this theme. |
47 | 47 | * @param array $instance An array of settings for this widget instance. |
48 | 48 | */ |
49 | - public function widget( $args, $instance ) { |
|
50 | - $format = isset( $instance['format'] ) && in_array( $instance['format'], $this->formats ) ? $instance['format'] : 'aside'; |
|
49 | + public function widget($args, $instance) { |
|
50 | + $format = isset($instance['format']) && in_array($instance['format'], $this->formats) ? $instance['format'] : 'aside'; |
|
51 | 51 | |
52 | - switch ( $format ) { |
|
52 | + switch ($format) { |
|
53 | 53 | case 'image': |
54 | - $format_string = __( 'Images', 'twentyfourteen' ); |
|
55 | - $format_string_more = __( 'More images', 'twentyfourteen' ); |
|
54 | + $format_string = __('Images', 'twentyfourteen'); |
|
55 | + $format_string_more = __('More images', 'twentyfourteen'); |
|
56 | 56 | break; |
57 | 57 | case 'video': |
58 | - $format_string = __( 'Videos', 'twentyfourteen' ); |
|
59 | - $format_string_more = __( 'More videos', 'twentyfourteen' ); |
|
58 | + $format_string = __('Videos', 'twentyfourteen'); |
|
59 | + $format_string_more = __('More videos', 'twentyfourteen'); |
|
60 | 60 | break; |
61 | 61 | case 'audio': |
62 | - $format_string = __( 'Audio', 'twentyfourteen' ); |
|
63 | - $format_string_more = __( 'More audio', 'twentyfourteen' ); |
|
62 | + $format_string = __('Audio', 'twentyfourteen'); |
|
63 | + $format_string_more = __('More audio', 'twentyfourteen'); |
|
64 | 64 | break; |
65 | 65 | case 'quote': |
66 | - $format_string = __( 'Quotes', 'twentyfourteen' ); |
|
67 | - $format_string_more = __( 'More quotes', 'twentyfourteen' ); |
|
66 | + $format_string = __('Quotes', 'twentyfourteen'); |
|
67 | + $format_string_more = __('More quotes', 'twentyfourteen'); |
|
68 | 68 | break; |
69 | 69 | case 'link': |
70 | - $format_string = __( 'Links', 'twentyfourteen' ); |
|
71 | - $format_string_more = __( 'More links', 'twentyfourteen' ); |
|
70 | + $format_string = __('Links', 'twentyfourteen'); |
|
71 | + $format_string_more = __('More links', 'twentyfourteen'); |
|
72 | 72 | break; |
73 | 73 | case 'gallery': |
74 | - $format_string = __( 'Galleries', 'twentyfourteen' ); |
|
75 | - $format_string_more = __( 'More galleries', 'twentyfourteen' ); |
|
74 | + $format_string = __('Galleries', 'twentyfourteen'); |
|
75 | + $format_string_more = __('More galleries', 'twentyfourteen'); |
|
76 | 76 | break; |
77 | 77 | case 'aside': |
78 | 78 | default: |
79 | - $format_string = __( 'Asides', 'twentyfourteen' ); |
|
80 | - $format_string_more = __( 'More asides', 'twentyfourteen' ); |
|
79 | + $format_string = __('Asides', 'twentyfourteen'); |
|
80 | + $format_string_more = __('More asides', 'twentyfourteen'); |
|
81 | 81 | break; |
82 | 82 | } |
83 | 83 | |
84 | - $number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] ); |
|
85 | - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? $format_string : $instance['title'], $instance, $this->id_base ); |
|
84 | + $number = empty($instance['number']) ? 2 : absint($instance['number']); |
|
85 | + $title = apply_filters('widget_title', empty($instance['title']) ? $format_string : $instance['title'], $instance, $this->id_base); |
|
86 | 86 | |
87 | - $ephemera = new WP_Query( array( |
|
87 | + $ephemera = new WP_Query(array( |
|
88 | 88 | 'order' => 'DESC', |
89 | 89 | 'posts_per_page' => $number, |
90 | 90 | 'no_found_rows' => true, |
91 | 91 | 'post_status' => 'publish', |
92 | - 'post__not_in' => get_option( 'sticky_posts' ), |
|
92 | + 'post__not_in' => get_option('sticky_posts'), |
|
93 | 93 | 'tax_query' => array( |
94 | 94 | array( |
95 | 95 | 'taxonomy' => 'post_format', |
96 | - 'terms' => array( "post-format-$format" ), |
|
96 | + 'terms' => array("post-format-$format"), |
|
97 | 97 | 'field' => 'slug', |
98 | 98 | 'operator' => 'IN', |
99 | 99 | ), |
100 | 100 | ), |
101 | - ) ); |
|
101 | + )); |
|
102 | 102 | |
103 | - if ( $ephemera->have_posts() ) : |
|
103 | + if ($ephemera->have_posts()) : |
|
104 | 104 | $tmp_content_width = $GLOBALS['content_width']; |
105 | 105 | $GLOBALS['content_width'] = 306; |
106 | 106 | |
107 | 107 | echo $args['before_widget']; |
108 | 108 | ?> |
109 | - <h1 class="widget-title <?php echo esc_attr( $format ); ?>"> |
|
110 | - <a class="entry-format" href="<?php echo esc_url( get_post_format_link( $format ) ); ?>"><?php echo esc_html( $title ); ?></a> |
|
109 | + <h1 class="widget-title <?php echo esc_attr($format); ?>"> |
|
110 | + <a class="entry-format" href="<?php echo esc_url(get_post_format_link($format)); ?>"><?php echo esc_html($title); ?></a> |
|
111 | 111 | </h1> |
112 | 112 | <ol> |
113 | 113 | |
114 | 114 | <?php |
115 | - while ( $ephemera->have_posts() ) : |
|
115 | + while ($ephemera->have_posts()) : |
|
116 | 116 | $ephemera->the_post(); |
117 | 117 | $tmp_more = $GLOBALS['more']; |
118 | 118 | $GLOBALS['more'] = 0; |
@@ -121,19 +121,19 @@ discard block |
||
121 | 121 | <article <?php post_class(); ?>> |
122 | 122 | <div class="entry-content"> |
123 | 123 | <?php |
124 | - if ( has_post_format( 'gallery' ) ) : |
|
124 | + if (has_post_format('gallery')) : |
|
125 | 125 | |
126 | - if ( post_password_required() ) : |
|
127 | - the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) ); |
|
126 | + if (post_password_required()) : |
|
127 | + the_content(__('Continue reading <span class="meta-nav">→</span>', 'twentyfourteen')); |
|
128 | 128 | else : |
129 | 129 | $images = array(); |
130 | 130 | |
131 | - $galleries = get_post_galleries( get_the_ID(), false ); |
|
132 | - if ( isset( $galleries[0]['ids'] ) ) |
|
133 | - $images = explode( ',', $galleries[0]['ids'] ); |
|
131 | + $galleries = get_post_galleries(get_the_ID(), false); |
|
132 | + if (isset($galleries[0]['ids'])) |
|
133 | + $images = explode(',', $galleries[0]['ids']); |
|
134 | 134 | |
135 | - if ( ! $images ) : |
|
136 | - $images = get_posts( array( |
|
135 | + if ( ! $images) : |
|
136 | + $images = get_posts(array( |
|
137 | 137 | 'fields' => 'ids', |
138 | 138 | 'numberposts' => -1, |
139 | 139 | 'order' => 'ASC', |
@@ -141,27 +141,27 @@ discard block |
||
141 | 141 | 'post_mime_type' => 'image', |
142 | 142 | 'post_parent' => get_the_ID(), |
143 | 143 | 'post_type' => 'attachment', |
144 | - ) ); |
|
144 | + )); |
|
145 | 145 | endif; |
146 | 146 | |
147 | - $total_images = count( $images ); |
|
147 | + $total_images = count($images); |
|
148 | 148 | |
149 | - if ( has_post_thumbnail() ) : |
|
149 | + if (has_post_thumbnail()) : |
|
150 | 150 | $post_thumbnail = get_the_post_thumbnail(); |
151 | - elseif ( $total_images > 0 ) : |
|
152 | - $image = reset( $images ); |
|
153 | - $post_thumbnail = wp_get_attachment_image( $image, 'post-thumbnail' ); |
|
151 | + elseif ($total_images > 0) : |
|
152 | + $image = reset($images); |
|
153 | + $post_thumbnail = wp_get_attachment_image($image, 'post-thumbnail'); |
|
154 | 154 | endif; |
155 | 155 | |
156 | - if ( ! empty ( $post_thumbnail ) ) : |
|
156 | + if ( ! empty ($post_thumbnail)) : |
|
157 | 157 | ?> |
158 | 158 | <a href="<?php the_permalink(); ?>"><?php echo $post_thumbnail; ?></a> |
159 | 159 | <?php endif; ?> |
160 | 160 | <p class="wp-caption-text"> |
161 | 161 | <?php |
162 | - printf( _n( 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photo</a>.', 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photos</a>.', $total_images, 'twentyfourteen' ), |
|
163 | - esc_url( get_permalink() ), |
|
164 | - number_format_i18n( $total_images ) |
|
162 | + printf(_n('This gallery contains <a href="%1$s" rel="bookmark">%2$s photo</a>.', 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photos</a>.', $total_images, 'twentyfourteen'), |
|
163 | + esc_url(get_permalink()), |
|
164 | + number_format_i18n($total_images) |
|
165 | 165 | ); |
166 | 166 | ?> |
167 | 167 | </p> |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | endif; |
170 | 170 | |
171 | 171 | else : |
172 | - the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) ); |
|
172 | + the_content(__('Continue reading <span class="meta-nav">→</span>', 'twentyfourteen')); |
|
173 | 173 | endif; |
174 | 174 | ?> |
175 | 175 | </div><!-- .entry-content --> |
@@ -177,21 +177,21 @@ discard block |
||
177 | 177 | <header class="entry-header"> |
178 | 178 | <div class="entry-meta"> |
179 | 179 | <?php |
180 | - if ( ! has_post_format( 'link' ) ) : |
|
181 | - the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' ); |
|
180 | + if ( ! has_post_format('link')) : |
|
181 | + the_title('<h1 class="entry-title"><a href="'.esc_url(get_permalink()).'" rel="bookmark">', '</a></h1>'); |
|
182 | 182 | endif; |
183 | 183 | |
184 | - 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>', |
|
185 | - esc_url( get_permalink() ), |
|
186 | - esc_attr( get_the_date( 'c' ) ), |
|
187 | - esc_html( get_the_date() ), |
|
188 | - esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), |
|
184 | + 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>', |
|
185 | + esc_url(get_permalink()), |
|
186 | + esc_attr(get_the_date('c')), |
|
187 | + esc_html(get_the_date()), |
|
188 | + esc_url(get_author_posts_url(get_the_author_meta('ID'))), |
|
189 | 189 | get_the_author() |
190 | 190 | ); |
191 | 191 | |
192 | - if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : |
|
192 | + if ( ! post_password_required() && (comments_open() || get_comments_number())) : |
|
193 | 193 | ?> |
194 | - <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyfourteen' ), __( '1 Comment', 'twentyfourteen' ), __( '% Comments', 'twentyfourteen' ) ); ?></span> |
|
194 | + <span class="comments-link"><?php comments_popup_link(__('Leave a comment', 'twentyfourteen'), __('1 Comment', 'twentyfourteen'), __('% Comments', 'twentyfourteen')); ?></span> |
|
195 | 195 | <?php endif; ?> |
196 | 196 | </div><!-- .entry-meta --> |
197 | 197 | </header><!-- .entry-header --> |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | <?php endwhile; ?> |
201 | 201 | |
202 | 202 | </ol> |
203 | - <a class="post-format-archive-link" href="<?php echo esc_url( get_post_format_link( $format ) ); ?>"> |
|
203 | + <a class="post-format-archive-link" href="<?php echo esc_url(get_post_format_link($format)); ?>"> |
|
204 | 204 | <?php |
205 | 205 | /* translators: used with More archives link */ |
206 | - printf( __( '%s <span class="meta-nav">→</span>', 'twentyfourteen' ), $format_string_more ); |
|
206 | + printf(__('%s <span class="meta-nav">→</span>', 'twentyfourteen'), $format_string_more); |
|
207 | 207 | ?> |
208 | 208 | </a> |
209 | 209 | <?php |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | * @param array $instance Original widget instance. |
231 | 231 | * @return array Updated widget instance. |
232 | 232 | */ |
233 | - function update( $new_instance, $instance ) { |
|
234 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
235 | - $instance['number'] = empty( $new_instance['number'] ) ? 2 : absint( $new_instance['number'] ); |
|
236 | - if ( in_array( $new_instance['format'], $this->formats ) ) { |
|
233 | + function update($new_instance, $instance) { |
|
234 | + $instance['title'] = strip_tags($new_instance['title']); |
|
235 | + $instance['number'] = empty($new_instance['number']) ? 2 : absint($new_instance['number']); |
|
236 | + if (in_array($new_instance['format'], $this->formats)) { |
|
237 | 237 | $instance['format'] = $new_instance['format']; |
238 | 238 | } |
239 | 239 | |
@@ -247,21 +247,21 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @param array $instance |
249 | 249 | */ |
250 | - function form( $instance ) { |
|
251 | - $title = empty( $instance['title'] ) ? '' : esc_attr( $instance['title'] ); |
|
252 | - $number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] ); |
|
253 | - $format = isset( $instance['format'] ) && in_array( $instance['format'], $this->formats ) ? $instance['format'] : 'aside'; |
|
250 | + function form($instance) { |
|
251 | + $title = empty($instance['title']) ? '' : esc_attr($instance['title']); |
|
252 | + $number = empty($instance['number']) ? 2 : absint($instance['number']); |
|
253 | + $format = isset($instance['format']) && in_array($instance['format'], $this->formats) ? $instance['format'] : 'aside'; |
|
254 | 254 | ?> |
255 | - <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'twentyfourteen' ); ?></label> |
|
256 | - <input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"></p> |
|
255 | + <p><label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title:', 'twentyfourteen'); ?></label> |
|
256 | + <input id="<?php echo esc_attr($this->get_field_id('title')); ?>" class="widefat" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>"></p> |
|
257 | 257 | |
258 | - <p><label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php _e( 'Number of posts to show:', 'twentyfourteen' ); ?></label> |
|
259 | - <input id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="text" value="<?php echo esc_attr( $number ); ?>" size="3"></p> |
|
258 | + <p><label for="<?php echo esc_attr($this->get_field_id('number')); ?>"><?php _e('Number of posts to show:', 'twentyfourteen'); ?></label> |
|
259 | + <input id="<?php echo esc_attr($this->get_field_id('number')); ?>" name="<?php echo esc_attr($this->get_field_name('number')); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p> |
|
260 | 260 | |
261 | - <p><label for="<?php echo esc_attr( $this->get_field_id( 'format' ) ); ?>"><?php _e( 'Post format to show:', 'twentyfourteen' ); ?></label> |
|
262 | - <select id="<?php echo esc_attr( $this->get_field_id( 'format' ) ); ?>" class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'format' ) ); ?>"> |
|
263 | - <?php foreach ( $this->formats as $slug ) : ?> |
|
264 | - <option value="<?php echo esc_attr( $slug ); ?>"<?php selected( $format, $slug ); ?>><?php echo esc_html( get_post_format_string( $slug ) ); ?></option> |
|
261 | + <p><label for="<?php echo esc_attr($this->get_field_id('format')); ?>"><?php _e('Post format to show:', 'twentyfourteen'); ?></label> |
|
262 | + <select id="<?php echo esc_attr($this->get_field_id('format')); ?>" class="widefat" name="<?php echo esc_attr($this->get_field_name('format')); ?>"> |
|
263 | + <?php foreach ($this->formats as $slug) : ?> |
|
264 | + <option value="<?php echo esc_attr($slug); ?>"<?php selected($format, $slug); ?>><?php echo esc_html(get_post_format_string($slug)); ?></option> |
|
265 | 265 | <?php endforeach; ?> |
266 | 266 | </select> |
267 | 267 | <?php |
@@ -125,12 +125,15 @@ discard block |
||
125 | 125 | |
126 | 126 | if ( post_password_required() ) : |
127 | 127 | the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) ); |
128 | - else : |
|
128 | + else { |
|
129 | + : |
|
129 | 130 | $images = array(); |
131 | + } |
|
130 | 132 | |
131 | 133 | $galleries = get_post_galleries( get_the_ID(), false ); |
132 | - if ( isset( $galleries[0]['ids'] ) ) |
|
133 | - $images = explode( ',', $galleries[0]['ids'] ); |
|
134 | + if ( isset( $galleries[0]['ids'] ) ) { |
|
135 | + $images = explode( ',', $galleries[0]['ids'] ); |
|
136 | + } |
|
134 | 137 | |
135 | 138 | if ( ! $images ) : |
136 | 139 | $images = get_posts( array( |
@@ -168,8 +171,10 @@ discard block |
||
168 | 171 | <?php |
169 | 172 | endif; |
170 | 173 | |
171 | - else : |
|
174 | + else { |
|
175 | + : |
|
172 | 176 | the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) ); |
177 | + } |
|
173 | 178 | endif; |
174 | 179 | ?> |
175 | 180 | </div><!-- .entry-content --> |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Twenty Fourteen Customizer support |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Twenty_Fourteen |
|
7 | - * @since Twenty Fourteen 1.0 |
|
8 | - */ |
|
3 | + * Twenty Fourteen Customizer support |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Twenty_Fourteen |
|
7 | + * @since Twenty Fourteen 1.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Implement Customizer additions and adjustments. |
@@ -14,55 +14,55 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @param WP_Customize_Manager $wp_customize Customizer object. |
16 | 16 | */ |
17 | -function twentyfourteen_customize_register( $wp_customize ) { |
|
17 | +function twentyfourteen_customize_register($wp_customize) { |
|
18 | 18 | // Add postMessage support for site title and description. |
19 | - $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; |
|
20 | - $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; |
|
21 | - $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; |
|
19 | + $wp_customize->get_setting('blogname')->transport = 'postMessage'; |
|
20 | + $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; |
|
21 | + $wp_customize->get_setting('header_textcolor')->transport = 'postMessage'; |
|
22 | 22 | |
23 | 23 | // Rename the label to "Site Title Color" because this only affects the site title in this theme. |
24 | - $wp_customize->get_control( 'header_textcolor' )->label = __( 'Site Title Color', 'twentyfourteen' ); |
|
24 | + $wp_customize->get_control('header_textcolor')->label = __('Site Title Color', 'twentyfourteen'); |
|
25 | 25 | |
26 | 26 | // Rename the label to "Display Site Title & Tagline" in order to make this option extra clear. |
27 | - $wp_customize->get_control( 'display_header_text' )->label = __( 'Display Site Title & Tagline', 'twentyfourteen' ); |
|
27 | + $wp_customize->get_control('display_header_text')->label = __('Display Site Title & Tagline', 'twentyfourteen'); |
|
28 | 28 | |
29 | 29 | // Add custom description to Colors and Background controls or sections. |
30 | - if ( property_exists( $wp_customize->get_control( 'background_color' ), 'description' ) ) { |
|
31 | - $wp_customize->get_control( 'background_color' )->description = __( 'May only be visible on wide screens.', 'twentyfourteen' ); |
|
32 | - $wp_customize->get_control( 'background_image' )->description = __( 'May only be visible on wide screens.', 'twentyfourteen' ); |
|
30 | + if (property_exists($wp_customize->get_control('background_color'), 'description')) { |
|
31 | + $wp_customize->get_control('background_color')->description = __('May only be visible on wide screens.', 'twentyfourteen'); |
|
32 | + $wp_customize->get_control('background_image')->description = __('May only be visible on wide screens.', 'twentyfourteen'); |
|
33 | 33 | } else { |
34 | - $wp_customize->get_section( 'colors' )->description = __( 'Background may only be visible on wide screens.', 'twentyfourteen' ); |
|
35 | - $wp_customize->get_section( 'background_image' )->description = __( 'Background may only be visible on wide screens.', 'twentyfourteen' ); |
|
34 | + $wp_customize->get_section('colors')->description = __('Background may only be visible on wide screens.', 'twentyfourteen'); |
|
35 | + $wp_customize->get_section('background_image')->description = __('Background may only be visible on wide screens.', 'twentyfourteen'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Add the featured content section in case it's not already there. |
39 | - $wp_customize->add_section( 'featured_content', array( |
|
40 | - 'title' => __( 'Featured Content', 'twentyfourteen' ), |
|
41 | - 'description' => sprintf( __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), |
|
42 | - esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ), |
|
43 | - admin_url( 'edit.php?show_sticky=1' ) |
|
39 | + $wp_customize->add_section('featured_content', array( |
|
40 | + 'title' => __('Featured Content', 'twentyfourteen'), |
|
41 | + 'description' => sprintf(__('Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen'), |
|
42 | + esc_url(add_query_arg('tag', _x('featured', 'featured content default tag slug', 'twentyfourteen'), admin_url('edit.php'))), |
|
43 | + admin_url('edit.php?show_sticky=1') |
|
44 | 44 | ), |
45 | 45 | 'priority' => 130, |
46 | 46 | 'active_callback' => 'is_front_page', |
47 | - ) ); |
|
47 | + )); |
|
48 | 48 | |
49 | 49 | // Add the featured content layout setting and control. |
50 | - $wp_customize->add_setting( 'featured_content_layout', array( |
|
50 | + $wp_customize->add_setting('featured_content_layout', array( |
|
51 | 51 | 'default' => 'grid', |
52 | 52 | 'sanitize_callback' => 'twentyfourteen_sanitize_layout', |
53 | - ) ); |
|
53 | + )); |
|
54 | 54 | |
55 | - $wp_customize->add_control( 'featured_content_layout', array( |
|
56 | - 'label' => __( 'Layout', 'twentyfourteen' ), |
|
55 | + $wp_customize->add_control('featured_content_layout', array( |
|
56 | + 'label' => __('Layout', 'twentyfourteen'), |
|
57 | 57 | 'section' => 'featured_content', |
58 | 58 | 'type' => 'select', |
59 | 59 | 'choices' => array( |
60 | - 'grid' => __( 'Grid', 'twentyfourteen' ), |
|
61 | - 'slider' => __( 'Slider', 'twentyfourteen' ), |
|
60 | + 'grid' => __('Grid', 'twentyfourteen'), |
|
61 | + 'slider' => __('Slider', 'twentyfourteen'), |
|
62 | 62 | ), |
63 | - ) ); |
|
63 | + )); |
|
64 | 64 | } |
65 | -add_action( 'customize_register', 'twentyfourteen_customize_register' ); |
|
65 | +add_action('customize_register', 'twentyfourteen_customize_register'); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Sanitize the Featured Content layout value. |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @param string $layout Layout type. |
73 | 73 | * @return string Filtered layout type (grid|slider). |
74 | 74 | */ |
75 | -function twentyfourteen_sanitize_layout( $layout ) { |
|
76 | - if ( ! in_array( $layout, array( 'grid', 'slider' ) ) ) { |
|
75 | +function twentyfourteen_sanitize_layout($layout) { |
|
76 | + if ( ! in_array($layout, array('grid', 'slider'))) { |
|
77 | 77 | $layout = 'grid'; |
78 | 78 | } |
79 | 79 | |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | * @since Twenty Fourteen 1.0 |
87 | 87 | */ |
88 | 88 | function twentyfourteen_customize_preview_js() { |
89 | - wp_enqueue_script( 'twentyfourteen_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20131205', true ); |
|
89 | + wp_enqueue_script('twentyfourteen_customizer', get_template_directory_uri().'/js/customizer.js', array('customize-preview'), '20131205', true); |
|
90 | 90 | } |
91 | -add_action( 'customize_preview_init', 'twentyfourteen_customize_preview_js' ); |
|
91 | +add_action('customize_preview_init', 'twentyfourteen_customize_preview_js'); |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Add contextual help to the Themes and Post edit screens. |
@@ -96,20 +96,20 @@ discard block |
||
96 | 96 | * @since Twenty Fourteen 1.0 |
97 | 97 | */ |
98 | 98 | function twentyfourteen_contextual_help() { |
99 | - if ( 'admin_head-edit.php' === current_filter() && 'post' !== $GLOBALS['typenow'] ) { |
|
99 | + if ('admin_head-edit.php' === current_filter() && 'post' !== $GLOBALS['typenow']) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | - get_current_screen()->add_help_tab( array( |
|
103 | + get_current_screen()->add_help_tab(array( |
|
104 | 104 | 'id' => 'twentyfourteen', |
105 | - 'title' => __( 'Twenty Fourteen', 'twentyfourteen' ), |
|
105 | + 'title' => __('Twenty Fourteen', 'twentyfourteen'), |
|
106 | 106 | 'content' => |
107 | - '<ul>' . |
|
108 | - '<li>' . sprintf( __( 'The home page features your choice of up to 6 posts prominently displayed in a grid or slider, controlled by a <a href="%1$s">tag</a>; you can change the tag and layout in <a href="%2$s">Appearance → Customize</a>. If no posts match the tag, <a href="%3$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ), admin_url( 'customize.php' ), admin_url( 'edit.php?show_sticky=1' ) ) . '</li>' . |
|
109 | - '<li>' . sprintf( __( 'Enhance your site design by using <a href="%s">Featured Images</a> for posts you’d like to stand out (also known as post thumbnails). This allows you to associate an image with your post without inserting it. Twenty Fourteen uses featured images for posts and pages—above the title—and in the Featured Content area on the home page.', 'twentyfourteen' ), 'https://codex.wordpress.org/Post_Thumbnails#Setting_a_Post_Thumbnail' ) . '</li>' . |
|
110 | - '<li>' . sprintf( __( 'For an in-depth tutorial, and more tips and tricks, visit the <a href="%s">Twenty Fourteen documentation</a>.', 'twentyfourteen' ), 'https://codex.wordpress.org/Twenty_Fourteen' ) . '</li>' . |
|
107 | + '<ul>'. |
|
108 | + '<li>'.sprintf(__('The home page features your choice of up to 6 posts prominently displayed in a grid or slider, controlled by a <a href="%1$s">tag</a>; you can change the tag and layout in <a href="%2$s">Appearance → Customize</a>. If no posts match the tag, <a href="%3$s">sticky posts</a> will be displayed instead.', 'twentyfourteen'), esc_url(add_query_arg('tag', _x('featured', 'featured content default tag slug', 'twentyfourteen'), admin_url('edit.php'))), admin_url('customize.php'), admin_url('edit.php?show_sticky=1')).'</li>'. |
|
109 | + '<li>'.sprintf(__('Enhance your site design by using <a href="%s">Featured Images</a> for posts you’d like to stand out (also known as post thumbnails). This allows you to associate an image with your post without inserting it. Twenty Fourteen uses featured images for posts and pages—above the title—and in the Featured Content area on the home page.', 'twentyfourteen'), 'https://codex.wordpress.org/Post_Thumbnails#Setting_a_Post_Thumbnail').'</li>'. |
|
110 | + '<li>'.sprintf(__('For an in-depth tutorial, and more tips and tricks, visit the <a href="%s">Twenty Fourteen documentation</a>.', 'twentyfourteen'), 'https://codex.wordpress.org/Twenty_Fourteen').'</li>'. |
|
111 | 111 | '</ul>', |
112 | - ) ); |
|
112 | + )); |
|
113 | 113 | } |
114 | -add_action( 'admin_head-themes.php', 'twentyfourteen_contextual_help' ); |
|
115 | -add_action( 'admin_head-edit.php', 'twentyfourteen_contextual_help' ); |
|
114 | +add_action('admin_head-themes.php', 'twentyfourteen_contextual_help'); |
|
115 | +add_action('admin_head-edit.php', 'twentyfourteen_contextual_help'); |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Twenty Fourteen Featured Content |
|
4 | - * |
|
5 | - * This module allows you to define a subset of posts to be displayed |
|
6 | - * in the theme's Featured Content area. |
|
7 | - * |
|
8 | - * For maximum compatibility with different methods of posting users |
|
9 | - * will designate a featured post tag to associate posts with. Since |
|
10 | - * this tag now has special meaning beyond that of a normal tags, users |
|
11 | - * will have the ability to hide it from the front-end of their site. |
|
12 | - */ |
|
3 | + * Twenty Fourteen Featured Content |
|
4 | + * |
|
5 | + * This module allows you to define a subset of posts to be displayed |
|
6 | + * in the theme's Featured Content area. |
|
7 | + * |
|
8 | + * For maximum compatibility with different methods of posting users |
|
9 | + * will designate a featured post tag to associate posts with. Since |
|
10 | + * this tag now has special meaning beyond that of a normal tags, users |
|
11 | + * will have the ability to hide it from the front-end of their site. |
|
12 | + */ |
|
13 | 13 | class Featured_Content { |
14 | 14 | |
15 | 15 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @since Twenty Fourteen 1.0 |
40 | 40 | */ |
41 | 41 | public static function setup() { |
42 | - add_action( 'init', array( __CLASS__, 'init' ), 30 ); |
|
42 | + add_action('init', array(__CLASS__, 'init'), 30); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * @since Twenty Fourteen 1.0 |
57 | 57 | */ |
58 | 58 | public static function init() { |
59 | - $theme_support = get_theme_support( 'featured-content' ); |
|
59 | + $theme_support = get_theme_support('featured-content'); |
|
60 | 60 | |
61 | 61 | // Return early if theme does not support Featured Content. |
62 | - if ( ! $theme_support ) { |
|
62 | + if ( ! $theme_support) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
@@ -67,31 +67,31 @@ discard block |
||
67 | 67 | * An array of named arguments must be passed as the second parameter |
68 | 68 | * of add_theme_support(). |
69 | 69 | */ |
70 | - if ( ! isset( $theme_support[0] ) ) { |
|
70 | + if ( ! isset($theme_support[0])) { |
|
71 | 71 | return; |
72 | 72 | } |
73 | 73 | |
74 | 74 | // Return early if "featured_content_filter" has not been defined. |
75 | - if ( ! isset( $theme_support[0]['featured_content_filter'] ) ) { |
|
75 | + if ( ! isset($theme_support[0]['featured_content_filter'])) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | 79 | $filter = $theme_support[0]['featured_content_filter']; |
80 | 80 | |
81 | 81 | // Theme can override the number of max posts. |
82 | - if ( isset( $theme_support[0]['max_posts'] ) ) { |
|
83 | - self::$max_posts = absint( $theme_support[0]['max_posts'] ); |
|
82 | + if (isset($theme_support[0]['max_posts'])) { |
|
83 | + self::$max_posts = absint($theme_support[0]['max_posts']); |
|
84 | 84 | } |
85 | 85 | |
86 | - add_filter( $filter, array( __CLASS__, 'get_featured_posts' ) ); |
|
87 | - add_action( 'customize_register', array( __CLASS__, 'customize_register' ), 9 ); |
|
88 | - add_action( 'admin_init', array( __CLASS__, 'register_setting' ) ); |
|
89 | - add_action( 'switch_theme', array( __CLASS__, 'delete_transient' ) ); |
|
90 | - add_action( 'save_post', array( __CLASS__, 'delete_transient' ) ); |
|
91 | - add_action( 'delete_post_tag', array( __CLASS__, 'delete_post_tag' ) ); |
|
92 | - add_action( 'customize_controls_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) ); |
|
93 | - add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) ); |
|
94 | - add_action( 'wp_loaded', array( __CLASS__, 'wp_loaded' ) ); |
|
86 | + add_filter($filter, array(__CLASS__, 'get_featured_posts')); |
|
87 | + add_action('customize_register', array(__CLASS__, 'customize_register'), 9); |
|
88 | + add_action('admin_init', array(__CLASS__, 'register_setting')); |
|
89 | + add_action('switch_theme', array(__CLASS__, 'delete_transient')); |
|
90 | + add_action('save_post', array(__CLASS__, 'delete_transient')); |
|
91 | + add_action('delete_post_tag', array(__CLASS__, 'delete_post_tag')); |
|
92 | + add_action('customize_controls_enqueue_scripts', array(__CLASS__, 'enqueue_scripts')); |
|
93 | + add_action('pre_get_posts', array(__CLASS__, 'pre_get_posts')); |
|
94 | + add_action('wp_loaded', array(__CLASS__, 'wp_loaded')); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @since Twenty Fourteen 1.0 |
106 | 106 | */ |
107 | 107 | public static function wp_loaded() { |
108 | - if ( self::get_setting( 'hide-tag' ) ) { |
|
109 | - add_filter( 'get_terms', array( __CLASS__, 'hide_featured_term' ), 10, 3 ); |
|
110 | - add_filter( 'get_the_terms', array( __CLASS__, 'hide_the_featured_term' ), 10, 3 ); |
|
108 | + if (self::get_setting('hide-tag')) { |
|
109 | + add_filter('get_terms', array(__CLASS__, 'hide_featured_term'), 10, 3); |
|
110 | + add_filter('get_the_terms', array(__CLASS__, 'hide_the_featured_term'), 10, 3); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | $post_ids = self::get_featured_post_ids(); |
125 | 125 | |
126 | 126 | // No need to query if there is are no featured posts. |
127 | - if ( empty( $post_ids ) ) { |
|
127 | + if (empty($post_ids)) { |
|
128 | 128 | return array(); |
129 | 129 | } |
130 | 130 | |
131 | - $featured_posts = get_posts( array( |
|
131 | + $featured_posts = get_posts(array( |
|
132 | 132 | 'include' => $post_ids, |
133 | - 'posts_per_page' => count( $post_ids ), |
|
134 | - ) ); |
|
133 | + 'posts_per_page' => count($post_ids), |
|
134 | + )); |
|
135 | 135 | |
136 | 136 | return $featured_posts; |
137 | 137 | } |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public static function get_featured_post_ids() { |
154 | 154 | // Get array of cached results if they exist. |
155 | - $featured_ids = get_transient( 'featured_content_ids' ); |
|
155 | + $featured_ids = get_transient('featured_content_ids'); |
|
156 | 156 | |
157 | - if ( false === $featured_ids ) { |
|
157 | + if (false === $featured_ids) { |
|
158 | 158 | $settings = self::get_setting(); |
159 | - $term = get_term_by( 'name', $settings['tag-name'], 'post_tag' ); |
|
159 | + $term = get_term_by('name', $settings['tag-name'], 'post_tag'); |
|
160 | 160 | |
161 | - if ( $term ) { |
|
161 | + if ($term) { |
|
162 | 162 | // Query for featured posts. |
163 | - $featured_ids = get_posts( array( |
|
163 | + $featured_ids = get_posts(array( |
|
164 | 164 | 'fields' => 'ids', |
165 | 165 | 'numberposts' => self::$max_posts, |
166 | 166 | 'suppress_filters' => false, |
@@ -171,19 +171,19 @@ discard block |
||
171 | 171 | 'terms' => $term->term_id, |
172 | 172 | ), |
173 | 173 | ), |
174 | - ) ); |
|
174 | + )); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | // Get sticky posts if no Featured Content exists. |
178 | - if ( ! $featured_ids ) { |
|
178 | + if ( ! $featured_ids) { |
|
179 | 179 | $featured_ids = self::get_sticky_posts(); |
180 | 180 | } |
181 | 181 | |
182 | - set_transient( 'featured_content_ids', $featured_ids ); |
|
182 | + set_transient('featured_content_ids', $featured_ids); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | // Ensure correct format before return. |
186 | - return array_map( 'absint', $featured_ids ); |
|
186 | + return array_map('absint', $featured_ids); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @return array Array of sticky posts. |
197 | 197 | */ |
198 | 198 | public static function get_sticky_posts() { |
199 | - return array_slice( get_option( 'sticky_posts', array() ), 0, self::$max_posts ); |
|
199 | + return array_slice(get_option('sticky_posts', array()), 0, self::$max_posts); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @since Twenty Fourteen 1.0 |
212 | 212 | */ |
213 | 213 | public static function delete_transient() { |
214 | - delete_transient( 'featured_content_ids' ); |
|
214 | + delete_transient('featured_content_ids'); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -228,34 +228,34 @@ discard block |
||
228 | 228 | * @param WP_Query $query WP_Query object. |
229 | 229 | * @return WP_Query Possibly-modified WP_Query. |
230 | 230 | */ |
231 | - public static function pre_get_posts( $query ) { |
|
231 | + public static function pre_get_posts($query) { |
|
232 | 232 | |
233 | 233 | // Bail if not home or not main query. |
234 | - if ( ! $query->is_home() || ! $query->is_main_query() ) { |
|
234 | + if ( ! $query->is_home() || ! $query->is_main_query()) { |
|
235 | 235 | return; |
236 | 236 | } |
237 | 237 | |
238 | 238 | // Bail if the blog page is not the front page. |
239 | - if ( 'posts' !== get_option( 'show_on_front' ) ) { |
|
239 | + if ('posts' !== get_option('show_on_front')) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | |
243 | 243 | $featured = self::get_featured_post_ids(); |
244 | 244 | |
245 | 245 | // Bail if no featured posts. |
246 | - if ( ! $featured ) { |
|
246 | + if ( ! $featured) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
250 | 250 | // We need to respect post ids already in the blacklist. |
251 | - $post__not_in = $query->get( 'post__not_in' ); |
|
251 | + $post__not_in = $query->get('post__not_in'); |
|
252 | 252 | |
253 | - if ( ! empty( $post__not_in ) ) { |
|
254 | - $featured = array_merge( (array) $post__not_in, $featured ); |
|
255 | - $featured = array_unique( $featured ); |
|
253 | + if ( ! empty($post__not_in)) { |
|
254 | + $featured = array_merge((array) $post__not_in, $featured); |
|
255 | + $featured = array_unique($featured); |
|
256 | 256 | } |
257 | 257 | |
258 | - $query->set( 'post__not_in', $featured ); |
|
258 | + $query->set('post__not_in', $featured); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -275,16 +275,16 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param int $tag_id The term_id of the tag that has been deleted. |
277 | 277 | */ |
278 | - public static function delete_post_tag( $tag_id ) { |
|
278 | + public static function delete_post_tag($tag_id) { |
|
279 | 279 | $settings = self::get_setting(); |
280 | 280 | |
281 | - if ( empty( $settings['tag-id'] ) || $tag_id != $settings['tag-id'] ) { |
|
281 | + if (empty($settings['tag-id']) || $tag_id != $settings['tag-id']) { |
|
282 | 282 | return; |
283 | 283 | } |
284 | 284 | |
285 | 285 | $settings['tag-id'] = 0; |
286 | - $settings = self::validate_settings( $settings ); |
|
287 | - update_option( 'featured-content', $settings ); |
|
286 | + $settings = self::validate_settings($settings); |
|
287 | + update_option('featured-content', $settings); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -302,32 +302,32 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @uses Featured_Content::get_setting() |
304 | 304 | */ |
305 | - public static function hide_featured_term( $terms, $taxonomies, $args ) { |
|
305 | + public static function hide_featured_term($terms, $taxonomies, $args) { |
|
306 | 306 | |
307 | 307 | // This filter is only appropriate on the front-end. |
308 | - if ( is_admin() ) { |
|
308 | + if (is_admin()) { |
|
309 | 309 | return $terms; |
310 | 310 | } |
311 | 311 | |
312 | 312 | // We only want to hide the featured tag. |
313 | - if ( ! in_array( 'post_tag', $taxonomies ) ) { |
|
313 | + if ( ! in_array('post_tag', $taxonomies)) { |
|
314 | 314 | return $terms; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Bail if no terms were returned. |
318 | - if ( empty( $terms ) ) { |
|
318 | + if (empty($terms)) { |
|
319 | 319 | return $terms; |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Bail if term objects are unavailable. |
323 | - if ( 'all' != $args['fields'] ) { |
|
323 | + if ('all' != $args['fields']) { |
|
324 | 324 | return $terms; |
325 | 325 | } |
326 | 326 | |
327 | 327 | $settings = self::get_setting(); |
328 | - foreach ( $terms as $order => $term ) { |
|
329 | - if ( ( $settings['tag-id'] === $term->term_id || $settings['tag-name'] === $term->name ) && 'post_tag' === $term->taxonomy ) { |
|
330 | - unset( $terms[ $order ] ); |
|
328 | + foreach ($terms as $order => $term) { |
|
329 | + if (($settings['tag-id'] === $term->term_id || $settings['tag-name'] === $term->name) && 'post_tag' === $term->taxonomy) { |
|
330 | + unset($terms[$order]); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
@@ -351,27 +351,27 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @uses Featured_Content::get_setting() |
353 | 353 | */ |
354 | - public static function hide_the_featured_term( $terms, $id, $taxonomy ) { |
|
354 | + public static function hide_the_featured_term($terms, $id, $taxonomy) { |
|
355 | 355 | |
356 | 356 | // This filter is only appropriate on the front-end. |
357 | - if ( is_admin() ) { |
|
357 | + if (is_admin()) { |
|
358 | 358 | return $terms; |
359 | 359 | } |
360 | 360 | |
361 | 361 | // Make sure we are in the correct taxonomy. |
362 | - if ( 'post_tag' != $taxonomy ) { |
|
362 | + if ('post_tag' != $taxonomy) { |
|
363 | 363 | return $terms; |
364 | 364 | } |
365 | 365 | |
366 | 366 | // No terms? Return early! |
367 | - if ( empty( $terms ) ) { |
|
367 | + if (empty($terms)) { |
|
368 | 368 | return $terms; |
369 | 369 | } |
370 | 370 | |
371 | 371 | $settings = self::get_setting(); |
372 | - foreach ( $terms as $order => $term ) { |
|
373 | - if ( ( $settings['tag-id'] === $term->term_id || $settings['tag-name'] === $term->name ) && 'post_tag' === $term->taxonomy ) { |
|
374 | - unset( $terms[ $term->term_id ] ); |
|
372 | + foreach ($terms as $order => $term) { |
|
373 | + if (($settings['tag-id'] === $term->term_id || $settings['tag-name'] === $term->name) && 'post_tag' === $term->taxonomy) { |
|
374 | + unset($terms[$term->term_id]); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | * @since Twenty Fourteen 1.0 |
387 | 387 | */ |
388 | 388 | public static function register_setting() { |
389 | - register_setting( 'featured-content', 'featured-content', array( __CLASS__, 'validate_settings' ) ); |
|
389 | + register_setting('featured-content', 'featured-content', array(__CLASS__, 'validate_settings')); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -398,41 +398,41 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @param WP_Customize_Manager $wp_customize Customizer object. |
400 | 400 | */ |
401 | - public static function customize_register( $wp_customize ) { |
|
402 | - $wp_customize->add_section( 'featured_content', array( |
|
403 | - 'title' => __( 'Featured Content', 'twentyfourteen' ), |
|
404 | - 'description' => sprintf( __( 'Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen' ), |
|
405 | - esc_url( add_query_arg( 'tag', _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), admin_url( 'edit.php' ) ) ), |
|
406 | - admin_url( 'edit.php?show_sticky=1' ) |
|
401 | + public static function customize_register($wp_customize) { |
|
402 | + $wp_customize->add_section('featured_content', array( |
|
403 | + 'title' => __('Featured Content', 'twentyfourteen'), |
|
404 | + 'description' => sprintf(__('Use a <a href="%1$s">tag</a> to feature your posts. If no posts match the tag, <a href="%2$s">sticky posts</a> will be displayed instead.', 'twentyfourteen'), |
|
405 | + esc_url(add_query_arg('tag', _x('featured', 'featured content default tag slug', 'twentyfourteen'), admin_url('edit.php'))), |
|
406 | + admin_url('edit.php?show_sticky=1') |
|
407 | 407 | ), |
408 | 408 | 'priority' => 130, |
409 | 409 | 'theme_supports' => 'featured-content', |
410 | - ) ); |
|
410 | + )); |
|
411 | 411 | |
412 | 412 | // Add Featured Content settings. |
413 | - $wp_customize->add_setting( 'featured-content[tag-name]', array( |
|
414 | - 'default' => _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), |
|
413 | + $wp_customize->add_setting('featured-content[tag-name]', array( |
|
414 | + 'default' => _x('featured', 'featured content default tag slug', 'twentyfourteen'), |
|
415 | 415 | 'type' => 'option', |
416 | - 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ), |
|
417 | - ) ); |
|
418 | - $wp_customize->add_setting( 'featured-content[hide-tag]', array( |
|
416 | + 'sanitize_js_callback' => array(__CLASS__, 'delete_transient'), |
|
417 | + )); |
|
418 | + $wp_customize->add_setting('featured-content[hide-tag]', array( |
|
419 | 419 | 'default' => true, |
420 | 420 | 'type' => 'option', |
421 | - 'sanitize_js_callback' => array( __CLASS__, 'delete_transient' ), |
|
422 | - ) ); |
|
421 | + 'sanitize_js_callback' => array(__CLASS__, 'delete_transient'), |
|
422 | + )); |
|
423 | 423 | |
424 | 424 | // Add Featured Content controls. |
425 | - $wp_customize->add_control( 'featured-content[tag-name]', array( |
|
426 | - 'label' => __( 'Tag Name', 'twentyfourteen' ), |
|
425 | + $wp_customize->add_control('featured-content[tag-name]', array( |
|
426 | + 'label' => __('Tag Name', 'twentyfourteen'), |
|
427 | 427 | 'section' => 'featured_content', |
428 | 428 | 'priority' => 20, |
429 | - ) ); |
|
430 | - $wp_customize->add_control( 'featured-content[hide-tag]', array( |
|
431 | - 'label' => __( 'Don’t display tag on front end.', 'twentyfourteen' ), |
|
429 | + )); |
|
430 | + $wp_customize->add_control('featured-content[hide-tag]', array( |
|
431 | + 'label' => __('Don’t display tag on front end.', 'twentyfourteen'), |
|
432 | 432 | 'section' => 'featured_content', |
433 | 433 | 'type' => 'checkbox', |
434 | 434 | 'priority' => 30, |
435 | - ) ); |
|
435 | + )); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * @since Twenty Fourteen 1.0 |
444 | 444 | */ |
445 | 445 | public static function enqueue_scripts() { |
446 | - wp_enqueue_script( 'featured-content-suggest', get_template_directory_uri() . '/js/featured-content-admin.js', array( 'jquery', 'suggest' ), '20131022', true ); |
|
446 | + wp_enqueue_script('featured-content-suggest', get_template_directory_uri().'/js/featured-content-admin.js', array('jquery', 'suggest'), '20131022', true); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -465,20 +465,20 @@ discard block |
||
465 | 465 | * @param string $key The key of a recognized setting. |
466 | 466 | * @return mixed Array of all settings by default. A single value if passed as first parameter. |
467 | 467 | */ |
468 | - public static function get_setting( $key = 'all' ) { |
|
469 | - $saved = (array) get_option( 'featured-content' ); |
|
468 | + public static function get_setting($key = 'all') { |
|
469 | + $saved = (array) get_option('featured-content'); |
|
470 | 470 | |
471 | 471 | $defaults = array( |
472 | 472 | 'hide-tag' => 1, |
473 | 473 | 'tag-id' => 0, |
474 | - 'tag-name' => _x( 'featured', 'featured content default tag slug', 'twentyfourteen' ), |
|
474 | + 'tag-name' => _x('featured', 'featured content default tag slug', 'twentyfourteen'), |
|
475 | 475 | ); |
476 | 476 | |
477 | - $options = wp_parse_args( $saved, $defaults ); |
|
478 | - $options = array_intersect_key( $options, $defaults ); |
|
477 | + $options = wp_parse_args($saved, $defaults); |
|
478 | + $options = array_intersect_key($options, $defaults); |
|
479 | 479 | |
480 | - if ( 'all' != $key ) { |
|
481 | - return isset( $options[ $key ] ) ? $options[ $key ] : false; |
|
480 | + if ('all' != $key) { |
|
481 | + return isset($options[$key]) ? $options[$key] : false; |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | return $options; |
@@ -498,20 +498,20 @@ discard block |
||
498 | 498 | * @param array $input Array of settings input. |
499 | 499 | * @return array Validated settings output. |
500 | 500 | */ |
501 | - public static function validate_settings( $input ) { |
|
501 | + public static function validate_settings($input) { |
|
502 | 502 | $output = array(); |
503 | 503 | |
504 | - if ( empty( $input['tag-name'] ) ) { |
|
504 | + if (empty($input['tag-name'])) { |
|
505 | 505 | $output['tag-id'] = 0; |
506 | 506 | } else { |
507 | - $term = get_term_by( 'name', $input['tag-name'], 'post_tag' ); |
|
507 | + $term = get_term_by('name', $input['tag-name'], 'post_tag'); |
|
508 | 508 | |
509 | - if ( $term ) { |
|
509 | + if ($term) { |
|
510 | 510 | $output['tag-id'] = $term->term_id; |
511 | 511 | } else { |
512 | - $new_tag = wp_create_tag( $input['tag-name'] ); |
|
512 | + $new_tag = wp_create_tag($input['tag-name']); |
|
513 | 513 | |
514 | - if ( ! is_wp_error( $new_tag ) && isset( $new_tag['term_id'] ) ) { |
|
514 | + if ( ! is_wp_error($new_tag) && isset($new_tag['term_id'])) { |
|
515 | 515 | $output['tag-id'] = $new_tag['term_id']; |
516 | 516 | } |
517 | 517 | } |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | $output['tag-name'] = $input['tag-name']; |
520 | 520 | } |
521 | 521 | |
522 | - $output['hide-tag'] = isset( $input['hide-tag'] ) && $input['hide-tag'] ? 1 : 0; |
|
522 | + $output['hide-tag'] = isset($input['hide-tag']) && $input['hide-tag'] ? 1 : 0; |
|
523 | 523 | |
524 | 524 | // Delete the featured post ids transient. |
525 | 525 | self::delete_transient(); |
@@ -22,22 +22,22 @@ discard block |
||
22 | 22 | <section id="primary" class="content-area"> |
23 | 23 | <div id="content" class="site-content" role="main"> |
24 | 24 | |
25 | - <?php if ( have_posts() ) : ?> |
|
25 | + <?php if (have_posts()) : ?> |
|
26 | 26 | |
27 | 27 | <header class="page-header"> |
28 | 28 | <h1 class="page-title"> |
29 | 29 | <?php |
30 | - if ( is_day() ) : |
|
31 | - printf( __( 'Daily Archives: %s', 'twentyfourteen' ), get_the_date() ); |
|
30 | + if (is_day()) : |
|
31 | + printf(__('Daily Archives: %s', 'twentyfourteen'), get_the_date()); |
|
32 | 32 | |
33 | - elseif ( is_month() ) : |
|
34 | - printf( __( 'Monthly Archives: %s', 'twentyfourteen' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'twentyfourteen' ) ) ); |
|
33 | + elseif (is_month()) : |
|
34 | + printf(__('Monthly Archives: %s', 'twentyfourteen'), get_the_date(_x('F Y', 'monthly archives date format', 'twentyfourteen'))); |
|
35 | 35 | |
36 | - elseif ( is_year() ) : |
|
37 | - printf( __( 'Yearly Archives: %s', 'twentyfourteen' ), get_the_date( _x( 'Y', 'yearly archives date format', 'twentyfourteen' ) ) ); |
|
36 | + elseif (is_year()) : |
|
37 | + printf(__('Yearly Archives: %s', 'twentyfourteen'), get_the_date(_x('Y', 'yearly archives date format', 'twentyfourteen'))); |
|
38 | 38 | |
39 | 39 | else : |
40 | - _e( 'Archives', 'twentyfourteen' ); |
|
40 | + _e('Archives', 'twentyfourteen'); |
|
41 | 41 | |
42 | 42 | endif; |
43 | 43 | ?> |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | |
47 | 47 | <?php |
48 | 48 | // Start the Loop. |
49 | - while ( have_posts() ) : the_post(); |
|
49 | + while (have_posts()) : the_post(); |
|
50 | 50 | |
51 | 51 | /* |
52 | 52 | * Include the post format-specific template for the content. If you want to |
53 | 53 | * use this in a child theme, then include a file called called content-___.php |
54 | 54 | * (where ___ is the post format) and that will be used instead. |
55 | 55 | */ |
56 | - get_template_part( 'content', get_post_format() ); |
|
56 | + get_template_part('content', get_post_format()); |
|
57 | 57 | |
58 | 58 | endwhile; |
59 | 59 | // Previous/next page navigation. |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | else : |
63 | 63 | // If no content, include the "No posts found" template. |
64 | - get_template_part( 'content', 'none' ); |
|
64 | + get_template_part('content', 'none'); |
|
65 | 65 | |
66 | 66 | endif; |
67 | 67 | ?> |
@@ -69,6 +69,6 @@ discard block |
||
69 | 69 | </section><!-- #primary --> |
70 | 70 | |
71 | 71 | <?php |
72 | -get_sidebar( 'content' ); |
|
72 | +get_sidebar('content'); |
|
73 | 73 | get_sidebar(); |
74 | 74 | get_footer(); |
@@ -36,8 +36,10 @@ discard block |
||
36 | 36 | elseif ( is_year() ) : |
37 | 37 | printf( __( 'Yearly Archives: %s', 'twentyfourteen' ), get_the_date( _x( 'Y', 'yearly archives date format', 'twentyfourteen' ) ) ); |
38 | 38 | |
39 | - else : |
|
39 | + else { |
|
40 | + : |
|
40 | 41 | _e( 'Archives', 'twentyfourteen' ); |
42 | + } |
|
41 | 43 | |
42 | 44 | endif; |
43 | 45 | ?> |
@@ -59,9 +61,11 @@ discard block |
||
59 | 61 | // Previous/next page navigation. |
60 | 62 | twentyfourteen_paging_nav(); |
61 | 63 | |
62 | - else : |
|
64 | + else { |
|
65 | + : |
|
63 | 66 | // If no content, include the "No posts found" template. |
64 | 67 | get_template_part( 'content', 'none' ); |
68 | + } |
|
65 | 69 | |
66 | 70 | endif; |
67 | 71 | ?> |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * The template for displaying Author archive pages |
|
4 | - * |
|
5 | - * @link https://codex.wordpress.org/Template_Hierarchy |
|
6 | - * |
|
7 | - * @package WordPress |
|
8 | - * @subpackage Twenty_Fourteen |
|
9 | - * @since Twenty Fourteen 1.0 |
|
10 | - */ |
|
3 | + * The template for displaying Author archive pages |
|
4 | + * |
|
5 | + * @link https://codex.wordpress.org/Template_Hierarchy |
|
6 | + * |
|
7 | + * @package WordPress |
|
8 | + * @subpackage Twenty_Fourteen |
|
9 | + * @since Twenty Fourteen 1.0 |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | get_header(); ?> |
13 | 13 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | <section id="primary" class="content-area"> |
15 | 15 | <div id="content" class="site-content" role="main"> |
16 | 16 | |
17 | - <?php if ( have_posts() ) : ?> |
|
17 | + <?php if (have_posts()) : ?> |
|
18 | 18 | |
19 | 19 | <header class="archive-header"> |
20 | 20 | <h1 class="archive-title"> |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | */ |
29 | 29 | the_post(); |
30 | 30 | |
31 | - printf( __( 'All posts by %s', 'twentyfourteen' ), get_the_author() ); |
|
31 | + printf(__('All posts by %s', 'twentyfourteen'), get_the_author()); |
|
32 | 32 | ?> |
33 | 33 | </h1> |
34 | - <?php if ( get_the_author_meta( 'description' ) ) : ?> |
|
35 | - <div class="author-description"><?php the_author_meta( 'description' ); ?></div> |
|
34 | + <?php if (get_the_author_meta('description')) : ?> |
|
35 | + <div class="author-description"><?php the_author_meta('description'); ?></div> |
|
36 | 36 | <?php endif; ?> |
37 | 37 | </header><!-- .archive-header --> |
38 | 38 | |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | rewind_posts(); |
46 | 46 | |
47 | 47 | // Start the Loop. |
48 | - while ( have_posts() ) : the_post(); |
|
48 | + while (have_posts()) : the_post(); |
|
49 | 49 | |
50 | 50 | /* |
51 | 51 | * Include the post format-specific template for the content. If you want to |
52 | 52 | * use this in a child theme, then include a file called called content-___.php |
53 | 53 | * (where ___ is the post format) and that will be used instead. |
54 | 54 | */ |
55 | - get_template_part( 'content', get_post_format() ); |
|
55 | + get_template_part('content', get_post_format()); |
|
56 | 56 | |
57 | 57 | endwhile; |
58 | 58 | // Previous/next page navigation. |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | else : |
62 | 62 | // If no content, include the "No posts found" template. |
63 | - get_template_part( 'content', 'none' ); |
|
63 | + get_template_part('content', 'none'); |
|
64 | 64 | |
65 | 65 | endif; |
66 | 66 | ?> |
@@ -69,6 +69,6 @@ discard block |
||
69 | 69 | </section><!-- #primary --> |
70 | 70 | |
71 | 71 | <?php |
72 | -get_sidebar( 'content' ); |
|
72 | +get_sidebar('content'); |
|
73 | 73 | get_sidebar(); |
74 | 74 | get_footer(); |
@@ -58,9 +58,11 @@ |
||
58 | 58 | // Previous/next page navigation. |
59 | 59 | twentyfourteen_paging_nav(); |
60 | 60 | |
61 | - else : |
|
61 | + else { |
|
62 | + : |
|
62 | 63 | // If no content, include the "No posts found" template. |
63 | 64 | get_template_part( 'content', 'none' ); |
65 | + } |
|
64 | 66 | |
65 | 67 | endif; |
66 | 68 | ?> |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * The Template for displaying all single posts |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Twenty_Fourteen |
|
7 | - * @since Twenty Fourteen 1.0 |
|
8 | - */ |
|
3 | + * The Template for displaying all single posts |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Twenty_Fourteen |
|
7 | + * @since Twenty Fourteen 1.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | get_header(); ?> |
11 | 11 |
@@ -13,20 +13,20 @@ discard block |
||
13 | 13 | <div id="content" class="site-content" role="main"> |
14 | 14 | <?php |
15 | 15 | // Start the Loop. |
16 | - while ( have_posts() ) : the_post(); |
|
16 | + while (have_posts()) : the_post(); |
|
17 | 17 | |
18 | 18 | /* |
19 | 19 | * Include the post format-specific template for the content. If you want to |
20 | 20 | * use this in a child theme, then include a file called called content-___.php |
21 | 21 | * (where ___ is the post format) and that will be used instead. |
22 | 22 | */ |
23 | - get_template_part( 'content', get_post_format() ); |
|
23 | + get_template_part('content', get_post_format()); |
|
24 | 24 | |
25 | 25 | // Previous/next post navigation. |
26 | 26 | twentyfourteen_post_nav(); |
27 | 27 | |
28 | 28 | // If comments are open or we have at least one comment, load up the comment template. |
29 | - if ( comments_open() || get_comments_number() ) { |
|
29 | + if (comments_open() || get_comments_number()) { |
|
30 | 30 | comments_template(); |
31 | 31 | } |
32 | 32 | endwhile; |
@@ -35,6 +35,6 @@ discard block |
||
35 | 35 | </div><!-- #primary --> |
36 | 36 | |
37 | 37 | <?php |
38 | -get_sidebar( 'content' ); |
|
38 | +get_sidebar('content'); |
|
39 | 39 | get_sidebar(); |
40 | 40 | get_footer(); |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * The template used for displaying page content |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Twenty_Fourteen |
|
7 | - * @since Twenty Fourteen 1.0 |
|
8 | - */ |
|
3 | + * The template used for displaying page content |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Twenty_Fourteen |
|
7 | + * @since Twenty Fourteen 1.0 |
|
8 | + */ |
|
9 | 9 | ?> |
10 | 10 | |
11 | 11 | <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> |
@@ -12,20 +12,20 @@ |
||
12 | 12 | <?php |
13 | 13 | // Page thumbnail and title. |
14 | 14 | twentyfourteen_post_thumbnail(); |
15 | - the_title( '<header class="entry-header"><h1 class="entry-title">', '</h1></header><!-- .entry-header -->' ); |
|
15 | + the_title('<header class="entry-header"><h1 class="entry-title">', '</h1></header><!-- .entry-header -->'); |
|
16 | 16 | ?> |
17 | 17 | |
18 | 18 | <div class="entry-content"> |
19 | 19 | <?php |
20 | 20 | the_content(); |
21 | - wp_link_pages( array( |
|
22 | - 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfourteen' ) . '</span>', |
|
21 | + wp_link_pages(array( |
|
22 | + 'before' => '<div class="page-links"><span class="page-links-title">'.__('Pages:', 'twentyfourteen').'</span>', |
|
23 | 23 | 'after' => '</div>', |
24 | 24 | 'link_before' => '<span>', |
25 | 25 | 'link_after' => '</span>', |
26 | - ) ); |
|
26 | + )); |
|
27 | 27 | |
28 | - edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' ); |
|
28 | + edit_post_link(__('Edit', 'twentyfourteen'), '<span class="edit-link">', '</span>'); |
|
29 | 29 | ?> |
30 | 30 | </div><!-- .entry-content --> |
31 | 31 | </article><!-- #post-## --> |