WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 3 years ago

Last modified 18 months ago

#15406 closed enhancement (wontfix)

Add a pending post count indicator to the admin menu

Reported by: iign Owned by:
Milestone: Priority: normal
Severity: trivial Version: 3.0.1
Component: Posts, Post Types Keywords: has-patch
Focuses: ui, administration Cc:

Description

Comments has an indicator bubble on the dashboard with the pending comments count.

Pending posts should have such a feature, since they are quite more important.

Attachments (2)

15406.diff (2.9 KB) - added by nikolov.tmw 3 years ago.
15406.2.diff (3.0 KB) - added by nikolov.tmw 3 years ago.
Same patch, but created from the root directory

Download all attachments as: .zip

Change History (16)

#1 @nacin
7 years ago

  • Keywords 2nd-opinion added; pending posts removed
  • Milestone changed from Awaiting Review to Future Release

#2 @somatic
7 years ago

  • Summary changed from Pending posts indicator not showing in menu bar to /

Not sure how to integrate this code into the core menu functions, but here's a workaround I'm currently using, which should demonstrate what's missing in the current menu output:

add_filter( 'add_menu_classes', 'show_pending_number');
function show_pending_number( $menu ) {
    $type = "animals";
    $status = "pending";
    $num_posts = wp_count_posts( $type, 'readable' );
    $pending_count = 0;
    if ( !empty($num_posts->$status) )
        $pending_count = $num_posts->$status;

    // build string to match in $menu array
    if ($type == 'post') {
        $menu_str = 'edit.php';
    // support custom post types
    } else {
        $menu_str = 'edit.php?post_type=' . $type;
    }

    // loop through $menu items, find match, add indicator
    foreach( $menu as $menu_key => $menu_data ) {
        if( $menu_str != $menu_data[2] )
            continue;
        $menu[$menu_key][0] .= " <span class='update-plugins count-$pending_count'><span class='plugin-count'>" . number_format_i18n($pending_count) . '</span></span>';
    }
    return $menu;
}

#3 @somatic
7 years ago

  • Summary changed from / to Pending posts indicator not showing in menu

#4 @helen
5 years ago

  • Component changed from UI to Administration
  • Keywords ui-focus added
  • Milestone changed from Future Release to Awaiting Review
  • Summary changed from Pending posts indicator not showing in menu to Add a pending post count indicator to the admin menu

Not totally sure what constitutes a pending post, especially once various post statuses are thrown into the mix.

#5 @celloexpressions
4 years ago

I like this idea. I'd consider a pending post one with the "Pending Review" status. Shown only for users who can publish_posts, this would serve a similar function to the comment count. It indicates that there are posts from contributors that are awaiting review and must be approved/published or reverted to drafts.

#6 @nacin
4 years ago

  • Component changed from Administration to Posts, Post Types
  • Focuses administration added

#7 @wonderboymusic
3 years ago

  • Keywords needs-patch added; 2nd-opinion removed
  • Milestone changed from Awaiting Review to Future Release

#8 @nikolov.tmw
3 years ago

  • Keywords has-patch added; needs-patch removed

I'm attaching a patch that introduces a new function called pending_posts_bubble()(naming convention suggestions anyone?) that when passed a post type slug, returns:

  • NULL if the post type doesn't exist.
  • false if the current user is not capable of publishing posts from that post type.
  • empty string if there are no pending posts.
  • HTML string for the bubble containing the number of pending posts.

Behind the scenes the function uses wp_count_posts() - that seemed like the most appropriate existing function to use.

pending_posts_bubble() is then called in the appropriate places in wp-admin/menu.php.

In the screenshot below you can see that the bubble is pretty much the standard one(as seen on the Plugins menu item).
https://i.imgur.com/OGb7qW5.png

@nikolov.tmw
3 years ago

@nikolov.tmw
3 years ago

Same patch, but created from the root directory

#9 @nikolov.tmw
3 years ago

I updated the patch, since the original one was created from /src/wp-admin/ directory instead of from / .

#10 @helen
3 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

I think I'd rather not make this a core thing - not everybody uses the various pending post statuses the same way, and unlike updates or comments awaiting moderation, they need not inherently be actionable. For instance, I store a lot of things as draft posts with no intention of ever publishing them, and the indicator would just be more visual noise. If something needs to be added to enable devs to do this should they want to, perhaps that's worth exploring, as certainly there do exist sites and post types that use pending posts as actionable items.

#11 follow-ups: @Satri
3 years ago

Hi @helen , would it make sense to implement this feature and make it an option that could be enabled/disabled as a setting? I think it makes sense for WordPress to have this feature within Core. I believe most people write drafts to eventually publish them. For those who don't want a 'pending post indicator', they could disable it in their settings.

What's your take? Thanks -- Alex

#12 in reply to: ↑ 11 @helen
3 years ago

Replying to Satri:

would it make sense to implement this feature and make it an option that could be enabled/disabled as a setting?

I would be very much against making this any kind of UI setting. I think this is far too individual to a given site or user's workflow to make sense as a higher level core API.

#13 in reply to: ↑ 11 ; follow-up: @LukeSeven
18 months ago

Replying to Satri:

Hi @helen , would it make sense to implement this feature and make it an option that could be enabled/disabled as a setting? I think it makes sense for WordPress to have this feature within Core. I believe most people write drafts to eventually publish them. For those who don't want a 'pending post indicator', they could disable it in their settings.

What's your take? Thanks -- Alex

I wish this was a core feature too. I couldn't even find a plugin to do this kind of useful trick for pending posts / questions ( Custom Post Type ) when people post something from the front-end, and it requires a moderation by the admin. I know we receive email notifications based on new posts or questions visitors make from the front-end but I think this would be nice to have this option in core of WP as well as Satri suggested.

@Satri. By the way, I found this useful article regarding WP Menu Bauble Notifivation

https://wisdmlabs.com/blog/display-dashboard-notifications-custom-post-types-menus/

#14 in reply to: ↑ 13 @Satri
18 months ago

Replying to LukeSeven:

@Satri. By the way, I found this useful article regarding WP Menu Bauble Notifivation
https://wisdmlabs.com/blog/display-dashboard-notifications-custom-post-types-menus/


Thanks @LukeSeven for sharing this link, I hope the solution will be built _into_ WordPress since I suspect a large majority of WordPress admins would be happy to benefit from this feature :-) Take care -- Alex

Last edited 18 months ago by Satri (previous) (diff)
Note: See TracTickets for help on using tickets.