我试图学习wordpress插件开发的一些基础知识,我偶然发现了两种类型的设置。
1个
add_settings_field(
\'custom_title\',
esc_html__(\'Custom Title\', \'myplugin\'),
\'myplugin_callback_field_text\',
\'myplugin\',
\'myplugin_section_login\',
[ \'id\' => \'custom_title\', \'label\' => esc_html__(\'Custom title attribute for the logo link\', \'myplugin\') ]
);
add_settings_field(
\'custom_style\',
esc_html__(\'Custom Style\', \'myplugin\'),
\'myplugin_callback_field_radio\',
\'myplugin\',
\'myplugin_section_login\',
[ \'id\' => \'custom_style\', \'label\' => esc_html__(\'Custom CSS for the Login screen\', \'myplugin\') ]
);
add_settings_field(
\'custom_message\',
esc_html__(\'Custom Message\', \'myplugin\'),
\'myplugin_callback_field_textarea\',
\'myplugin\',
\'myplugin_section_login\',
[ \'id\' => \'custom_message\', \'label\' => esc_html__(\'Custom text and/or markup\', \'myplugin\') ]
);
add_settings_field(
\'custom_footer\',
esc_html__(\'Custom Footer\', \'myplugin\'),
\'myplugin_callback_field_text\',
\'myplugin\',
\'myplugin_section_admin\',
[ \'id\' => \'custom_footer\', \'label\' => esc_html__(\'Custom footer text\', \'myplugin\') ]
);
add_settings_field(
\'custom_toolbar\',
esc_html__(\'Custom Toolbar\', \'myplugin\'),
\'myplugin_callback_field_checkbox\',
\'myplugin\',
\'myplugin_section_admin\',
[ \'id\' => \'custom_toolbar\', \'label\' => esc_html__(\'Remove new post and comment links from the Toolbar\', \'myplugin\') ]
);
在其他插件中,我发现它是这样的:
function paytm_settings_list(){
$settings = array(
array(
\'display\' => \'Merchant ID\',
\'name\' => \'paytm_merchant_id\',
\'value\' => \'\',
\'type\' => \'textbox\',
\'hint\' => \'Merchant ID\'
),
array(
\'display\' => \'Merchant Key\',
\'name\' => \'paytm_merchant_key\',
\'value\' => \'\',
\'type\' => \'textbox\',
\'hint\' => \'Merchant key\'
),
array(
\'display\' => \'Website\',
\'name\' => \'paytm_website\',
\'value\' => \'\',
\'type\' => \'textbox\',
\'hint\' => \'Website\'
),
array(
\'display\' => \'Industry Type ID\',
\'name\' => \'paytm_industry_type_id\',
\'value\' => \'\',
\'type\' => \'textbox\',
\'hint\' => \'Industry Type ID\'
),
array(
\'display\' => \'Channel ID\',
\'name\' => \'paytm_channel_id\',
\'value\' => \'\',
\'type\' => \'textbox\',
\'hint\' => \'Channel ID e.g. WEB/WAP\'
),
array(
\'display\' => \'Mode\',
\'name\' => \'paytm_mode\',
\'value\' => \'TEST\',
\'values\' => array(\'TEST\'=>\'TEST\',\'LIVE\'=>\'LIVE\'),
\'type\' => \'select\',
\'hint\' => \'Change the mode of the payments\'
),
我有点困惑,哪种方法是正确的?或者如果上面的任何一个都过时了?
我是新来的,请容忍我。ThanksRicha sharma公司