前言介紹
- 這款 WordPress 外掛「Easy Custom Fields」是 2010-05-01 上架。
- 目前有 70 個安裝啟用數。
- 上一次更新是 2012-07-11,距離現在已有 4679 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 2.9.2 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
tott | automattic |
外掛標籤
post meta | post_meta | custom fields | custom post fields |
內容簡介
功能:
使用多個欄位 / 群組簡單生成文章框
易於驗證 / 清理輸入和輸出數據
通過 $easy_cf->field_id->get() 或 $easy_cf->field_id->get(NULL,$raw=true) 輕鬆訪問欄位數據
通過管理員通知獲取驗證失敗的錯誤消息
自定義文章類型感知
通過擴展 Easy_CF_Field 和 Easy_CF_Validator 類來擴展您的需求(請參閱高級用法)
由於此腳本主要作為開發人員的基礎,因此需要一些編程技能才能為您的主題添加此功能。
為了使用這個類,只需按照下面的說明從您的主題的 functions.php 文件中初始化它即可。
簡單用法
require_once( WP_PLUGIN_DIR . '/easy-custom-fields/easy-custom-fields.php' );
$field_data = array (
'testgroup' => array ( // 唯一的群組 ID
'fields' => array( // 拥有字段定义的字段数组
'field1' => array(), // 全局唯一的字段 ID
'field2' => array(),
'field3' => array(),
),
),
);
$easy_cf = new Easy_CF($field_data);
高級用法
require_once( WP_PLUGIN_DIR . '/easy-custom-fields/easy-custom-fields.php' );
$field_data = array (
'testgroup' => array (
'fields' => array(
'field1' => array(),
'field2' => array(),
'field3' => array(),
),
),
'advanced_testgroup' => array ( // 唯一的群組 ID
'fields' => array( // 拥有字段定义的字段数组
'advanced_field' => array( // 全局唯一的字段 ID
'label' => '進階字段描述', // 字段標籤
'hint' => '長進階字段描述', // 字段的一個描述性提示
'type' => 'textarea', // 自訂欄位類型(見參考:field_type)
'class' => 'aclass', // CSS 封裝器類
'input_class' => 'theEditor', // 輸入欄位的 CSS 類
'error_msg' => '進階字段出現問題', // 驗證失敗時顯示的錯誤消息
'validate' => 'validatorname', // 自定義驗證器(見參考:validator)
'advanced_email' => array(
'label' => '電子郵件',
'hint' => '輸入您的電子郵件地址',
'validate' => 'email', )
),
'title' => '產品描述', // 群組標題
'context' => 'advanced', // 與 https://codex.wordpress.org/Function_Reference/add_meta_box 中一致的上下文
'pages' => array( 'post', 'page' ), // 與 https://codex.wordpress.org/Function_Reference/add_meta_box 中相同的頁面
),
);
if ( !class_exists( "Easy_CF_Validator_Email" ) ) {
class Easy_CF_Validator_Email extends Easy_CF_Validator {
public function get( $value='' ) {
return esc_attr( $value );
}
public function set( $value='' ) {
$value = esc_attr( trim( stripslashes( $value ) ) );
return $value;
}
public function validate( $value='' ) {
原文外掛簡介
Features:
simply generate post boxes with multiple fields / groups
easily validate/sanitize input and output data
easy access to field data via $easy_cf->field_id->get() or $easy_cf->field_id->get( NULL, $raw=true );
get error messages for validation failures via admin notices
custom post type aware
extendable to your needs by extending Easy_CF_Field and Easy_CF_Validator classes (see advanced usage)
As this script is mainly meant as basis for developers it needs minor coding skills to add this functionality
to your theme.
In order to make use of this class simply initialize it from the functions.php file of your theme as described below.
Simple Usage
require_once( WP_PLUGIN_DIR . '/easy-custom-fields/easy-custom-fields.php' );
$field_data = array (
'testgroup' => array ( // unique group id
'fields' => array( // array "fields" with field definitions
'field1' => array(), // globally unique field id
'field2' => array(),
'field3' => array(),
),
),
);
$easy_cf = new Easy_CF($field_data);
Advanced Usage
require_once( WP_PLUGIN_DIR . '/easy-custom-fields/easy-custom-fields.php' );
$field_data = array (
'testgroup' => array (
'fields' => array(
'field1' => array(),
'field2' => array(),
'field3' => array(),
),
),
'advanced_testgroup' => array ( // unique group id
'fields' => array( // array "fields" with field definitions
'advanced_field' => array( // globally unique field id
'label' => 'Advanced Field Description', // Field Label
'hint' => 'Long Advanced Field description', // A descriptive hint for the field
'type' => 'textarea', // Custom Field Type (see Ref: field_type)
'class' => 'aclass', // CSS Wrapper class for the field
'input_class' => 'theEditor', // CSS class for the input field
'error_msg' => 'The Advanced Field is wrong' ), // Error message to show when validate fails
'validate' => 'validatorname', // Custom Validator (see Ref: validator)
'advanced_email' => array(
'label' => 'Email',
'hint' => 'Enter your email',
'validate' => 'email', )
),
'title' => 'Product Description', // Group Title
'context' => 'advanced', // context as in https://codex.wordpress.org/Function_Reference/add_meta_box
'pages' => array( 'post', 'page' ), // pages as in https://codex.wordpress.org/Function_Reference/add_meta_box
),
);
if ( !class_exists( "Easy_CF_Validator_Email" ) ) {
class Easy_CF_Validator_Email extends Easy_CF_Validator {
public function get( $value='' ) {
return esc_attr( $value );
}
public function set( $value='' ) {
$value = esc_attr( trim( stripslashes( $value ) ) );
return $value;
}
public function validate( $value='' ) {
if ( empty( $value ) || is_email( $value ) )
return true;
else
return false;
}
}
}
if ( !class_exists( "Easy_CF_Field_Textarea" ) ) {
class Easy_CF_Field_Textarea extends Easy_CF_Field {
public function print_form() {
$class = ( empty( $this->_field_data['class'] ) ) ? $this->_field_data['id'] . '_class' : $this->_field_data['class'];
$input_class = ( empty( $this->_field_data['input_class'] ) ) ? $this->_field_data['id'] . '_input_class' : $this->_field_data['input_class'];
$id = ( empty( $this->_field_data['id'] ) ) ? $this->_field_data['id'] : $this->_field_data['id'];
$label = ( empty( $this->_field_data['label'] ) ) ? $this->_field_data['id'] : $this->_field_data['label'];
$value = $this->get();
$hint = ( empty( $this->_field_data['hint'] ) ) ? '' : '
' . $this->_field_data['hint'] . '
';
$label_format =
'
'
'.
'
'.
'%s'.
'
';
printf( $label_format, $class, $id, $label, $input_class, $id, $value, $hint );
}
}
}
$easy_cf = new Easy_CF($field_data);
Note
If you’re not using auto_init then meta boxes need to be added individually using
add_meta_box( $group_id, $group_title, array( &$easy_cf, ‘meta_box_cb’ ), $page, $group_context );
and the save methods need to be initialized after adding all meta boxes using
$easy_cf->add_save_method();
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Easy Custom Fields」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Post Meta Inspector 》這個外掛可以快速輕鬆地查看和顯示與任意文章相關聯的文章元數據。啟用後,該外掛會在文章元素區域內用方框顯示文章元數據的鍵和值。, 最初為WordPress.com V...。
Post Meta Data Manager 》厭倦了透過資料庫或編碼更改隱藏的文章或自訂文章資源的值?, 那麼你找對了 WordPress 外掛。, 需要一些幫助來查看您的文章資源或自訂欄位嗎?, 文章資源數據...。
Just Custom Fields 》Just Custom Fields(即自定義欄位)增加了在文章、頁面(與其他自定義文章類型)和分類中添加附加欄位的功能。安裝後,您將看到一個簡單的設置頁面,易於使...。
Ultimate Fields 》使用 Ultimate Fields 可以輕鬆在管理員中創建欄位。這些欄位可以在編輯帖子或頁面(任何帖子類型)或選項頁面(例如主題選項)中顯示。在管理員中的任何位置...。
Custom Metadata Manager 》這是一個方便的 WordPress 外掛程式,可讓你輕鬆地為你的對象類型(文章、頁面、自訂文章類型、使用者)添加自訂欄位,並且產生選項頁面。, 這個外掛的目的是...。
WP Ultimate Search 》這是一個高度可定制的 AJAX-based WordPress 搜尋欄,具有自動完成faceted 搜尋查詢的功能。使用者可以快速動態瀏覽您網站的分類和文章元數據,以找到他們想...。
WP-Admin Search Post Meta 》可在管理員頁面上搜尋文章的自訂欄位。。
Show Hidden Post Meta 》這個外掛讓所有自訂欄位(文章後設資料)在文章編輯頁面上的「自訂欄位」元框中可見。。
Post Meta Viewer 》這個外掛可以方便地查看某篇文章或頁面裡所有儲存在 post meta 中的資料以及每個 meta 所對應的值,對於測試、快速查閱資料或者純粹想知道文章或頁面儲存了哪...。
Cleanup Duplicate Meta 》有時您的數據庫可能充滿了您不需要的重複條目。Cleanup Duplicate Meta 可以讓您檢查文章元數據或用戶元數據表中的任何重複條目。如果您想要刪除它們,只需點...。
Metadata Viewer 》總結:Metadata Viewer 外掛可在WordPress文章和用戶編輯頁面底部顯示文章、頁面、自訂文章類型和用戶的Meta鍵和值,並具有即時搜索功能。一個外掛解決多個目...。
Post Meta Manager 》此外掛可建立一個版面,允許以批次方式變更或刪除資料庫中的 meta key。當您更換使用特定 meta key 的外掛或佈景主題,或是在整理舊網站上已不再使用的 meta ...。
Post Meta 》外掛首頁 | 使用說明 | 影片教學 | 示意圖, Post Meta 是一個 WordPress 的自訂文章欄位、文章類型和分類管理外掛。它具有用 AJAX 和 jQuery 開發的現代化介...。
Metabase – Post & User Meta Editor 》這個外掛可以顯示網站上的文章資訊(meta)和使用者資訊(meta)。自定義文章類型的文章資訊(meta)也可以查看。只有管理員可以查看這些資訊。, 文章資訊(meta), ...。
Default Post Content 》厭倦了每次撰寫文章都要輸入重複內容嗎?每次新增文章都要使用相同的自訂欄位嗎?讓 WordPress 外掛替你自動完成吧!, 文章內容, 快速且輕鬆地建立一組預設文...。