[WordPress] 外掛分享: Share Target

WordPress 外掛 Share Target 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Share Target」是 2021-04-05 上架。
  • 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
  • 上一次更新是 2021-04-06,距離現在已有 1489 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 5.2 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 7.0 以上。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

flixos90 |

外掛標籤

web | image | media | sharing | share target |

內容簡介

透過此外掛,您可以直接從適用裝置和瀏覽器分享圖像、媒體、URL 和文字到您的 WordPress 網站。舉例來說,您可以像使用原生訊息應用程式一樣,將您剛在手機上拍攝的照片分享到 WordPress 網站上。

使用此外掛分享內容到您的 WordPress 網站後,它會自動開啟一篇新的區塊編輯器草稿文章,接著您只需添加任何其他內容,或者直接以目前內容立即發布。對於某些用例,例如圖像部落格,分享圖片創建文章可能就足夠並能立即發布。

此外掛可分享的其他範例包括音訊和視訊檔案、短文本備註、Spotify 播放清單,基本上您可以通過手機應用程式分享的任何內容,現在也可以直接分享到 WordPress 網站上。

需求
為了使用此外掛,您還需要安裝並啟用 PWA 外掛,它為您的網站提供成為 PWA 的基礎架構。

用法
當兩個外掛都啟用後,當您在合適的裝置和瀏覽器上訪問您的網站時,您應該會看到提示(通過 PWA 外掛的功能),要將該外掛新增到您的主畫面(例如手機上的應用程式)。

當您將內容從該裝置分享到 WordPress 網站時,您的網站已安裝的 PWA 應該會打開。然後,您應該(可能需要登錄)直接進入一篇包含共用內容的新文章編輯器,如果您分享的是媒體檔案(例如影像或影片檔),它會自動添加到您的網站媒體庫中。

背景資訊
此外掛由 Web Share Target API 驅動。Web Share Target API 是一種現代瀏覽器 API,允許直接將圖像、媒體、URL 和基本文本內容分享到您的網站,依賴於您的手機中整合的常規分享 UI。請查看 Web Share Target API 的更多技術背景資訊。

第三方開發者 API
Share Target 外掛允許其他外掛與之整合。當共用內容到達區塊編輯器時,您可以條件性地覆蓋外掛的預設行為,從而自定義共用行為。

在 PHP 中,載入您的自定義 JavaScript 檔案。請務必在它的依賴項中包含 share-target script。例如:
wp_enqueue_script(
'my-share-target-handler',
'/assets/js/my-share-target-handler.js',
array( 'share-target' )
);

然後在您的 JavaScript 檔案中,您可以使用以下函數添加自定義共用程序處理:
wp.shareTarget.registerShareHandler( options )

註冊一個新的共用程序處理程式,處理傳入的共用資料。

參數:

options:(Object)(必填)處理程序選項。
options.handle:(Function)(必填)共用程序處理功能。 必須是 asynchronous,並接受一個具有 title、description、link 屬性(每個字符串)、和 image(URL字符串)屬性的物件。

原文外掛簡介

By using this plugin, you can share content like images, media, URLs and text directly to your WordPress site from a capable device and browser. For example, you can share a photo that you just took on your phone to your WordPress site in the same way that you would otherwise share it with your friends in a native messaging app.
When you share content to your WordPress site using this plugin, it will automatically start a new block editor draft post with it; you can then just add anything else you like, or immediately publish it as is. For certain use-cases, e.g. an image blog, creating a post with the shared image might be everything that’s needed before publishing right away!
To name a few other examples of what you can share to your WordPress site using this plugin, think about audio and video files, short text notes, Spotify playlists – basically anything that you can share from an app on your phone you can now also share directly to your WordPress site.
Requirements
In order to use this plugin, you will also need to install and activate the PWA plugin, which provides the basic infrastructure for your site to become a PWA.
Usage
With both plugins active, once you visit your site on a capable device and browser, you should see a prompt (via the PWA plugin’s functionality) to add the plugin to your home screen (e.g. similar to an app on your phone).
Once you have added your website to the home screen of your device, it should be available as a target when sharing any content from that device, e.g. a photo or a URL.
When you share something to your WordPress site, the installed PWA of your website should open. You should then (potentially after logging in) land directly on a new post in the block editor where the shared content has already been added. If you are sharing a media file (e.g. an image or video file), it will be automatically added to your site’s media library.
Background information
This plugin is powered by the Web Share Target API. The Web Share Target API is a modern browser API which allows sharing images, media, URLs and basic text content directly to your website, relying on the regular sharing UI that is for example integrated in your phone. See here for more technical background information about the Web Share Target API.
Third-party developer API
The Share Target plugin allows other plugins to integrate with it. You can customize what should happen with incoming shared content when it arrives in the block editor, conditionally overriding the default behavior of the plugin.
In PHP, enqueue your custom JavaScript file. Make sure to include the share-target script in its dependencies. For example:
wp_enqueue_script(
'my-share-target-handler',
'/assets/js/my-share-target-handler.js',
array( 'share-target' )
);

In your JavaScript file you can then add your custom share handler using the following function:
wp.shareTarget.registerShareHandler( options )
Registers a new share handler for incoming shared data.
Parameters:

options: (Object) (required) Handler options.
options.handle: (Function) (required) Share handler function. Must be asynchronous and accept an object with properties title, description, link (each strings), and attachment (object). Any of these may be undefined. Depending on the data, the function should decide whether to handle it and if so run the necessary logic and return true, to stop following handlers from being called. Otherwise, it should return false.
options.priority: (number) (optional) Priority for the handler. A lower number means higher priority, like for WordPress hooks. Default is 10.

The following example handles any shared Spotify content and embeds it into the post:
// Matches a shared Spotify URL.
const spotifyRegex = /^https:\/\/open\.spotify\.com/;

wp.shareTarget.registerShareHandler( {
handle: async ( { link, attachment } ) => {
// Do not handle if a media file is being shared.
if ( attachment ) {
return false;
}

// If a shared Spotify URL, embed it.
if ( link && link.match( spotifyRegex ) ) {
wp.data.dispatch( 'core/block-editor' ).insertBlocks( [
wp.blocks.createBlock( 'core/embed', {
url: link,
type: 'rich',
providerNameSlug: 'spotify',
responsive: true,
} ),
] );
return true;
}

// Otherwise fall back to other handlers.
return false;
},
priority: 5,
} );

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Share Target」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


trunk | 1.0.0-beta.1 |

延伸相關外掛(你可能也想知道)

  • StatCounter – Free Real Time Visitor Stats 》官方 StatCounter WordPress 外掛為您的 WordPress 網誌帶來所有有力的 StatCounter 功能。, 包括但不限於以下功能:, , 隱形計數器選項, 可配置計數器, 可配...。
  • AWeber – Free Sign Up Form and Landing Page Builder Plugin for Lead Generation and Email Newsletter Growth 》想要在不太麻煩的情況下進行電子郵件營銷嗎?, AWeber 的 WordPress 外掛擁有您所需的所有工具:, , , 擴大您的電子郵件名單, , , 增加網站流量, , , 利用您...。
  • BigBlueButton 》BigBlueButton 是一個開源的網路視訊會議系統。這款 WordPress 外掛將 BigBlueButton 整合進 WordPress,讓部落客可以建立和管理會議室並與讀者互動。它是由B...。
  • WonderPush – Web Push Notifications – WooCommerce Abandoned Cart – GDPR 》Web push通知是保留您的使用者和增加您的WordPress網站觀眾的最有效方法。WonderPush讓您發送無限量的web push通知。, , Web push通知是一種提醒風格的訊息,...。
  • Naver webmaster syndication v2 》這是一個與 NAVER 網站管理員工具和 Syndication v2 整合的外掛程式。, , , 透過 NAVER Syndication 整合,可以快速在 NAVER 搜尋結果中展示網站網頁。, , , ...。
  • TopList.cz 》請參閱下方的英文說明。, 捷克語:此插件可輕鬆將統計服務 TopList.cz 整合至 WordPress 網誌中。插件將新增一個小工具(名為 TopList.cz),將其放入您的頁...。
  • BBB Administration Panel 》BigBlueButton 是一個開源的網路視訊會議系統。此外掛將 BigBlueButton 整合至 WordPress 中,讓部落客可以建立和管理會議室,達到與讀者互動的目的。, , 此...。
  • Remove Web Field From Comments Form 》「移除評論表單中的網站欄位」是一個小型的外掛程式,可以讓您移除所有評論表單中的網站欄位,因此您再也不必處理不需要的網站連結。您可以勾選「設定 > 一般...。
  • TOPlist 》這個外掛讓你能夠輕鬆地將網站統計服務 TOPlist.cz 整合到由 WordPress 運作的部落格中。這個外掛會新增一個名為 TOPlist 的小工具(widget)到 WordPress,...。
  • WP-UserAgent 》WP-UserAgent 是一個簡單的外掛,允許你顯示訪客在留言時的電腦 作業系統 或 網頁瀏覽器 的詳細資訊。, 該外掛使用留言的 agent 屬性來存取 User-Agent 字串...。
  • ReachDeck Toolbar 》使用 ReachDeck 工具列讓您的網站或部落格支援語音、閱讀及翻譯功能, 想為您的網站或部落格訪客提供更好的體驗嗎?, 數百萬人無法理解您的網站或部落格上的資...。
  • Add To Home Screen 》「加至主畫面」外掛可讓您的 WordPress 站台出現在讀者的行動裝置主畫面上,就像他們的其他喜愛應用程式一樣。這不僅是收藏夾,「加至主畫面」提供了完整的應...。
  • Auto Fill Form Fields 》功能, 本外掛只做了一件事情,且非常簡單,就是若您將資訊透過 URL 傳遞,例如 https://example.com/?firstname=John&lastname=Doe,此外掛就會將相關的 ...。
  • WordPress Web Service 》WordPress Web Service(WPWS)可通過WSDL和SOAP訪問WordPress資源。, 它允許您連接支持WSDL的軟件,比如Adobe Flex/Flash Builder,, Microsoft Visual Stud...。
  • Disable REST API and Require JWT / OAuth Authentication 》啟用此外掛後,所有非授權請求的 REST API 端點將被禁用。, 最好與以下任何一個外掛一起使用:, , JWT Authentication for WP REST API, WP OAuth Server, , ...。

文章
Filter
Apply Filters
Mastodon