author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 10 | 372f2766ea20 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Twenty Thirteen functions and definitions |
|
4 |
* |
|
5 |
* Sets up the theme and provides some helper functions, which are used in the |
|
6 |
* theme as custom template tags. Others are attached to action and filter |
|
7 |
* hooks in WordPress to change core functionality. |
|
8 |
* |
|
5 | 9 |
* When using a child theme (see https://codex.wordpress.org/Theme_Development |
10 |
* and https://codex.wordpress.org/Child_Themes), you can override certain |
|
0 | 11 |
* functions (those wrapped in a function_exists() call) by defining them first |
12 |
* in your child theme's functions.php file. The child theme's functions.php |
|
13 |
* file is included before the parent theme's file, so the child theme |
|
14 |
* functions would be used. |
|
15 |
* |
|
16 |
* Functions that are not pluggable (not wrapped in function_exists()) are |
|
17 |
* instead attached to a filter or action hook. |
|
18 |
* |
|
5 | 19 |
* For more information on hooks, actions, and filters, @link https://codex.wordpress.org/Plugin_API |
0 | 20 |
* |
21 |
* @package WordPress |
|
22 |
* @subpackage Twenty_Thirteen |
|
23 |
* @since Twenty Thirteen 1.0 |
|
24 |
*/ |
|
25 |
||
26 |
/* |
|
27 |
* Set up the content width value based on the theme's design. |
|
28 |
* |
|
29 |
* @see twentythirteen_content_width() for template-specific adjustments. |
|
30 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
if ( ! isset( $content_width ) ) { |
0 | 32 |
$content_width = 604; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
} |
0 | 34 |
|
35 |
/** |
|
36 |
* Add support for a custom header image. |
|
37 |
*/ |
|
38 |
require get_template_directory() . '/inc/custom-header.php'; |
|
39 |
||
40 |
/** |
|
41 |
* Twenty Thirteen only works in WordPress 3.6 or later. |
|
42 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
if ( version_compare( $GLOBALS['wp_version'], '3.6-alpha', '<' ) ) { |
0 | 44 |
require get_template_directory() . '/inc/back-compat.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
} |
0 | 46 |
|
47 |
/** |
|
48 |
* Twenty Thirteen setup. |
|
49 |
* |
|
50 |
* Sets up theme defaults and registers the various WordPress features that |
|
51 |
* Twenty Thirteen supports. |
|
52 |
* |
|
53 |
* @uses load_theme_textdomain() For translation/localization support. |
|
54 |
* @uses add_editor_style() To add Visual Editor stylesheets. |
|
55 |
* @uses add_theme_support() To add support for automatic feed links, post |
|
56 |
* formats, and post thumbnails. |
|
57 |
* @uses register_nav_menu() To add support for a navigation menu. |
|
58 |
* @uses set_post_thumbnail_size() To set a custom post thumbnail size. |
|
59 |
* |
|
60 |
* @since Twenty Thirteen 1.0 |
|
61 |
*/ |
|
62 |
function twentythirteen_setup() { |
|
63 |
/* |
|
64 |
* Makes Twenty Thirteen available for translation. |
|
65 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
* Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentythirteen |
0 | 67 |
* If you're building a theme based on Twenty Thirteen, use a find and |
68 |
* replace to change 'twentythirteen' to the name of your theme in all |
|
69 |
* template files. |
|
70 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
load_theme_textdomain( 'twentythirteen' ); |
0 | 72 |
|
73 |
/* |
|
74 |
* This theme styles the visual editor to resemble the theme style, |
|
75 |
* specifically font, colors, icons, and column width. |
|
76 |
*/ |
|
5 | 77 |
add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css', twentythirteen_fonts_url() ) ); |
0 | 78 |
|
79 |
// Adds RSS feed links to <head> for posts and comments. |
|
80 |
add_theme_support( 'automatic-feed-links' ); |
|
81 |
||
82 |
/* |
|
83 |
* Switches default core markup for search form, comment form, |
|
84 |
* and comments to output valid HTML5. |
|
85 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
add_theme_support( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
'html5', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
'search-form', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
'comment-form', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
'comment-list', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
'gallery', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
'caption', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
); |
0 | 95 |
|
96 |
/* |
|
97 |
* This theme supports all available post formats by default. |
|
5 | 98 |
* See https://codex.wordpress.org/Post_Formats |
0 | 99 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
add_theme_support( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
'post-formats', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
'aside', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
'audio', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
'chat', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
'gallery', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
'image', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
'link', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
108 |
'quote', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
109 |
'status', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
'video', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
112 |
); |
0 | 113 |
|
114 |
// This theme uses wp_nav_menu() in one location. |
|
115 |
register_nav_menu( 'primary', __( 'Navigation Menu', 'twentythirteen' ) ); |
|
116 |
||
117 |
/* |
|
118 |
* This theme uses a custom image size for featured images, displayed on |
|
119 |
* "standard" posts and pages. |
|
120 |
*/ |
|
121 |
add_theme_support( 'post-thumbnails' ); |
|
122 |
set_post_thumbnail_size( 604, 270, true ); |
|
123 |
||
124 |
// This theme uses its own gallery styles. |
|
125 |
add_filter( 'use_default_gallery_style', '__return_false' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
126 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
// 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
|
128 |
add_theme_support( 'customize-selective-refresh-widgets' ); |
0 | 129 |
} |
130 |
add_action( 'after_setup_theme', 'twentythirteen_setup' ); |
|
131 |
||
132 |
/** |
|
133 |
* Return the Google font stylesheet URL, if available. |
|
134 |
* |
|
135 |
* The use of Source Sans Pro and Bitter by default is localized. For languages |
|
136 |
* that use characters not supported by the font, the font can be disabled. |
|
137 |
* |
|
138 |
* @since Twenty Thirteen 1.0 |
|
139 |
* |
|
140 |
* @return string Font stylesheet or empty string if disabled. |
|
141 |
*/ |
|
142 |
function twentythirteen_fonts_url() { |
|
143 |
$fonts_url = ''; |
|
144 |
||
145 |
/* Translators: If there are characters in your language that are not |
|
146 |
* supported by Source Sans Pro, translate this to 'off'. Do not translate |
|
147 |
* into your own language. |
|
148 |
*/ |
|
149 |
$source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'twentythirteen' ); |
|
150 |
||
151 |
/* Translators: If there are characters in your language that are not |
|
152 |
* supported by Bitter, translate this to 'off'. Do not translate into your |
|
153 |
* own language. |
|
154 |
*/ |
|
155 |
$bitter = _x( 'on', 'Bitter font: on or off', 'twentythirteen' ); |
|
156 |
||
157 |
if ( 'off' !== $source_sans_pro || 'off' !== $bitter ) { |
|
158 |
$font_families = array(); |
|
159 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
if ( 'off' !== $source_sans_pro ) { |
0 | 161 |
$font_families[] = 'Source Sans Pro:300,400,700,300italic,400italic,700italic'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
162 |
} |
0 | 163 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
if ( 'off' !== $bitter ) { |
0 | 165 |
$font_families[] = 'Bitter:400,700'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
} |
0 | 167 |
|
168 |
$query_args = array( |
|
169 |
'family' => urlencode( implode( '|', $font_families ) ), |
|
170 |
'subset' => urlencode( 'latin,latin-ext' ), |
|
171 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); |
0 | 173 |
} |
174 |
||
175 |
return $fonts_url; |
|
176 |
} |
|
177 |
||
178 |
/** |
|
179 |
* Enqueue scripts and styles for the front end. |
|
180 |
* |
|
181 |
* @since Twenty Thirteen 1.0 |
|
182 |
*/ |
|
183 |
function twentythirteen_scripts_styles() { |
|
184 |
/* |
|
185 |
* Adds JavaScript to pages with the comment form to support |
|
186 |
* sites with threaded comments (when in use). |
|
187 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { |
0 | 189 |
wp_enqueue_script( 'comment-reply' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
} |
0 | 191 |
|
192 |
// Adds Masonry to handle vertical alignment of footer widgets. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
if ( is_active_sidebar( 'sidebar-1' ) ) { |
0 | 194 |
wp_enqueue_script( 'jquery-masonry' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
} |
0 | 196 |
|
197 |
// Loads JavaScript file with functionality specific to Twenty Thirteen. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20160717', true ); |
0 | 199 |
|
200 |
// Add Source Sans Pro and Bitter fonts, used in the main stylesheet. |
|
201 |
wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null ); |
|
202 |
||
203 |
// Add Genericons font, used in the main stylesheet. |
|
5 | 204 |
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.03' ); |
0 | 205 |
|
206 |
// Loads our main stylesheet. |
|
207 |
wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri(), array(), '2013-07-18' ); |
|
208 |
||
209 |
// Loads the Internet Explorer specific stylesheet. |
|
210 |
wp_enqueue_style( 'twentythirteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentythirteen-style' ), '2013-07-18' ); |
|
211 |
wp_style_add_data( 'twentythirteen-ie', 'conditional', 'lt IE 9' ); |
|
212 |
} |
|
213 |
add_action( 'wp_enqueue_scripts', 'twentythirteen_scripts_styles' ); |
|
214 |
||
215 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
216 |
* Add preconnect for Google Fonts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
217 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
* @since Twenty Thirteen 2.1 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
* @param array $urls URLs to print for resource hints. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
221 |
* @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
|
222 |
* @return array URLs to print for resource hints. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
223 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
224 |
function twentythirteen_resource_hints( $urls, $relation_type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
if ( wp_style_is( 'twentythirteen-fonts', 'queue' ) && 'preconnect' === $relation_type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
226 |
if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
227 |
$urls[] = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
228 |
'href' => 'https://fonts.gstatic.com', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
229 |
'crossorigin', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
230 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
231 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
232 |
$urls[] = 'https://fonts.gstatic.com'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
233 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
234 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
235 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
236 |
return $urls; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
238 |
add_filter( 'wp_resource_hints', 'twentythirteen_resource_hints', 10, 2 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
240 |
/** |
0 | 241 |
* Filter the page title. |
242 |
* |
|
243 |
* Creates a nicely formatted and more specific title element text for output |
|
244 |
* in head of document, based on current view. |
|
245 |
* |
|
246 |
* @since Twenty Thirteen 1.0 |
|
247 |
* |
|
248 |
* @param string $title Default title text for current view. |
|
249 |
* @param string $sep Optional separator. |
|
250 |
* @return string The filtered title. |
|
251 |
*/ |
|
252 |
function twentythirteen_wp_title( $title, $sep ) { |
|
253 |
global $paged, $page; |
|
254 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
if ( is_feed() ) { |
0 | 256 |
return $title; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
} |
0 | 258 |
|
259 |
// Add the site name. |
|
5 | 260 |
$title .= get_bloginfo( 'name', 'display' ); |
0 | 261 |
|
262 |
// Add the site description for the home/front page. |
|
263 |
$site_description = get_bloginfo( 'description', 'display' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
if ( $site_description && ( is_home() || is_front_page() ) ) { |
0 | 265 |
$title = "$title $sep $site_description"; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
} |
0 | 267 |
|
268 |
// Add a page number if necessary. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { |
0 | 270 |
$title = "$title $sep " . sprintf( __( 'Page %s', 'twentythirteen' ), max( $paged, $page ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
} |
0 | 272 |
|
273 |
return $title; |
|
274 |
} |
|
275 |
add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 ); |
|
276 |
||
277 |
/** |
|
278 |
* Register two widget areas. |
|
279 |
* |
|
280 |
* @since Twenty Thirteen 1.0 |
|
281 |
*/ |
|
282 |
function twentythirteen_widgets_init() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
283 |
register_sidebar( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
284 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
'name' => __( 'Main Widget Area', 'twentythirteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
'id' => 'sidebar-1', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
'description' => __( 'Appears in the footer section of the site.', 'twentythirteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
'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
|
289 |
'after_widget' => '</aside>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
'before_title' => '<h3 class="widget-title">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
'after_title' => '</h3>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
); |
0 | 294 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
register_sidebar( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
296 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
'name' => __( 'Secondary Widget Area', 'twentythirteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
'id' => 'sidebar-2', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
'description' => __( 'Appears on posts and pages in the sidebar.', 'twentythirteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
300 |
'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
|
301 |
'after_widget' => '</aside>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
'before_title' => '<h3 class="widget-title">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
'after_title' => '</h3>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
); |
0 | 306 |
} |
307 |
add_action( 'widgets_init', 'twentythirteen_widgets_init' ); |
|
308 |
||
309 |
if ( ! function_exists( 'twentythirteen_paging_nav' ) ) : |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
* Display navigation to next/previous set of posts when applicable. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
* @since Twenty Thirteen 1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
function twentythirteen_paging_nav() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
global $wp_query; |
0 | 317 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
// Don't print empty markup if there's only one page. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
if ( $wp_query->max_num_pages < 2 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
return; |
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 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
<nav class="navigation paging-navigation" role="navigation"> |
0 | 324 |
<h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentythirteen' ); ?></h1> |
325 |
<div class="nav-links"> |
|
326 |
||
327 |
<?php if ( get_next_posts_link() ) : ?> |
|
328 |
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentythirteen' ) ); ?></div> |
|
329 |
<?php endif; ?> |
|
330 |
||
331 |
<?php if ( get_previous_posts_link() ) : ?> |
|
332 |
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentythirteen' ) ); ?></div> |
|
333 |
<?php endif; ?> |
|
334 |
||
335 |
</div><!-- .nav-links --> |
|
336 |
</nav><!-- .navigation --> |
|
337 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
} |
0 | 339 |
endif; |
340 |
||
341 |
if ( ! function_exists( 'twentythirteen_post_nav' ) ) : |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
* Display navigation to next/previous post when applicable. |
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 |
* @since Twenty Thirteen 1.0 |
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 |
function twentythirteen_post_nav() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
global $post; |
0 | 349 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
// Don't print empty markup if there's nowhere to navigate. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
$next = get_adjacent_post( false, '', false ); |
0 | 353 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
if ( ! $next && ! $previous ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
<nav class="navigation post-navigation" role="navigation"> |
0 | 359 |
<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentythirteen' ); ?></h1> |
360 |
<div class="nav-links"> |
|
361 |
||
362 |
<?php previous_post_link( '%link', _x( '<span class="meta-nav">←</span> %title', 'Previous post link', 'twentythirteen' ) ); ?> |
|
363 |
<?php next_post_link( '%link', _x( '%title <span class="meta-nav">→</span>', 'Next post link', 'twentythirteen' ) ); ?> |
|
364 |
||
365 |
</div><!-- .nav-links --> |
|
366 |
</nav><!-- .navigation --> |
|
367 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
} |
0 | 369 |
endif; |
370 |
||
371 |
if ( ! function_exists( 'twentythirteen_entry_meta' ) ) : |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
* Print 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
|
374 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
* Create your own twentythirteen_entry_meta() to override in a child theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
376 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
* @since Twenty Thirteen 1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
function twentythirteen_entry_meta() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
if ( is_sticky() && is_home() && ! is_paged() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
echo '<span class="featured-post">' . esc_html__( 'Sticky', 'twentythirteen' ) . '</span>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
} |
0 | 383 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
if ( ! has_post_format( 'link' ) && 'post' == get_post_type() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
twentythirteen_entry_date(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
386 |
} |
0 | 387 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
// 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
|
389 |
$categories_list = get_the_category_list( __( ', ', 'twentythirteen' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
if ( $categories_list ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
echo '<span class="categories-links">' . $categories_list . '</span>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
392 |
} |
0 | 393 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
// 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
|
395 |
$tag_list = get_the_tag_list( '', __( ', ', 'twentythirteen' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
if ( $tag_list ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
echo '<span class="tags-links">' . $tag_list . '</span>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
// Post author |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
if ( 'post' == get_post_type() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
403 |
'<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
|
404 |
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
|
405 |
esc_attr( sprintf( __( 'View all posts by %s', 'twentythirteen' ), get_the_author() ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
get_the_author() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
} |
0 | 409 |
} |
410 |
endif; |
|
411 |
||
412 |
if ( ! function_exists( 'twentythirteen_entry_date' ) ) : |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
413 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
* Print HTML with date information for current post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
415 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
416 |
* Create your own twentythirteen_entry_date() to override in a child theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
* @since Twenty Thirteen 1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
* @param boolean $echo (optional) Whether to echo the date. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
* @return string The HTML-formatted post date. |
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 |
function twentythirteen_entry_date( $echo = true ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
if ( has_post_format( array( 'chat', 'status' ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
$format_prefix = _x( '%1$s on %2$s', '1: post format name. 2: date', 'twentythirteen' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
$format_prefix = '%2$s'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
} |
0 | 429 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
$date = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
431 |
'<span class="date"><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a></span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
esc_url( get_permalink() ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
433 |
esc_attr( sprintf( __( 'Permalink to %s', 'twentythirteen' ), the_title_attribute( 'echo=0' ) ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
esc_attr( get_the_date( 'c' ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
esc_html( sprintf( $format_prefix, get_post_format_string( get_post_format() ), get_the_date() ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
); |
0 | 437 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
if ( $echo ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
439 |
echo $date; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
} |
0 | 441 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
return $date; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
443 |
} |
0 | 444 |
endif; |
445 |
||
446 |
if ( ! function_exists( 'twentythirteen_the_attached_image' ) ) : |
|
447 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
* Print the attached image with a link to the next attached image. |
0 | 449 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
* @since Twenty Thirteen 1.0 |
0 | 451 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
function twentythirteen_the_attached_image() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
454 |
* Filter the image attachment size to use. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
455 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
* @since Twenty thirteen 1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
* @param array $size { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
* @type int The attachment height in pixels. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* @type int The attachment width in pixels. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
* } |
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 |
$attachment_size = apply_filters( 'twentythirteen_attachment_size', array( 724, 724 ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
464 |
$next_attachment_url = wp_get_attachment_url(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
465 |
$post = get_post(); |
0 | 466 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
467 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
* Grab the IDs of all the image attachments in a gallery so we can get the URL |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
469 |
* of the next adjacent image in a gallery, or the first image (if we're |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
470 |
* looking at the last image in a gallery), or, in a gallery of one, just the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
471 |
* link to that image file. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
472 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
473 |
$attachment_ids = get_posts( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
474 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
475 |
'post_parent' => $post->post_parent, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
476 |
'fields' => 'ids', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
477 |
'numberposts' => -1, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
478 |
'post_status' => 'inherit', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
479 |
'post_type' => 'attachment', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
480 |
'post_mime_type' => 'image', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
'order' => 'ASC', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
'orderby' => 'menu_order ID', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
484 |
); |
0 | 485 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
// If there is more than 1 attachment in a gallery... |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
if ( count( $attachment_ids ) > 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
488 |
foreach ( $attachment_ids as $idx => $attachment_id ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
if ( $attachment_id == $post->ID ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
490 |
$next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
491 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
492 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
493 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
494 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
495 |
// get the URL of the next image attachment... |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
496 |
if ( $next_id ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
$next_attachment_url = get_attachment_link( $next_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
498 |
} // or get the URL of the first image attachment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
499 |
else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
500 |
$next_attachment_url = get_attachment_link( reset( $attachment_ids ) ); |
0 | 501 |
} |
502 |
} |
|
503 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
504 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
505 |
'<a href="%1$s" title="%2$s" rel="attachment">%3$s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
506 |
esc_url( $next_attachment_url ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
507 |
the_title_attribute( array( 'echo' => false ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
508 |
wp_get_attachment_image( $post->ID, $attachment_size ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
509 |
); |
0 | 510 |
} |
511 |
endif; |
|
512 |
||
513 |
/** |
|
514 |
* Return the post URL. |
|
515 |
* |
|
516 |
* @uses get_url_in_content() to get the URL in the post meta (if it exists) or |
|
517 |
* the first link found in the post content. |
|
518 |
* |
|
519 |
* Falls back to the post permalink if no URL is found in the post. |
|
520 |
* |
|
521 |
* @since Twenty Thirteen 1.0 |
|
522 |
* |
|
523 |
* @return string The Link format URL. |
|
524 |
*/ |
|
525 |
function twentythirteen_get_link_url() { |
|
526 |
$content = get_the_content(); |
|
527 |
$has_url = get_url_in_content( $content ); |
|
528 |
||
529 |
return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() ); |
|
530 |
} |
|
531 |
||
5 | 532 |
if ( ! function_exists( 'twentythirteen_excerpt_more' ) && ! is_admin() ) : |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
533 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
534 |
* Replaces "[...]" (appended to automatically generated excerpts) with ... |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
* and a Continue reading link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
537 |
* @since Twenty Thirteen 1.4 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
538 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
* @param string $more Default Read More excerpt link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
540 |
* @return string Filtered Read More excerpt link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
541 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
542 |
function twentythirteen_excerpt_more( $more ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
543 |
$link = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
544 |
'<a href="%1$s" class="more-link">%2$s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
545 |
esc_url( get_permalink( get_the_ID() ) ), |
5 | 546 |
/* translators: %s: Name of current post */ |
547 |
sprintf( __( 'Continue reading %s <span class="meta-nav">→</span>', 'twentythirteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' ) |
|
548 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
return ' … ' . $link; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
550 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
551 |
add_filter( 'excerpt_more', 'twentythirteen_excerpt_more' ); |
5 | 552 |
endif; |
553 |
||
0 | 554 |
/** |
555 |
* Extend the default WordPress body classes. |
|
556 |
* |
|
557 |
* Adds body classes to denote: |
|
558 |
* 1. Single or multiple authors. |
|
559 |
* 2. Active widgets in the sidebar to change the layout and spacing. |
|
560 |
* 3. When avatars are disabled in discussion settings. |
|
561 |
* |
|
562 |
* @since Twenty Thirteen 1.0 |
|
563 |
* |
|
564 |
* @param array $classes A list of existing body class values. |
|
565 |
* @return array The filtered body class list. |
|
566 |
*/ |
|
567 |
function twentythirteen_body_class( $classes ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
568 |
if ( ! is_multi_author() ) { |
0 | 569 |
$classes[] = 'single-author'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
} |
0 | 571 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
572 |
if ( is_active_sidebar( 'sidebar-2' ) && ! is_attachment() && ! is_404() ) { |
0 | 573 |
$classes[] = 'sidebar'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
574 |
} |
0 | 575 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
if ( ! get_option( 'show_avatars' ) ) { |
0 | 577 |
$classes[] = 'no-avatars'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
} |
0 | 579 |
|
580 |
return $classes; |
|
581 |
} |
|
582 |
add_filter( 'body_class', 'twentythirteen_body_class' ); |
|
583 |
||
584 |
/** |
|
585 |
* Adjust content_width value for video post formats and attachment templates. |
|
586 |
* |
|
587 |
* @since Twenty Thirteen 1.0 |
|
588 |
*/ |
|
589 |
function twentythirteen_content_width() { |
|
590 |
global $content_width; |
|
591 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
592 |
if ( is_attachment() ) { |
0 | 593 |
$content_width = 724; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
} elseif ( has_post_format( 'audio' ) ) { |
0 | 595 |
$content_width = 484; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
596 |
} |
0 | 597 |
} |
598 |
add_action( 'template_redirect', 'twentythirteen_content_width' ); |
|
599 |
||
600 |
/** |
|
601 |
* Add postMessage support for site title and description for the Customizer. |
|
602 |
* |
|
603 |
* @since Twenty Thirteen 1.0 |
|
604 |
* |
|
605 |
* @param WP_Customize_Manager $wp_customize Customizer object. |
|
606 |
*/ |
|
607 |
function twentythirteen_customize_register( $wp_customize ) { |
|
608 |
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; |
|
609 |
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; |
|
610 |
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; |
|
7
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 |
if ( isset( $wp_customize->selective_refresh ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
$wp_customize->selective_refresh->add_partial( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
'blogname', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
'selector' => '.site-title', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
616 |
'container_inclusive' => false, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
'render_callback' => 'twentythirteen_customize_partial_blogname', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
620 |
$wp_customize->selective_refresh->add_partial( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
621 |
'blogdescription', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
622 |
'selector' => '.site-description', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
'container_inclusive' => false, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
624 |
'render_callback' => 'twentythirteen_customize_partial_blogdescription', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
626 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
627 |
} |
0 | 628 |
} |
629 |
add_action( 'customize_register', 'twentythirteen_customize_register' ); |
|
630 |
||
631 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
632 |
* Render the site title for the selective refresh partial. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
633 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
634 |
* @since Twenty Thirteen 1.9 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
635 |
* @see twentythirteen_customize_register() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
637 |
* @return void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
638 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
function twentythirteen_customize_partial_blogname() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
640 |
bloginfo( 'name' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
641 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
642 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
643 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
644 |
* Render the site tagline for the selective refresh partial. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
645 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
646 |
* @since Twenty Thirteen 1.9 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
647 |
* @see twentythirteen_customize_register() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
648 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
649 |
* @return void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
function twentythirteen_customize_partial_blogdescription() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
bloginfo( 'description' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
654 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
655 |
/** |
0 | 656 |
* Enqueue Javascript postMessage handlers for the Customizer. |
657 |
* |
|
658 |
* Binds JavaScript handlers to make the Customizer preview |
|
659 |
* reload changes asynchronously. |
|
660 |
* |
|
661 |
* @since Twenty Thirteen 1.0 |
|
662 |
*/ |
|
663 |
function twentythirteen_customize_preview_js() { |
|
5 | 664 |
wp_enqueue_script( 'twentythirteen-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20141120', true ); |
0 | 665 |
} |
666 |
add_action( 'customize_preview_init', 'twentythirteen_customize_preview_js' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
668 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
669 |
* 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
|
670 |
* and use list format for better accessibility. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
* @since Twenty Thirteen 2.3 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
674 |
* @param array $args Arguments for tag cloud widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
675 |
* @return array The filtered arguments for tag cloud widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
676 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
function twentythirteen_widget_tag_cloud_args( $args ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
678 |
$args['largest'] = 22; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
679 |
$args['smallest'] = 8; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
680 |
$args['unit'] = 'pt'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
$args['format'] = 'list'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
683 |
return $args; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
684 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
685 |
add_filter( 'widget_tag_cloud_args', 'twentythirteen_widget_tag_cloud_args' ); |