-
Notifications
You must be signed in to change notification settings - Fork 3
/
functions.php
339 lines (307 loc) · 11.9 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
<?php
/**
* WordPress Sverige functions and definitions
*
* @package WordPress Sverige
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) :
$content_width = 640; /* pixels */
endif;
if ( ! function_exists( 'wpsvse_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 wpsvse_setup() {
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you're building a theme based on WordPress Sverige, use a find and replace
* to change 'wpsvse' to the name of your theme in all the template files
*/
load_theme_textdomain( 'wpsvse', get_template_directory() . '/languages' );
/* Always shot admin bar */
//show_admin_bar( true );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
/**
* Support title tag
*/
add_theme_support( 'title-tag' );
/**
* 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' );
/**
* Extra image sizes
*/
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'post-image', 850, 550, true );
add_image_size( 'about-grid-image', 500, 500, true );
}
/**
* Resizes avatars (buddypress)
*/
define ( 'BP_AVATAR_THUMB_WIDTH', 256 );
define ( 'BP_AVATAR_THUMB_HEIGHT', 256 );
define ( 'BP_AVATAR_FULL_WIDTH', 512 );
define ( 'BP_AVATAR_FULL_HEIGHT', 512 );
define ( 'BP_AVATAR_ORIGINAL_MAX_WIDTH', 512 );
define ( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 819200 );
define ( 'BP_AVATAR_TINY_WIDTH', 50);
define ( 'BP_AVATAR_TINY_HEIGHT', 50);
/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus( array(
'primary' => __( 'Huvudmeny', 'wpsvse' ),
'footer' => __( 'Sidfot', 'wpsvse' ),
'gp-menu' => __( 'GP', 'wpsvse' ),
) );
// Register Custom Navigation Walker
require_once('inc/wp_bootstrap_navwalker.php');
}
endif; // wpsvse_setup
add_action( 'after_setup_theme', 'wpsvse_setup' );
if ( ! function_exists( 'wpsvse_widgets_init' ) ) :
/**
* Register widgetized area and update sidebar with default widgets
*/
add_filter('widget_text', 'do_shortcode');
function wpsvse_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidofält', 'wpsvse' ),
'id' => 'sidebar-1',
'description' => 'Allmänt widgetfält för sidopaneler i generella mallar, så som t.ex sökresultat.',
'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' => __( 'Sidofält för nyheter', 'wpsvse' ),
'id' => 'news-widgets',
'description' => 'Widgetfält för sidopaneler på nyhetssidor.',
'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' => __( 'Sidofält för blogg', 'wpsvse' ),
'id' => 'blog-widgets',
'description' => 'Widgetfält för sidopaneler på bloggsidor.',
'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' => __( 'Sidofält för filarkiv', 'wpsvse' ),
'id' => 'file-widgets',
'description' => 'Widgetfält för sidofält på bloggsidor.',
'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' => __( 'Huvudsponsor', 'wpsvse' ),
'id' => 'sponsor-widget',
'description' => 'Widgetfält på startsidan för huvudsponsor.',
'before_widget' => '<div id="%1$s" class="widget sponsor-link %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title screen-reader-text">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Widgets för 404', 'wpsvse' ),
'id' => 'error-404',
'description' => 'Widgetfält som visas på felsidan för 404.',
'before_widget' => '<aside id="%1$s" class="col-md-4 widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => __( 'Gruppregler', 'wpsvse' ),
'id' => 'groups-creation-rules',
'description' => 'Widgetfält som används för att visa regler för att skapa nya grupper.',
'before_widget' => '<div id="%1$s" class="box-shortcode box-info %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'TOS Registrering', 'wpsvse' ),
'id' => 'register-tos',
'description' => 'Widgetfält som används för att visa webbplatsens förhållningsregler vid registrering.',
'before_widget' => '<div id="%1$s" class="register-tos-content %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title screen-reader-text">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Sidofält för översättningsprojekt', 'wpsvse' ),
'id' => 'translator-widgets',
'description' => 'Widgetfält för sidofält på sidor för översättningsprojekt och validatorer.',
'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' => __( 'Flikar för Twitter', 'wpsvse' ),
'id' => 'tab-widget',
'description' => 'Widgetfält för flik-widget på startsidan.',
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title screen-reader-text">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Slack (inloggad)', 'wpsvse' ),
'id' => 'slack-members',
'description' => 'Widgetfält för inbjudan till Slack (Medlemmar).',
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title screen-reader-text">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Slack (inte inloggad)', 'wpsvse' ),
'id' => 'slack',
'description' => 'Widgetfält för inbjudan till Slack (ej inloggad).',
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title screen-reader-text">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Twitter-flik - #wpse', 'wpsvse' ),
'id' => 'twitter-wpse',
'description' => 'Twitterwidget för #wpse.',
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title screen-reader-text">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Twitter-flik - @WPSverige', 'wpsvse' ),
'id' => 'twitter-wpsverige',
'description' => 'Twitterwidget för @WPSverige.',
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title screen-reader-text">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Notis - Översättningsplattform', 'wpsvse' ),
'id' => 'gp-notice',
'description' => 'Notiser som visas under sidhuvudet i översättningsplattformen GlotPress.',
'before_widget' => '<div id="%1$s" class="box-shortcode box-info %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title screen-reader-text">',
'after_title' => '</h3>',
) );
}
endif;
add_action( 'widgets_init', 'wpsvse_widgets_init' );
/**
* Enqueue scripts and styles
*/
function wpsvse_scripts() {
// Enqueue Stylesheets
wp_enqueue_style( 'bootstrap-style', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'fontawesome-style', get_template_directory_uri() . '/css/font-awesome.min.css' );
wp_enqueue_style( 'dropdowns-enhancement-style', get_template_directory_uri() . '/css/dropdowns-enhancement.min.css' );
// wp_enqueue_style( 'bbpress-style', get_template_directory_uri() . '/css/bbpress.css' );
wp_enqueue_style( 'wpsvse-style', get_stylesheet_uri() );
// Engueue Javascripts
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '3.3.2', true );
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/dropdowns-enhancement.js', array('jquery'), '3.2.0', true );
wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/js/modernizr.min.js', array(), '2.8.3' );
wp_enqueue_script( 'HTML5shiv', get_template_directory_uri() . '/js/html5shiv.js', array('jquery'), '3.7.0' );
wp_enqueue_script( 'respond_js', get_template_directory_uri() . '/js/respond.min.js', array('jquery'), '1.3.0' );
wp_enqueue_script( 'magnific_popup', get_template_directory_uri() . '/js/jquery.magnific-popup.min.js', array('jquery'), '1.0.0' );
wp_enqueue_script( 'match_height', get_template_directory_uri() . '/js/jquery.matchHeight-min.js', array('jquery'), '1.0.0' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_page('oversatt') ) {
wp_enqueue_script( 'jquery-iframe-auto-height', get_template_directory_uri() . '/js/jquery-iframe-auto-height.min.js', array('jquery'), '2.0.0' );
}
wp_enqueue_script( 'wpsvse-scripts', get_template_directory_uri() . '/js/wpsvse.js', array(), '20140719', true );
}
add_action( 'wp_enqueue_scripts', 'wpsvse_scripts' );
// Set editor style
add_filter('the_editor_content', 'wpsvse_add_editor_styles');
function wpsvse_add_editor_styles($content) {
add_editor_style('css/wpsvse-editor-style.css');
if ( ! is_admin() ) {
global $editor_styles;
$editor_styles = (array) $editor_styles;
$stylesheet = (array) $stylesheet;
$stylesheet[] = 'css/wpsvse-editor-style.css';
$editor_styles = array_merge( $editor_styles, $stylesheet );
}
return $content;
}
/*
* Set WordPress email and name
*/
// Set from email
add_filter( 'wp_mail_from', 'wpsvse_mail_from' );
function wpsvse_mail_from( $email )
{
return "[email protected]";
}
// Set from name
add_filter( 'wp_mail_from_name', 'wpsvse_mail_from_name' );
function wpsvse_mail_from_name( $name )
{
return "WordPress Sverige";
}
/**
* Custom callback function for comments.
*/
require get_template_directory() . '/inc/wpsvse_comments.php';
/**
* 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';
/**
* Custom functions metaboxes
*/
require get_template_directory() . '/inc/metaboxes.php';
/**
* Custom shortcodes
*/
require get_template_directory() . '/inc/shortcodes.php';
/**
* Branding and adminbar functions
*/
require get_template_directory() . '/inc/branding.php';
/**
* Custom BuddyPress Docs
*/
// require get_template_directory() . '/inc/bp-doc-functions.php';
/**
* CPTs
*/
require get_template_directory() . '/inc/cpt-blog.php';
require get_template_directory() . '/inc/cpt-person.php';