Expandable Dashboard Recent Comments

Author:Scott Reilly
Version:2.5.3
First released:2009-06-11
Last update:2019-06-27
Compatibility:WP 4.6 – 5.2.4
Download:[ zip ]
Description:

Enables in-place expansion of excerpts in the admin dashboard 'Comments' section of the 'Activity' widget to view full comments.

Extended Description

By default, the ‘Comments’ section of the ‘Activity’ admin dashboard widget only shows an excerpt for the comments, truncating the content of the comments to the first 20 words while at the same time stripping out all markup.

This plugin adds a link at the end of the comment actions row (the links for the comment that become visible under the comment when you hover over the comment). The “Show more” link, when clicked, will replace the excerpt with the full comment. The full comment will include all markup, including originally utilized markup and changes applied via filters, plugins, etc (such as shortcode expansion, smilies, paragraphing, etc). The full comment can be switched back to the except by clicking the “Show less” link (which replaces the “Show more” link when the comment is expanded).

“In-place expansion” refers to the ability to click the link to see the full comment and it will be presented in place of the excerpt without requiring a page reload or navigation.

NOTE: This plugin only works for users who have JavaScript enabled.

Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage

Hooks

The plugin exposes one filter for hooking. Such code should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain).

c2c_expandable_dashboard_recent_comments_start_expanded (filter)

The ‘c2c_expandable_dashboard_recent_comments_start_expanded’ hook allows you to configure the ‘Recent Comments’ admin dashboard widget initially display all comments in their expanded state (i.e. not excerpted).

Arguments:

  • $default (boolean): The default state, which is ‘false’ (therefore comments are initially shown excerpted)
  • $comment (object) : The comment object being displayed

Example:

// Initially show dashboard comments fully expanded
add_filter( 'c2c_expandable_dashboard_recent_comments_start_expanded', '__return_true' );

Find out more at the plugin’s WordPress Plugin Repository page.

Screenshots

Click to see full-size image.

  1. A screenshot of the 'Recent Comments' admin dashboard widget with the plugin active, showing comments that have been truncated/excerpted by WordPress (the 2nd and 4th listed) and full, short comments. The third comment has the mouse over it (though the cursor doesn't appear in the screenshot) so you can see the action links, including the "Show more" link. Note, also, the 'Expand All' and 'Collapse All' links added to the bottom of the widget.

    A screenshot of the ‘Recent Comments’ admin dashboard widget with the plugin active, showing comments that have been truncated/excerpted by WordPress (the 2nd and 4th listed) and full, short comments. The third comment has the mouse over it (though the cursor doesn’t appear in the screenshot) so you can see the action links, including the “Show more” link. Note, also, the ‘Expand All’ and ‘Collapse All’ links added to the bottom of the widget.

  2. A screenshot of the 'Recent Comments' admin dashboard page with the plugin active, now showing the second excerpted comment (the third comment in the list) fully in-place expanded and with markup and formatting applied.

    A screenshot of the ‘Recent Comments’ admin dashboard page with the plugin active, now showing the second excerpted comment (the third comment in the list) fully in-place expanded and with markup and formatting applied.

Installation

  1. Install via the built-in WordPress plugin installer. Or download and unzip expandable-dashboard-recent-comments.zip inside the plugins directory for your site (typically wp-content/plugins/)
  2. Activate the plugin through the ‘Plugins’ admin menu in WordPress
  3. Visit the admin dashboard and check out the ‘Comments’ section of the ‘Activity’ widget (assuming you have recent comments and that one or more of them have been automatically excerpted)

Frequently Asked Questions

Q. How do I expand an excepted comment?
A. When you hover over the comment, a line of action links will appear (typically “Approve”, “Reply”, “Edit”, “Spam”, and “Trash”). If the comment has been automatically excerpted by WordPress, then a “Show more” link will appear. Click it to view the full comment.

Q. Why don’t I see the “Show more” link when hovering over a comment?
A. The comment has not been been excerpted; you are already seeing the comment in its entirety so there is no need to be able to “show more”.

Q. Why don’t I see the “Expand all” and “Collapse all” links at the bottom of the widget?
A. Assuming you are using a supported version of WordPress, this just means that none of the comments being listed have been excerpted, thus there is no need to be able to “Expand all” or “Collapse all” in this instance.

Q. Why does either of the “Expand all” or “Collapse all” links appear grayed out?
A. If all of the comments in the widget are currently collapsed, then the “Collapse all” link will appear grayed out to indicate there is nothing for it to collapse. Likewise, if all of the comments in the widget are currently expanded, then “Expand all” will appear grayed out to indicate there is nothing for it to expand. As comments are expanded and collapsed, these two links will adjust themselves to appear grayed out or active as appropriate.

Q. Can I make it so all comments initially appear fully expanded without needing to click the links to expand them?
A. Yes. Please see the “Hooks” section for documentation on the ‘c2c_expandable_dashboard_recent_comments_start_expanded’ filter which allows for this.

Q. Does this plugin include unit tests?
A. Yes.

Release Log

2.5.3 (2019-06-26)

  • New: Add CHANGELOG.md and move all but most recent changelog entries into it
  • Unit tests:
    • Change: Update unit test install script and bootstrap to use latest WP unit test repo
    • New: Test that plugin hooks plugins_loaded action to initialize itself
  • Change: Note compatibility through WP 5.2+
  • Change: Split paragraph in README.md’s “Support” section into two

2.5.2 (2019-03-03)

  • Fix: Ensure preceding up/down arrow for collapse/expand link does not get orphaned from the associated text
  • New: Add inline documentation for hooks
  • Change: Initialize plugin on ‘plugins_loaded’ action instead of on load
  • Change: Cast return value of filter ‘c2c_expandable_dashboard_recent_comments_start_expanded’ as boolean
  • Change: Rename readme.txt section from ‘Filters’ to ‘Hooks’
  • Change: Note compatibility through WP 5.1+
  • Change: Update copyright date (2019)
  • Change: Update License URI to be HTTPS

2.5.1 (2018-04-30)

  • New: Add README.md
  • Change: Add GitHub link to readme
  • Change: Unit tests: Minor whitespace tweaks to bootstrap
  • Change: Note compatibility through WP 4.9+
  • Change: Update copyright date (2018)

Copyright & Disclaimer

Copyright © 2009-2019 by Scott Reilly (aka coffee2code)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Discussion / Support

Have any questions, comments, or suggestions? Please provide them via the plugin’s WordPress.org support forum. I’ll do my best to reply in a timely fashion and help as best I can.

Unfortunately, I cannot provide guaranteed support, nor do I provide support via any other means.

Was this plugin useful useful to you? Consider giving it a rating. If you’re inclined to give it a poor rating, please first post to the support forum to give me a chance to address or explain the situation.