久久精品水蜜桃av综合天堂,久久精品丝袜高跟鞋,精品国产肉丝袜久久,国产一区二区三区色噜噜,黑人video粗暴亚裔

WordPress: Creating Options Pages:修訂間差異

來自站長百科
跳轉(zhuǎn)至: 導(dǎo)航、? 搜索
(新頁面: == Introduction == Creating custom options panels in WordPress is relatively easy. Firstly, to create the menu item and the new page, see WordPress:Adding Administration Menus. So ...)
?
無編輯摘要
?
第1行: 第1行:
== Introduction ==
== Introduction ==
== 介紹 ==


Creating custom options panels in WordPress is relatively easy.
Creating custom options panels in WordPress is relatively easy.
在WordPress中創(chuàng)建自定義選項面板,較為簡單。


Firstly, to create the menu item and the new page, see [[WordPress:Adding Administration Menus]].
Firstly, to create the menu item and the new page, see [[WordPress:Adding Administration Menus]].
首先,請看看[[WordPress:Adding Administration Menus|添加管理菜單]],創(chuàng)建菜單內(nèi)容和新的頁面。


So long as you stick to this structure, WordPress will handle all of the option creation, update, saving, and redirection for you. It will check permissions, and do all that other magic behind the scenes.
So long as you stick to this structure, WordPress will handle all of the option creation, update, saving, and redirection for you. It will check permissions, and do all that other magic behind the scenes.
只要你遵循這個結(jié)構(gòu),WordPress會處理所有的選項創(chuàng)建,更新,保存和更改的內(nèi)容。WordPress會檢查權(quán)限,并且在幕后操作進行許多其它神奇的操作。


== Form Tag ==
== Form Tag ==
== 表格標(biāo)簽 ==


Once you have your page, you need to create an HTML form. Use this code:
Once you have your page, you need to create an HTML form. Use this code:
創(chuàng)建了網(wǎng)頁后,你就需要創(chuàng)建HTML表格。使用這個代碼:
? <form method="post" action="options.php">
? <form method="post" action="options.php">
<form method="post" action="options.php">
== nonce Magic ==


== nonce Magic ==
== nonce Magic ==
第16行: 第33行:
Then after the opening form tag, insert this PHP code:
Then after the opening form tag, insert this PHP code:
? <?php wp_nonce_field('update-options'); ?>
? <?php wp_nonce_field('update-options'); ?>
打開表格標(biāo)簽后,插入這個PHP代碼:
<?php wp_nonce_field('update-options'); ?>


This will insert two hidden fields which automatically help to check that the user can update options and also redirect the user back to the correct admin page (because the form action is a different page).
This will insert two hidden fields which automatically help to check that the user can update options and also redirect the user back to the correct admin page (because the form action is a different page).
這樣會插入兩個隱藏的欄,可以自動地幫助核對,用戶可以更新選項,也可以使用戶返回到當(dāng)前的管理頁面(因為form action是個不同的頁面)。


== Update Options Button ==
== Update Options Button ==
== 更新選項按鈕 ==


At this point you may choose to insert the standard Update Options button, the HTML for which is:
At this point you may choose to insert the standard Update Options button, the HTML for which is:
這時,你可以選擇插入標(biāo)準(zhǔn)的更新選項按鈕,HTML是:
? &lt;p class="submit">
? &lt;p class="submit">
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /&gt;
</p>
&lt;p class="submit">
? <input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /&gt;
? <input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /&gt;
? </p>
? </p>


Note the use of the _e() function to handle translation of the text, see [[WordPress:Localizing WordPress]] for more info.
Note the use of the _e() function to handle translation of the text, see [[WordPress:Localizing WordPress]] for more info.
注意使用the _e() function處理文本翻譯,更多的信息,請看看[[WordPress:Localizing WordPress|WordPress本地化]]。


== Field Names ==
== Field Names ==
== Field 名稱 ==


Use fields with the same names that you want your newly created options (stored in the options table) to be called, for example:
Use fields with the same names that you want your newly created options (stored in the options table) to be called, for example:
使用欄的名稱,與你希望最新創(chuàng)建的選項(儲存在選項表格中)得到調(diào)用的名稱相同,例如:
? <input type="text" name="new_option_name" value="<?php echo get_option('new_option_name'); ?>" />
? <input type="text" name="new_option_name" value="<?php echo get_option('new_option_name'); ?>" />
<input type="text" name="new_option_name" value="<?php echo get_option('new_option_name'); ?>" />


Note that by using the get_option() function as the value for the field, this will automatically be updated when the options are saved.
Note that by using the get_option() function as the value for the field, this will automatically be updated when the options are saved.
注意通過使用get_option()函數(shù)作為欄的參數(shù)值,選項保存的時候,這會自動更新。
== action Field ==


== action Field ==
== action Field ==
第39行: 第86行:
Next, create a hidden field called action containing the value update.
Next, create a hidden field called action containing the value update.
? <input type="hidden" name="action" value="update" />
? <input type="hidden" name="action" value="update" />
其次,創(chuàng)建創(chuàng)建隱藏的欄called action,包含更新的參數(shù)值。
<input type="hidden" name="action" value="update" />
== page_options Field ==


== page_options Field ==
== page_options Field ==


Finally, create a hidden field called page_options containing a comma separated list of all the options in the page that should be written on save.
Finally, create a hidden field called page_options containing a comma separated list of all the options in the page that should be written on save.
最后,創(chuàng)建包含用逗號分開的網(wǎng)頁中所有選項的列表,稱為page_options,隱藏的field,編寫這些網(wǎng)頁時,應(yīng)該保存。
? <input type="hidden" name="page_options" value="new_option_name,some_other_option,option_etc" />
? <input type="hidden" name="page_options" value="new_option_name,some_other_option,option_etc" />
<input type="hidden" name="page_options" value="new_option_name,some_other_option,option_etc" />


== Closing Tags ==
== Closing Tags ==
== 關(guān)閉標(biāo)簽==


Then obviously close the form tag after your other options, and if you like, include another "Update Options" button, this is the WordPress default.
Then obviously close the form tag after your other options, and if you like, include another "Update Options" button, this is the WordPress default.
接著,很明顯,在你的其它選項之后,關(guān)閉表格標(biāo)簽,如果你愿意,可以加上另一個"更新選項"按鈕,這個按鈕是WordPress默認(rèn)帶有的。
? &lt;p class="submit">
? &lt;p class="submit">
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
</p>
</form>
&lt;p class="submit">
? <input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
? <input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
? </p>
? </p>
? </form>
? </form>

2008年9月3日 (三) 09:28的最新版本

Introduction[ ]

介紹[ ]

Creating custom options panels in WordPress is relatively easy.

在WordPress中創(chuàng)建自定義選項面板,較為簡單。

Firstly, to create the menu item and the new page, see WordPress:Adding Administration Menus.

首先,請看看添加管理菜單,創(chuàng)建菜單內(nèi)容和新的頁面。

So long as you stick to this structure, WordPress will handle all of the option creation, update, saving, and redirection for you. It will check permissions, and do all that other magic behind the scenes.

只要你遵循這個結(jié)構(gòu),WordPress會處理所有的選項創(chuàng)建,更新,保存和更改的內(nèi)容。WordPress會檢查權(quán)限,并且在幕后操作進行許多其它神奇的操作。

Form Tag[ ]

表格標(biāo)簽[ ]

Once you have your page, you need to create an HTML form. Use this code:

創(chuàng)建了網(wǎng)頁后,你就需要創(chuàng)建HTML表格。使用這個代碼:

<form method="post" action="options.php">

<form method="post" action="options.php">

nonce Magic[ ]

nonce Magic[ ]

Then after the opening form tag, insert this PHP code:

<?php wp_nonce_field('update-options'); ?>

打開表格標(biāo)簽后,插入這個PHP代碼:

<?php wp_nonce_field('update-options'); ?>

This will insert two hidden fields which automatically help to check that the user can update options and also redirect the user back to the correct admin page (because the form action is a different page).

這樣會插入兩個隱藏的欄,可以自動地幫助核對,用戶可以更新選項,也可以使用戶返回到當(dāng)前的管理頁面(因為form action是個不同的頁面)。

Update Options Button[ ]

更新選項按鈕[ ]

At this point you may choose to insert the standard Update Options button, the HTML for which is:

這時,你可以選擇插入標(biāo)準(zhǔn)的更新選項按鈕,HTML是:

<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />


<p class="submit">

<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />

Note the use of the _e() function to handle translation of the text, see WordPress:Localizing WordPress for more info.

注意使用the _e() function處理文本翻譯,更多的信息,請看看WordPress本地化。

Field Names[ ]

Field 名稱[ ]

Use fields with the same names that you want your newly created options (stored in the options table) to be called, for example:

使用欄的名稱,與你希望最新創(chuàng)建的選項(儲存在選項表格中)得到調(diào)用的名稱相同,例如:

<input type="text" name="new_option_name" value="<?php echo get_option('new_option_name'); ?>" />


<input type="text" name="new_option_name" value="<?php echo get_option('new_option_name'); ?>" />

Note that by using the get_option() function as the value for the field, this will automatically be updated when the options are saved.

注意通過使用get_option()函數(shù)作為欄的參數(shù)值,選項保存的時候,這會自動更新。

action Field[ ]

action Field[ ]

Next, create a hidden field called action containing the value update.

<input type="hidden" name="action" value="update" />

其次,創(chuàng)建創(chuàng)建隱藏的欄called action,包含更新的參數(shù)值。 <input type="hidden" name="action" value="update" />

page_options Field[ ]

page_options Field[ ]

Finally, create a hidden field called page_options containing a comma separated list of all the options in the page that should be written on save.

最后,創(chuàng)建包含用逗號分開的網(wǎng)頁中所有選項的列表,稱為page_options,隱藏的field,編寫這些網(wǎng)頁時,應(yīng)該保存。

<input type="hidden" name="page_options" value="new_option_name,some_other_option,option_etc" />

<input type="hidden" name="page_options" value="new_option_name,some_other_option,option_etc" />

Closing Tags[ ]

關(guān)閉標(biāo)簽[ ]

Then obviously close the form tag after your other options, and if you like, include another "Update Options" button, this is the WordPress default.

接著,很明顯,在你的其它選項之后,關(guān)閉表格標(biāo)簽,如果你愿意,可以加上另一個"更新選項"按鈕,這個按鈕是WordPress默認(rèn)帶有的。

<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />

</form>


<p class="submit">

<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />

</form>