-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunmus_glance.php
63 lines (48 loc) · 1.71 KB
/
unmus_glance.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
<?php
/**
* Glance
*
* @package unmus
* @since 0.7
*/
// Security: Stops code execution if WordPress is not loaded
if (!defined('ABSPATH')) { exit; }
/**
* Add Custom Post Types @ Auf einen Blick
*
* @param array Blank
* @return array Extra Widget Items
*/
function unmus_custom_post_types_glance( $items = array() ) {
$post_types = array( 'ello', 'raketenstaub', 'podcast', 'pinseldisko' );
foreach( $post_types as $type ) {
if( ! post_type_exists( $type ) ) continue;
$num_posts = wp_count_posts( $type );
if( $num_posts ) {
$published = intval( $num_posts->publish );
$post_type = get_post_type_object( $type );
$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'your_textdomain' );
$text = sprintf( $text, number_format_i18n( $published ) );
if ( current_user_can( $post_type->cap->edit_posts ) ) {
$output = '' . $text . '';
echo '<li class="post-count"><a class="'.esc_attr($type).'-count" href="edit.php?post_type='.esc_attr($type).'">' . esc_html($output) . '</a></li>';
} else {
$output = '' . $text . '';
echo ' ' . esc_html($output) . '';
}
}
}
return $items;
}
add_filter( 'dashboard_glance_items', 'unmus_custom_post_types_glance', 10, 1 );
/**
* Enqueue Plugin CSS Styles
*
* Styles are required for "At A Glance" Extensions in WordPress Dashboard
*
*/
function unmus_plugin_admin_styles() {
wp_enqueue_style('admin-styles', plugin_dir_url( __FILE__ ).'/unmus_styles.css');
}
add_action('admin_enqueue_scripts', 'unmus_plugin_admin_styles');
?>