我即将为我的WordPress主题创建自己的选项页面,我有点困惑。
我见过很多使用数组生成选项页的主题,看起来是这样的:
$options = array (
array( "name" => "Welcome Message",
"type" => "title"),
array( "type" => "open"),
array( "name" => "Title",
"desc" => "Enter a title to display for your welcome message.",
"id" => $shortname."_welcome_title",
"std" => "",
"type" => "text"),
);
再加上一些生成前端、表、表单等的其他函数。
另一方面,Codex(http://codex.wordpress.org/Creating_Options_Pages ).
它们看起来像:
<form method="post" action="options.php">
<?php settings_fields( \'baw-settings-group\' ); ?>
<?php do_settings( \'baw-settings-group\' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">New Option Name</th>
<td><input type="text" name="new_option_name" value="<?php echo get_option(\'new_option_name\'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Some Other Option</th>
<td><input type="text" name="some_other_option" value="<?php echo get_option(\'some_other_option\'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Options, Etc.</th>
<td><input type="text" name="option_etc" value="<?php echo get_option(\'option_etc\'); ?>" /></td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e(\'Save Changes\') ?>" />
</p>
</form>
什么是优点和缺点;这些方法的缺点以及我应该使用/首选哪种方法?