author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
permissions | -rw-r--r-- |
5 | 1 |
<?php |
2 |
/** |
|
3 |
* Twenty Fourteen functions and definitions |
|
4 |
* |
|
5 |
* Set 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 |
* |
|
9 |
* When using a child theme you can override certain functions (those wrapped |
|
10 |
* in a function_exists() call) by defining them first in your child theme's |
|
11 |
* functions.php file. The child theme's functions.php file is included before |
|
12 |
* the parent theme's file, so the child theme functions would be used. |
|
13 |
* |
|
14 |
* @link https://codex.wordpress.org/Theme_Development |
|
15 |
* @link https://codex.wordpress.org/Child_Themes |
|
16 |
* |
|
17 |
* Functions that are not pluggable (not wrapped in function_exists()) are |
|
18 |
* instead attached to a filter or action hook. |
|
19 |
* |
|
20 |
* For more information on hooks, actions, and filters, |
|
21 |
* @link https://codex.wordpress.org/Plugin_API |
|
22 |
* |
|
23 |
* @package WordPress |
|
24 |
* @subpackage Twenty_Fourteen |
|
25 |
* @since Twenty Fourteen 1.0 |
|
26 |
*/ |
|
27 |
||
28 |
/** |
|
29 |
* Set up the content width value based on the theme's design. |
|
30 |
* |
|
31 |
* @see twentyfourteen_content_width() |
|
32 |
* |
|
33 |
* @since Twenty Fourteen 1.0 |
|
34 |
*/ |
|
35 |
if ( ! isset( $content_width ) ) { |
|
36 |
$content_width = 474; |
|
37 |
} |
|
38 |
||
39 |
/** |
|
40 |
* Twenty Fourteen only works in WordPress 3.6 or later. |
|
41 |
*/ |
|
42 |
if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) ) { |
|
43 |
require get_template_directory() . '/inc/back-compat.php'; |
|
44 |
} |
|
45 |
||
46 |
if ( ! function_exists( 'twentyfourteen_setup' ) ) : |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
* Twenty Fourteen setup. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
* Set up theme defaults and registers support for various WordPress features. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
* Note that this function is hooked into the after_setup_theme hook, which |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
* runs before the init hook. The init hook is too late for some features, such |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
54 |
* as indicating support post thumbnails. |
5 | 55 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
* @since Twenty Fourteen 1.0 |
5 | 57 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
function twentyfourteen_setup() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
* Make Twenty Fourteen available for translation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
* Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentyfourteen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
* If you're building a theme based on Twenty Fourteen, use a find and |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
* replace to change 'twentyfourteen' to the name of your theme in all |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
* template files. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
67 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
load_theme_textdomain( 'twentyfourteen' ); |
5 | 69 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
// This theme styles the visual editor to resemble the theme style. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
add_editor_style( array( 'css/editor-style.css', twentyfourteen_font_url(), 'genericons/genericons.css' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
// Add RSS feed links to <head> for posts and comments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
add_theme_support( 'automatic-feed-links' ); |
5 | 75 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
// Enable support for Post Thumbnails, and declare two sizes. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
add_theme_support( 'post-thumbnails' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
set_post_thumbnail_size( 672, 372, true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
add_image_size( 'twentyfourteen-full-width', 1038, 576, true ); |
5 | 80 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
// This theme uses wp_nav_menu() in two locations. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
register_nav_menus( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
'primary' => __( 'Top primary menu', 'twentyfourteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
'secondary' => __( 'Secondary menu in left sidebar', 'twentyfourteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
); |
5 | 88 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
* Switch default core markup for search form, comment form, and comments |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
* to output valid HTML5. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
add_theme_support( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
'html5', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
'search-form', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
'comment-form', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
'comment-list', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
'gallery', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
'caption', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
); |
5 | 102 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
* Enable support for Post Formats. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
* See https://codex.wordpress.org/Post_Formats |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
add_theme_support( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
108 |
'post-formats', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
109 |
'aside', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
'image', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
'video', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
112 |
'audio', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
'quote', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
'link', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
'gallery', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
116 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
117 |
); |
5 | 118 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
119 |
// This theme allows users to set a custom background. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
120 |
add_theme_support( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
'custom-background', apply_filters( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
122 |
'twentyfourteen_custom_background_args', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
123 |
'default-color' => 'f5f5f5', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
124 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
126 |
); |
5 | 127 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
// Add support for featured content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
add_theme_support( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
'featured-content', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
'featured_content_filter' => 'twentyfourteen_get_featured_posts', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
'max_posts' => 6, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
); |
5 | 135 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
136 |
// This theme uses its own gallery styles. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
add_filter( 'use_default_gallery_style', '__return_false' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
// 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
|
140 |
add_theme_support( 'customize-selective-refresh-widgets' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
} |
5 | 142 |
endif; // twentyfourteen_setup |
143 |
add_action( 'after_setup_theme', 'twentyfourteen_setup' ); |
|
144 |
||
145 |
/** |
|
146 |
* Adjust content_width value for image attachment template. |
|
147 |
* |
|
148 |
* @since Twenty Fourteen 1.0 |
|
149 |
*/ |
|
150 |
function twentyfourteen_content_width() { |
|
151 |
if ( is_attachment() && wp_attachment_is_image() ) { |
|
152 |
$GLOBALS['content_width'] = 810; |
|
153 |
} |
|
154 |
} |
|
155 |
add_action( 'template_redirect', 'twentyfourteen_content_width' ); |
|
156 |
||
157 |
/** |
|
158 |
* Getter function for Featured Content Plugin. |
|
159 |
* |
|
160 |
* @since Twenty Fourteen 1.0 |
|
161 |
* |
|
162 |
* @return array An array of WP_Post objects. |
|
163 |
*/ |
|
164 |
function twentyfourteen_get_featured_posts() { |
|
165 |
/** |
|
166 |
* Filter the featured posts to return in Twenty Fourteen. |
|
167 |
* |
|
168 |
* @since Twenty Fourteen 1.0 |
|
169 |
* |
|
170 |
* @param array|bool $posts Array of featured posts, otherwise false. |
|
171 |
*/ |
|
172 |
return apply_filters( 'twentyfourteen_get_featured_posts', array() ); |
|
173 |
} |
|
174 |
||
175 |
/** |
|
176 |
* A helper conditional function that returns a boolean value. |
|
177 |
* |
|
178 |
* @since Twenty Fourteen 1.0 |
|
179 |
* |
|
180 |
* @return bool Whether there are featured posts. |
|
181 |
*/ |
|
182 |
function twentyfourteen_has_featured_posts() { |
|
183 |
return ! is_paged() && (bool) twentyfourteen_get_featured_posts(); |
|
184 |
} |
|
185 |
||
186 |
/** |
|
187 |
* Register three Twenty Fourteen widget areas. |
|
188 |
* |
|
189 |
* @since Twenty Fourteen 1.0 |
|
190 |
*/ |
|
191 |
function twentyfourteen_widgets_init() { |
|
192 |
require get_template_directory() . '/inc/widgets.php'; |
|
193 |
register_widget( 'Twenty_Fourteen_Ephemera_Widget' ); |
|
194 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
register_sidebar( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
'name' => __( 'Primary Sidebar', 'twentyfourteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
'id' => 'sidebar-1', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
'description' => __( 'Main sidebar that appears on the left.', 'twentyfourteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
'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
|
201 |
'after_widget' => '</aside>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
'before_title' => '<h1 class="widget-title">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
203 |
'after_title' => '</h1>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
204 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
205 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
206 |
register_sidebar( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
207 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
208 |
'name' => __( 'Content Sidebar', 'twentyfourteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
209 |
'id' => 'sidebar-2', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
'description' => __( 'Additional sidebar that appears on the right.', 'twentyfourteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
'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
|
212 |
'after_widget' => '</aside>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
'before_title' => '<h1 class="widget-title">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
214 |
'after_title' => '</h1>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
215 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
216 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
217 |
register_sidebar( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
'name' => __( 'Footer Widget Area', 'twentyfourteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
'id' => 'sidebar-3', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
221 |
'description' => __( 'Appears in the footer section of the site.', 'twentyfourteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
222 |
'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
|
223 |
'after_widget' => '</aside>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
224 |
'before_title' => '<h1 class="widget-title">', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
'after_title' => '</h1>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
226 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
227 |
); |
5 | 228 |
} |
229 |
add_action( 'widgets_init', 'twentyfourteen_widgets_init' ); |
|
230 |
||
231 |
/** |
|
232 |
* Register Lato Google font for Twenty Fourteen. |
|
233 |
* |
|
234 |
* @since Twenty Fourteen 1.0 |
|
235 |
* |
|
236 |
* @return string |
|
237 |
*/ |
|
238 |
function twentyfourteen_font_url() { |
|
239 |
$font_url = ''; |
|
240 |
/* |
|
241 |
* Translators: If there are characters in your language that are not supported |
|
242 |
* by Lato, translate this to 'off'. Do not translate into your own language. |
|
243 |
*/ |
|
244 |
if ( 'off' !== _x( 'on', 'Lato font: on or off', 'twentyfourteen' ) ) { |
|
245 |
$query_args = array( |
|
246 |
'family' => urlencode( 'Lato:300,400,700,900,300italic,400italic,700italic' ), |
|
247 |
'subset' => urlencode( 'latin,latin-ext' ), |
|
248 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
$font_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); |
5 | 250 |
} |
251 |
||
252 |
return $font_url; |
|
253 |
} |
|
254 |
||
255 |
/** |
|
256 |
* Enqueue scripts and styles for the front end. |
|
257 |
* |
|
258 |
* @since Twenty Fourteen 1.0 |
|
259 |
*/ |
|
260 |
function twentyfourteen_scripts() { |
|
261 |
// Add Lato font, used in the main stylesheet. |
|
262 |
wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null ); |
|
263 |
||
264 |
// Add Genericons font, used in the main stylesheet. |
|
265 |
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.0.3' ); |
|
266 |
||
267 |
// Load our main stylesheet. |
|
268 |
wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri() ); |
|
269 |
||
270 |
// Load the Internet Explorer specific stylesheet. |
|
271 |
wp_enqueue_style( 'twentyfourteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentyfourteen-style' ), '20131205' ); |
|
272 |
wp_style_add_data( 'twentyfourteen-ie', 'conditional', 'lt IE 9' ); |
|
273 |
||
274 |
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { |
|
275 |
wp_enqueue_script( 'comment-reply' ); |
|
276 |
} |
|
277 |
||
278 |
if ( is_singular() && wp_attachment_is_image() ) { |
|
279 |
wp_enqueue_script( 'twentyfourteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20130402' ); |
|
280 |
} |
|
281 |
||
282 |
if ( is_active_sidebar( 'sidebar-3' ) ) { |
|
283 |
wp_enqueue_script( 'jquery-masonry' ); |
|
284 |
} |
|
285 |
||
286 |
if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) { |
|
287 |
wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20131205', true ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
wp_localize_script( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
'twentyfourteen-slider', 'featuredSliderDefaults', array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
'prevText' => __( 'Previous', 'twentyfourteen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
'nextText' => __( 'Next', 'twentyfourteen' ), |
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 |
); |
5 | 294 |
} |
295 |
||
296 |
wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150315', true ); |
|
297 |
} |
|
298 |
add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' ); |
|
299 |
||
300 |
/** |
|
301 |
* Enqueue Google fonts style to admin screen for custom header display. |
|
302 |
* |
|
303 |
* @since Twenty Fourteen 1.0 |
|
304 |
*/ |
|
305 |
function twentyfourteen_admin_fonts() { |
|
306 |
wp_enqueue_style( 'twentyfourteen-lato', twentyfourteen_font_url(), array(), null ); |
|
307 |
} |
|
308 |
add_action( 'admin_print_scripts-appearance_page_custom-header', 'twentyfourteen_admin_fonts' ); |
|
309 |
||
310 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
* Add preconnect for Google Fonts. |
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 Fourteen 1.9 |
5 | 314 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
* @param array $urls URLs to print for resource hints. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
* @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
|
317 |
* @return array URLs to print for resource hints. |
5 | 318 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
function twentyfourteen_resource_hints( $urls, $relation_type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
if ( wp_style_is( 'twentyfourteen-lato', 'queue' ) && 'preconnect' === $relation_type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '>=' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
$urls[] = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
'href' => 'https://fonts.gstatic.com', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
'crossorigin', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
$urls[] = 'https://fonts.gstatic.com'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
return $urls; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
add_filter( 'wp_resource_hints', 'twentyfourteen_resource_hints', 10, 2 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
if ( ! function_exists( 'twentyfourteen_the_attached_image' ) ) : |
5 | 336 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
* Print the attached image with a link to the next attached image. |
5 | 338 |
* |
339 |
* @since Twenty Fourteen 1.0 |
|
340 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
function twentyfourteen_the_attached_image() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
$post = get_post(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
* Filter the default Twenty Fourteen attachment size. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
* @since Twenty Fourteen 1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
* @param array $dimensions { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
* An array of height and width dimensions. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
* @type int $height Height of the image in pixels. Default 810. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
* @type int $width Width of the image in pixels. Default 810. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
$attachment_size = apply_filters( 'twentyfourteen_attachment_size', array( 810, 810 ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
$next_attachment_url = wp_get_attachment_url(); |
5 | 357 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
* 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
|
360 |
* 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
|
361 |
* 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
|
362 |
* link to that image file. |
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 |
$attachment_ids = get_posts( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
'post_parent' => $post->post_parent, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
'fields' => 'ids', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
'numberposts' => -1, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
'post_status' => 'inherit', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
'post_type' => 'attachment', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
'post_mime_type' => 'image', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
'order' => 'ASC', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
'orderby' => 'menu_order ID', |
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 |
); |
5 | 376 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
// 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
|
378 |
if ( count( $attachment_ids ) > 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
foreach ( $attachment_ids as $idx => $attachment_id ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
if ( $attachment_id == $post->ID ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
$next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
386 |
// get the URL of the next image attachment... |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
387 |
if ( $next_id ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
$next_attachment_url = get_attachment_link( $next_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
} // or get the URL of the first image attachment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
$next_attachment_url = get_attachment_link( reset( $attachment_ids ) ); |
5 | 392 |
} |
393 |
} |
|
394 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
'<a href="%1$s" rel="attachment">%2$s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
esc_url( $next_attachment_url ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
wp_get_attachment_image( $post->ID, $attachment_size ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
); |
5 | 400 |
} |
401 |
endif; |
|
402 |
||
403 |
if ( ! function_exists( 'twentyfourteen_list_authors' ) ) : |
|
7
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 |
* Print a list of all site contributors who published at least one post. |
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 |
* @since Twenty Fourteen 1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
function twentyfourteen_list_authors() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
410 |
$contributor_ids = get_users( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
'fields' => 'ID', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
413 |
'orderby' => 'post_count', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
'order' => 'DESC', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
415 |
'who' => 'authors', |
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 |
); |
5 | 418 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
foreach ( $contributor_ids as $contributor_id ) : |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
$post_count = count_user_posts( $contributor_id ); |
5 | 421 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
422 |
// Move on if user has not published a post (yet). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
if ( ! $post_count ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
?> |
5 | 427 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
<div class="contributor"> |
5 | 429 |
<div class="contributor-info"> |
430 |
<div class="contributor-avatar"><?php echo get_avatar( $contributor_id, 132 ); ?></div> |
|
431 |
<div class="contributor-summary"> |
|
432 |
<h2 class="contributor-name"><?php echo get_the_author_meta( 'display_name', $contributor_id ); ?></h2> |
|
433 |
<p class="contributor-bio"> |
|
434 |
<?php echo get_the_author_meta( 'description', $contributor_id ); ?> |
|
435 |
</p> |
|
436 |
<a class="button contributor-posts-link" href="<?php echo esc_url( get_author_posts_url( $contributor_id ) ); ?>"> |
|
437 |
<?php printf( _n( '%d Article', '%d Articles', $post_count, 'twentyfourteen' ), $post_count ); ?> |
|
438 |
</a> |
|
439 |
</div><!-- .contributor-summary --> |
|
440 |
</div><!-- .contributor-info --> |
|
441 |
</div><!-- .contributor --> |
|
442 |
||
443 |
<?php |
|
444 |
endforeach; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
} |
5 | 446 |
endif; |
447 |
||
448 |
/** |
|
449 |
* Extend the default WordPress body classes. |
|
450 |
* |
|
451 |
* Adds body classes to denote: |
|
452 |
* 1. Single or multiple authors. |
|
453 |
* 2. Presence of header image except in Multisite signup and activate pages. |
|
454 |
* 3. Index views. |
|
455 |
* 4. Full-width content layout. |
|
456 |
* 5. Presence of footer widgets. |
|
457 |
* 6. Single views. |
|
458 |
* 7. Featured content layout. |
|
459 |
* |
|
460 |
* @since Twenty Fourteen 1.0 |
|
461 |
* |
|
462 |
* @param array $classes A list of existing body class values. |
|
463 |
* @return array The filtered body class list. |
|
464 |
*/ |
|
465 |
function twentyfourteen_body_classes( $classes ) { |
|
466 |
if ( is_multi_author() ) { |
|
467 |
$classes[] = 'group-blog'; |
|
468 |
} |
|
469 |
||
470 |
if ( get_header_image() ) { |
|
471 |
$classes[] = 'header-image'; |
|
472 |
} elseif ( ! in_array( $GLOBALS['pagenow'], array( 'wp-activate.php', 'wp-signup.php' ) ) ) { |
|
473 |
$classes[] = 'masthead-fixed'; |
|
474 |
} |
|
475 |
||
476 |
if ( is_archive() || is_search() || is_home() ) { |
|
477 |
$classes[] = 'list-view'; |
|
478 |
} |
|
479 |
||
480 |
if ( ( ! is_active_sidebar( 'sidebar-2' ) ) |
|
481 |
|| is_page_template( 'page-templates/full-width.php' ) |
|
482 |
|| is_page_template( 'page-templates/contributors.php' ) |
|
483 |
|| is_attachment() ) { |
|
484 |
$classes[] = 'full-width'; |
|
485 |
} |
|
486 |
||
487 |
if ( is_active_sidebar( 'sidebar-3' ) ) { |
|
488 |
$classes[] = 'footer-widgets'; |
|
489 |
} |
|
490 |
||
491 |
if ( is_singular() && ! is_front_page() ) { |
|
492 |
$classes[] = 'singular'; |
|
493 |
} |
|
494 |
||
495 |
if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) { |
|
496 |
$classes[] = 'slider'; |
|
497 |
} elseif ( is_front_page() ) { |
|
498 |
$classes[] = 'grid'; |
|
499 |
} |
|
500 |
||
501 |
return $classes; |
|
502 |
} |
|
503 |
add_filter( 'body_class', 'twentyfourteen_body_classes' ); |
|
504 |
||
505 |
/** |
|
506 |
* Extend the default WordPress post classes. |
|
507 |
* |
|
508 |
* Adds a post class to denote: |
|
509 |
* Non-password protected page with a post thumbnail. |
|
510 |
* |
|
511 |
* @since Twenty Fourteen 1.0 |
|
512 |
* |
|
513 |
* @param array $classes A list of existing post class values. |
|
514 |
* @return array The filtered post class list. |
|
515 |
*/ |
|
516 |
function twentyfourteen_post_classes( $classes ) { |
|
517 |
if ( ! post_password_required() && ! is_attachment() && has_post_thumbnail() ) { |
|
518 |
$classes[] = 'has-post-thumbnail'; |
|
519 |
} |
|
520 |
||
521 |
return $classes; |
|
522 |
} |
|
523 |
add_filter( 'post_class', 'twentyfourteen_post_classes' ); |
|
524 |
||
525 |
/** |
|
526 |
* Create a nicely formatted and more specific title element text for output |
|
527 |
* in head of document, based on current view. |
|
528 |
* |
|
529 |
* @since Twenty Fourteen 1.0 |
|
530 |
* |
|
531 |
* @global int $paged WordPress archive pagination page count. |
|
532 |
* @global int $page WordPress paginated post page count. |
|
533 |
* |
|
534 |
* @param string $title Default title text for current view. |
|
535 |
* @param string $sep Optional separator. |
|
536 |
* @return string The filtered title. |
|
537 |
*/ |
|
538 |
function twentyfourteen_wp_title( $title, $sep ) { |
|
539 |
global $paged, $page; |
|
540 |
||
541 |
if ( is_feed() ) { |
|
542 |
return $title; |
|
543 |
} |
|
544 |
||
545 |
// Add the site name. |
|
546 |
$title .= get_bloginfo( 'name', 'display' ); |
|
547 |
||
548 |
// Add the site description for the home/front page. |
|
549 |
$site_description = get_bloginfo( 'description', 'display' ); |
|
550 |
if ( $site_description && ( is_home() || is_front_page() ) ) { |
|
551 |
$title = "$title $sep $site_description"; |
|
552 |
} |
|
553 |
||
554 |
// Add a page number if necessary. |
|
555 |
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) { |
|
556 |
$title = "$title $sep " . sprintf( __( 'Page %s', 'twentyfourteen' ), max( $paged, $page ) ); |
|
557 |
} |
|
558 |
||
559 |
return $title; |
|
560 |
} |
|
561 |
add_filter( 'wp_title', 'twentyfourteen_wp_title', 10, 2 ); |
|
562 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
563 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
564 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
565 |
* 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
|
566 |
* and use list format for better accessibility. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
567 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
568 |
* @since Twenty Fourteen 2.1 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
569 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
* @param array $args Arguments for tag cloud widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
571 |
* @return array The filtered arguments for tag cloud widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
572 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
573 |
function twentyfourteen_widget_tag_cloud_args( $args ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
574 |
$args['largest'] = 22; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
575 |
$args['smallest'] = 8; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
$args['unit'] = 'pt'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
577 |
$args['format'] = 'list'; |
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 |
return $args; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
580 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
581 |
add_filter( 'widget_tag_cloud_args', 'twentyfourteen_widget_tag_cloud_args' ); |
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 |
|
5 | 584 |
// Implement Custom Header features. |
585 |
require get_template_directory() . '/inc/custom-header.php'; |
|
586 |
||
587 |
// Custom template tags for this theme. |
|
588 |
require get_template_directory() . '/inc/template-tags.php'; |
|
589 |
||
590 |
// Add Customizer functionality. |
|
591 |
require get_template_directory() . '/inc/customizer.php'; |
|
592 |
||
593 |
/* |
|
594 |
* Add Featured Content functionality. |
|
595 |
* |
|
596 |
* To overwrite in a plugin, define your own Featured_Content class on or |
|
597 |
* before the 'setup_theme' hook. |
|
598 |
*/ |
|
599 |
if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] ) { |
|
600 |
require get_template_directory() . '/inc/featured-content.php'; |
|
601 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
602 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
603 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
* Add an `is_customize_preview` function if it is missing. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
605 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
* Enables installing Twenty Fourteen in WordPress versions before 4.0.0 when the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
* `is_customize_preview` function was introduced. |
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 |
if ( ! function_exists( 'is_customize_preview' ) ) : |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
function is_customize_preview() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
611 |
global $wp_customize; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
612 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
endif; |