-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfunctions.php
More file actions
282 lines (246 loc) · 8.63 KB
/
functions.php
File metadata and controls
282 lines (246 loc) · 8.63 KB
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
<?php
/**
* Binary Bootstrap functions and definitions.
*
* Sets 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 (see http://codex.wordpress.org/Theme_Development
* and http://codex.wordpress.org/Child_Themes), 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.
*
* 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,
* see http://codex.wordpress.org/Plugin_API
*
* @package WordPress
* @subpackage Binary_Bootstrap
* @since Binary Bootstrap 1.0
*/
/**
* Sets up the content width value based on the theme's design.
* @see binarybootstrap_content_width() for template-specific adjustments.
*/
if ( !isset( $content_width ) )
$content_width = 940;
/**
* Custom template tags for this theme.
*/
require_once locate_template( '/inc/binarybootstrap-template-tags.php' );
/**
* Custom functions that act independently of the theme templates
*/
require_once locate_template( '/inc/binarybootstrap-filters.php' );
/**
* Custom Comment Walker
*/
require_once locate_template( '/inc/binarybootstrap-walker-comment.php' );
/**
* Custom Menu Walker
*/
require_once locate_template( '/inc/binarybootstrap-walker-menu.php' );
/**
* Bootstrap gallery shortcode
*/
require_once locate_template( '/inc/binarybootstrap-gallery.php' );
/**
* Binary Bootstrap only works in WordPress 3.6 or later.
*/
if ( version_compare( $GLOBALS['wp_version'], '3.6-alpha', '<' ) )
require get_template_directory() . '/inc/back-compat.php';
/**
* Sets up theme defaults and registers the various WordPress features that
* Binary Bootstrap supports.
*
* @uses load_theme_textdomain() For translation/localization support.
* @uses add_editor_style() To add Visual Editor stylesheets.
* @uses add_theme_support() To add support for automatic feed links, post
* formats, and post thumbnails.
* @uses register_nav_menu() To add support for a navigation menu.
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
*
* @since Binary Bootstrap 1.0
*
* @return void
*/
function binarybootstrap_setup() {
/*
* Makes Binary Bootstrap available for translation.
*
* Translations can be added to the /languages/ directory.
* If you're building a theme based on Binary Bootstrap, use a find and
* replace to change 'binarybootstrap' to the name of your theme in all
* template files.
*/
load_theme_textdomain( 'binarybootstrap', get_template_directory() . '/languages' );
/*
* 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', 'fonts/genericons.css' ) );
// Adds RSS feed links to <head> for posts and comments.
add_theme_support( 'automatic-feed-links' );
// Switches default core markup for search form to output valid HTML5.
add_theme_support( 'html5', array('search-form', 'comment-form', 'comment-list') );
/*
* This theme supports 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 uses wp_nav_menu() in two locations.
*/
register_nav_menus( array(
'top_nav' => __( 'Top Navbar', 'binarybootstrap' ),
'primary' => __( 'Primary Menu', 'binarybootstrap' ),
) );
/*
* This theme uses a custom image size for featured images, displayed on
* "standard" posts and pages.
*/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 1140, 712, true );
/**
* Use Bootstrap thumbnails and grid for [gallery]
*/
add_theme_support( 'bootstrap-gallery' );
// This theme uses its own gallery styles.
add_filter( 'use_default_gallery_style', '__return_false' );
}
add_action( 'after_setup_theme', 'binarybootstrap_setup' );
/**
* Loads our special font CSS file.
*
* To disable in a child theme, use wp_dequeue_style()
* function mytheme_dequeue_fonts() {
* wp_dequeue_style( 'binarybootstrap-fonts' );
* }
* add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 );
*
* Also used in the Appearance > Header admin panel:
* @see binarybootstrap_custom_header_setup()
*
* @since Binary Bootstrap 1.0
*
* @return void
*/
function binarybootstrap_fonts() {
$fonts_url = binarybootstrap_fonts_url();
if ( !empty( $fonts_url ) )
wp_enqueue_style( 'binarybootstrap-fonts', esc_url_raw( $fonts_url ), array(), null );
}
//add_action( 'wp_enqueue_scripts', 'binarybootstrap_fonts' );
/**
* Enqueues scripts and styles for front end.
*
* @since Binary Bootstrap 1.0
*
* @return void
*/
function binarybootstrap_scripts_styles() {
/* Stylesheets */
wp_enqueue_style( 'binarybootstrap', get_template_directory_uri() . '/css/binarybootstrap.min.css', false, null );
/* Load the main stylesheet */
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), null, true );
/*
* Adds JavaScript to pages with the comment form to support sites with
* threaded comments (when in use).
*/
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
}
add_action( 'wp_enqueue_scripts', 'binarybootstrap_scripts_styles' );
/**
* Registers two widget areas.
*
* @since Binary Bootstrap 1.0
*
* @return void
*/
function binarybootstrap_widgets_init() {
register_sidebar( array(
'name' => __( 'Main Widget Area', 'binarybootstrap' ),
'id' => 'sidebar-1',
'description' => __( 'Appears in the footer section of the site.', 'binarybootstrap' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s ' . binarybootstrap_secondary_widget_class() . '">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Secondary Widget Area', 'binarybootstrap' ),
'id' => 'sidebar-2',
'description' => __( 'Appears on posts and pages in the sidebar.', 'binarybootstrap' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s ' . binarybootstrap_tertiary_widget_class() . '">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'binarybootstrap_widgets_init' );
/**
* Adjusts content_width value for video post formats and attachment templates.
*
* @since Binary Bootstrap 1.0
*
* @return void
*/
function binarybootstrap_content_width() {
global $content_width;
if ( is_active_sidebar( 'sidebar-2' ) )
$content_width = 870;
elseif ( is_attachment() )
$content_width = 940;
elseif ( has_post_format( 'audio' ) )
$content_width = 484;
}
add_action( 'template_redirect', 'binarybootstrap_content_width' );
/**
* Add postMessage support for site title and description for the Customizer.
*
* @since Binary Bootstrap 1.0
*
* @param WP_Customize_Manager $wp_customize Customizer object.
* @return void
*/
function binarybootstrap_customize_register($wp_customize) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->add_setting( 'display_site_title', array('default' => 1) );
$wp_customize->add_control( 'display_site_title', array(
'settings' => 'display_site_title',
'label' => __( 'Display site title', 'binarybootstrap' ),
'section' => 'title_tagline',
'type' => 'checkbox',
) );
}
add_action( 'customize_register', 'binarybootstrap_customize_register' );
/**
* Binds JavaScript handlers to make Customizer preview reload changes
* asynchronously.
*
* @since Binary Bootstrap 1.0
*/
function binarybootstrap_customize_preview_js() {
wp_enqueue_script( 'binarybootstrap-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array('customize-preview'), '20130226', true );
}
add_action( 'customize_preview_init', 'binarybootstrap_customize_preview_js' );
/**
* Replace the [gallery] shortcode
*
*/
function binarybootstrap_gallery_support() {
if ( current_theme_supports( 'bootstrap-gallery' ) ) {
remove_shortcode( 'gallery' );
add_shortcode( 'gallery', 'binarybootstrap_gallery_shortcode' );
}
}
add_action( 'template_redirect', 'binarybootstrap_gallery_support' );