[WordPress] 外掛分享: Favorites

首頁外掛目錄 › Favorites
WordPress 外掛 Favorites 的封面圖片
10,000+
安裝啟用
★★★★
4.6/5 分(132 則評價)
342 天前
最後更新
0%
問題解決
WordPress 3.8+ PHP 5.4+ v2.3.6 上架:2015-03-04

內容簡介

取得函式: get_favorites_button($post_id, $site_id)
列印函式: the_favorites_button($post_id, $site_id)
短代碼: [favorite_button post_id="" site_id=""]

收藏計數(根據文章)

每篇文章的總收藏數都被保存為一個簡單的整數。如果用戶取消收藏文章,這個計數就會更新。預設情況下,匿名用戶的收藏計入總數,但可以通過外掛的設置來禁用。在所有情況下,如果在循環內部,則可以將文章 ID 留空。

取得函式: get_favorites_count($post_id)
列印函式: the_favorites_count($post_id)
顯示總收藏計數: [favorite_count post_id=""]

用戶收藏列表

要顯示已收藏文章的列表,使用以下功能。如果要顯示屬於不同網站的文章列表,可以通過選擇適當的站點 ID 來實現多站點兼容性。

顯示收藏列表: [favorite_list]
按照站點顯示: [favorite_list site_id=""]
按照文章顯示: [favorite_list post_ids=""]

收藏徽章(輸出按文章排序後的收藏計數)

以可配置的格式輸出收藏次數: [favorite_badge format="collapsed"]
按站點顯示: [favorite_badge site_id=""]

對於完整的可用函數列表和短代碼列表,請訪問 favoriteposts.com。

重要提示:Favorites 需要 WordPress 版本 3.8 或更高版本,以及 PHP 版本 5.4 或更高版本。

使用方法

收藏按鈕

通過在外掛設置中啟用特定的文章類型,可以自動在文章內容之前和/或之後添加收藏按鈕。也可以使用包含的功能或短代碼在模板文件中添加。如果在循環內部,文章 ID 可以留空。對於多站點安裝,網站 ID 參數為可選參數(默認為當前站點)。

外掛標籤

開發者團隊

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

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

原文外掛簡介

Why Favorites?
Favorites is designed for end users and theme developers. It provides an easy-to-use API for adding favorite button functionality to any post type.
The plugin can provide a way to save favorites, likes, bookmarks, or any other similar types of data with its customizable button text.
Visit favoriteposts.com for a full list of available template functions and shortcodes.
Features
Use with Any Post Type – Enable or disable favorite functionality per post type while automatically adding a favorite button before and/or after the content. Or, use the included functions to display the button anywhere in your template.
Available for All Users – Don’t want to hide functionality behind a login? Favorites includes an option to save anonymous users’ favorites by either Session or Cookie. Logged-In users’ favorites are also saved as user meta
Designed for Developers – Favorites works great out-of-the-box for beginners, but a full set of template functions unlocks just about any sort of custom functionality developers may need. Favorites outputs the minimum amount of markup needed, putting the style and control in your hands.
GDPR
As of version 2.2, a setting is provided to help comply with GDPR standards. To enable this setting, visit Settings > Favorites > Users, and check the field under “User Cookie Consent.” When this setting is enabled, the content saved under the setting displays in a modal window, and the user must agree to the terms you provide before favorite cookies can be saved. Note: There is no language provided by default. This should be supplied by a qualified attorney or legal entity. Once the user has approved or denied cookies, that is saved in the “simplefavorites” cookie along with the timestamp of approval or denial. If the site is part of a multi-site installation, the setting will carry through to all sites.
If your site already has a cookie compliance solution in place, there are two document-level jQuery events that may be triggered in order to approve or deny cookies in the background.
To approve the use of cookies, trigger the event “favorites-user-consent-approved”. To deny the use of cookies, trigger the event “favorites-user-consent-denied”.
Multisite Compatible – As of version 1.1.0, Favorites is multisite compatible. User favorites are saved on a site/blog basis, and may be retrieved and displayed across sites.
For more information visit favoriteposts.com.
Important: Favorites requires WordPress version 3.8 or higher, and PHP version 5.4 or higher.
Usage
Favorite Button
The favorite button can be added automatically to the content by enabling specific post types in the plugin settings. It may also be added to template files or through the content editor using the included functions or shortcodes. The post id may be left blank in all cases if inside the loop. The site id parameter is optional, for use in multisite installations (defaults to current site).

Get function: get_favorites_button($post_id, $site_id)
Print function: the_favorites_button($post_id, $site_id)
Shortcode: [favorite_button post_id="" site_id=""]

Favorite Count (by Post)
Total favorites for each post are saved as a simple integer. If a user unfavorites a post, this count is updated. Anonymous users’ favorites count towards the total by default, but may be disabled via the plugin settings. The post id may be left blank in all cases if inside the loop.

Get function: get_favorites_count($post_id)
Print function: the_favorites_count($post_id)
Shortcode: [favorite_count post_id=""]

Favorite Count (by User)
Displays the total number of favorites a user has favorited. Template functions accept the same filters parameter as the user favorites functions.

Get function: get_user_favorites_count($user_id, $site_id, $filters)
Print function: the_user_favorites_count($user_id, $site_id, $filters)
Shortcode: [user_favorites user_id="" site_id="" post_types=""]

User Favorites
User favorites are stored as an array of post ids. Logged-in users’ favorites are stored as a custom user meta field, while anonymous users’ favorites are stored in either the session or browser cookie (configurable in the plugin settings). If the user id parameter is omitted, the favorites default to the current user. The site id parameter is optional, for use in multisite installations (defaults to current site).

Get function (returns array of IDs): get_user_favorites($user_id, $site_id)
Get function (returns html list): get_user_favorites_list($user_id, $site_id, $include_links, $filters, $include_button, $include_thumbnails = false, $thumbnail_size = 'thumbnail', $include_excerpt = false)
Print function (prints an html list): the_user_favorites_list($user_id, $site_id, $include_links, $filters, $include_button, $include_thumbnails = false, $thumbnail_size = 'thumbnail', $include_excerpt = false)
Shortcode (prints an html list, with the option of omitting links): `[user_favorites user_id=”” include_links=”true” site_id=”” include_buttons=”false” post_types=”post” include_thumbnails=”false” thumbnail_size=”thumbnail” include_excerpt=”false”]

List Users Who Have Favorited a Post
Display a list of users who have favorited a specific post. If the user id parameter is omitted, the favorites default to the current user. The site id parameter is optional, for use in multisite installations (defaults to current site). The get function returns an array of user objects.

Get function (returns array of User Objects): get_users_who_favorited_post($post_id, $site_id)
Print function (prints an html list): the_users_who_favorited_post($post_id = null, $site_id = null, $separator = 'list', $include_anonymous = true, $anonymous_label = 'Anonymous Users', $anonymous_label_single = 'Anonymous User')
Shortcode (prints an html list): `[post_favorites post_id=”” site_id=”” separator=”list” include_anonymous=”true” anonymous_label=”Anonymous Users” anonymous_label_single=”Anonymous User”]

Clear Favorites Button
Displays a button that allows users to clear all of their favorites.

Get function: get_clear_favorites_button($site_id, $text)
Print function: the_clear_favorites_button($site_id, $text)
Shortcode: `[clear_favorites_button site_id=”” text=”Clear Favorites”]

Favorite Count (Across all Posts)
Displays the total number of favorites for a given site.

Get function: get_total_favorites_count($site_id)
Print function: the_total_favorites_count($site_id)

延伸相關外掛

文章
Filter
Apply Filters
Mastodon