WIKI使用導(dǎo)航
站長(zhǎng)百科導(dǎo)航
站長(zhǎng)專題
- 網(wǎng)站推廣
- 網(wǎng)站程序
- 網(wǎng)站賺錢(qián)
- 虛擬主機(jī)
- cPanel
- 網(wǎng)址導(dǎo)航專題
- 云計(jì)算
- 微博營(yíng)銷(xiāo)
- 虛擬主機(jī)管理系統(tǒng)
- 開(kāi)放平臺(tái)
- WIKI程序與應(yīng)用
- 美國(guó)十大主機(jī)
編輯“WordPress:Creating Options Pages”
該編輯可以被撤銷(xiāo)。 請(qǐng)檢查下面的對(duì)比以核實(shí)您想要撤銷(xiāo)的內(nèi)容,然后發(fā)布下面的更改以完成撤銷(xiāo)。
最后版本 | 您的文本 | ||
第1行: | 第1行: | ||
== Introduction == | == Introduction == | ||
Creating custom options panels in WordPress is relatively easy. | Creating custom options panels in WordPress is relatively easy. | ||
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]]. | ||
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. | ||
== Form Tag == | == Form Tag == | ||
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: | ||
? <form method="post" action="options.php"> | ? <form method="post" action="options.php"> | ||
== nonce Magic == | == nonce Magic == | ||
第33行: | 第16行: | ||
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'); ?> | ||
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). | ||
== 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: | ||
? <p class="submit"> | ? <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> | ||
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. | ||
== Field Names == | == Field Names == | ||
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: | ||
? <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. | ||
== action Field == | == action Field == | ||
第86行: | 第39行: | ||
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" /> | ||
== 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. | ||
? <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 == | ||
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. | ||
? <p class="submit"> | ? <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> |