[WordPress] 外掛分享: Smart Custom Fields

首頁外掛目錄 › Smart Custom Fields
WordPress 外掛 Smart Custom Fields 的封面圖片
50,000+
安裝啟用
★★★★
4.9/5 分(20 則評價)
剛更新
最後更新
問題解決
WordPress 6.4+ PHP 7.4+ v5.0.7 上架:2014-10-08

內容簡介

Smart Custom Fields 是一個管理自訂欄位的簡單外掛。

功能

支援自訂欄位群組迴圈。
支援元資料修訂。
支援元資料預覽。

欄位類型

文字
文字區域
單選
下拉式選單
核取方塊
所見即所得編輯器
圖片
檔案
相關文章
相關標籤
顏色選擇器
日期選擇器
日期時間選擇器
布林值
訊息

如何取得元資料?

文章元資料

此方法可取得任何元資料。

SCF::get( '欄位名稱' )

此方法可取得任何群組的元資料。

SCF::get( '群組名稱' )

此方法可取得所有元資料。

SCF::gets()

使用者元資料

此方法可取得任何使用者元資料。

SCF::get_user_meta( $user_id, '欄位名稱' )

此方法可取得任何群組的使用者元資料。

SCF::get_user_meta( $user_id, '群組名稱' )

此方法可取得所有使用者元資料。

SCF::get_user_meta( $user_id )

分類法元資料

此方法可取得任何分類法元資料。

SCF::get_term_meta( $term_id, $taxonomy '欄位名稱' )

此方法可取得任何群組的分類法元資料。

SCF::get_term_meta( $term_id, $taxonomy, '群組名稱' )

此方法可取得所有分類法元資料。

SCF::get_term_meta( $term_id, $taxonomy )

自訂選項頁面元資料

此方法可取得任何自訂選項頁面元資料。

SCF::get_option_meta( $menu_slug, '欄位名稱' )

此方法可取得任何群組的自訂選項頁面元資料。

SCF::get_option_meta( $menu_slug, '群組名稱' )

此方法可取得所有自訂選項頁面元資料。

SCF::get_option_meta( $menu_slug )

建立自訂選項頁面
SCF::add_options_page( $頁面標題, $選單標題, $能力, $選單別名, $圖示網址 = '', $位置 = null );

以程式碼註冊自訂欄位。

.gist table { margin-bottom: 0; }

此文件包含雙向 Unicode 文字,可能與下方顯示的內容不同解釋或編譯。若要檢查,請在顯示隱藏 Unicode 字元的編輯器中開啟該文件。
了解有關雙向 Unicode 字元的更多資訊

顯示隱藏字元

<?php

/**

* 定義自訂欄位

*

* @param array $設定 Smart_Custom_Fields_Setting 物件陣列

* @param string $類型 文章類型或角色

* @param int $id 文章 ID 或使用者 ID

* @param string $meta_typedata[revealButtonData] = ""; 元資料型別

*/
add_action( 'init', function() {
    $settings = array();
    // 在此定義自訂欄位
    SCF::add_meta_box( '自訂欄位標題', '投稿類型', $settings, 'normal', 'high' );
} );

外掛標籤

開發者團隊

⬇ 下載最新版 (v5.0.7) 或搜尋安裝

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

原文外掛簡介

Smart Custom Fields is a simple plugin for managing custom fields.
Features

Field group loop support.
Meta data revision support.
Meta data preview support.

Field Types

Text
Textarea
Radio
Select
Checkbox
WYSIWYG editor
Image
File
Related Posts
Related Terms
Color picker
Date picker
Datetime picker
Boolean
Message

How to get meta data ?
**The return value of each of the following methods is not sanitized. Please sanitize them if necessary. **

Escaping Data


Post meta data
This method can get any meta data.
SCF::get( 'field-name' )

This method can get meta data of any group.
SCF::get( 'group-name' )

This method can get all meta data.
SCF::gets()

User meta data
This method can get any user meta data.
SCF::get_user_meta( $user_id, 'field-name' )

This method can get user meta data of any group.
SCF::get_user_meta( $user_id, 'group-name' )

This method can get all user meta data.
SCF::get_user_meta( $user_id )

Term meta data
This method can get any term meta data.
SCF::get_term_meta( $term_id, $taxonomy 'field-name' )

This method can get term meta data of any group.
SCF::get_term_meta( $term_id, $taxonomy, 'group-name' )

This method can get all term meta data.
SCF::get_term_meta( $term_id, $taxonomy )

Custom options page meta data
This method can get any custom options page meta data.
SCF::get_option_meta( $menu_slug, 'field-name' )

This method can get custom options page meta data of any group.
SCF::get_option_meta( $menu_slug, 'group-name' )

This method can get all custom options page meta data.
SCF::get_option_meta( $menu_slug )

Create custom options page
SCF::add_options_page( $page_title, $menu_title, $capability, $menu_slug, $icon_url = '', $position = null );

Register custom fields by the code.
.gist table { margin-bottom: 0; }

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters

Show hidden characters

add_group( 'ユニークなID', 繰り返し可能か, カスタムフィールドの配列 );

$Setting->add_group( 'group-name-1', false, array(

array(

'name' => 'field-1',

'label' => 'テストフィールド',

'type' => 'text',

),

array(

'name' => 'field-2',

'label' => 'テストフィール2',

'type' => 'text',

'default' => 2,

),

) );

$settings[] = $Setting;

return $settings;

}

add_filter( 'smart-cf-register-fields', 'my_register_fields', 10, 4 );

view raw

gistfile1.php

hosted with ❤ by GitHub

GitHub
https://github.com/inc2734/smart-custom-fields/
Translators

Japanese(ja) – JOTAKI Taisuke

You can translate this plugin into your language by using GlotPress.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon