[WordPress] 外掛分享: Minimal Share Buttons

首頁外掛目錄 › Minimal Share Buttons
WordPress 外掛 Minimal Share Buttons 的封面圖片
100+
安裝啟用
★★★★
4.6/5 分(9 則評價)
279 天前
最後更新
問題解決
PHP 5.6+ v1.8.0 上架:2017-08-09

內容簡介

3>簡介

此外掛可在文章下方加入簡單分享按鈕、在新的編輯器中加入分享區塊,或使用元件加入分享並放置在任何佈景主題提供的小工具區。此掛使用簡單的 SVG 圖示作為社交網路標誌,以及純 JavaScript 大小程式碼,以允許使用者分享當前發佈或頁面。分享圖示承襲佈景主題連結顏色,以符合網站設計風格。

為什麼會選擇 Minimal Share Buttons 而不是其他類似的外掛呢?

極簡優雅的外觀,融入佈景主題中 (已測試所有最新的預設 WordPress 佈景主題以及一些其他受歡迎的佈景主題)。
對網站效能影響最小 - 此掛僅加載少量 SVG 圖示檔案,小於 1k CSS 和 3.5k 非壓縮 JavaScript 程式碼 - 大部分程式碼是為了使 SVG 圖示能在舊版瀏覽器上運作。
不監視您的使用者 - 此掛不會加載任何記錄使用者在您網站上的活動的第三方程式碼,也不會設置或讀取任何 cookie。
可透過支援原生分享對話框的裝置進行分享。
符合 GDPR 規定 - 由於此外掛不會向第三方洩露個人資訊,因此讓網站擁有者更容易遵循歐洲隱私規定。
輕鬆使用 - 分享連結具有標籤,可供螢幕閱讀器讀取,並對於鍵盤使用者可見。
支援 Gutenberg 和 WordPress 5.0 - 此外掛提供區塊,可顯示分享按鈕,讓作者可以將它們放置在文章內容的任何位置。

用法

有五種方法可在文章或頁面上顯示分享按鈕:

勾選插件設定螢幕上「顯示設定」部分中相關核取方塊,強制讓它們在文章內容下方顯示。
將分享小工具加到側邊欄或其他小工具區。
使用 Gutenberg 區塊,將分享按鈕放置在文章內容中的任何位置。
在經典編輯器中使用短代碼 [msb_share title="Share this"] 。
在主題模板中使用函數 msb_display_buttons() 來渲染小工具。

佈景主題開發人員

從 1.4 版開始,您可以更輕鬆地使用 msb_display_buttons() 函數在模板中顯示分享小工具。該功能接受兩個引數-一個傳遞給小工具的選項數組,以及第二個布林引數,告訴函數要回應的標記。以下是一個示例:

$args = [
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '',
    'after_title' => '',
    'title' => __( 'Share this article', 'mytextdomain' ),
];
msb_display_buttons( $args, true );

如果您的佈景主題使用 SVG 圖示,結合成 SVG 精靈,並且您的精靈具有 Facebook、Twitter、Google+ 和 LinkedIn 圖示,那麼您可以使用兩個篩檢器將外掛程序提供的圖示替換為您的圖示。這兩個篩選器的結果會與其間的哈希連接,並經過 esc_url 傳遞後輸出。

另一個篩選器允許操作社交網路數組。

msb_sprite_url

將篩選器應用於精靈圖像的 URL,篩選器函數應返回包含 symbol 元素圖示的 SVG 精靈圖像的 URL(未使用哈希標記)。

msb_social_networks

篩選器應用於社交網路數組。篩選器函數應返回一個數組,其中包含要在小工具中顯示的社交網路。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.8.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Minimal Share Buttons」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Add simple share buttons under your posts, add share block in the new editor, or use the widget to add sharing to any widget area your theme provides. This plugin uses simple SVG icons for social network logos and small vanilla JavaScript to allow the user to share the current post or page. Share icons inherit their colours from the theme link colours to match the website design.
Why choose Minimal Share Buttons before other similar plugins?

Minimal and elegant look that blends with your theme (tested with all latest default WordPress themes as well as with some other popular themes).
Minimal impact on your site’s performance – the plugin loads only a small SVG file with the icons, less than 1k CSS and 3.5к unminified and uncompressed JavaScript – most of it to make SVG icons work in old browsers.
Doesn’t spy on your users – the plugin doesn’t load any thitd-party scripts that record your user’s activity on your site, doesn’t set or read any cookies.
Sharing through the native share dialog on devices that support it.
GDPR-hasle-free – since the plugin doesn’t leak personal information to third parties, this makes it easier for website owners to comply with the European privacy regulations.
Accessibility – the share links have labels, read by screen readers, and visible for keyboard users.
Gutenberg and WordPress 5.0 ready – the plugin provides block that displays the share buttons so that authors can place them wherever they want in the post content.

Usage
There are five ways of displaying the share buttons on a post or page:

Force them to display under the content of the post by checking the relevant checkboxes in the Display settings sections on the plugin settings screen.
Add Share widget to the sidebar or another widget area.
Use the Gutenberg block to add the share buttons whereever you want in the post content.
Use the shortcode [msb_share title="Share this"] in the classic editor.
Use the function msb_display_buttons() to render the widget in your theme templates.

Theme developers
From version 1.4 you can more easily display the sharing widget in your templates using the function msb_display_buttons(). The function accepts two arguments – an array of options, passed to the widget, and a second boolean argument that tells the function to echo the resulting markup. Here’s an example:
$args = [
'before_widget' => '<div class="msb-container">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
'title' => __( 'Share this article', 'mytextdomain' ),
];
msb_display_buttons( $args, true );

If your theme uses SVG icons, combined into a SVG sprite, and your sprite has icons for Facebook, Twitter, Google+ and LinkedIn, there are two filters you can use to replace the icons, provided by the plugin, with yours. The results of the two filters are concatenated with a hash between them and passed through esc_url before output.
Another filter allows manipulation of the array of social networks.
msb_sprite_url
The filter is applied to the URL of the sprite image and the filter function should return the URL (without the hash sign) of an SVG sprite image, consisting of icons in symbol elements.
msb_icon_name
The filter is applied to the icon name before concatenating it to the sprite URL. It should return the ID of the icon symbol in the sprite.
msb_icon
The filter allows to change the whole icons markup, It receives the icon markup and the icon name as parameters.
msb_socials
The filter is applied to the default list of social networks and allows adding or removing socials networks. The array of social networks is associative array, the key is used for the option name on settings page and for the icon ID, and the value is associative array with three elements – field_label (the label of the field in settings), button_label (the label of the button for screenreader users), and share_url (the URL for sharing links). The share_url is passed through sprintf with two params – the URL of the current page and the title of the page. Example:
function my_add_xing( $socials ){

$socials['xing'] = array(
'field_label' => __( 'Xing', 'mytheme' ),
'button_label' => __( 'Share on Xing', 'mytheme' ),
'share_url' => 'https://www.xing.com/spi/shares/new?url=%1$s&title=%2$s'
);

return $socials;

}
add_filter( 'msb_socials', 'my_add_xing' );

msb_button_classes

This filter allows changing the classes of the individual buttons. Two parameters are apssed to the filter functions: the array with classes and the social network / button slug.
Credits

SVG Icons from FontAwesome, Creative Commons CC BY 4.0, MIT licence
Banner image by heinzremyschindler on pixbay, Creative Commons CC0
Plugin icon based on work by Nathan Diesel from the Noun Project, Creative Commons CC-BY

延伸相關外掛

文章
Filter
Mastodon