-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
335 lines (291 loc) · 9.5 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
325
326
327
328
329
330
331
332
333
334
335
<?php
/**
* eighties functions and definitions
*
* @package Eighties
* @author Justin Kopepasah
* @since 1.0.0
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 760; /* pixels */
}
/**
* Eighties only works in WordPress 3.6 or later.
* Let's make sure users do not run into any
* troubles when trying to activate Eighties on WP
* versions less than 3.6.
*
* @since 1.0.0
*/
if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) ) {
require_once( dirname( __FILE__ ) . '/inc/compatibility.php' );
}
/**
* Set the theme mods in a global variable. This makes it easier to
* retrieve in templates and functions.
*/
// $GLOBALS['eighties_theme_mod'] = get_theme_mod( 'eighties' );
if ( ! function_exists( 'eighties_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 for post thumbnails.
*/
function eighties_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on eighties, use a find and replace
* to change 'eighties' to the name of your theme in all the template files
*/
load_theme_textdomain( 'eighties', 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 on posts and pages.
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
add_image_size( 'main-featured', '1000', '700', array( 'center', 'center' ) );
add_image_size( 'portfolio-featured', '500', '350', true );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'eighties' ),
'social' => __( 'Social Menu', 'eighties' )
) );
// Enable support for Post Formats.
add_theme_support( 'post-formats', array( 'gallery', 'image', 'video', 'audio', 'status', 'aside', 'link' ) );
// Enable support for HTML5 markup.
add_theme_support( 'html5', array(
'comment-list',
'search-form',
'comment-form',
'gallery',
) );
// Add Editor Style
add_editor_style( 'css/editor.css' );
// Add shortcodes for the_excerpt
add_filter( 'the_excerpt', 'do_shortcode' );
}
endif; // eighties_setup
add_action( 'after_setup_theme', 'eighties_setup' );
/**
* Register a footer and interactive widget area.
*/
function eighties_widgets_init() {
/**
* Set up our interactive sidebar if a user decided
* to enable this sidebar via the Customizer.
*/
register_sidebar( array(
'name' => __( 'Interactive Sidebar', 'eighties' ),
'id' => 'eighties-interactive-sidebar',
'description' => __( 'This sidebar opens as a toggle on the right side of a users browser window. Note that the toggle feature requires JavaScript in order to function. But no need to worry, a plain sidebar will appear if JavaScript does not work. If empty, the sidebar with not display.', 'eighties' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
// Footer widget area.
register_sidebar( array(
'name' => __( 'Footer', 'eighties' ),
'id' => 'eighties-footer',
'description' => __( 'Widget area for the footer. If no widgets are provided, this footer will not appear.', 'eighties' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
}
add_action( 'widgets_init', 'eighties_widgets_init' );
/**
* Register Righteous Google font for Eighties
*
* @since 1.0.0
* @return string
*/
function eighties_header_font_url() {
$font_url = '';
/*
* Translators: If there are characters in your language
* that are not supported by Righteous, translate this to
* 'off'. Do not translate into your own language.
*/
if ( 'off' !== _x( 'on', 'Righteous font: on or off', 'eighties' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Righteous' ), "//fonts.googleapis.com/css" );
}
return $font_url;
}
/**
* Register Raleway Google font for Eighties
*
* @since 1.0.0
* @return string
*/
function eighties_headings_font_url() {
$font_url = '';
/*
* Translators: If there are characters in your language
* that are not supported by Raleway, translate this to
* 'off'. Do not translate into your own language.
*/
if ( 'off' !== _x( 'on', 'Varela Round font: on or off', 'eighties' ) ) {
$font_url = add_query_arg( 'family', 'Varela+Round', "//fonts.googleapis.com/css" );
}
return $font_url;
}
/**
* Register Open Sans Google font for Eighties
*
* @since 1.0.0
* @return string
*/
function eighties_body_font_url() {
$font_url = '';
/*
* Translators: If there are characters in your language
* that are not supported by Open Sans, translate this to
* 'off'. Do not translate into your own language.
*/
if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'eighties' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Open Sans:400italic,700italic,400,700' ), "//fonts.googleapis.com/css" );
}
return $font_url;
}
/**
* Enqueue scripts and styles.
*/
function eighties_styles() {
$suffix = defined( 'STYLES_DEBUG' ) && STYLES_DEBUG ? '.css' : '.min.css';
// Add Righteous font, used in the main stylesheet.
wp_enqueue_style( 'eighties-header', eighties_header_font_url(), array(), null );
// Add Raleway font, used in the main stylesheet.
wp_enqueue_style( 'eighties-headings', eighties_headings_font_url(), array(), null );
// Add Open Sans font, used in the main stylesheet.
wp_enqueue_style( 'eighties-body', eighties_body_font_url(), array(), null );
// Font Awesome Icons
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/fonts/fa/font-awesome' . $suffix );
// Eighties Styles
wp_enqueue_style( 'eighties', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'eighties_styles' );
/**
* Enqueue scripts.
*/
function eighties_scripts() {
// If script debug is true, do not serve minified scripts.
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.js' : '.min.js';
// Our scripts.
$scripts = array(
'backstretch' => array(
'deps' => array( 'jquery' ),
'version' => '2.0.4',
'footer' => true
),
'fitvids' => array(
'deps' => array( 'jquery' ),
'version' => '1.0.3',
'footer' => true
),
'eighties' => array(
'deps' => array( 'fitvids' ),
'version' => '20140711',
'footer' => true
),
'eighties-enable-js' => array(
'deps' => false,
'version' => '20140711',
'footer' => false
),
'eighties-blog' => array(
'deps' => array( 'backstretch' ),
'version' => '20140711',
'footer' => true
),
'eighties-portfolio' => array(
'deps' => array( 'jquery' ),
'version' => '20140711',
'footer' => true
),
'eighties-header' => array(
'deps' => array( 'backstretch' ),
'version' => '20140711',
'footer' => true
),
'skip-link-focus-fix' => array(
'deps' => false,
'version' => '20140711',
'footer' => true
)
);
// Foreach of the scripts, let's register them.
foreach ( $scripts as $script => $args ) {
wp_register_script( $script, get_template_directory_uri() . '/js/' . $script . $suffix, $args['deps'], $args['version'], $args['footer'] );
}
// Change no-js to js on the documentElement.
wp_enqueue_script( 'eighties-enable-js' );
// Enqueue global (includes navigation and others).
wp_enqueue_script( 'eighties' );
// Skip link focus.
wp_enqueue_script( 'skip-link-focus-fix' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_home() || is_archive() || is_search() ) {
wp_enqueue_script( 'eighties-blog' );
}
if ( is_post_type_archive( 'jetpack-portfolio' ) ) {
wp_enqueue_script( 'eighties-portfolio' );
}
if ( eighties_header_image() ) {
wp_enqueue_script( 'eighties-header' );
}
}
add_action( 'wp_enqueue_scripts', 'eighties_scripts' );
/**
* Enqueue Header Google fonts style to admin
* screen for custom header display.
*
* @since 1.0.0
*/
function eighties_admin_fonts() {
wp_enqueue_style( 'eighties-header', eighties_header_font_url(), array(), null );
}
add_action( 'admin_print_scripts-appearance_page_custom-header', 'eighties_admin_fonts' );
// Pick out the version number from scripts and styles
function wp_remove_script_version( $src )
{
return remove_query_arg( 'ver', $src );
}
add_filter( 'script_loader_src', 'wp_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', 'wp_remove_script_version', 15, 1 );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom post format functionality.
*/
require get_template_directory() . '/inc/post-formats.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';