Suppongo tu abbia entrambi gli snippets nel file functions.php
Di conseguenza puoi richiamare la funzione custom_glance_items() anche dalla funzione custom_dashboard_help()
Codice PHP:
add_filter( 'dashboard_glance_items', 'custom_glance_items', 10, 1 );
function custom_glance_items( $items = array() ) {
$post_types = array( 'company', 'portfolios', 'events', 'deals', 'blog' );
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 ) ) {
$items[] = sprintf( '%2$s', $type, $text ) . "\n";
} else {
$items[] = sprintf( '<span class="%1$s-count">%2$s</span>', $type, $text ) . "\n";
}
}
}
return $items;
}
add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');
function my_custom_dashboard_widgets() {
global $wp_meta_boxes;
wp_add_dashboard_widget('custom_help_widget', 'Diario', 'custom_dashboard_help');
}
function custom_dashboard_help() {
$items=custom_glance_items( array() );//richiamo la funzione
foreach($items as $item){//loop sull'array ritornato
echo $item.'<br>'; //stampo gli elementi dell'array
}
}
Nota che ho invertito l'ordine degli snippets