janboddez / share-on-mastodon

Easily share WordPress posts on Mastodon.
https://jan.boddez.net/wordpress/share-on-mastodon
GNU General Public License v3.0
39 stars 5 forks source link

Use publish->{$post->post_type}? #27

Closed janboddez closed 2 years ago

janboddez commented 2 years ago

We currently use transition_post_status because it runs for every post type, then return early if the post type is not supported. Going for a more specific hook (we could foreach() over the supported post types array) may reduce this overhead.

Will require some of the (very few) tests to be rewritten.

janboddez commented 2 years ago

Like, we can't use save_post to save the checkbox value before publish_post is run, because it runs after. (save_post is run pretty much at the very end.)

We could use transition_post_status to save the checkbox value, and publish_post, which runs almost immediately after, to toot (or not). But what's the benefit, other than not attaching the second callback when we save as draft? What's the actual gain?