[WordPress] 外掛分享: Autopost for X (formerly Autoshare for Twitter)

首頁外掛目錄 › Autopost for X (formerly Autoshare for Twitter)
WordPress 外掛 Autopost for X (formerly Autoshare for Twitter) 的封面圖片
6,000+
安裝啟用
★★★★★
5/5 分(6 則評價)
44 天前
最後更新
問題解決
WordPress 6.8+ PHP 7.4+ v2.3.3 上架:2020-01-15

內容簡介

自動推文文章標題或自訂訊息以及文章連結。

註:文章和頁面是預設支援的,開發人員可以使用autoshare_for_twitter_default_post_types篩選器更改預設支援的文章類型。

現在可以選擇自訂文章類型以啟用自動分享功能:

function opt_my_cpt_into_autoshare() {
add_post_type_support( 'my-cpt', 'autoshare-for-twitter' );
}
add_action( 'init', 'opt_my_cpt_into_autoshare' );

此外,也可以在註冊自訂文章類型時添加支援。文章類型會自動設置為自動分享。此外,未來此外掛的版本還可能允許手動設定。

雖然可以使用上述篩選器選擇文章類型加入自動分享功能,但預設情況下編輯人員仍需要在文章發佈期間手動啟用自動分享功能。autoshare_for_twitter_enabled_default篩選器允許在給定文章類型的所有文章中預設啟用自動分享功能。但編輯仍然可以在發佈過程中手動取消勾選該選項。

示例:

function enable_autoshare_by_default_for_core_post_type( $enabled, $post_type ) {
if ( 'post' === $post_type ) {
return true;
}

return $enabled;
}
add_filter( 'autoshare_for_twitter_enabled_default', 'enable_autoshare_by_default_for_core_post_type', 10, 2 );

更多技術細節可以在我們的 GitHub 存儲庫中找到。

免責聲明:TWITTER,TWEET,RETWEET 和 Twitter 徽標是 Twitter, Inc. 或其附屬公司的商標。

外掛標籤

開發者團隊

⬇ 下載最新版 (v2.3.3) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Autopost for X (formerly Autoshare for Twitter)」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Autopost for X (formerly Autoshare for Twitter) automatically shares your posts to X/Twitter as soon as they’re published. Once you hit the Publish button, the plugin sends your post’s title, featured image, and link to X/Twitter, along with a custom message.
Unlike a myriad of other social media, multitool solutions, Autopost for X is built solely for X/Twitter. It focuses on doing one thing and does it well, with the code and interface craftsmanship we apply to every project.
With Autopost for X, developers can further customize nearly everything about the posts, including the image, author, and link, using an extensive set of hooks built into the code. Among its other features, the WordPress plugin:

Works in both the classic and new block editors.
Becomes part of the pre-publish checklist step that’s part of the new block editor.
Posts a high-quality featured image with your post to X/Twitter.
Counts characters to keep you under the X/Twitter limit.
Adds a link to the post to X/Twitter in the block editor sidebar.

Disclaimer: TWITTER, TWEET, RETWEET and the Twitter logo are trademarks of Twitter, Inc. or its affiliates.
Plugin Compatibility
Distributor
When using with 10up’s Distributor plugin, posts that are distributed will not be autoposted if they are already posted to X/Twitter from the origin site. Autopost for X tracks posts that have been posted to X/Twitter in post meta to avoid “double posting”. To avoid this behavior, use the dt_blacklisted_meta filter to exclude the ‘autoshare_for_twitter_status’ meta value from being distributed :
add_filter( 'dt_blacklisted_meta', function( $blacklisted_metas ) {
$blacklisted_metas[] = 'autoshare_for_twitter_status';
return $blacklisted_metas;
} )

Developers
Note: Posts and pages are supported by default. Developers can use the autoshare_for_twitter_default_post_types filter to change the default supported post types
Custom post types can now be opted into autopost features like so:
function opt_my_cpt_into_autoshare() {
add_post_type_support( 'my-cpt', 'autoshare-for-twitter' );
}
add_action( 'init', 'opt_my_cpt_into_autoshare' );

In addition, adding support while registering custom post types also works. Post types are automatically set to autopost. Future versions of this plugin could allow this to be set manually.
While the autopost feature can be opted into for post types using the above filter, by default the editor still has to manually enable autopost during the post prepublish flow. The autoshare_for_twitter_enabled_default filter allows autopost to be enabled by default for all posts of a given post type. Editors can still manually uncheck the option during the publishing flow.
Example:
function enable_autoshare_by_default_for_core_post_type( $enabled, $post_type ) {
if ( 'post' === $post_type ) {
return true;
}

return $enabled;
}
add_filter( 'autoshare_for_twitter_enabled_default', 'enable_autoshare_by_default_for_core_post_type', 10, 2 );

Additional technical details can be found in our GitHub repository.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon