forked from fant0mex/DIAS_
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·88 lines (66 loc) · 2.28 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
<?php
if (!current_user_can(‘edit_posts’)) {
show_admin_bar(false);
}
add_theme_support( 'menus');
add_theme_support( 'post-thumbnails' );
add_image_size( $name, $width, $height, $crop );
function create_widget( $name, $id, $description ) {
$args = array(
'name' => __( $name ),
'id' => $id,
'description' => $description,
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
);
register_sidebar( $args );
}
create_widget( 'Blog page sidebar', "sidebar_single_blog", "Sidebar widget for single blog page");
create_widget( 'Blog listings sidebar', "sidebar_blog", "Sidebar widget for blog listings page");
add_action('init', 'create_custom_post_types');
function create_custom_post_types() {
register_post_type( 'work',
array(
'labels' => array(
'name' => __( 'Projects' ),
'singular_name' => __( 'Project' )
),
'public' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/images/admin-work.png',
'menu_position' => 7,
'has_archive' => true,
)
);
}
// Front end only, don't hack on the settings page
if ( ! is_admin() ) {
// Hook in early to modify the menu
// This is before the CSS "selected" classes are calculated
add_filter( 'wp_get_nav_menu_items', 'replace_placeholder_nav_menu_item_with_latest_post', 10, 3 );
}
// Replaces a custom URL placeholder with the URL to the latest post
function replace_placeholder_nav_menu_item_with_latest_post( $items, $menu, $args ) {
// Loop through the menu items looking for placeholder(s)
foreach ( $items as $item ) {
// Is this the placeholder we're looking for?
if ( '#latestpost' != $item->url )
continue;
// Get the latest post
$latestpost = get_posts( array(
'numberposts' => 1,
) );
if ( empty( $latestpost ) )
continue;
// Replace the placeholder with the real URL
$item->url = get_permalink( $latestpost[0]->ID );
}
// Return the modified (or maybe unmodified) menu items array
return $items;
}
function cc_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );