Title: Picker
Author: Andrea Landonio
Published: <strong>2015 年 1 月 6 日</strong>
Last modified: 2021 年 3 月 14 日

---

搜尋外掛

![](https://ps.w.org/picker/assets/banner-772x250.jpg?rev=2091343)

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

![](https://ps.w.org/picker/assets/icon-256x256.png?rev=2091343)

# Picker

 由 [Andrea Landonio](https://profiles.wordpress.org/lando1982/) 開發

[下載](https://downloads.wordpress.org/plugin/picker.1.1.6.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/picker/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/picker/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/picker/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/picker/#developers)

 [技術支援](https://wordpress.org/support/plugin/picker/)

## 外掛說明

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](https://codex.wordpress.org/Transients_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

 1. Go to _WP-Admin -> Appearance -> Widgets_.
 2. Drag _Picker_ widget to a sidebar.
 3. Customize _Picker_ widget.

Links: [Author’s Site](http://www.andrealandonio.it)

## 螢幕擷圖

 * [[
 * Widget admin page (customizing widget)
 * [[
 * Widget admin page (datetimepicker usage)
 * [[
 * Frontend widget layout
 * [[
 * Admin settings page

## 安裝方式

 1. Unzip the downloaded _picker_ zip file
 2. Upload the _picker_ folder and its contents into the _wp-content/plugins/_ directory
    of your WordPress installation
 3. Activate _picker_ from Plugins page

## 常見問題集

### Works on multisite?

Yes

### How works with different locales?

Plugin works with 2 different locale and formats:

 * italian locale date format “dd/mm/yy”
 * default locale date format “mm/dd/yy”

### Can I use my custom image sizes on widget?

Yes, in addition to predefined image formats, you can display your registered image
sizes

### Works on with custom post types?

No, for now only standard post types are available

## 使用者評論

![](https://secure.gravatar.com/avatar/88f949545ced02da3a5804a1731db949346344004473f1d898151622ad2969e7?
s=60&d=retro&r=g)

### 󠀁[Great plugin](https://wordpress.org/support/topic/great-plugin-21870/)󠁿

 [Em](https://profiles.wordpress.org/mcottell/) 2019 年 5 月 21 日 1 則留言

Very effective for being able to pick exactly what post you what to highlight.

 [ 閱讀全部 2 則使用者評論 ](https://wordpress.org/support/plugin/picker/reviews/)

## 參與者及開發者

以下人員參與了開源軟體〈Picker〉的開發相關工作。

參與者

 *   [ Andrea Landonio ](https://profiles.wordpress.org/lando1982/)

[將〈Picker〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/picker)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/picker/)、查看
[SVN 存放庫](https://plugins.svn.wordpress.org/picker/)，或透過 [RSS](https://plugins.trac.wordpress.org/log/picker/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/picker/)。

## 變更記錄

#### 1.1.6 – 2021-03-14

 * Tested up with WordPress 5.7 release

#### 1.1.5 – 2020-12-09

 * Tested up to latest WordPress releases

#### 1.1.3 – 2019-05-22

 * Updated WordPress requirements

#### 1.1.1 – 2019-05-20

 * Fixed deprecated constructor methods

#### 1.1.0 – 2016-06-30

 * Added custom types management

#### 1.0.0 – 2015-01-01

 * First release

## 中繼資料

 *  版本 **1.1.6**
 *  最後更新 **5 年前**
 *  啟用安裝數 **10+**
 *  WordPress 版本需求 ** 4.0 或更新版本 **
 *  已測試相容的 WordPress 版本 **5.7.15**
 *  語言
 * [English (US)](https://wordpress.org/plugins/picker/)
 * 標籤:
 * [admin](https://tw.wordpress.org/plugins/tags/admin/)[pick](https://tw.wordpress.org/plugins/tags/pick/)
   [picker](https://tw.wordpress.org/plugins/tags/picker/)[usability](https://tw.wordpress.org/plugins/tags/usability/)
   [widget](https://tw.wordpress.org/plugins/tags/widget/)
 *  [進階檢視](https://tw.wordpress.org/plugins/picker/advanced/)

## 評分

 5 星，滿分為 5 星

 *  [  2 個 5 星使用者評論     ](https://wordpress.org/support/plugin/picker/reviews/?filter=5)
 *  [  0 個 4 星使用者評論     ](https://wordpress.org/support/plugin/picker/reviews/?filter=4)
 *  [  0 個 3 星使用者評論     ](https://wordpress.org/support/plugin/picker/reviews/?filter=3)
 *  [  0 個 2 星使用者評論     ](https://wordpress.org/support/plugin/picker/reviews/?filter=2)
 *  [  0 個 1 星使用者評論     ](https://wordpress.org/support/plugin/picker/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/picker/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/picker/reviews/)

## 參與者

 *   [ Andrea Landonio ](https://profiles.wordpress.org/lando1982/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/picker/)