[WordPress] 外掛分享: Picker

WordPress 外掛 Picker 的封面圖片。

前言介紹

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

外掛協作開發者

lando1982 |

外掛標籤

pick | admin | picker | widget | usability |

內容簡介

Picker 是一款簡單靈活的外掛,允許用戶在後台小工具頁面上選擇特定的文章,並在其網站前端顯示該文章。如果您需要顯示特定的文章,而不是一般的最新文章列表、排名前列的文章、分類文章等,而只是在後台配置的文章, Picker 外掛可以非常快速便捷地實現。它在後台小工具頁面上添加了一個小工具,您可以使用它來選擇並在您網站的前端顯示文章。您可以通過更改外掛的設置頁面來使用標準類型(如文章)和自定義類型。
Picker 外掛在其許多功能中是可擴展的,例如應用篩選器和操作,管理佈局模板等等。此外,該外掛基於 WordPress 緩存 API 進行緩存處理。正如前面提到的,該外掛提供了一種覆蓋默認佈局模板的方法。通過幾行代碼,您可以創建自己的佈局模板(復制默認模板),並完全改變外掛的外觀和感覺,因為您可以完全訪問所有的 Picker 類別。

小工具用法

您可以像使用其他 WordPress 外掛一樣使用 Picker,將小工具拖到側邊欄中即可啟用 Picker 小工具。初始化時,該小工具未在前端上發布。這樣,您可以安全地配置小工具的數據,然後發布/顯示小工具。 Picker 小工具由以下字段組成:

發布核取方塊:標誌懸掛小工具。
小工具標題:小工具標題,僅供後端和用戶使用,不顯示在前端。
文章列表:按日期列出的最新文章列表。
文章搜索:提供文章 ID 或搜索文章的搜索框,如果文章不在上述文章列表中,就可以在其中搜索文章。
發布時間:設置小工具在前端顯示的時間。
到期時間:設置小工具應從前端中刪除的時間。
替代 URL:替代默認文章永久網址的替代 URL。
替代標題:替代默認 post_title 字段的替代標題。
替代摘錄:替代默認 post_excerpt 字段的替代摘錄。

對於某些字段,有一個 jQuery 驗證來檢查正確的格式。 Picker 外掛檢查所有數字、URL 和日期時間字段,如果數據錯誤,會顯示提示。

自定義佈局模板

Picker 外掛提供了一個默認的小工具模板,顯示一個被連結的標題(使用文章標題)、帖子特色圖像和文章摘要。或者,您可以管理小工具模板並覆蓋默認模板。 Picker 外掛有一個工具來檢測用於小工具佈局包含的模板路徑。下面是模板文件的加載順序:

主題/模板路徑/模板名稱(默認值:主題模板文件夾)
主題/模板名稱(默認值:主題根文件夾)
default_path /模板名稱(默認:插件模板文件夾)

外掛篩選器

Picker 外掛提供了許多篩選器,用於擴展外掛核心功能的默認行為。這是一個可用的最重要的篩選器列表:

picker_item_title:允許修改選取器項目標題。
picker_item_excerpt:允許修改選取器項目摘要。
picker_item_content:允許修改選取器項目內容。
picker_template_path:允許修改佈局模板路徑。

為了更好地理解如何與外掛篩選器交互,以下是一些示例。如果需要,您可以修改默認(通常為 picker/ 文件夾)為您的佈景主題根目錄中的文件夾。在下面的示例中,將這個函數添加到您的 " fun " 檔案中:

原文外掛簡介

Picker is a simple and flexible plugin which allow users to choose a specific post inside admin widgets page and display it in their site frontend.
If you need to display a specific post, not a generic list of last posts, top ranked posts, category posts, etc.. but only the one that you configure in the backend. Picker plugin makes it possible in a very quick and easy way. It adds a widget on the admin widgets page that you can use to select and show a post on your site’s frontend. You can work with standard types (like posts) and custom types simply by changing the settings page of the plugin.
Picker plugin is extensible in many of its features, such as, applying filters and action, managing layout template, etc.. moreover, plugin is based on the WordPress Transient API for caching issue.
As mentioned before, the plugin provides a way to override the default layout template. With a few lines of code, you can create your layout template (copying the default one) and completely override the plugin look&feel thanks to a complete access to all widget item data throw Picker classes.
Widget usage
You can use Picker plugin like all the other WordPress plugins, dragging the widget to a sidebar you can enable a Picker widget. Initially, the widget is not published on the frontend. In this way you can safely configure widget’s data and then publish/display the widget.
Picker widget is composed by the following fields:

Publish checkbox: flag it to publish the widget
Widget title: a widget title, for backend and users only, not shown on frontend
Post list: a lists of the last posts by date
Post search: a search field to provide a post ID or search it if post is not in the above post list
Time to publish: a datetime to set when the widget could be shown on frontend
Time to expire: a datetime to set when the widget should be removed from frontend
Alternative URL: an alternative URL instead the default posts permalink
Alternative title: an alternative title instead the default post_title field
Alternative excerpt: an alternative excerpt instead the default post_excerpt field

For some field there is a jQuery validation to check right formats. Picker plugin checks all numbers, url and datetime fields showing you an alert if data are wrong.
Customizing layout template
Picker plugin provide a default widget template that show a linked title (using post title), the featured image of the post and the post excerpt. Alternatively, you can manage widget template overriding default template. Picker plugin has a tool to detect the template path used for widget layout inclusion.
This is the load order of the template files:

theme / template_path / template_name (default: theme template folder)
theme / template_name (default: theme root folder)
default_path / template_name (default: plugin templates folder)

Plugin filters
Picker plugin provides many filters to extend default behavior of the plugin core functions. This is a list of the most important available filters:

picker_item_title: allow to modify picker item title
picker_item_excerpt: allow to modify picker item excerpt
picker_item_content: allow to modify picker item content
picker_template_path: allow to modify layout template path

To better understand how you can interact with plugin filters, here are some examples.
If you want, you can modify the default (usually “picker/” folder), with a folder in your theme root. In the following example, adding the function to your “functions.php” theme file, we are telling to Picker plugin to search template files inside a “templates/” folder in your theme root.
function modify_picker_template_path() {
return 'templates';
}
add_filter( 'picker_template_path', 'modify_picker_template_path' );

Also, you can modify the default post title (usually “post_title” field), adding for example a prefix/suffix. In the following example, adding the function to your “functions.php” theme file, we are telling to Picker plugin to call your function before return to template the item post title value.
function modify_picker_post_title( $value ) {
return 'my_prefix ' . $value;
}
add_filter( 'picker_item_title', 'modify_picker_post_title' );

Template utility class and functions
As described in the previous paragraph, you can customize widget template according to you site specs. Inside the template file you can use a $picker_item global variable to access the picker class methods:

get_post_data(): get WP_Post object
get_permalink(): get post permalink
get_title(): get post title
get_excerpt($max_words = ”, $use_content_if_empty = false): get post excerpt
get_content($max_words = ”): get post content
get_categories($sep = ‘, ‘, $before = ”, $after = ”): get post categories as a list of category links
get_tags($sep = ‘, ‘, $before = ”, $after = ”): get post tags as a list of tag links
get_formats($sep = ‘, ‘, $before = ”, $after = ”): get post formats as a list of format links
has_image(): tell if post has image
get_image($size = ‘thumbnail’, $attr = array()): get post featured image (use thumbnail, medium, large, full default sizes or your registered new image size)
get_image_id(): get post featured image ID
using __get magic method you can read a custom field (eg: $picker_item->my_custom_field)

In addition to $picker_item global variable, you can use custom variables values, such as:

get_custom_url(): the provided alternative post URL
get_custom_title(): the provided alternative post title
get_custom_excerpt(): the provided alternative post excerpt
get_widget_sidebar(): which sidebar contains the the widget
get_widget_order(): the widget order (position)

In the template file are available special variables, for now:

$use_cache: boolean

Very important is the widget_sidebar variable. With this value you can display a different widget layout according to which sidebar contains the widget.
Caching management
To increase performance and reduce database queries Picker plugin use a persistent caching management. To get a persistent cache without using external plugins Picker plugin uses WordPress Transient API.
Anytime WordPress display Picker plugin on a site frontend page a calls Picker plugin widget management. First of all, Picker plugin look for a cached object into Transient cache, if found it, gets data, prepares HTML and provides it to frontend.
If data isn’t in Transient cache, Picker plugin go on with widget date and status validation, then, after looked up post into database, create Picker item object that contains all the widget post data, and in the end like a cached object prepares HTML and provides it to frontend.
Before concluding by Picker plugin widget management, the Picker item is saved to Transient cache. Only the Picker item is saved to cache, no HTML neither frontend logic are saved to cache. The goal to Picker caching management is only to reduce database usage.
Picker plugin cache has many expiration rules, the most important are:

widgets are cached 5 minutes if you specify a time to publish or a time to expire
widgets are cached 1 day if you don’t specify a time to publish and a time to expire
widgets cache expire if you update the widget
widgets cache expire when one of the following action is triggered:

save_post
deleted_post
publish_future_post
switch_theme

Usage

Go to WP-Admin -> Appearance -> Widgets.
Drag Picker widget to a sidebar.
Customize Picker widget.

Links: Author’s Site

各版本下載點

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

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


1.1.1 | 1.1.2 | 1.1.3 | 1.1.4 | 1.1.5 | 1.1.6 | trunk |

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

  • Remove Widget Titles 》這個 Remove Widget Titles 外掛可以移除任何以 "!" 字元開頭的小工具的標題。, 為什麼要使用它?, 這讓你可以在後端為小工具命名,以方便你快速看出哪個小工...。
  • WCAG 2.0 form fields for Gravity Forms 》, 此外掛是 Gravity Forms 的附加元件。如果您還沒有擁有 Gravity Forms 授權,請 現在購買!(聯盟網路連結), , 此外掛的功能是什麼?, , 將單選、勾選框和...。
  • WooCommerce Better Usability 》這個 WordPress 外掛提供了購買 WooCommerce 店家產品時的整體用戶體驗改進。改進的範圍包括:商店、產品、購物車和結帳。, 免費版功能:, , 使用 AJAX 自動...。
  • Taxonomy Filter 》Taxonomy filter是一個簡單靈活的外掛,允許用戶在管理頁面內過濾層次性詞彙分類。如果您需要簡化管理頁面上的標籤和分類,這個外掛會讓您更容易。它會添加一...。
  • Remove Redundant Links 》此 WordPress 外掛會將指向目前頁面的 元素更改為移除 href 屬性並新增描述性的 title。, 與大多數佈景主題相容。已在 TwentyTen 進行測試。, 範例...。
  • Admin Page Notes 》您曾經建立過一個頁面模板,僅彙總自訂文章類型的文章嗎?看起來很酷對吧?, 不過,兩個月後當您的客戶要編輯他們的網站時,他們就不會覺得那麼酷了。他們點...。
  • Hotspots Analytics 》熱點分析是 WordPress 網站上最先進的分析外掛,包括熱點圖、使用者活動和自訂事件追蹤。它可以有效地與 Google Analytics 搭配使用,並支援回應式網頁設計和...。
  • resmio button & widget 》Resmio 提供您一個為餐廳提供線上訂位系統軟體,讓您可以快速且輕鬆地管理所有餐廳收到的訂位。若要從您的網站接收訂位,您必須整合 Resmio 提供的代碼片段,...。
  • J7 Beaver Header Footer Templates 》, 相容於 Beaver Builder 主題, , 你可以透過 Beaver Builder 外掛自建一個 header 並儲存排版,接著,透過 J7 Beaver Headers Footers 外掛輕鬆套用到你的網...。
  • Proper Pagination 》此外掛主要針對主題開發人員,旨在簡化 WordPress 列表頁面(如存檔、作者、分類、搜尋、標籤列表等)的語義化、可用性分割控制器的建立。, 受到「The Loop」...。
  • Kahi's WP Lite 》WordPress 管理介面中總會有一些你暫時不需要的部分,這個外掛程式可以方便地隱藏它們,例如不必要的選單項目或文章編輯介面上的任何框格(例如自訂欄位或引...。
  • Auto Insert Title To Link 》這個外掛可以自動填入 WordPress 編輯器中連結的標題屬性。, 如果使用者在「插入連結」彈出視窗的標題欄位上聚焦,外掛會嘗試從 URL 欄位擷取 URL 並發送請求...。
  • Quick Configuration Links 》這個外掛將在「外掛」頁面中列出所有啟用的外掛旁(在「停用」和「編輯」鏈接旁邊)加入一個「設定」鏈接,讓您可以輕鬆地設定外掛,而不必在整個儀表板菜單...。
  • Dyslexic Fonts 》在使用者資料畫面上新增一個核取方塊,讓已登入的使用者可以將網站上的字型更改為適合誦讀障礙者使用的字型。。
  • HUEM: Huge Upload Enabler, mostly 》HUEAM 是一個 WordPress 外掛,儘管不會干擾 WordPress 的運作,仍會試圖對其進行改進。安裝此外掛後,您不會立即注意到任何變化,但這些功能已默默啟用。, ,...。

文章
Filter
Apply Filters
Mastodon