我正在编写我的第一个插件,要访问/保存我遵循的选项codex.wordpress.org/Creating_Options_Pages 我基本上是在一个单独的文件中复制了“一起看”的示例mhomepage_admin_menu.php
插件的主代码如下
if ( is_admin() ){ // admin actions
add_action(\'admin_menu\', \'add_plugin_admin_page\' );
add_action(\'admin_init\', \'register_mhomepage_settings\' );
} else {
// non-admin enqueues, actions, and filters
}
function register_mhomepage_settings() { // whitelist options
register_setting( \'mhomepage_option_group\', \'left_right_margin_option\' );
register_setting( \'mhomepage_option_group\', \'top_margin_option\' );
register_setting( \'mhomepage_option_group\', \'include_comments_option\' );
}
function add_plugin_admin_page($plugin_name) {
add_menu_page( \'mHomePage\', \'mHomePage\', \'manage_options\', \'mhomepage/mhomepage_admin_menu.php\', \'\', \'\', 6 );
}
以及
mhomepage_admin_menu.php
看起来像
<div class="wrap">
<h2>Your Plugin Name</h2>
<form method="post" action="options.php">
<?php settings_fields( \'mhomepage_option_group\' ); ?>
<?php do_settings( \'mhomepage_option_group\' ); ?>
<table class="form-table">
我有很多问题
Q1:如何修复错误问题2:中的正确文件名是什么<form method="post" action="options.php">
? 是吗mhomepage_admin_menu.php
?