我有一个主题,我正在开发一个HTML模板。我还设计了一个选项页面,以及主题本身内置的大量插件。我选择了一个选项卡式界面,并试图学习如何使用WordPress的设置API。
我正在为主题的函数使用类结构。以下是注册设置等的声明。
public function __admin_init()
{
register_setting( \'cncfps_twitter\', \'cncfps_twitter_options\', array( &$this, \'wp_cncfps_twitter\' ) );
add_settings_section( \'cncfps_twitter\', \'Twitter\', array( &$this, \'wp_cncfps_twitter\' ), \'cncfps\' );
add_settings_field( \'cncfps_twitter_consumer_key\', \'Consumer Key\', array( &$this, \'twitter_consumer_key\' ), \'cncfps\', \'cncfps_twitter\' );
add_settings_field( \'cncfps_twitter_consumer_secret\', \'Consumer Secret\', array( &$this, \'twitter_consumer_secret\' ), \'cncfps\', \'cncfps_twitter\' );
add_settings_field( \'cncfps_twitter_apikey\', \'API Key\', array( &$this, \'twitter_apikey\' ), \'cncfps\', \'cncfps_twitter\' );
}
public function wp_cncfps_twitter()
{
// TODO: wut. ?!?!
echo "what is this?";
}
public function twitter_consumer_key()
{
echo "Hello";
}
public function twitter_consumer_secret()
{
echo "World";
}
When I want to display the fields as shown here, I don\'t see a thing. The following is how I attempt to display them. I did follow a few tutorials but it\'s just not clicking in my brain for some reason.
settings_fields(\'cncfps_twitter\');
do_settings_sections(\'cncfps_twitter\');