Created
January 13, 2024 15:23
-
-
Save janboddez/c9027bacbfaaedb8c2a837a5589eba11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Always share asides, even if their checkbox is disabled. So if you had the | |
// plugin's "opt in" option enabled, this would share all asides, plus whatever | |
// posts (regardless of their format) have sharing enabled explicitly. | |
add_filter( 'share_on_mastodon_enabled', function ( $is_enabled, $post_id ) { | |
if ( 'aside' === get_post_format( $post_id ) ) { | |
return true; | |
} | |
return $is_enabled; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that you can't actually disable crossposting this way: if the checkbox is checked and the post saved, it will get crossposted. (The plugin used to allow that sort of thing, but I had to rewrite bits of it for all sorts of reasons, and, well, it is what it is.)
So you can override an unticked checkbox, but not a checked one.
Most folks are anyway interested in forcing crossposting even if the checkbox value doesn't get saved, because it can't, like when they post from a mobile app. Which is why I came up with a "Share Always" setting.
Which is why I wanted to deprecate the
share_on_mastodon_enabled
filter (as "wrongly" mentioned in the docs), even though I haven't, and likely never will. I should correct the documentation. In fact, I should probably rename the filter toshare_on_mastodon_share_always
, because it basically overrides that setting.