Skip to content

Commit

Permalink
Add filter to customize status array sent to mastodon
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Dec 29, 2023
1 parent 44104af commit 092aa74
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/wpt-post-to-mastodon.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ function wpt_send_post_to_mastodon( $connection, $auth, $id, $status ) {
*/
$do_post = apply_filters( 'wpt_do_toot', true, $auth, $id, $status['text'] );
$status_id = false;
// Change status array to Mastodon expectation.
$status['status'] = $status['text'];
unset( $status['text'] );
/**
* Filter status array for Mastodon.
*
* @hook wpt_filter_mastodon_status
*
* @param {array} $status Array of parameters sent to Mastodon.
* @param {int} $post Post ID being tweeted.
* @param {int|bool} $auth Authoring context.
*
* @return {array}
*/
$status = apply_filters( 'wpt_filter_mastodon_status', $status, $id, $auth );
if ( $do_post ) {
$return = $connection->postStatus( $status );
$http_code = 200;
Expand Down

0 comments on commit 092aa74

Please sign in to comment.