I’ve been hacking away at modifying the “Right Now” widget in the WordPress dashboard, and although there are some hooks/filters which apply to just that, they are sparsely documented or explained.
Using the example given here, I’ve created a new row of information in the “Content” section of the widget… I also tried a few other hooks and one of them placed my row of information in the “Discussion” section of the widget… However, I don’t really feel that this data belongs in either of those two sections…
Does anyone know how, or if it’s possible to add a new section to the “Right Now” widget? I’d like to add my own section called “Feedback” which would be styled much like the comments (“Discussion”) section.
Here’s the code I’m using at the moment:
function add_testimonial_counts() {
if(!post_type_exists('testimonials')) {
return;
}
$num_posts = wp_count_posts('testimonials');
$num = number_format_i18n($num_posts->publish);
$text = _n('Approved Testimonial', 'Approved Testimonials', intval($num_posts->publish));
if(current_user_can('edit_posts')) {
$num = "<a href='edit.php?post_type=testimonials'>$num</a>";
$text = "<a href='edit.php?post_type=testimonials'>$text</a>";
}
echo '<td class="first b b-testimonials">'.$num.'</td>';
echo '<td class="t testimonials">'.$text.'</td>';
echo '</tr>';
if($num_posts->pending > 0) {
$num = number_format_i18n($num_posts->pending);
$text = _n('Testimonial Pending', 'Testimonials Pending', intval($num_posts->pending));
if(current_user_can('edit_posts')) {
$num = "<a href='edit.php?post_status=pending&post_type=testimonials'>$num</a>";
$text = "<a href='edit.php?post_status=pending&post_type=testimonials'>$text</a>";
}
echo '<td class="first b b-testimonials">'.$num.'</td>';
echo '<td class="t testimonials">'.$text.'</td>';
echo '</tr>';
}
if($num_posts->draft > 0) {
$num = number_format_i18n($num_posts->draft);
$text = _n('Testimonial Draft', 'Testimonial Drafts', intval($num_posts->draft));
if(current_user_can('edit_posts')) {
$num = "<a href='edit.php?post_status=draft&post_type=testimonials'>$num</a>";
$text = "<a href='edit.php?post_status=draft&post_type=testimonials'>$text</a>";
}
echo '<td class="first b b-testimonials">'.$num.'</td>';
echo '<td class="t testimonials">'.$text.'</td>';
echo '</tr>';
}
}
add_action('right_now_content_table_end', 'add_testimonial_counts');
Here’s a screenshot of how it currently looks just so you can get a better idea of what I’m jabbering on about.
I believe the hook you are looking for is
right_now_discussion_table_end
Update:
From your comment i see that i did not explain myself, WordPress closes the table and div just after
right_now_discussion_table_end
action hook so you can useright_now_discussion_table_end
and at the begging of your function close the table and div yourself and open your own, then leave your custom table and div open and let WordPress close them.