Skip to content

Commit

Permalink
feat(corrections): add corrections and clarifications behind feature …
Browse files Browse the repository at this point in the history
…flag (#3638)

This PR adds the corrections feature behind the `NEWSPACK_CORRECTIONS_ENABLED` feature flag. Note this is a quick and simple implementation based on an already existing custom plugin strictly for the purpose of getting ready for a site migration.
  • Loading branch information
chickenn00dle authored Jan 11, 2025
1 parent 0ed8bd8 commit ea745cf
Show file tree
Hide file tree
Showing 5 changed files with 666 additions and 0 deletions.
1 change: 1 addition & 0 deletions includes/class-newspack.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ private function includes() {
include_once NEWSPACK_ABSPATH . 'includes/tracking/class-twitter-pixel.php';
include_once NEWSPACK_ABSPATH . 'includes/revisions-control/class-revisions-control.php';
include_once NEWSPACK_ABSPATH . 'includes/authors/class-authors-custom-fields.php';
include_once NEWSPACK_ABSPATH . 'includes/corrections/class-corrections.php';

include_once NEWSPACK_ABSPATH . 'includes/starter_content/class-starter-content-provider.php';
include_once NEWSPACK_ABSPATH . 'includes/starter_content/class-starter-content-generated.php';
Expand Down
34 changes: 34 additions & 0 deletions includes/corrections/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Corrections

This feature allows authors to add article corrections to the top or bottom of a post.

## How it works

When you enable this feature, a new meta box will be added to the post editor screen. You can use this meta box to add a correction to the post. The correction will be displayed at the top or bottom of the post, depending on the settings.

## Usage

This feature can be enabled by adding the following constant to your `wp-config.php`:

```php
define( 'NEWSPACK_CORRECTIONS_ENABLED', true );
```

## Data

Corrections are stored as `newspack_correction` custom post type. A correction consists of the following fields:

| Name | Type | Stored As | Description |
| ----------------------------- | -------- | -------------- | --------------------------------------------------------------- |
| `title` | `string` | `post_title` | The correction title. Defaults to 'Correction for [post title]' |
| `content` | `string` | `post_content` | The correction text. |
| `date` | `string` | `post_date` | The date assigned to the correction. |
| `newspack_correction-post-id` | `int` | `post_meta` | The ID of the post to which the correction is associated. |

In addition, some correction data is stored in the associated post as post meta:

| Name | Type | Stored As | Description |
| ------------------------------- | ----------------------- | ----------- | ------------------------------------------------------------- |
| `newspack_corrections_active` | `bool` | `post_meta` | Whether the feature is enabled for the post. |
| `newspack_corrections_location` | `string` | `post_meta` | Where the correction should be displayed. (`top` or `bottom`) |
| `newspack_corrections_ids` | `array` | `post_meta` | An array of IDs of the corrections associated with the post. |
Loading

0 comments on commit ea745cf

Please sign in to comment.