template-functions.php 2.39 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

  if (is_singular('post')) {
36
    $menu = str_replace( 'news', 'news current-menu-item', $menu );
Benthe Kuijpers's avatar
Benthe Kuijpers committed
37
  }
38
  if (get_post_type($post) == 'resources') {
39
    $menu = str_replace( 'resources', 'resources current-menu-item', $menu );
40
41
42
  }
  return $menu;
}
43
44
45
46
47
48
49
50
51
52
add_filter( 'nav_menu_css_class', 'current_menu_item_for_archives', 10,2 );

add_action('wp_dashboard_setup', 'mio_custom_dashboard_widgets');
  
function mio_custom_dashboard_widgets() {
  global $wp_meta_boxes;
  wp_add_dashboard_widget('custom_help_widget', 'Make It Open - website manual', 'mio_dashboard_widget');
}
 
function mio_dashboard_widget() {
alain's avatar
alain committed
53
  echo '<a href="' . home_url() . '"><img src="' . get_template_directory_uri() . '/assets/img/make-it-open-logo-wordmark.png" width="100%" style="margin:0 0 20px"></a>';
54
55
56
57
58
59
60
61
62
63
  echo '<strong>Welcome to the Make It Open CMS!</strong>';
  echo '<p>Here is a list quick links to edit this site:</p>';
  echo '<li><a href="' . admin_url() . '/post-new.php">Add a news article</a></li>';
  echo '<li><a href="' . admin_url() . '/post-new.php?post_type=page">Add a new page</a></li>';
  echo '<li><a href="' . admin_url() . '/post-new.php?post_type=resources">Add a new resource</a></li>';
  echo '<li><a href="' . admin_url() . '/post-new.php?post_type=events">Add a new event</a></li>';
  echo '<li><a href="' . admin_url() . '/post.php?post=2&action=edit">Change the homepage</a></li>';
  echo '<li><a href="' . admin_url() . '/nav-menus.php">Change the menu</a></li>';
  echo '<li><a href="' . admin_url() . '/admin.php?page=acf-options-footer">Change the footer</a></li>';
}