Skip to content
WP Engine Developers

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

Registered comment meta to be used for mp_comments_inline comment type.

  • mediapress_comments_soft_delete flag to indicate soft deletion
  • mediapress_comments_block flag to indicate comment is attached to block

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.

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.

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
>

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'];
},
);

All inline comments and soft deletes are removed from the front-end content by RemoveFormats

Defines which blocks can have ‘block comments’ associated with them.

Parameters

NameTypeDescription
allowedBlocksarrayAn array of block names which support block comments

Usage

addFilter(
'mediaPress.comments.allowedBlocks',
'my-plugin/add-block-comments-support',
(allowedBlocks) => [...allowedBlocks, 'core/embed'],
);

Allows you to override the default keyboard shortcut to add an inline comment.

Parameters

NameTypeDescription
keyCombinationObjectThe keyboard shortcut key combination
keyCombination.characterstringThe keyboard character (e.g: ‘5’)
keyCombination.modifierstringThe keyboard modifier (e.g: ‘alt’)

Usage

addFilter(
'mediaPress.comments.inlineCommentShortcut',
'my-plugin/set-comments-inline-comment-shortcut',
({ character, modifier }) => ({ character: 'i', modifier }),
);

Allows you to override the default keyboard shortcut to add a soft delete.

Parameters

NameTypeDescription
keyCombinationObjectThe keyboard shortcut key combination
keyCombination.characterstringThe keyboard character (e.g: ‘5’)
keyCombination.modifierstringThe keyboard modifier (e.g: ‘alt’)

Usage

addFilter(
'mediaPress.comments.softDeleteShortcut',
'my-plugin/set-comments-soft-delete-shortcut',
({ character, modifier }) => ({ character, modifier: 'primary' }),
);

Defines the post types on which the comments functionality will be enabled.

Default Value

[ 'post' ]

Parameters

NameTypeDescription
post_typesarrayArray 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;
}

Last updated: