---
title: Comments
description: MediaPress Comments allows users to create article notes, inline comments and soft deletes on posts.
url: https://developers.wpengine.com/docs/newsroom/mediapress/comments/
image: https://developers.wpengine.com/og/docs/newsroom/mediapress/comments.png
---

# 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

### Registered Meta

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

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

> **Note**
>
> When creating inline or soft deletes make sure to save the post to make the formats in the editor persist. The same should be done when resolving / restoring inline comments.

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

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:

```html
<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:

```html
<mark
  data-mediapress-comments-id="2"
  data-mediapress-comments-soft-delete="true"
  class="mediapress-comments-highlight--soft-delete"
  >...</mark
>
```

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

<!-- spell-checker:ignore myplugin -->

```js
import { addFilter } from '@wordpress/hooks';


addFilter(
  'mediaPress.comments.allowedBlocks',
  'myplugin/modifyAllowedBlocks',
  (allowedBlocks) => {
    return [...allowedBlocks, 'core/paragraph'];
  },
);
```

## Filters/Actions

### JavaScript

#### Filters

##### `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**

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

##### `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**

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

##### `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**

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

### PHP

#### Filters

##### `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**

```php
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;
}
```

## Was this helpful?

Thanks for the feedback!

```json
{"@context":"https://schema.org","@graph":[{"@type":"WebSite","@id":"https://developers.wpengine.com/#website","name":"WP Engine Product Documentation","url":"https://developers.wpengine.com/","description":"Resources for developing, deploying, and scaling on WP Engine.","inLanguage":"en-US","keywords":["API documentation","product documentation","headless WordPress","managed WordPress hosting"],"publisher":{"@id":"https://wpengine.com/#organization"}}]}
```
