前言介紹
- 這款 WordPress 外掛「WordPress Registry」是 2012-02-24 上架。
- 目前有 10 個安裝啟用數。
- 上一次更新是 2012-09-12,距離現在已有 4617 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 1.5 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
rbncha |
外掛標籤
$_GET | $_POST | Scope | globals | registry |
內容簡介
這個外掛建立的主要原因是因為 WordPress 沒有現成的中央註冊系統,可以儲存像是變數值、物件、陣列等等,可以在全域空間中取用。這個外掛基本上嘗試減少變數等等的重複宣告。它與 Magento 註冊表 "Mage_Registry" 相似,但是是輕量版。
這個外掛也可作為 GET 和 POST 請求參數處理器。好處是,您不需要檢查 isset($_GET['myparam']) 或 isset($_POST['myparam'])。如果參數未設置,它將在第二個參數設定預設值。預設值是 false。
輕鬆處理 Session 資料。使用動態方法輕鬆儲存、檢查存在性、取得和取消它。
希望這能對您有所幫助。
使用非常容易、整潔和直接:
即時註冊動態方法:
`registry()->setDynamicMethodName('this is my value');`
`registry()->setMyName('My Name is Rubin Shrestha');`
驗證方法是否存在並 echo:
`if(registry()->hasDynamicMethodName()) echo 'Has ' . registry()->getDynamicMethodName();`
取消動態方法:
`registry()->unsDynamicMethodName();`
之後,如果回應 registry()->getDynamicMethodName(),它將返回 null。
對於 GET 和 POST 請求處理器,使用以下方式:
對於 $_GET,只需呼叫 registry()->request()->getParam('param_key', [預設值,如果沒有則保持為空,將返回 false]);`
要檢查頁面類型是否為 $_POST 使用 if(registry()->request()->isPost()) { // 在這裡做你的事 }
對於 $_POST,只需呼叫 `registry()->request()->getPost('param_key', [預設值,如果沒有則保持為空,將返回 false]);
您也可以執行 registry()->request()->getParams() 和 registry()->request()->getPosts();
您也可以添加 request 物件範圍變數,`registry()->request()->setVariableName('this is my value');。以 registry()->request()->getVariableName() 取得值。
Session 處理:
像這樣輕鬆處理 session 中的資料 `registry()->session()->setDynamicMethodName('this is my value')`,並且透過 `registry()->session()->getDynamicMethodName()` 檢索它。取消 `registry()->session()->unsDynamicMethodName()`。
原文外掛簡介
The main reason for building this plugin is because wordpress doesn’t readily have a central registry system where things can be stored such as variable values, objects, arrays. Which can be retrieved from a global space. This plugin basically tries to lessen the repeating declarations of variables and etc. It is something quite similar to Magento registry “Mage_Registry”, but very light version.
This plugin can also be used as GET and POST request parameters handler. The benefit is, you don’t have to check isset($_GET[‘myparam’]) or isset($_POST[‘myparam’]). If the param is not set, it will return a default value you supplied in second param. By default, the default value is false.
Handle the session data as easy as never before. Save to session, check existance, get, unset it easily using dynamic methods.
Hope this could be of some use.
Usage is very easy, neat and straight forward:
Register a dynamic method on the fly:
registry()->setDynamicMethodName(‘this is my value’);
registry()->setMyName(‘My Name is Rubin Shrestha’);
Validate existance of your method and echo:
if( registry()->hasDynamicMethodName() ) echo ‘Has ‘ . registry()->getDynamicMethodName();
Unset the dynamic method:
registry()->unsDynamicMethodName(); after this, if you echo registry()->getDynamicMethodName() it will return null;
For GET and POST request handler use it like this:
For $_GET, you can simply call registry()->request()->getParam(‘param_key’, [default value if any, else blank, will return false]);
To check if the page type is $_POST use if( registry()->request()->isPost() ) { //do your stuffs here }
For $_POST, you can simply call registry()->request()->getPost(‘param_key’, [default value if any, else blank; will return false]);
You can also do registry()->request()->getParams() and registry()->request()->getPosts();
You can also add request object scope variable, registry()->request()->setVariableName(‘this is my value’);. Get the value by registry()->request()->getVariableName();
Session handler:
Handle the data in session as easy as registry()->session()->setDynamicMethodName(‘this is my value’); and get it as registry()->session()->getDynamicMethodName(); Unset it registry()->session()->unsDynamicMethodName();
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「WordPress Registry」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Brazilian Fields in WordPress Registry 》此外掛會在 Woocommerce 的使用者註冊表單中加入像是身分證字號、統一編號、電話、州級登記等欄位,並在 billing_{欄位名稱} 儲存,可與 Brazillian Market ...。
wpCLink 》wpCLink外掛是一個分散式系統的客戶端組件,首次整合了權利數據、具有元數據的持久標識符、點對點內容許可和傳送功能到內容管理系統中。該外掛僅供個人使用,...。
Wedding Gifts 》在這個簡化版本中,使用者需要使用資料庫存取權限,才能夠新增或編輯禮物。 。
WP_Registry 》此外掛提供一個全域可用的容器,用來儲存任何類型的值。Registry 為單例模式,您可以這樣在 Registry 內設定值:, WP_Registry::set( 'key', $value ) , 然後...。