-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·324 lines (273 loc) · 8.89 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
<?php
/**
* Spun functions and definitions
*
* @package Spun
*/
/**
* Set the content width based on the theme's design and stylesheet.
*
*/
if ( ! isset( $content_width ) )
$content_width = 700; /* pixels */
if ( ! function_exists( 'spun_setup' ) ):
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*
*/
function spun_setup() {
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you're building a theme based on Spun, use a find and replace
* to change 'spun' to the name of your theme in all the template files
*/
load_theme_textdomain( 'spun', get_template_directory() . '/languages' );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
/**
* Enable support for Post Thumbnails
*/
add_theme_support( 'post-thumbnails' );
add_image_size( 'home-post', 360, 360, true );
add_image_size( 'single-post', 700, 999 );
/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'spun' ),
) );
/**
* Add support for custom backgrounds
*/
add_theme_support( 'custom-background' );
/**
* Add support for editor styles
*/
add_editor_style();
/**
* Add support for Post Formats
*/
add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'status', 'gallery' ) );
}
endif; // spun_setup
add_action( 'after_setup_theme', 'spun_setup' );
/**
* Register widgetized area and update sidebar with default widgets
*
*/
function spun_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar 1', 'spun' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Sidebar 2', 'spun' ),
'id' => 'sidebar-2',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Sidebar 3', 'spun' ),
'id' => 'sidebar-3',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
}
add_action( 'widgets_init', 'spun_widgets_init' );
/**
* Enqueue scripts and styles
*/
function spun_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_script( 'spun-toggle', get_template_directory_uri() . '/js/toggle.js', array( 'jquery' ), '20121005', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
}
wp_enqueue_style( 'spun-quicksand' );
wp_enqueue_style( 'spun-playfair' );
wp_enqueue_style( 'spun-nunito' );
}
add_action( 'wp_enqueue_scripts', 'spun_scripts', 1 );
function spun_options_styles() {
if ( false == get_theme_mod( 'spun_grayscale', false ) ) : ?>
<style type="text/css">
.blog .hentry a .attachment-home-post,
.archive .hentry a .attachment-home-post,
.search .hentry a .attachment-home-post {
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-webkit-filter: grayscale(1); /* Older versions of webkit */
-moz-filter: grayscale(100%);
-o-filter: grayscale(100%);
-ms-filter: grayscale(100%); /* IE 10 */
filter: gray; /* IE 9 */
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox */
}
@media screen and ( max-width: 800px ) {
/* Remove hover effects for touchscreens */
.blog .hentry a .attachment-home-post,
.archive .hentry a .attachment-home-post,
.search .hentry a .attachment-home-post {
filter:none;
-webkit-filter:none;
-moz-filter:none;
-o-filter:none;
}
}
</style>
<?php
endif;
if ( false == get_theme_mod( 'spun_opacity', false ) ) : ?>
<style type="text/css">
.site-content #nav-below .nav-previous a,
.site-content #nav-below .nav-next a,
.site-content #image-navigation .nav-previous a,
.site-content #image-navigation .nav-next a,
.comment-navigation .nav-next,
.comment-navigation .nav-previous,
#infinite-handle span,
.sidebar-link,
a.comment-reply-link,
a#cancel-comment-reply-link,
.comments-link a,
.hentry.no-thumbnail,
button,
html input[type="button"],
input[type="reset"],
input[type="submit"],
.site-footer {
opacity: .2;
}
.site-header,
.entry-meta-wrapper,
.comment-meta,
.page-links span.active-link,
.page-links a span.active-link {
opacity: .3;
}
@media screen and ( max-width: 800px ) {
/* Increase opacity for small screen sizes and touch screens */
.site-header,
.site-content #nav-below .nav-previous a,
.site-content #nav-below .nav-next a,
.site-content #image-navigation .nav-previous a,
.site-content #image-navigation .nav-next a,
.comment-navigation .nav-next a,
.comment-navigation .nav-previous a,
#infinite-handle span,
.sidebar-link,
a.comment-reply-link,
a#cancel-comment-reply-link,
.site-footer,
.comments-link a,
.comment-meta,
.entry-meta-wrapper,
.hentry.no-thumbnail,
.page-links span.active-link,
.page-links a span.active-link {
opacity: 1;
}
}
</style>
<?php
endif;
if ( false == get_theme_mod( 'spun_titles', false ) ) : ?>
<style type="text/css">
.hentry .thumbnail-title {
display: none;
}
</style>
<?php
endif;
}
add_action( 'wp_head', 'spun_options_styles', 1 );
/**
* Register Google Fonts
*/
function spun_google_fonts() {
$protocol = is_ssl() ? 'https' : 'http';
/* translators: If there are characters in your language that are not supported
by Playfair, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Playfair font: on or off', 'spun' ) ) {
wp_register_style( 'spun-playfair', "$protocol://fonts.googleapis.com/css?family=Playfair+Display:400,700,400italic,700italic" );
}
/* translators: If there are characters in your language that are not supported
by Quicksand, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Quicksand font: on or off', 'spun' ) ) {
wp_register_style( 'spun-quicksand', "$protocol://fonts.googleapis.com/css?family=Quicksand:300" );
}
/* translators: If there are characters in your language that are not supported
by Nunito, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Nunito font: on or off', 'spun' ) ) {
wp_register_style( 'spun-nunito', "$protocol://fonts.googleapis.com/css?family=Nunito:300" );
}
}
add_action( 'init', 'spun_google_fonts' );
/**
* Filter TinyMCE CSS path to include Google Fonts.
*
* Adds additional stylesheets to the TinyMCE editor if needed.
*
* @param string $mce_css CSS path to load in TinyMCE.
* @return string Filtered CSS path.
*/
function typo_mce_css( $mce_css ) {
$protocol = is_ssl() ? 'https' : 'http';
$font_url = $protocol . '://fonts.googleapis.com/css?family=Quicksand:300|Playfair+Display:400,700,400italic,700italic';
if ( empty( $font_url ) )
return $mce_css;
if ( ! empty( $mce_css ) )
$mce_css .= ',';
$mce_css .= esc_url_raw( str_replace( ',', '%2C', $font_url ) );
return $mce_css;
}
add_filter( 'mce_css', 'typo_mce_css' );
/**
* Enqueue Google Fonts for custom headers
*/
function spun_admin_scripts( $hook_suffix ) {
if ( 'appearance_page_custom-header' != $hook_suffix )
return;
wp_enqueue_style( 'spun-playfair' );
wp_enqueue_style( 'spun-quicksand' );
}
add_action( 'admin_enqueue_scripts', 'spun_admin_scripts' );
/**
* Implement the Custom Header feature
*/
require( get_template_directory() . '/inc/custom-header.php' );
/**
* Load Jetpack compatibility file.
*/
if ( file_exists( get_template_directory() . '/inc/jetpack.php' ) )
require get_template_directory() . '/inc/jetpack.php';
/**
* Custom template tags for this theme.
*/
require( get_template_directory() . '/inc/template-tags.php' );
/**
* Custom functions that act independently of the theme templates
*/
require( get_template_directory() . '/inc/extras.php' );
/**
* Customizer support for theme options
*/
require( get_template_directory() . '/inc/customizer.php' );