-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
251 lines (219 loc) · 6.99 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
<?php
/**
* Figure/Ground functions and definitions.
*
* @package Figure/Ground
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 576; /* pixels */
}
if ( ! function_exists( 'figureground_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 figureground_setup() {
/**
* Make theme available for translation via language packs.
*/
load_theme_textdomain( 'figureground' );
/*
* 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 to resemble the theme style,
* specifically font, colors, icons, and column width.
*/
add_editor_style( array( 'editor-style.css', 'genericons/genericons/genericons.css', figureground_fonts_url() ) );
// 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' ) );
/**
* 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' );
set_post_thumbnail_size( 640, 320, true );
/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'figureground' ),
'social' => __( 'Social', 'figureground' ),
) );
/**
* Enable support for Post Formats.
*/
add_theme_support( 'post-formats', array( 'aside', 'image', 'gallery', 'video', 'audio', 'quote', 'link' ) );
/**
* Enable support for automatic feed links.
*/
add_theme_support( 'automatic-feed-links' );
/**
* Set up custom headers.
*
* There is no image by default, and headers are fairly small in this theme.
*/
$defaults = array(
'width' => 48,
'height' => 48,
'flex-height' => false,
'flex-width' => true,
'header-text' => false,
'uploads' => true,
);
add_theme_support( 'custom-header', $defaults );
/**
* Allow widgets to be previewed faster in the customizer with selective refresh.
*/
add_theme_support( 'customize-selective-refresh-widgets' );
/*
* Add theme support for starter content.
*/
add_theme_support( 'starter-content', array(
// No widgets by default for simplicity.
'posts' => array(
'about',
'contact',
),
'options' => array(
'show_on_front' => 'posts',
),
'nav_menus' => array(
'primary' => array(
'name' => __( 'Primary Menu', 'figureground' ),
'items' => array(
'link_home' => array( // The core `page_home` item is wrong. See https://core.trac.wordpress.org/ticket/39104.
'title' => __( 'Home', 'figureground' ),
'url' => get_home_url(),
),
'page_about',
'page_contact',
),
),
'social' => array(
'name' => __( 'Social Links Menu', 'figureground' ),
'items' => array(
'link_facebook',
'link_twitter',
'link_youtube',
'link_email',
),
),
),
) );
}
endif; // figureground_setup
add_action( 'after_setup_theme', 'figureground_setup' );
/**
* Register widgetized area and update sidebar with default widgets.
*/
function figureground_widgets_init() {
register_sidebar( array(
'name' => __( 'Footer', 'figureground' ),
'id' => 'main',
'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', 'figureground_widgets_init' );
/**
* Enqueue scripts and styles
*/
function figureground_scripts() {
wp_enqueue_style( 'figureground-style', get_stylesheet_uri() );
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons/genericons.css', '3.0.3' );
wp_enqueue_style( 'figureground-fonts', figureground_fonts_url() );
// Adds Masonry to handle vertical alignment of footer widgets.
if ( is_active_sidebar( 'main' ) ) {
wp_enqueue_script( 'jquery-masonry' );
}
// Includes misc. theme scripts.
wp_enqueue_script( 'figureground-functions', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20160717', true );
// Load Figure/Ground animation.
wp_enqueue_script( 'figureground', get_template_directory_uri() . '/js/figure-ground.js', array(), '20140622', false );
// Load theme options to pass to the Figure/Ground script.
$type = get_theme_mod( 'fg_type', 'orthogonal' );
$maxh = get_theme_mod( 'fg_max_height', 256 );
$maxw = get_theme_mod( 'fg_max_width', 256 );
$maxr = $maxw * 2 / 3;
$delay = get_theme_mod( 'fg_speed', 320 );
$initial = get_theme_mod( 'fg_initial', 192 );
$color = get_theme_mod( 'fg_color_dark', '#222' );
// Pass data to JS.
$settings = array(
'type' => $type,
'maxw' => $maxw,
'maxh' => $maxh,
'maxr' => $maxr,
'delay' => $delay,
'initial' => $initial,
'color' => $color,
);
wp_localize_script( 'figureground', 'figureGroundSettings', $settings );
// Misc. theme scripts.
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'figureground-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20140623' );
}
}
add_action( 'wp_enqueue_scripts', 'figureground_scripts' );
/**
* Get the url of the webfonts required for the theme.
*
* @since Figure/Ground 1.0
*
* @return string Fonts url.
*/
function figureground_fonts_url() {
$font_families = array();
$font_families[] = 'Raleway:400,600';
$font_families[] = 'Merriweather Sans:400,700,400italic';
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, "//fonts.googleapis.com/css" );
return $fonts_url;
}
/**
* Adjust content_width value for post-formatted posts.
*
* @since Figure/Ground 1.0
*
* @return void
*/
function figureground_content_width() {
global $content_width;
if ( has_post_format() ) {
$content_width = 448;
}
}
add_action( 'template_redirect', 'figureground_content_width' );
/**
* 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';
/**
* Register theme options via the Customizer.
*/
require get_template_directory() . '/inc/customizer.php';