author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Twenty Twelve functions and definitions |
|
4 |
* |
|
5 |
* Sets up the theme and provides some helper functions, which are used |
|
6 |
* in the theme as custom template tags. Others are attached to action and |
|
7 |
* filter hooks in WordPress to change core functionality. |
|
8 |
* |
|
5 | 9 |
* When using a child theme (see https://codex.wordpress.org/Theme_Development and |
10 |
* https://codex.wordpress.org/Child_Themes), you can override certain functions |
|
0 | 11 |
* (those wrapped in a function_exists() call) by defining them first in your child theme's |
12 |
* functions.php file. The child theme's functions.php file is included before the parent |
|
13 |
* theme's file, so the child theme functions would be used. |
|
14 |
* |
|
15 |
* Functions that are not pluggable (not wrapped in function_exists()) are instead attached |
|
16 |
* to a filter or action hook. |
|
17 |
* |
|
5 | 18 |
* For more information on hooks, actions, and filters, @link https://codex.wordpress.org/Plugin_API |
0 | 19 |
* |
20 |
* @package WordPress |
|
21 |
* @subpackage Twenty_Twelve |
|
22 |
* @since Twenty Twelve 1.0 |
|
23 |
*/ |
|
24 |
||
25 |
// Set up the content width value based on the theme's design and stylesheet. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
if ( ! isset( $content_width ) ) { |
0 | 27 |
$content_width = 625; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
} |
0 | 29 |
|
30 |
/** |
|
31 |
* Twenty Twelve setup. |
|
32 |
* |
|
33 |
* Sets up theme defaults and registers the various WordPress features that |
|
34 |
* Twenty Twelve supports. |
|
35 |
* |
|
36 |
* @uses load_theme_textdomain() For translation/localization support. |
|
37 |
* @uses add_editor_style() To add a Visual Editor stylesheet. |
|
38 |
* @uses add_theme_support() To add support for post thumbnails, automatic feed links, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
* custom background, and post formats. |
0 | 40 |
* @uses register_nav_menu() To add support for navigation menus. |
41 |
* @uses set_post_thumbnail_size() To set a custom post thumbnail size. |
|
42 |
* |
|
43 |
* @since Twenty Twelve 1.0 |
|
44 |
*/ |
|
45 |
function twentytwelve_setup() { |
|
46 |
/* |
|
47 |
* Makes Twenty Twelve available for translation. |
|
48 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
* Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentytwelve |
0 | 50 |
* If you're building a theme based on Twenty Twelve, use a find and replace |
51 |
* to change 'twentytwelve' to the name of your theme in all the template files. |
|
52 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
load_theme_textdomain( 'twentytwelve' ); |
0 | 54 |
|
55 |
// This theme styles the visual editor with editor-style.css to match the theme style. |
|
56 |
add_editor_style(); |
|
57 |
||
58 |
// Adds RSS feed links to <head> for posts and comments. |
|
59 |
add_theme_support( 'automatic-feed-links' ); |
|
60 |
||
61 |
// This theme supports a variety of post formats. |
|
62 |
add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote', 'status' ) ); |
|
63 |
||
64 |
// This theme uses wp_nav_menu() in one location. |
|
65 |
register_nav_menu( 'primary', __( 'Primary Menu', 'twentytwelve' ) ); |
|
66 |
||
67 |
/* |
|
68 |
* This theme supports custom background color and image, |
|
69 |
* and here we also set up the default background color. |
|
70 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
add_theme_support( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
'custom-background', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
'default-color' => 'e6e6e6', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
); |
0 | 76 |
|
77 |
// This theme uses a custom image size for featured images, displayed on "standard" posts. |
|
78 |
add_theme_support( 'post-thumbnails' ); |
|
79 |
set_post_thumbnail_size( 624, 9999 ); // Unlimited height, soft crop |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
// Indicate widget sidebars can use selective refresh in the Customizer. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
add_theme_support( 'customize-selective-refresh-widgets' ); |
0 | 83 |
} |
84 |
add_action( 'after_setup_theme', 'twentytwelve_setup' ); |
|
85 |
||
86 |
/** |
|
87 |
* Add support for a custom header image. |
|
88 |
*/ |
|
89 |
require( get_template_directory() . '/inc/custom-header.php' ); |
|
90 |
||
91 |
/** |
|
92 |
* Return the Google font stylesheet URL if available. |
|
93 |
* |
|
94 |
* The use of Open Sans by default is localized. For languages that use |
|
95 |
* characters not supported by the font, the font can be disabled. |
|
96 |
* |
|
97 |
* @since Twenty Twelve 1.2 |
|
98 |
* |
|
99 |
* @return string Font stylesheet or empty string if disabled. |
|
100 |
*/ |
|
101 |
function twentytwelve_get_font_url() { |
|
102 |
$font_url = ''; |
|
103 |
||
104 |
/* translators: If there are characters in your language that are not supported |
|
105 |
* by Open Sans, translate this to 'off'. Do not translate into your own language. |
|
106 |
*/ |
|
107 |
if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'twentytwelve' ) ) { |
|
108 |
$subsets = 'latin,latin-ext'; |
|
109 |
||
110 |
/* translators: To add an additional Open Sans character subset specific to your language, |
|
111 |
* translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. |
|
112 |
*/ |
|
113 |
$subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'twentytwelve' ); |
|
114 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
if ( 'cyrillic' == $subset ) { |
0 | 116 |
$subsets .= ',cyrillic,cyrillic-ext'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
117 |
} elseif ( 'greek' == $subset ) { |
0 | 118 |
$subsets .= ',greek,greek-ext'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
119 |
} elseif ( 'vietnamese' == $subset ) { |
0 | 120 |
$subsets .= ',vietnamese'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
} |
0 | 122 |
|
123 |
$query_args = array( |
|
124 |
'family' => 'Open+Sans:400italic,700italic,400,700', |
|
125 |
'subset' => $subsets, |
|
126 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
$font_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); |
0 | 128 |
} |
129 |
||
130 |
return $font_url; |
|
131 |
} |
|
132 |
||
133 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
* Enqueue scripts and styles for front end. |
0 | 135 |
* |
136 |
* @since Twenty Twelve 1.0 |
|
137 |
*/ |
|
138 |
function twentytwelve_scripts_styles() { |
|
139 |
global $wp_styles; |
|
140 |
||
141 |
/* |
|
142 |
* Adds JavaScript to pages with the comment form to support |
|
143 |
* sites with threaded comments (when in use). |
|
144 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { |
0 | 146 |
wp_enqueue_script( 'comment-reply' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
} |
0 | 148 |
|
149 |
// Adds JavaScript for handling the navigation menu hide-and-show behavior. |
|
5 | 150 |
wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'jquery' ), '20140711', true ); |
0 | 151 |
|
152 |
$font_url = twentytwelve_get_font_url(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
if ( ! empty( $font_url ) ) { |
0 | 154 |
wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), null ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
} |
0 | 156 |
|
157 |
// Loads our main stylesheet. |
|
158 |
wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() ); |
|
159 |
||
160 |
// Loads the Internet Explorer specific stylesheet. |
|
161 |
wp_enqueue_style( 'twentytwelve-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentytwelve-style' ), '20121010' ); |
|
162 |
$wp_styles->add_data( 'twentytwelve-ie', 'conditional', 'lt IE 9' ); |
|
163 |
} |
|
164 |
add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' ); |
|
165 |
||
166 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
167 |
* Add preconnect for Google Fonts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
169 |
* @since Twenty Twelve 2.2 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
* @param array $urls URLs to print for resource hints. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
* @param string $relation_type The relation type the URLs are printed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
* @return array URLs to print for resource hints. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
174 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
function twentytwelve_resource_hints( $urls, $relation_type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) && 'preconnect' === $relation_type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
178 |
$urls[] = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
'href' => 'https://fonts.gstatic.com', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
'crossorigin', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
183 |
$urls[] = 'https://fonts.gstatic.com'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
184 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
187 |
return $urls; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
189 |
add_filter( 'wp_resource_hints', 'twentytwelve_resource_hints', 10, 2 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
191 |
/** |
0 | 192 |
* Filter TinyMCE CSS path to include Google Fonts. |
193 |
* |
|
194 |
* Adds additional stylesheets to the TinyMCE editor if needed. |
|
195 |
* |
|
196 |
* @uses twentytwelve_get_font_url() To get the Google Font stylesheet URL. |
|
197 |
* |
|
198 |
* @since Twenty Twelve 1.2 |
|
199 |
* |
|
200 |
* @param string $mce_css CSS path to load in TinyMCE. |
|
201 |
* @return string Filtered CSS path. |
|
202 |
*/ |
|
203 |
function twentytwelve_mce_css( $mce_css ) { |
|
204 |
$font_url = twentytwelve_get_font_url(); |
|
205 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
206 |
if ( empty( $font_url ) ) { |
0 | 207 |
return $mce_css; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
208 |
} |
0 | 209 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
if ( ! empty( $mce_css ) ) { |
0 | 211 |
$mce_css .= ','; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
} |
0 | 213 |
|
214 |
$mce_css .= esc_url_raw( str_replace( ',', '%2C', $font_url ) ); |
|
215 |
||
216 |
return $mce_css; |
|
217 |
} |
|
218 |
add_filter( 'mce_css', 'twentytwelve_mce_css' ); |
|
219 |
||
220 |
/** |
|
221 |
* Filter the page title. |
|
222 |
* |
|
223 |
* Creates a nicely formatted and more specific title element text |
|
224 |
* for output in head of document, based on current view. |
|
225 |
* |
|
226 |
* @since Twenty Twelve 1.0 |
|
227 |
* |
|
228 |
* @param string $title Default title text for current view. |
|
229 |
* @param string $sep Optional separator. |
|
230 |
* @return string Filtered title. |
|
231 |
*/ |
|
232 |
function twentytwelve_wp_title( $title, $sep ) { |
|
233 |
global $paged, $page; |
|
234 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
235 |
if ( is_feed() ) { |
0 | 236 |
return $title; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
} |
0 | 238 |
|
239 |
// Add the site name. |
|
5 | 240 |
$title .= get_bloginfo( 'name', 'display' ); |
0 | 241 |
|
242 |
// Add the site description for the home/front page. |
|
243 |
$site_description = get_bloginfo( 'description', 'display' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
244 |
if ( $site_description && ( is_home() || is_front_page() ) ) { |
0 | 245 |
$title = "$title $sep $site_description"; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
} |
0 | 247 |
|
248 |
// Add a page number if necessary. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { |
0 | 250 |
$title = "$title $sep " . sprintf( __( 'Page %s', 'twentytwelve' ), max( $paged, $page ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
} |
0 | 252 |
|
253 |
return $title; |
|
254 |
} |
|
255 |
add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 ); |
|
256 |
||
257 |
/** |
|
258 |
* Filter the page menu arguments. |
|
259 |
* |
|
260 |
* Makes our wp_nav_menu() fallback -- wp_page_menu() -- show a home link. |
|
261 |
* |
|
262 |
* @since Twenty Twelve 1.0 |
|
263 |
*/ |
|
264 |
function twentytwelve_page_menu_args( $args ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
if ( ! isset( $args['show_home'] ) ) { |
0 | 266 |
$args['show_home'] = true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
} |
0 | 268 |
return $args; |
269 |
} |
|
270 |
add_filter( 'wp_page_menu_args', 'twentytwelve_page_menu_args' ); |
|
271 |
||
272 |
/** |
|
273 |
* Register sidebars. |
|
274 |
* |
|
275 |
* Registers our main widget area and the front page widget areas. |
|
276 |
* |
|
277 |
* @since Twenty Twelve 1.0 |
|
278 |
*/ |
|
279 |
function twentytwelve_widgets_init() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
register_sidebar( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
281 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
282 |
'name' => __( 'Main Sidebar', 'twentytwelve' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
283 |
'id' => 'sidebar-1', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
284 |
'description' => __( 'Appears on posts and pages except the optional Front Page template, which has its own widgets', 'twentytwelve' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
'after_widget' => '</aside>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
'before_title' => '<h3 class="widget-title">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
'after_title' => '</h3>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
); |
0 | 291 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
register_sidebar( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
'name' => __( 'First Front Page Widget Area', 'twentytwelve' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
'id' => 'sidebar-2', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
296 |
'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
'after_widget' => '</aside>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
'before_title' => '<h3 class="widget-title">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
300 |
'after_title' => '</h3>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
); |
0 | 303 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
register_sidebar( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
'name' => __( 'Second Front Page Widget Area', 'twentytwelve' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
'id' => 'sidebar-3', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
'after_widget' => '</aside>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
'before_title' => '<h3 class="widget-title">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
'after_title' => '</h3>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
); |
0 | 315 |
} |
316 |
add_action( 'widgets_init', 'twentytwelve_widgets_init' ); |
|
317 |
||
318 |
if ( ! function_exists( 'twentytwelve_content_nav' ) ) : |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
* Displays navigation to next/previous pages when applicable. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
* @since Twenty Twelve 1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
function twentytwelve_content_nav( $html_id ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
global $wp_query; |
0 | 326 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
if ( $wp_query->max_num_pages > 1 ) : ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
<nav id="<?php echo esc_attr( $html_id ); ?>" class="navigation" role="navigation"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentytwelve' ) ); ?></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
</nav><!-- .navigation --> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
endif; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
} |
0 | 336 |
endif; |
337 |
||
338 |
if ( ! function_exists( 'twentytwelve_comment' ) ) : |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
* Template for comments and pingbacks. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
* To override this walker in a child theme without modifying the comments template |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
* simply create your own twentytwelve_comment(), and that function will be used instead. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
* Used as a callback by wp_list_comments() for displaying the comments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
* @since Twenty Twelve 1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
function twentytwelve_comment( $comment, $args, $depth ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
$GLOBALS['comment'] = $comment; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
switch ( $comment->comment_type ) : |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
case 'pingback': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
case 'trackback': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
// Display trackbacks differently than normal comments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>"> |
0 | 357 |
<p><?php _e( 'Pingback:', 'twentytwelve' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?></p> |
358 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
360 |
default: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
// Proceed with normal comments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
362 |
global $post; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
363 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
364 |
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> |
0 | 365 |
<article id="comment-<?php comment_ID(); ?>" class="comment"> |
366 |
<header class="comment-meta comment-author vcard"> |
|
367 |
<?php |
|
368 |
echo get_avatar( $comment, 44 ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
'<cite><b class="fn">%1$s</b> %2$s</cite>', |
0 | 371 |
get_comment_author_link(), |
372 |
// If current post author is also comment author, make it known visually. |
|
373 |
( $comment->user_id === $post->post_author ) ? '<span>' . __( 'Post author', 'twentytwelve' ) . '</span>' : '' |
|
374 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
376 |
'<a href="%1$s"><time datetime="%2$s">%3$s</time></a>', |
0 | 377 |
esc_url( get_comment_link( $comment->comment_ID ) ), |
378 |
get_comment_time( 'c' ), |
|
379 |
/* translators: 1: date, 2: time */ |
|
380 |
sprintf( __( '%1$s at %2$s', 'twentytwelve' ), get_comment_date(), get_comment_time() ) |
|
381 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
</header><!-- .comment-meta --> |
0 | 384 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
<?php if ( '0' == $comment->comment_approved ) : ?> |
0 | 386 |
<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentytwelve' ); ?></p> |
387 |
<?php endif; ?> |
|
388 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
<section class="comment-content comment"> |
0 | 390 |
<?php comment_text(); ?> |
391 |
<?php edit_comment_link( __( 'Edit', 'twentytwelve' ), '<p class="edit-link">', '</p>' ); ?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
392 |
</section><!-- .comment-content --> |
0 | 393 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
<div class="reply"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
comment_reply_link( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
array_merge( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
$args, array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
'reply_text' => __( 'Reply', 'twentytwelve' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
'after' => ' <span>↓</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
'depth' => $depth, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
'max_depth' => $args['max_depth'], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
403 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
</div><!-- .reply --> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
</article><!-- #comment-## --> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
410 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
endswitch; // end comment_type check |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
} |
0 | 413 |
endif; |
414 |
||
415 |
if ( ! function_exists( 'twentytwelve_entry_meta' ) ) : |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
416 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
* Set up post entry meta. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
* Prints HTML with meta information for current post: categories, tags, permalink, author, and date. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
* Create your own twentytwelve_entry_meta() to override in a child theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
422 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
* @since Twenty Twelve 1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
function twentytwelve_entry_meta() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
// Translators: used between list items, there is a space after the comma. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) ); |
0 | 428 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
// Translators: used between list items, there is a space after the comma. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) ); |
0 | 431 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
$date = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
433 |
'<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
esc_url( get_permalink() ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
esc_attr( get_the_time() ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
esc_attr( get_the_date( 'c' ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
437 |
esc_html( get_the_date() ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
); |
0 | 439 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
$author = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
'<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
443 |
esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
get_the_author() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
); |
0 | 446 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
if ( $tag_list ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
449 |
$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
} elseif ( $categories_list ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
451 |
$utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
$utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
454 |
} |
0 | 455 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
$utility_text, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
$categories_list, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
$tag_list, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
$date, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
$author |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
} |
0 | 464 |
endif; |
465 |
||
466 |
/** |
|
467 |
* Extend the default WordPress body classes. |
|
468 |
* |
|
469 |
* Extends the default WordPress body class to denote: |
|
470 |
* 1. Using a full-width layout, when no active widgets in the sidebar |
|
471 |
* or full-width template. |
|
472 |
* 2. Front Page template: thumbnail in use and number of sidebars for |
|
473 |
* widget areas. |
|
474 |
* 3. White or empty background color to change the layout and spacing. |
|
475 |
* 4. Custom fonts enabled. |
|
476 |
* 5. Single or multiple authors. |
|
477 |
* |
|
478 |
* @since Twenty Twelve 1.0 |
|
479 |
* |
|
480 |
* @param array $classes Existing class values. |
|
481 |
* @return array Filtered class values. |
|
482 |
*/ |
|
483 |
function twentytwelve_body_class( $classes ) { |
|
484 |
$background_color = get_background_color(); |
|
485 |
$background_image = get_background_image(); |
|
486 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
if ( ! is_active_sidebar( 'sidebar-1' ) || is_page_template( 'page-templates/full-width.php' ) ) { |
0 | 488 |
$classes[] = 'full-width'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
} |
0 | 490 |
|
491 |
if ( is_page_template( 'page-templates/front-page.php' ) ) { |
|
492 |
$classes[] = 'template-front-page'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
493 |
if ( has_post_thumbnail() ) { |
0 | 494 |
$classes[] = 'has-post-thumbnail'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
495 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
496 |
if ( is_active_sidebar( 'sidebar-2' ) && is_active_sidebar( 'sidebar-3' ) ) { |
0 | 497 |
$classes[] = 'two-sidebars'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
498 |
} |
0 | 499 |
} |
500 |
||
501 |
if ( empty( $background_image ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
502 |
if ( empty( $background_color ) ) { |
0 | 503 |
$classes[] = 'custom-background-empty'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
504 |
} elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) ) { |
0 | 505 |
$classes[] = 'custom-background-white'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
506 |
} |
0 | 507 |
} |
508 |
||
509 |
// Enable custom font class only if the font CSS is queued to load. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
510 |
if ( wp_style_is( 'twentytwelve-fonts', 'queue' ) ) { |
0 | 511 |
$classes[] = 'custom-font-enabled'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
} |
0 | 513 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
514 |
if ( ! is_multi_author() ) { |
0 | 515 |
$classes[] = 'single-author'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
516 |
} |
0 | 517 |
|
518 |
return $classes; |
|
519 |
} |
|
520 |
add_filter( 'body_class', 'twentytwelve_body_class' ); |
|
521 |
||
522 |
/** |
|
523 |
* Adjust content width in certain contexts. |
|
524 |
* |
|
525 |
* Adjusts content_width value for full-width and single image attachment |
|
526 |
* templates, and when there are no active widgets in the sidebar. |
|
527 |
* |
|
528 |
* @since Twenty Twelve 1.0 |
|
529 |
*/ |
|
530 |
function twentytwelve_content_width() { |
|
531 |
if ( is_page_template( 'page-templates/full-width.php' ) || is_attachment() || ! is_active_sidebar( 'sidebar-1' ) ) { |
|
532 |
global $content_width; |
|
533 |
$content_width = 960; |
|
534 |
} |
|
535 |
} |
|
536 |
add_action( 'template_redirect', 'twentytwelve_content_width' ); |
|
537 |
||
538 |
/** |
|
539 |
* Register postMessage support. |
|
540 |
* |
|
541 |
* Add postMessage support for site title and description for the Customizer. |
|
542 |
* |
|
543 |
* @since Twenty Twelve 1.0 |
|
544 |
* |
|
545 |
* @param WP_Customize_Manager $wp_customize Customizer object. |
|
546 |
*/ |
|
547 |
function twentytwelve_customize_register( $wp_customize ) { |
|
548 |
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; |
|
549 |
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; |
|
550 |
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
551 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
552 |
if ( isset( $wp_customize->selective_refresh ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
553 |
$wp_customize->selective_refresh->add_partial( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
554 |
'blogname', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
555 |
'selector' => '.site-title > a', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
556 |
'container_inclusive' => false, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
557 |
'render_callback' => 'twentytwelve_customize_partial_blogname', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
558 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
559 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
560 |
$wp_customize->selective_refresh->add_partial( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
561 |
'blogdescription', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
562 |
'selector' => '.site-description', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
563 |
'container_inclusive' => false, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
564 |
'render_callback' => 'twentytwelve_customize_partial_blogdescription', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
565 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
566 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
567 |
} |
0 | 568 |
} |
569 |
add_action( 'customize_register', 'twentytwelve_customize_register' ); |
|
570 |
||
571 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
572 |
* Render the site title for the selective refresh partial. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
573 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
574 |
* @since Twenty Twelve 2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
575 |
* @see twentytwelve_customize_register() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
577 |
* @return void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
579 |
function twentytwelve_customize_partial_blogname() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
580 |
bloginfo( 'name' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
581 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
583 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
584 |
* Render the site tagline for the selective refresh partial. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
586 |
* @since Twenty Twelve 2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
587 |
* @see twentytwelve_customize_register() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
588 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
589 |
* @return void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
590 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
591 |
function twentytwelve_customize_partial_blogdescription() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
592 |
bloginfo( 'description' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
593 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
595 |
/** |
0 | 596 |
* Enqueue Javascript postMessage handlers for the Customizer. |
597 |
* |
|
598 |
* Binds JS handlers to make the Customizer preview reload changes asynchronously. |
|
599 |
* |
|
600 |
* @since Twenty Twelve 1.0 |
|
601 |
*/ |
|
602 |
function twentytwelve_customize_preview_js() { |
|
5 | 603 |
wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20141120', true ); |
0 | 604 |
} |
605 |
add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
* Modifies tag cloud widget arguments to display all tags in the same font size |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
* and use list format for better accessibility. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
611 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
612 |
* @since Twenty Twelve 2.4 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
* @param array $args Arguments for tag cloud widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
* @return array The filtered arguments for tag cloud widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
616 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
function twentytwelve_widget_tag_cloud_args( $args ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
$args['largest'] = 22; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
$args['smallest'] = 8; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
620 |
$args['unit'] = 'pt'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
621 |
$args['format'] = 'list'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
622 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
return $args; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
624 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
add_filter( 'widget_tag_cloud_args', 'twentytwelve_widget_tag_cloud_args' ); |