• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

janboddez/import-from-mastodon: Automatically turn toots—short messages on Mast ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

janboddez/import-from-mastodon

开源软件地址(OpenSource Url):

https://github.com/janboddez/import-from-mastodon

开源编程语言(OpenSource Language):

PHP 99.5%

开源软件介绍(OpenSource Introduction):

Import From Mastodon

Automatically turn toots—short messages on Mastodon—into WordPress posts.

Installation

For now, download the ZIP file. Upload to wp-content/plugins and unzip. (Optionally) rename the resulting folder from import-from-mastodon-master to import-from-mastodon. (This last step may help resolve possible future conflicts.)

After activating the plugin, visit Settings > Import From Mastodon. Fill out your instance's URL as well as the other options. Press Save Changes.

Then, on the same settings page, click the Authorize Access button. This should take you to your Mastodon instance and allow you to authorize WordPress to read from your timeline. (We don't request write access.) You'll be automatically redirected to WordPress afterward.

Note: WordPress won't immediately start importing toots, but will take a couple minutes before doing so. I'll "fix" this in a next version.

How It Works

Every 15 minutes—more or less, because WordPress's cron system isn't quite exact—your Mastodon timeline is polled for new toots, which are then imported as the post type of your choice.

By default, only the 40 most recent toots are considered. (This is also the maximum value the Mastodon API will allow. Unless you create more than 40 toots per 15 minutes, this shouldn't be an issue.)

Of Note

The very first time this plugin does its thing, up to 40 (per the remark above) toots are imported. (This might get changed to just one in a next version.) From then on, only the most recent toots are taken into account. (We use a since_id API param to tell Mastodon which toots to look up for us. This since_id corresponds with the most recently imported existing, i.e., in WordPress, post.)

If all that sounds confusing, it is. Well, maybe not. Regardless, it's okay to just forget about it.

Boosts and Replies, and Custom Formatting

It's possible to either exclude or include boosts or replies.

Just, uh, know that boosts and replies may look a bit off, and miss some context.

Threading

There isn't any. Replies-to-self, when replies are enabled, are imported as separate, new posts, not comments. (Again, this would make a nice add-on plugin.)

Tags and Blocklist

Tags: (Optional) Poll for toots with any of these tags only (and ignore all other toots). Separate tags by commas.
Blocklist: (Optional) Ignore toots with any of these words. (One word, or part of a word, per line.) Beware partial matches!

Images

Images are downloaded and attached to imported toots, but not (yet) automatically included in the post.

The first image, however, is set as the freshly imported post's Featured Image. Of course, this behavior, too, can be changed:

add_filter( 'import_from_mastodon_featured_image', '__return_false' ); // Do not set Featured Images

Miscellaneous

There are in fact a few more filters and settings that I might eventually document a bit better (though the settings should kind of speak for themselves).

Custom Post Types

Like, if you wanted your imported toots be a Custom Post Type (rather than the default post):

add_filter( 'import_from_mastodon_args', function( $args, $status ) {
	$args['post_type'] = 'iwcpt_note'; // My "Note" type.

	unset( $args['post_category'] ); // Because my CPT may not support the "category" taxonomy at all.

	return $args;
}, 10, 2 );

Above $args are in fact the very arguments passed on to wp_insert_post(). (Endless possibilities!)




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap