From 092aa7423c4b3b81ec402375a141ca09f11cc1fd Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Fri, 29 Dec 2023 15:23:17 -0600 Subject: [PATCH] Add filter to customize status array sent to mastodon --- src/wpt-post-to-mastodon.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/wpt-post-to-mastodon.php b/src/wpt-post-to-mastodon.php index b9d0293..2ff342b 100644 --- a/src/wpt-post-to-mastodon.php +++ b/src/wpt-post-to-mastodon.php @@ -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;