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

RFE: Content warnings #36

Closed
swaldman3 opened this issue Nov 13, 2022 · 5 comments
Closed

RFE: Content warnings #36

swaldman3 opened this issue Nov 13, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@swaldman3
Copy link

On some Mastodon instances it is considered polite to add a content warning for bot-posted toots like these. I would love to be able to have a configurable content warning, ideally one which allowed the CW to include the title of the Wordpress post.

Thanks for considering.

@janboddez
Copy link
Owner

Alright, I think a sort of semi-automated CW (“new blog post” or something, maybe based on tags or similar) is already possible through the current filter mechanism (but would require some custom PHP).

Let me get back to you with a code example once I’ve figured this out.

The alternative would be an extra text field for a completely “manual” CW. I was hoping to eventually rework the meta box anyway, but I might be able to something even before that happens.

@janboddez
Copy link
Owner

OK, so it is possible to add the following to, e.g., a functions.php file or similar.

add_filter( 'share_on_mastodon_toot_args', function( $args ) {
  $args['spoiler_text'] = 'new blog post';

  return $args;
} );

Unfortunately, it doesn't look like global $post can be used to retrieve the post title as well.

I can add an optional second argument ($post) to that filter in a next version.

@janboddez janboddez added the enhancement New feature or request label Nov 13, 2022
janboddez added a commit that referenced this issue Nov 13, 2022
@janboddez
Copy link
Owner

janboddez commented Nov 14, 2022

OK, so with that new parameter (not up on WP.org, yet!) you should be able to do something like:

add_filter( 'share_on_mastodon_toot_args', function( $args, $post = null ) {
  $args['spoiler_text'] = 'new blog post';

  if ( $post ) {
    $args['spoiler_text'] .= ': ' . get_the_title( $post );
  }

  return $args;
}, 10, 2 );

And then you could either modify $args['status'] or use the share_on_mastodon_status filter to modify the actual text, like change it into an excerpt + a permalink, or include tags, etc. Or you could fetch the post's tags right there and base your CW off them, and so on, and so on.

Not sure when I'll push to WP.org, maybe in a week or so. Could be in the future I add a CW setting, but it will probably be limited to static text (which you could then override using the filter).

@swaldman3
Copy link
Author

thanks!

@gloriousnoise
Copy link

Thank you!

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

No branches or pull requests

3 participants