Mastodon Autopost Plugin for WordPress

 blog, mastodon  Comments Off on Mastodon Autopost Plugin for WordPress
Oct 302022

There are several plugins for WordPress that allow to automatically create a new Mastodon toot (what a stupid name!) for each blog post. I’m using “Mastodon Autopost“. Unfortunately this plugin seems to be outdated and also has a bug that with the current PHP version results in an error/warning message if the post does not have any tags. I was able to fix it though and that fix is amazingly simple.

In line 545 of mastodon_autopost.php there is an if statement using sizeOf() which bombs out because the parameter $post_tags is not an array. Since I am far from being a PHP expert I had to first google that command and found that it isn’t necessary in this case since the foreach that follows later takes care of empty arrays. So the fix looks like this:

    $post_tags = get_the_tags($id);
    // <==== check was here
    if ($post_tags) {
        foreach ($post_tags as $tag) {
            $post_tags_content = $post_tags_content . '#' . preg_replace('/\s+/', '', html_entity_decode($tag->name, ENT_COMPAT, 'UTF-8')) . ' ';
        $post_tags_content = trim($post_tags_content);
    $message_template = str_replace("[tags]", $post_tags_content, $message_template);

If you can see this post on Mastodon, the fix works.

 Posted by on 2022-10-30 at 17:02

I’m on Mastodon now

 mastodon  Comments Off on I’m on Mastodon now
Oct 302022

I never really liked Twitter, but I created an account there to be able to

  1. Announce new posts on my blog
  2. Allow some feedback to my blog without enabling the comments

Now I joined Mastodon as simply to add another channel for those who don’t want to use Twitter.

 Posted by on 2022-10-30 at 11:55