-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
238 lines (236 loc) · 9.83 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
<?php
/**
* Twenty Fifteen functions and definitions
*
* Set up the theme and provides some helper functions, which are used in the
* theme as custom template tags. Others are attached to action and filter
* hooks in WordPress to change core functionality.
*
* When using a child theme you can override certain functions (those wrapped
* in a function_exists() call) by defining them first in your child theme's
* functions.php file. The child theme's functions.php file is included before
* the parent theme's file, so the child theme functions would be used.
*
* @link https://codex.wordpress.org/Theme_Development
* @link https://codex.wordpress.org/Child_Themes
*
* Functions that are not pluggable (not wrapped in function_exists()) are
* instead attached to a filter or action hook.
*
* For more information on hooks, actions, and filters,
* {@link https://codex.wordpress.org/Plugin_API}
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
/**
* Set the content width based on the theme's design and stylesheet.
*
* @since Twenty Fifteen 1.0
*/
if ( ! isset( $content_width ) ) {
$content_width = 660;
}
/**
* Twenty Fifteen only works in WordPress 4.1 or later.
*/
if ( version_compare( $GLOBALS['wp_version'], '4.1-alpha', '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
}
if ( ! function_exists( '_esc_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.
*
* @since Twenty Fifteen 1.0
*/
function _esc_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on twentyfifteen, use a find and replace
* to change 'esc' to the name of your theme in all the template files
*/
load_theme_textdomain( 'esc', get_template_directory() . '/languages' );
// 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' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* See: https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 825, 510, true );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'main' => __( 'Main Menu', 'esc' ),
'footer'=> __( 'Footer Menu', 'esc' ),
) );
/*
* Switch 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'
) );
/*
* Enable support for Post Formats.
*
* See: https://codex.wordpress.org/Post_Formats
*/
/*add_theme_support( 'post-formats', array(
'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
) );*/
/*$color_scheme = _esc_get_color_scheme();
$default_color = trim( $color_scheme[0], '#' );
// Setup the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( '_esc_custom_background_args', array(
'default-color' => $default_color,
'default-attachment' => 'fixed',
) ) );*/
/*
* This theme styles the visual editor to resemble the theme style,
* specifically font, colors, icons, and column width.
*/
add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css', _esc_fonts_url() ) );
}
endif; // _esc_setup
add_action( 'after_setup_theme', '_esc_setup' );
/**
* Register widget area.
*
* @since Twenty Fifteen 1.0
*
* @link https://codex.wordpress.org/Function_Reference/register_sidebar
*/
function _esc_widgets_init() {
register_sidebar( array(
'name' => __( 'Widget Area Blog', 'esc' ),
'id' => 'sidebar-blog',
'description' => __( 'Add widgets here to appear in your sidebar.', 'esc' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Widget Area Pages', 'esc' ),
'id' => 'sidebar-page',
'description' => __( 'Add widgets here to appear in your sidebar.', 'esc' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', '_esc_widgets_init' );
if ( ! function_exists( '_esc_fonts_url' ) ) :
/**
* Register Google fonts for Twenty Fifteen.
*
* @since Twenty Fifteen 1.0
*
* @return string Google fonts URL for the theme.
*/
function _esc_fonts_url() {
$fonts_url = '';
$fonts = array();
$subsets = 'latin,latin-ext';
/* translators: If there are characters in your language that are not supported by Noto Sans, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Noto Sans font: on or off', 'esc' ) ) {
$fonts[] = 'Noto Sans:400italic,700italic,400,700';
}
/* translators: If there are characters in your language that are not supported by Noto Serif, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Noto Serif font: on or off', 'esc' ) ) {
$fonts[] = 'Noto Serif:400italic,700italic,400,700';
}
/* translators: If there are characters in your language that are not supported by Inconsolata, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'esc' ) ) {
$fonts[] = 'Inconsolata:400,700';
}
if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'esc' ) ) {
$fonts[] = 'Lato:400,300,100,100italic,300italic,400italic,700,700italic,900italic,900';
}
if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'esc' ) ) {
$fonts[] = 'Raleway:400,100,100italic,200,200italic,300,300italic,400italic,500,500italic,600,600italic,700,900,800italic,800,700italic,900italic';
}
/* translators: To add an additional character subset specific to your language, translate this to 'greek', 'cyrillic', 'devanagari' or 'vietnamese'. Do not translate into your own language. */
$subset = _x( 'no-subset', 'Add new subset (greek, cyrillic, devanagari, vietnamese)', 'esc' );
if ( 'cyrillic' == $subset ) {
$subsets .= ',cyrillic,cyrillic-ext';
} elseif ( 'greek' == $subset ) {
$subsets .= ',greek,greek-ext';
} elseif ( 'devanagari' == $subset ) {
$subsets .= ',devanagari';
} elseif ( 'vietnamese' == $subset ) {
$subsets .= ',vietnamese';
}
if ( $fonts ) {
$fonts_url = add_query_arg( array(
'family' => urlencode( implode( '|', $fonts ) ),
'subset' => urlencode( $subsets ),
), '//fonts.googleapis.com/css' );
}
return $fonts_url;
}
endif;
/**
* Enqueue scripts and styles.
*
* @since Twenty Fifteen 1.0
*/
function _esc_scripts() {
// Add custom fonts, used in the main stylesheet.
wp_enqueue_style( 'esc-google-fonts', _esc_fonts_url(), array(), null );
wp_enqueue_style( 'esc-genericons', get_template_directory_uri() . '/css/genericons.css', array(), '3.2' );
wp_enqueue_style( 'esc-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), '' );
wp_enqueue_style( 'esc-fonts', get_template_directory_uri() . '/css/fonts.css', array(), '' );
wp_enqueue_style( 'esc-wp', get_template_directory_uri() . '/css/wp.css', array(), '' );
wp_enqueue_style( 'esc-bs-min', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '' );
wp_enqueue_style( 'esc-bs', get_template_directory_uri() . '/css/bs.css', array(), '' );
wp_enqueue_style( 'esc-style', get_stylesheet_uri() );
// Load the Internet Explorer specific stylesheet.
wp_enqueue_style( 'esc-ie', get_template_directory_uri() . '/css/ie.css', array( 'esc-style' ), '' );
wp_style_add_data( 'esc-ie', 'conditional', 'lt IE 9' );
// Load the Internet Explorer 7 specific stylesheet.
wp_enqueue_style( 'esc-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'esc-style' ), '' );
wp_style_add_data( 'esc-ie7', 'conditional', 'lt IE 8' );
wp_enqueue_script( 'esc-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '', 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( 'esc-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '' );
}
wp_enqueue_script( 'esc-script-bs', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'esc-script-functions', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '', true );
wp_localize_script( 'esc-script-functions', 'screenReaderText', array(
'expand' => '<span class="screen-reader-text">' . __( 'expand child menu', 'esc' ) . '</span>',
'collapse' => '<span class="screen-reader-text">' . __( 'collapse child menu', 'esc' ) . '</span>',
) );
}
add_action( 'wp_enqueue_scripts', '_esc_scripts' );
/**
* Add a `screen-reader-text` class to the search form's submit button.
*
* @since Twenty Fifteen 1.0
*
* @param string $html Search form HTML.
* @return string Modified search form HTML.
*/
function _esc_search_form_modify( $html ) {
return str_replace( 'class="search-submit"', 'class="search-submit screen-reader-text"', $html );
}
add_filter( 'get_search_form', '_esc_search_form_modify' );
require get_template_directory() . '/inc/init.php';