-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunctions.php
executable file
·374 lines (319 loc) · 10.3 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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<?php
/**
* Indieweb Publisher functions and definitions
*
* @package Indieweb Publisher
* @since Indieweb Publisher 1.0
*/
/**
* Set the content width based on the theme's design and stylesheet.
*
* @since Indieweb Publisher 1.0
*/
if ( ! isset( $content_width ) ) {
$content_width = 700;
} /* pixels */
if ( ! function_exists( 'indieweb_publisher_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 Indieweb Publisher 1.0
*/
function indieweb_publisher_setup() {
/**
* Custom template tags for this theme.
*/
include get_template_directory() . '/inc/template-tags.php';
/**
* Customizer additions.
*/
include get_template_directory() . '/inc/customizer.php';
/**
* Template Functions
*/
include get_template_directory() . '/inc/template-functions.php';
/**
* MF2 Compatibility Functions
*/
include get_template_directory() . '/inc/mf2.php';
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
*/
load_theme_textdomain( 'indieweb-publisher', get_template_directory() . '/languages' );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
/**
* Add title tag support
*/
add_theme_support( 'title-tag' );
/**
* Enable Custom Backgrounds
*/
add_theme_support(
'custom-background',
apply_filters(
'indieweb_publisher_custom_background_args',
array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
// Enable support for HTML5 markup.
add_theme_support(
'html5',
array(
'comment-list',
'search-form',
'comment-form',
'gallery',
)
);
/**
* Enable Post Thumbnails
*/
add_theme_support( 'post-thumbnails' );
/**
* Enable Navigation Widgets
*/
add_theme_support( 'navigation-widgets' );
/**
* Enable Responsive Embeds
*/
add_theme_support( 'responsive-embeds' );
/*
* Add custom thumbnail size for use with featured images
*/
add_image_size( 'indieweb_publisher_post_thumbnail', 700, 700 );
/**
* Enable editor style
*/
add_editor_style();
/**
* Set max width of full screen visual editor to match content width
*/
set_user_setting( 'dfw_width', 700 );
/**
* Set default value for Show Post Word Count theme option
*/
add_option( 'indieweb_publisher_general_options', array( 'show_post_word_count' => true ) );
/**
* Set default value for Show Author Card theme option
*/
add_option( 'indieweb_publisher_general_options', array( 'show_author_card' => true ) );
/**
* Set default value for Show Post Thumbnails theme option
*/
add_option( 'indieweb_publisher_excerpt_options', array( 'show_post_thumbnails' => false ) );
/**
* This theme uses wp_nav_menu() in two locations.
*/
register_nav_menus(
array(
'primary' => __( 'Primary Menu', 'indieweb-publisher' ),
'single' => __( 'Single Posts Menu', 'indieweb-publisher' ),
)
);
/**
* Add support for Post Formats if Post Kinds are not loaded
*/
if ( ! class_exists( 'Kind_Taxonomy' ) ) {
add_theme_support(
'post-formats',
array(
'aside',
'link',
'gallery',
'status',
'quote',
'chat',
'image',
'video',
'audio',
)
);
}
}
endif; // indieweb_publisher_setup
add_action( 'after_setup_theme', 'indieweb_publisher_setup' );
/**
* Include additional plugin support routines
*/
require get_template_directory() . '/inc/plugin-support.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* Register widgetized areas and update sidebar with default widgets
*
* @since Indieweb Publisher 1.0
*/
function indieweb_publisher_widgets_init() {
register_sidebar(
array(
'name' => __( 'Sidebar', 'indieweb-publisher' ),
'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' => __( 'Footer', 'indieweb-publisher' ),
'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' => __( 'Archive Page', 'indieweb-publisher' ),
'id' => 'archive-page',
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);
}
add_action( 'widgets_init', 'indieweb_publisher_widgets_init' );
/**
* Enqueue scripts and styles
*/
function indieweb_publisher_scripts() {
global $post;
wp_enqueue_style( 'genericons-neue', get_template_directory_uri() . '/fonts/genericons-neue/Genericons-Neue.min.css', array(), '4.0.5' );
wp_enqueue_script( 'indieweb-publisher-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
if ( indieweb_publisher_option( 'show_page_load_progress_bar' ) ) {
wp_enqueue_style( 'nprogress', get_template_directory_uri() . '/css/nprogress.css', array(), '0.1.3' );
wp_enqueue_script( 'nprogress', get_template_directory_uri() . '/js/nprogress.js', array(), '0.1.3' );
}
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) && ! indieweb_publisher_hide_comments() ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image( $post->ID ) ) {
wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
}
if ( is_singular() ) {
wp_enqueue_script( 'fade-post-title', get_template_directory_uri() . '/js/fade-post-title.js', array( 'jquery' ) );
}
/**
* Load Jetpack Infinite Scroll Dark Overlay Bug Fix
*/
indieweb_publisher_jetpack_dark_overlay_fix_css();
/*
* Load WP-PageNavi CSS enhancements, if applicable.
*/
indieweb_publisher_wp_pagenavi_css();
}
add_action( 'wp_enqueue_scripts', 'indieweb_publisher_scripts' );
if ( ! function_exists( 'indieweb_publisher_progress_bar_markup' ) ) :
/**
* Insert Page Load Progress Bar markup
*/
function indieweb_publisher_progress_bar_markup() {
if ( indieweb_publisher_option( 'show_page_load_progress_bar' ) ) {
indieweb_publisher_show_page_load_progress_bar();
}
}
endif;
add_action( 'wp_footer', 'indieweb_publisher_progress_bar_markup' );
if ( ! function_exists( 'indieweb_publisher_remove_locale_stylesheet' ) ) :
/**
* Remove locale_stylesheet() hook to prevent WordPress from
* automatically loading rtl.css. We need to load this manually
* so that we can load it before loading CSS from Customizer.
*
* @see /~https://github.com/raamdev/indieweb-publisher/issues/230
*/
function indieweb_publisher_remove_locale_stylesheet() {
remove_action( 'wp_head', 'locale_stylesheet' );
}
endif;
if ( ! function_exists( 'indieweb_publisher_stylesheet_rtl' ) ) :
/**
* Enqueue RTL stylesheet
*/
function indieweb_publisher_stylesheet_rtl() {
wp_enqueue_style( 'indieweb-publisher-style', get_template_directory_uri() . '/css/rtl-style.css' );
}
endif;
if ( ! function_exists( 'indieweb_publisher_stylesheet' ) ) :
/**
* Enqueue main stylesheet
*/
function indieweb_publisher_stylesheet() {
wp_enqueue_style( 'indieweb-publisher-style', get_template_directory_uri() . '/css/default.min.css' );
}
endif;
/*
* Loads the PHP file that generates the Customizer CSS for the front-end
*/
function indieweb_publisher_customizer_css() {
include get_template_directory() . '/css/customizer.css.php';
wp_die();
}
/*
* Enqueue the AJAX call to the dynamic Customizer CSS
* See http://codex.wordpress.org/AJAX_in_Plugins
*/
function indieweb_publisher_customizer_stylesheet() {
wp_enqueue_style( 'customizer', admin_url( 'admin-ajax.php' ) . '?action=indieweb_publisher_customizer_css', array(), '1.7' );
}
add_action( 'wp_ajax_indieweb_publisher_customizer_css', 'indieweb_publisher_customizer_css' );
add_action( 'wp_ajax_nopriv_indieweb_publisher_customizer_css', 'indieweb_publisher_customizer_css' );
/*
* IMPORTANT: Customizer CSS *must* be called _after_ the main stylesheet,
* to ensure that customizer-modified styles override the defaults.
*/
if ( is_rtl() ) {
add_action( 'init', 'indieweb_publisher_remove_locale_stylesheet' );
add_action( 'wp_enqueue_scripts', 'indieweb_publisher_stylesheet_rtl' );
} else {
add_action( 'wp_enqueue_scripts', 'indieweb_publisher_stylesheet' );
}
add_action( 'wp_enqueue_scripts', 'indieweb_publisher_customizer_stylesheet' );
if ( ! function_exists( 'indieweb_publisher_wp_fullscreen_title_editor_style' ) ) :
/**
* Enqueue the stylesheet for styling the full-screen visual editor post title
* so that it closely matches the front-end theme design. Hat tip to Helen:
* https://core.trac.wordpress.org/ticket/25783#comment:3
*/
function indieweb_publisher_wp_fullscreen_title_editor_style() {
if ( 'post' === get_current_screen()->base ) {
wp_enqueue_style( 'indieweb-publisher-wp-fullscreen-title', get_template_directory_uri() . '/css/wp-fullscreen-title.css', array(), '1.0' );
}
}
endif;
add_action( 'admin_enqueue_scripts', 'indieweb_publisher_wp_fullscreen_title_editor_style' );
if ( ! function_exists( 'indieweb_publisher_get_footer_credits' ) ) :
/**
* Returns the theme's footer credits
*
* @return string
*
* @since Indieweb Publisher 1.0
*/
function indieweb_publisher_get_footer_credits() {
return sprintf(
'%1$s',
sprintf( __( '%1$s empowered by %2$s', 'indieweb-publisher' ), '<a href="' . esc_url( 'http://independentpublisher.me' ) . '" rel="designer" title="Indieweb Publisher: A beautiful reader-focused WordPress theme, for you.">Indieweb Publisher</a>', '<a href="http://wordpress.org/" rel="generator" title="WordPress: A free open-source publishing platform">WordPress</a>' )
);
}
endif;
/**
* Implement the Custom Logo feature
*/
require get_template_directory() . '/inc/custom-logo.php';