This repository has been archived by the owner on Aug 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions.php
executable file
·240 lines (203 loc) · 7.21 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
<?php
/**
* accessiblezen functions and definitions.
*
* @package Accessible_Zen
* @since Accessible Zen 1.0
*/
/**
* Set the content width based on the theme's design and stylesheet.
*
* @since Accessible Zen 1.0
*/
if ( ! isset( $content_width ) )
$content_width = 768; /* pixels */
if ( ! function_exists( 'accessiblezen_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.
*
* @since Accessible Zen 1.0
*/
function accessiblezen_setup() {
/**
* Make theme available for translation
* Translations can be filed on https://translate.wordpress.org/
* If you're building a theme based on Accessible Zen, use a find and replace
* to change 'accessible-zen' to the name of your theme in all the template files
*/
load_theme_textdomain( 'accessible-zen' );
// Switches default core markup for search form, comment form, and comments
// to output valid HTML5.
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
/*
* This theme styles the visual editor to resemble the theme style,
* specifically font, colors, and column width.
*/
add_editor_style( 'css/editor-style.css' );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/** This theme styles the visual editor with editor-style.css to match the theme style. */
add_editor_style('css/editor-style.css');
/**
* Enable support for Post Thumbnails
*/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 768, 150, true );
/**
* This theme uses wp_nav_menu() in two locations.
*/
register_nav_menus( array(
'primary' => esc_html__( 'Primary Menu', 'accessible-zen' ),
'secondary' => esc_html__( 'Secondary Menu', 'accessible-zen' )
) );
/*
* Add support for all available post formats by default.
* See http://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video'
) );
/*
* This theme supports custom background color and image, and here
* we also set up the default background color.
*/
add_theme_support( 'custom-background', array(
'default-color' => '',
) );
}
endif; // accessiblezen_setup
add_action( 'after_setup_theme', 'accessiblezen_setup' );
/**
* Register widgetized area and update sidebar with default widgets
*
* @since Accessible Zen 1.0
*/
function accessiblezen_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Footer Widget Area One', 'accessible-zen' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'A widget area for the left side of the footer', 'accessible-zen' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>",
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Widget Area Two', 'accessible-zen' ),
'id' => 'sidebar-2',
'description' => esc_html__( 'A widget area for the right side of the footer', 'accessible-zen' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>",
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'accessiblezen_widgets_init' );
/**
* Returns the Google font stylesheet URL, if available.
*
* The use of Noticia Text by default is localized. For languages
* that use characters not supported by the font, the font can be disabled.
*
* @since Accessible Zen 1.0
*
* @return string Font stylesheet or empty string if disabled.
*/
function accessiblezen_fonts_url() {
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by Source Sans Pro, translate this to 'off'. Do not translate
* into your own language.
*/
$merriweather_sans = esc_html_x( 'on', 'Merriweather Sans font: on or off', 'accessible-zen' );
/* Translators: If there are characters in your language that are not
* supported by Bitter, translate this to 'off'. Do not translate into your
* own language.
*/
$merriweather = esc_html_x( 'on', 'Merriweather font: on or off', 'accessible-zen' );
if ( 'off' !== $merriweather_sans || 'off' !== $merriweather ) {
$font_families = array();
if ( 'off' !== $merriweather_sans )
$font_families[] = 'Merriweather+Sans:400,700,400italic,700italic';
if ( 'off' !== $merriweather )
$font_families[] = 'Merriweather:400,700,400italic,700italic';
$protocol = is_ssl() ? 'https' : 'http';
$query_args = array(
'family' => implode( '|', $font_families ),
'subset' => 'latin,latin-ext',
);
$fonts_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" );
}
return esc_url_raw( $fonts_url );
}
/**
* Adds additional stylesheets to the TinyMCE editor if needed.
*
* @uses accessiblezen_fonts_url() to get the Google Font stylesheet URL.
*
* @since Accessible Zen 1.0
*
* @param string $mce_css CSS path to load in TinyMCE.
* @return string The filtered CSS paths list.
*/
function accessiblezen_mce_css( $mce_css ) {
$fonts_url = accessiblezen_fonts_url();
if ( empty( $fonts_url ) )
return $mce_css;
if ( ! empty( $mce_css ) )
$mce_css .= ',';
$mce_css .= esc_url_raw( str_replace( ',', '%2C', $fonts_url ) );
return $mce_css;
}
add_filter( 'mce_css', 'accessiblezen_mce_css' );
/**
* Enqueue scripts and styles.
*/
function accessiblezen_scripts_styles() {
global $wp_styles;
$fonts_url = accessiblezen_fonts_url();
if ( ! empty( $fonts_url ) )
wp_enqueue_style( 'accessiblezen-fonts', esc_url_raw( $fonts_url ), array(), null );
// Loads the icon fonts stylesheet.
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.2' );
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_script( 'skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', 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' );
}
}
add_action( 'wp_enqueue_scripts', 'accessiblezen_scripts_styles' );
/**
* 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' );
/**
* Add custom functions that act independently of the theme templates.
*/
require( get_template_directory() . '/inc/tweaks.php' );
/**
* Add Customizer additions.
*/
require( get_template_directory() . '/inc/customizer.php' );