Comments
MediaPress Comments allows users to create article notes, inline comments and soft deletes on posts.
The plugin uses the WordPress comment API to store data in custom comment types which are intended for backend/editorial usage.
Comments must be activated via the “MediaPress” settings page. Post, block, inline and soft-delete comments will then be available for use on the ‘post’ post type. Support for additional post types can be enabled via filters (see below).
Additional Information
Section titled “Additional Information”Registered Meta
Section titled “Registered Meta”Registered comment meta to be used for mp_comments_inline comment type.
mediapress_comments_soft_deleteflag to indicate soft deletionmediapress_comments_blockflag to indicate comment is attached to block
Adding comments
Section titled “Adding comments”For note comments, navigate to the comments sidebar and go to the notes tab.
For inline comments, select the text you want to attached to the comment and select the inline comment icon in the block toolbar.
For soft deletes, select the text and in the block toolbar go to more options and select the soft delete option.
Resolving / Restoring comments
Section titled “Resolving / Restoring comments”When comments are first created, they have a status of hold, indicating they are unresolved.
When comments are resolved, their status is updated to approved.
If a comment is restored, its status reverts to hold.
When the inline comment status changes, the formats attribute in editor will get updated. Requiring a post save.
Inline comments markup
Section titled “Inline comments markup”These marks are used to visually indicate a comment or soft delete in the editor and to link the comment in the sidebar.
Creating a inline comment will wrap the following around the selected text:
<mark data-mediapress-comments-id="1" data-mediapress-comments-resolved="false" class="mediapress-comments-highlight" >...</mark>When creating a soft delete, the following will get wrap around the selected text:
<mark data-mediapress-comments-id="2" data-mediapress-comments-soft-delete="true" class="mediapress-comments-highlight--soft-delete" >...</mark>Block Comments
Section titled “Block Comments”Select a block and in the block toolbar select the block comment button.
Successfully adding a comment to a block will add mediaPressCommentsId attribute to the block. This will require a post save to persist the change.
You can allow which blocks can have comments by using the filter mediaPress.comments.allowedBlocks
By default core/image blocks are allowed.
import { addFilter } from '@wordpress/hooks';
addFilter( 'mediaPress.comments.allowedBlocks', 'myplugin/modifyAllowedBlocks', (allowedBlocks) => { return [...allowedBlocks, 'core/paragraph']; },);Removing comments from the frontend
Section titled “Removing comments from the frontend”All inline comments and soft deletes are removed from the front-end content by RemoveFormats
Filters/Actions
Section titled “Filters/Actions”JavaScript
Section titled “JavaScript”Filters
Section titled “Filters”mediaPress.comments.allowedBlocks
Section titled “mediaPress.comments.allowedBlocks”Defines which blocks can have ‘block comments’ associated with them.
Parameters
| Name | Type | Description |
|---|---|---|
| allowedBlocks | array | An array of block names which support block comments |
Usage
addFilter( 'mediaPress.comments.allowedBlocks', 'my-plugin/add-block-comments-support', (allowedBlocks) => [...allowedBlocks, 'core/embed'],);mediaPress.comments.softDeleteShortcut
Section titled “mediaPress.comments.softDeleteShortcut”Allows you to override the default keyboard shortcut to add an inline comment.
Parameters
| Name | Type | Description |
|---|---|---|
| keyCombination | Object | The keyboard shortcut key combination |
| keyCombination.character | string | The keyboard character (e.g: ‘5’) |
| keyCombination.modifier | string | The keyboard modifier (e.g: ‘alt’) |
Usage
addFilter( 'mediaPress.comments.inlineCommentShortcut', 'my-plugin/set-comments-inline-comment-shortcut', ({ character, modifier }) => ({ character: 'i', modifier }),);mediaPress.comments.softDeleteShortcut
Section titled “mediaPress.comments.softDeleteShortcut”Allows you to override the default keyboard shortcut to add a soft delete.
Parameters
| Name | Type | Description |
|---|---|---|
| keyCombination | Object | The keyboard shortcut key combination |
| keyCombination.character | string | The keyboard character (e.g: ‘5’) |
| keyCombination.modifier | string | The keyboard modifier (e.g: ‘alt’) |
Usage
addFilter( 'mediaPress.comments.softDeleteShortcut', 'my-plugin/set-comments-soft-delete-shortcut', ({ character, modifier }) => ({ character, modifier: 'primary' }),);Filters
Section titled “Filters”mediapress_comments_supported_post_types
Section titled “mediapress_comments_supported_post_types”Defines the post types on which the comments functionality will be enabled.
Default Value
[ 'post' ]
Parameters
| Name | Type | Description |
|---|---|---|
| post_types | array | Array of post type slugs |
Usage
add_filter( 'mediapress_comments_supported_post_types', 'my_plugin_add_comments_support' );function my_plugin_add_comments_support( array $post_types ): array { $post_types[] = 'my_custom_post_type'; return $post_types;}