template-functions.php 1.26 KB
Newer Older
1
<?php
2
// WP admin logo
3
4
5
6
7
8
9
10
11
function mio_admin_logo() { ?> 
	<style type="text/css"> 
		body.login div#login h1 a {
		 	background-image: url('<?php echo get_template_directory_uri(); ?>/assets/img/wordmark.png');
		 	width: 200px;
		 	background-size: 200px;
		} 
	</style>
<?php }
Benthe Kuijpers's avatar
Benthe Kuijpers committed
12
13
add_action( 'login_enqueue_scripts', 'mio_admin_logo' );

14
// Allow SVG files
Benthe Kuijpers's avatar
Benthe Kuijpers committed
15
function cc_mime_types($mimes) {
Benthe Kuijpers's avatar
Benthe Kuijpers committed
16
17
  $mimes['svg'] = 'image/svg+xml';
  return $mimes;
Benthe Kuijpers's avatar
Benthe Kuijpers committed
18
}
19
20
21
22
23
24
add_filter('upload_mimes', 'cc_mime_types');

// Custom excerpt length
function excerpt($string,$length) {
  $string = strip_tags($string);
  if (strlen($string) > $length) {
Benthe Kuijpers's avatar
Benthe Kuijpers committed
25
26
    $stringCut = substr($string, 0, $length);
    $string = substr($stringCut, 0, strrpos($stringCut, ' ')). ' ...';
27
28
29
30
31
32
33
  }
  return $string;
}

// Fix current menu item class for CPT archives
function current_menu_item_for_archives($menu) {
  global $post;
Benthe Kuijpers's avatar
Benthe Kuijpers committed
34
35
36
37

  if (is_singular('post')) {
    $menu = str_replace( 'news', 'current-menu-item', $menu );
  }
38
39
40
41
42
43
44
45
46
  if (get_post_type($post) == 'resources') {
    $menu = str_replace( 'resources', 'current-menu-item', $menu );
  }
  if (get_post_type($post) == 'events') {
    $menu = str_replace( 'events', 'current-menu-item', $menu );
  }
  return $menu;
}
add_filter( 'nav_menu_css_class', 'current_menu_item_for_archives', 10,2 );