[WordPress] 外掛分享: Unread Posts

WordPress 外掛 Unread Posts 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Unread Posts」是 2015-05-07 上架。
  • 目前有 20 個安裝啟用數。
  • 上一次更新是 2015-10-14,距離現在已有 3490 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.5.0 以上版本才可以安裝。
  • 有 1 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

danielpataki |

外掛標籤

posts | widget | related |

內容簡介

未讀文章是一款適用於一般用戶和開發人員的外掛。對於一般用戶,它允許創建小部件,顯示用戶尚未閱讀的文章。它適用於已登錄和未登錄的用戶。您還可以在單篇文章內容正下方添加未讀文章。

針對未登錄的用戶,該外掛會使用 cookie,因此請確保您的用戶同意使用 cookie,例如使用Cookie Law Info外掛。

該外掛包含一些開發人員友好的功能,因此您可以輕鬆利用核心功能、管理已讀/未讀文章。該類別可以獨立使用,您可以使用一些內建函數,並且我已為您添加了許多過濾器,讓您修改從列表中顯示的內容,到如何實際顯示列表,都有更多控制權。

如需更多有關開發人員方面的資訊,請參閱“其他注意事項”部分。

使用方法

此外掛提供了小部件和可以在文章下方添加的可選部分。可以在外觀 -> 小工具中添加小部件,並有多個選項。希望這些選項都很明確,如果您有任何問題,請隨時與我聯繫。

在“設置 -> 未讀文章”下還有一個設置部分。此頁面包含未讀文章部分的設置,用於放置在文章下部。可以通過選擇“在文章顯示下方?”,啟用此部分。選項與小部件相同,但您可以更加控制何時顯示什麼。

首先,使用“在文章下方顯示文章類型”設置,設置此部分的顯示位置。未讀文章部分僅會在設定文章類型的文章下方顯示。

“列出的文章類型”部分允許您控制要在列表中顯示哪些文章類型。如果選擇“與當前文章相同”,則會列出與顯示的文章類型相同的文章類型。例如:在頁面上僅顯示頁面,在文章上僅顯示文章。

如果選擇“從列表中選擇”,則會顯示下拉菜單,允許您指定要在列表中顯示的文章類型。

感謝

FontAwesome,用於外掛特色圖像和圖標中的圖標
該外掛是完全以物件導向的方式編寫的,可輕鬆擴展。如果您需要使用未讀文章的功能,則需要使用$up_unread_posts變數,該變數可以全局化並在任何地方使用。

使用未讀文章類別

該外掛具有以下可供使用的方法:

set_posts_as_read($posts)
set_posts_as_unread($posts)
get_read_posts()
get_unread_posts()
delete_read_posts()

請參閱相應文件以獲取有關這些函數以及如何使用它們的更多資訊。所有文件都有豐富的 phpDoc,應該可以幫助您。

根據用戶狀態不同,不同的類別處理這些功能,您還可以創建自己的處理程序。每個處理程序都必須遵守UP_Unread_Posts_Handler_Interface接口。

還要注意,某些函數可能無法在任何地方使用。例如,cookie用於存儲已讀文章。必須在發送任何HTML之前設置cookie的值,因此您無法只在任何地方使用set_posts_as_read()函數。

掛鉤

該外掛有很多掛鉤可幫助您擴展它。以下是目前可用的所有掛鉤的完整列表:

up/cookie_name
使用的默認cookie名稱為“[blog-name]-up_read_posts”。如果您想要更改它,可以使用此過濾器。它只接收一個參數,即cookie名稱。

原文外掛簡介

Unread posts is a plugin for regular users and developers alike. For regular users it allows for the creation of widgets that display posts the user has not yet read. It will work for logged in and logged out users as well. You can also add unread posts just below your single post content.
For logged out users the plugin uses cookies so please make sure your users consent to cookies by using a plugin like Cookie Law Info.
The plugin contains a bunch of developer friendly features so you can easily leverage the core functionality, the management of read/unread posts. The class may be used alone, you can use some built in functions and I’ve added a bunch of filters for you to modify everything from what shows up in lists to how the lists are actually displayed.
For more information on developer features take a look at the Other Notes section.
Usage
The plugin offers a widget and an optional section below posts. The widget can be added in Appearance->Widgets and has a number of options. Hopefully these are all self explanatory, let me know if you have any questions.
There is also a settings section under Settings->Unread Posts. This page contains settings for the unread posts section to be placed under posts. You can enable this section by ticking the “Show Below Post Content?” box. The options are much the same as the widgets but you have a bit more control over when and what is shown.
First of all, use “Show Below Post Types” setting to set where this section shows up at all. The unread posts section will only show up under posts with the set post type(s).
The “Post Types To List” section allows you to control which post types are shown in the list. If “Same as the current post” is selected the post types listed will match the post type shown. Ie: On pages only pages will be shown, on posts only posts will be shown.
If you select “Select from a list” you will get a dropdown which allows you to specify the post types you would like shown in the list.
Thanks

FontAwesome for the icons used in the plugin featured image and icon
The plugin was written in a completely object oriented fashion to make it easy to extend. If you need to use the raw functionality of unread posts you’ll want to use the $up_unread_posts variable which can be globalized and used anywhere.

Using The Unread Posts Class
This has the following methods you can use:

set_posts_as_read( $posts )
set_posts_as_unread( $posts )
get_read_posts()
get_unread_posts()
delete_read_posts()

Please see the appropriate files for more information on these functions and how to use them. All files have extensive phpDoc which should help you out.
Depending on the user state different classes handle these functions, you can also create your own handler. Each handler must adhere to the UP_Unread_Posts_Handler_Interface interface.
Also note that some functions may not be usable everywhere. For example, cookies are used to store read posts. The value of cookies must be set before any HTML is sent so you can’t just use the set_posts_as_read() function anywhere you’d like.
Hooks
The plugin has lots of hooks which help you extend it. Here is a full list of the ones available right now:
up/cookie_name
The default cookie name used will be ‘[blog-name]-up_read_posts’. If you’d like to change it you can use this filter. The only parameter it receives is the cookie name.
add_filter( 'up/cookie_name', 'my_up_cookie_name' );
function my_up_cookie_name() {
return 'my-awesome-up-cookie';
}

up/meta_field
The default user meta key used will be ‘up_read_posts’. If you’d like to change it you can use this filter. The only parameter it receives is the meta key name.
add_filter( 'up/meta_field', 'my_up_meta_field' );
function my_up_meta_field() {
return 'my_read_posts';
}

up/unread_query_args
This filter modifies the query arguments passed to the WP_Query object when querying for unread posts. Unread posts are retrieved by passing the array of read post IDs to the post__not_in parameter. If you would like to place additional restrictions you can do so with this filter. It receives the arguments as the first parameter.
add_filter( 'up/unread_query_args', 'my_up_unread_query_args' );
function my_up_unread_query_args( $args ) {
$args['cat'] = 10;
return $args;
}

up/unread_widget_display
This filter can modify the display of the post list in the widget. It receives three parameters. The original HTML to be displayed, the WP_Query object of unread posts and the instance variables for the widget. You can use it to completely customize the display of the posts.
add_filter( 'up/unread_widget_display', 'my_unread_widget_display', 10, 3 );
function my_unread_widget_display( $display, $unread, $instance ) {
$output = '

    ';
    while( $unread->have_posts() ) {
    $unread->the_post();
    $output = '
  • ' . the_title( '', '', false ) . '
  • ';
    }
    $output = '

';
return $output;
}

up/show_widget
If you want to hide the widget in the admin because you are only using the functionality of the plugin to build something yourself you can do so with this filter. Return false to hide the widget.
add_filter( 'up/show_widget', 'hide_up_widget' );
function hide_up_widget() {
return false;
}

up/show_settings_page
If you want to hide the settings page in the admin because you are only using the functionality of the plugin to build something yourself you can do so with this filter. Return false to hide the settings page.
add_filter( 'up/show_settings_page', 'hide_settings_page' );
function hide_settings_page() {
return false;
}

up/posts_section_settings
This filter can be used to modify the settings for the unread posts section shown below single posts. It’s only parameter is the settings it received, print that parameter to figure out all the options.
add_filter( 'up/posts_section_settings', 'my_posts_section_settings' );
function my_posts_section_settings( $settings ) {
$settings['count'] = 10;
return $settings;
}

up/unread_section_display
This filter can modify the display of the unread posts list shown below single posts. It receives three parameters. The original HTML to be displayed, the WP_Query object of unread posts and the settings for the section. You can use it to completely customize the display of the posts.
add_filter( 'up/unread_section_display', 'my_unread_section_display', 10, 3 );
function my_unread_section_display( $display, $unread, $settings ) {
$output = '

    ';
    while( $unread->have_posts() ) {
    $unread->the_post();
    $output = '
  • ' . the_title( '', '', false ) . '
  • ';
    }
    $output = '

';
return $output;
}

up/usable_post_types
If you would like to restrict the post types available to the plugin you can use this filter to do so. It takes the currently available post types as the first parameter.
add_filter( 'up/usable_post_types', 'my_usable_post_types' );
function my_usable_post_types( $post_types ) {
$post_types = array( 'post', 'product' );
return $post_types;
}

各版本下載點

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

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


最新版本

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

  • WP Shortcodes Plugin — Shortcodes Ultimate 》Shortcodes Ultimate 是一個全面的視覺與功能性元素收集,您可以在文章編輯器、文字小工具甚至是範本檔案中使用。使用 Shortcodes Ultimate,您可以輕鬆地建...。
  • Post Duplicator 》這個外掛是用來製作選定文章的完全一模一樣複製。它支援自訂文章類型、自訂分類和自訂欄位。, *注意: 評論不會被複製到新文章。, 這個外掛的目的是為了快速且...。
  • GenerateBlocks 》將不同的功能整合至編輯器,但並不會因為過多的一維方塊造成內容過於臃腫。使用 GenerateBlocks,您只需深入學習少量的方塊,即可用於創建任何內容。, Genera...。
  • YARPP – Yet Another Related Posts Plugin 》WordPress 相關文章外掛, Yet Another Related Posts Plugin (YARPP) 是一個經過專業維護、高度自訂和功能豐富的外掛程式,可以顯示與當前文章相關的頁面、文...。
  • WP Meta and Date Remover 》移除點擊文章的Meta、作者和日期。 安裝、啟用,完成!, 如何移除文章和頁面的作者Meta和日期?, , 安裝 WP Meta and Date remover。, 啟用外掛。, 選擇隱藏...。
  • WordPress Popular Posts 》WordPress Popular Posts 是一個高度可定製的小工具,可以顯示您最受歡迎的文章。, 主要特點, , 多小工具功能 – 您可以在您的博客上擁有多個 WordPress...。
  • Public Post Preview 》此外掛可讓您分享一個鏈接給匿名使用者,以便他們在發布前預覽文章(或其他公開文章類型)。, 您是否曾經與沒有訪問您網站權限的人共同撰寫文章,並需要給予...。
  • List category posts 》List Category Posts 可以讓你透過使用 [catlist] 短碼在文章或頁面中按類別列出文章。在編輯頁面或文章時,直接插入短碼到文章中,文章就會被列出來。基本的...。
  • Display Posts – Easy lists, grids, navigation, and more 》Display Posts 讓您輕鬆地列出網站上的所有內容。首先在內容編輯器中新增此短碼,以列出最近的文章清單:, [display-posts], , 按類別篩選, 若只想顯示特定類...。
  • CMS Tree Page View 》將所有頁面和自訂文章以 CMS 樹狀概覽方式添加到 WordPress,類似於專注於頁面的 CMS 中經常找到的檢視方式。, 如果您的目標是將多個內容類型合併到單一檢視...。
  • Category Posts Widget 》Category Posts Widget是一個輕巧的小工具,設計用於一件事並且做得很好:顯示特定類別中最新的文章。, 基於詞語和類別的文章小工具, 這個免費小工具的高級版...。
  • WP Telegram (Auto Post and Notifications) 》完美整合 Telegram 至 WordPress,讓您完全掌握控制。, Telegram 的卓越 LIVER 支援, 加入聊天室, 我們在 Telegram 上有一個公開小組,提供協助設置外掛、討...。
  • WP Admin UI Customize 》, 儀表板, 顯示選項標籤, 輸出 - 元網站, 管理工具列 (Toolbar), 側邊選單 (Side menu), 元箱的管理, 登入畫面, 其他功能, , 這些自訂化都是可以實現的。, , ...。
  • Ultimate Post Kit Addons For Elementor – (Post Grid, Post Carousel, Post Slider, Category List, Post Tabs, Timeline, Post Ticker and Tag Cloud) 》Ultimate Post Kit Elementor 外掛程式是首個允許您全新且清新地設計部落格網站的外掛程式。這是博客作者、行銷人員和文章類型網站擁有者的最佳工具。, Ultim...。
  • Reading Time WP 》WP Reading Time 讓你輕鬆地在 WordPress 文章中加入預估閱讀時間。啟用這個外掛會自動在你的文章內容的開始加入閱讀時間。你可以在「閱讀時間」設定中取消這...。

文章
Filter
Mastodon