Expandable Dashboard Recent Comments

Περιγραφή

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 excerpt 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

Παράδειγμα:

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

Στιγμιότυπα

  • 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 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.

Εγκατάσταση

  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)

Συχνές Ερωτήσεις

How do I expand an excerpted comment?

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.

Why don’t I see the “Show more” link when hovering over a comment?

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”.

Why don’t I see the “Expand all” and “Collapse all” links at the bottom of the widget?

Assuming you are using a supported version of WordPress and you have JavaScript enabled in your browser, 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.

Why does either of the “Expand all” or “Collapse all” links appear grayed out?

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.

Can I make it so all comments initially appear fully expanded without needing to click the links to expand them?

Yes. Please see the “Hooks” section for documentation on the c2c_expandable_dashboard_recent_comments_start_expanded filter which allows for this.

Does this work if JavaScript has been disabled in my browser?

If JavaScript is disabled in a visitor’s browser, then all of the expand/collapse links and behavior aren’t enabled. But rest assured, there aren’t any errors. Why not implement a fallback if JS is disabled? If you’re going to click a link that causes a page reload to view the full comment, you might as well just click through to the comment.

Does this plugin include unit tests?

Yes.

Κριτικές

28 Φεβρουαρίου 2017
I love simple little tweaks like this.
Ανάγνωση όλων των 2 κριτικών

Συνεισφέροντες & Προγραμματιστές

“Expandable Dashboard Recent Comments” είναι λογισμικό ανοιχτού κώδικα. Οι παρακάτω έχουν συνεισφέρει στη δημιουργία του.

Συντελεστές

“Expandable Dashboard Recent Comments” έχει μεταφραστεί σε 1 γλώσσα. Thank you to the translators for their contributions.

Μεταφράστε το “Expandable Dashboard Recent Comments” στην γλώσσα σας.

Interested in development?

Περιηγηθείτε στον κώδικα , ανατρέξτε στο αποθετήριο SVN ή εγγραφείτε στο αρχείο καταγραφής αλλαγών μέσω RSS .

Σύνοψη αλλαγών

2.8 (2020-08-21)

Highlights:

  • This minor update features a rewrite of the JavaScript to use vanilla JS instead of jQuery, improves handling of some unlikely edgecase situations, restructures the unit test file structure, and notes compatibility through WP 5.5+.

Details:

  • Change: Rewrite JavaScript into vanilla JS and away from using jQuery
  • Change: Prevent edgecase issues with get_comment_class()
    • Verify global comment is an actual comment object before use
    • Return an empty string if no comment ID is known
  • Fix: Remove stray double-quote from comment row markup
  • Change: Restructure unit test file structure
    • New: Create new subdirectory phpunit/ to house all files related to unit testing
    • Change: Move bin/ to phpunit/bin/
    • Change: Move tests/bootstrap.php to phpunit/
    • Change: Move tests/ to phpunit/tests/
    • Change: Rename phpunit.xml to phpunit.xml.dist per best practices
  • Unit tests:
    • New: Add unit tests for comment_row_action(), enqueue_admin_css(), enqueue_admin_js(), get_comment_class(), register_styles()
    • New: Add another unit test for c2c_expandable_dashboard_recent_comments_start_expanded filter
    • Change: Add comment separators to document test groupings
    • Change: Tweak code spacing
  • Change: Note compatibility through WP 5.5+
  • Change: Change get_comments_class() from private to protected to facilitate unit testing
  • Change: Supplement FAQ with info regarding behavior when JS is disabled
  • Change: Fix some typos in readme.txt

2.7 (2020-04-30)

  • New: Add count of comments that could be affected by either “Expand all” or “Collapse all” next to both link, respectively
  • New: Add TODO.md and move existing TODO list from top of main plugin file into it (and add more items to the list)
  • Change: Add more space between the expand/collapse down/up icons and their associated text
  • Unit tests:
    • Fix: Fix typo in that an add_action() should be a has_action()
    • Fix: Fix typo in unit test function name preventing it from being run as a unit test
    • Change: Remove unnecessary remove_filter()
  • Change: Use HTTPS for link to WP SVN repository in bin script for configuring unit tests
  • Change: Note compatibility through WP 5.4+
  • Change: Update links to coffee2code.com to be HTTPS

2.6 (2019-11-21)

  • New: Handle comments containing multi-byte characters that may not have been excerpted by WordPress
  • New: Add reset() to reset plugin’s internal state
  • Change: Don’t memoize value for if comment should appear initially expanded since it may vary based on comment
  • Change: Switch is_comment_initially_expanded() and is_text_excerpted() from private to protected to facilitate unit testing
  • Unit tests:
    • New: Add tests for admin dashboard comment excerpts
    • New: Add tests for is_comment_initially_expanded()
    • New: Add tests for is_text_excerpted()
    • New: Add tests for expandable_comment_excerpts()
    • New: Add test for the filter c2c_expandable_dashboard_recent_comments_start_expanded
    • Change: Remove unused test
    • Change: Invoke plugin’s reset() after every test
  • Change: Note compatibility through WP 5.3+
  • Change: Update copyright date (2020)

Full changelog is available in CHANGELOG.md.