前言介紹
- 這款 WordPress 外掛「Template Dictionary」是 2017-08-14 上架。
- 目前有 10 個安裝啟用數。
- 上一次更新是 2020-11-16,距離現在已有 1630 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.5 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
radovank |
外掛標籤
options | settings | template | variables | dictionary |
內容簡介
Template Dictionary 是一個外掛,可用於創建由管理員編輯的模板變數。
這個外掛支援多語言,包含 Polylang 整合,也可以透過過濾器整合其他多語言外掛。
管理員頁面
這個外掛有幾個管理員頁面。
模板字典 - 查看、編輯和刪除模板變數值
設定清單 - 查看、編輯和刪除模板變數設定
新增設定 - 新增或編輯模板變數設定
編輯值 - 編輯值,可以從模板字典頁面訪問
匯出/匯入 - 將設定和值匯出為 XML 或從 XML 匯入
在模板中使用
可以透過呼叫 Template Dictionary 物件的 function get 在模板中使用值,而此物件可以透過 function TmplDict() 存取。
例如,若您將設定代碼設為 the_code,可透過以下方式使用此值:
TmplDict()->get( 'the_code' );
此 function 會傳回值。如需 echo 此值,可以使用 function eget。兩個 function 都有可選參數 $default,若管理員值為空,則回傳 / echo 的預設值為此參數的值。
您也可以直接透過代碼作為屬性存取值:
$value = TmplDict()->the_code;
使用 shortcode
可以使用帶有屬性code、default 和do_shortcode的 shortcode [tmpl_dict]。最後一個屬性指示是否在值上呼叫 function do_shortcode。
設定模板語言
可以透過在 wp-config 中設定常數 TMPL_DICT_DEFAULT_LANG 來設置預設的模板語言。此常數的預設值為當前 WP 地區的前兩個字母。如果您想在未來創建多語言網站,請適當地設置預設語言常數。
如果您有多語言網站,則需要使用過濾器 template_dictionary_language 設置當前模板語言。對於 Polylang 的使用者,此外掛已經包含整合,當前模板語言即為 Polylang 當前語言別名。
設定可用語言
如果您有多語言網站,還需要使用過濾器 template_dictionary_languages 設定可用語言。再次提醒,如果啟用了 Polylang,這些可用語言包含 Polylang 語言別名。
如果您的網站是單語言的,只有一種可用語言,即預設語言。
使用 JS 物件
可以定義 TMPL_DICT_JS_VAR_NAME 常數以生成 JavaScript 字典物件。在 wp_config.php 中新增此常數:
define( 'TMPL_DICT_JS_VAR_NAME', 'dict' );
然後可以在 JS 中使用它:
$('#some-element').text( dict.the_code );
原文外掛簡介
Template Dictionary is a plugin which can be used to create template variables editable by admins.
The plugin is multilingual ready. It includes Polylang integration, another multilingual plugin can be integrated with filters.
Admin pages
There are few admin pages for managing the plugin.
Template Dictionary – view, edit and delete the template variables values
Settings list – view, edit and delete template variables settings
Add setting – add new or edit template variables setting
Edit values – edit a value, this page is accessable from the page Template Dictionary
Export/Import – export settings and values to xml or import it from xml
Usage in template
You can use a value in template by calling function get of Template Dictionary object, which can be accessed by function TmplDict().
For example, if you set a setting with code the_code, you can use it’s value by:
TmplDict()->get( 'the_code' );
This function returns the value. If you need to echo the value, you can use function eget. Both functions have an optional argument $default, which is the default returned/echoed value, if the admin value is empty.
You can also get the value by accessing the code as property:
$value = TmplDict()->the_code;
Usage with shortcode
You can also use a shortcode [tmpl_dict] with attributes code, default and do_shortcode. The last attribute says, if the function do_shortcode will be called on the value.
Setup template language
Default template language can be set by setting the constant TMPL_DICT_DEFAULT_LANG in wp-config. Default value of this constant consists of two first characters of the current WP locale. It is important to set the default language constant properly if you plan to create your site multilingual in future.
If you have a multilingual site, you need to set current template language with the filter template_dictionary_language. For users of Polylang, it is already integrated in this plugin, the current template language is the Polylang current language slug.
Setup available languages
If you have a multilingual site, you also need to set available languages with the filter template_dictionary_languages. Again, if Polylang is activated, these available languages consist of Polylang languages slugs.
If your site is not multilingual, there is only one available language – the default language.
Use JS object
To generate JavaScript dictionary object, you need to define TMPL_DICT_JS_VAR_NAME constant. Add to wp_config.php:
define( 'TMPL_DICT_JS_VAR_NAME', 'dict' );
Then you can use it in JS:
$('#some-element').text( dict.the_code );
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Template Dictionary」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
1.0 | 1.3 | 1.4 | 1.5 | 1.6 | 1.01 | 1.02 | 1.6.1 | trunk |
延伸相關外掛(你可能也想知道)
Custom Global Variables 》使用此 WordPress 外掛可以建立自己的自訂變數,管理網站上的資訊,例如:, , 電話號碼, 地址, 社交媒體連結, HTML 片段, 以及其他任何資訊, , 可以輕鬆地在 ...。
Just Variables 》這個外掛讓你可以創建單/多行的簡單文本變數,並在主題模板中使用它們。, 一旦你添加了至少一個變數,就會在外觀菜單下出現一個名為「主題變數(Theme Variab...。
Sip Advanced Email Notification For WC Free 》有了進階條件篩選功能,您終於可以依據更精確的標準,向特定的客戶發送郵件,永遠不必再手動寄發郵件!, 建立郵件輕而易舉。從 WordPress 選單中,前往 SIP P...。
bidorbuy Store Integrator 》您正在尋找適合電子商務業務的新地方嗎?, 使用免費的 bidorbuy 商店整合器開始在線銷售。讓您的產品展示給 bidorbuy 觀眾——南非其中一個最大的網上購物人群...。
Global Content by BusinessBox 》Global Content by BusinessBox 可讓您在一處定義網站各處均會使用的內容。, 因此,它可避免多次撰寫一些難以維護的文本。, 每個全域變數中可以放置純文本以...。
Mindvalley Post & Get Variables 》使用短碼來輸出 $_POST 或者 $_GET 變數值。, 在追蹤電子商務感謝頁面上的腳本方面非常有用。, 舉例來說:, , $_POST['email'] > [post_var name=”e...。
ACTUS Xfields 》新增網站上的自訂資料。, , 為您的網頁和文章創建自訂欄位,或者為您的網站設置全局選項。, ACTUS Xfields 可幫助您創建任何類型的欄位集並將它們指定給頁面...。
Snippets SE 》Snippets SE 是一款 WordPress 外掛,允許您創建變數,這些變數在您的網站上會呈現不同的文字。您可以使用 "{{phone}}" 來顯示公司的電話號碼,僅需在 1 個地...。
Shortcode Datastore 》這是一個 WordPress 外掛,可讓您靈活地將文字或 HTML 綁定到短代碼,然後將其插入到頁面、文章或範本中。這樣可以將相同的文字/HTML 插入到多個位置,然後從...。
Mountee 》使用您喜愛的工具, 每個人都有自己喜歡的 Mac 應用程式,那為什麼要被限制在 WordPress 瀏覽器視窗內創建模板呢?Mountee 讓您可以將模板作為 Finder 檔案進...。