Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content warnings! #900

Merged
merged 9 commits into from
Sep 25, 2024
Merged

Content warnings! #900

merged 9 commits into from
Sep 25, 2024

Conversation

mattwiebe
Copy link
Contributor

@mattwiebe mattwiebe commented Sep 24, 2024

We now support content warnings! They are per-post.

fix #757 #176

Proposed changes:

Adds a "Fediverse" settings section to the post editor that allows entering a content warning.

Screenshot 2024-09-24 at 16 12 06

The warning is used to set sensitive: true and populates the summary attribute.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

On a post, set the value as above. I entered a value of warning!!! and then by appending ?activitypub to the post, I got this JSON:

{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    {
      "Hashtag": "as:Hashtag"
    }
  ],
  "id": "http://wp.test/2024/09/make-a-poast/",
  "type": "Note",
  "attachment": [],
  "attributedTo": "http://wp.test/author/mattwiebe/",
  "audience": "http://wp.test/@wp.test",
  "content": "<p>Poasty poast</p><p><a href=\"http://wp.test/2024/09/make-a-poast/\" class=\"status-link unhandled-link\">http://wp.test/2024/09/make-a-poast/</a></p>",
  "contentMap": {
    "en": "<p>Poasty poast</p><p><a href=\"http://wp.test/2024/09/make-a-poast/\" class=\"status-link unhandled-link\">http://wp.test/2024/09/make-a-poast/</a></p>"
  },
  "published": "2024-09-16T19:04:37Z",
  "summary": "warning!!!",
  "tag": [],
  "updated": "2024-09-24T14:05:10Z",
  "url": "http://wp.test/2024/09/make-a-poast/",
  "to": [
    "https://www.w3.org/ns/activitystreams#Public",
    "http://wp.test/wp-json/activitypub/1.0/actors/1/followers"
  ],
  "cc": [],
  "sensitive": true
}

@@ -1177,6 +1177,11 @@ function generate_post_summary( $post, $length = 500 ) {
return '';
}

$content_warning = get_content_warning( $post->ID );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you set it in the transformer, you do not also have to add it here.

I quite like the idea to set it in the transformer only, this we can still generate the summary!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we would keep it in there, it would show the "content warning" also in the content field if someone would use the shortcode [ap_excerpt] for the content field.

@pfefferle
Copy link
Member

Awesome!

includes/functions.php Outdated Show resolved Hide resolved
@pfefferle pfefferle merged commit de85cca into master Sep 25, 2024
21 checks passed
@pfefferle pfefferle deleted the add/content-warning-metabox branch September 25, 2024 15:22
@mattwiebe
Copy link
Contributor Author

@pfefferle thanks for taking this to the finish line!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Content Warnings
2 participants