I am writing my first plugin and to access/save options I follow codex.wordpress.org/Creating_Options_Pages I basically copied the example from ‘See It All Together’ in a separate file mhomepage_admin_menu.php
The main code of the plugin goes like
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 );
}
and the beginning of mhomepage_admin_menu.php
looks like
<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">
I have to questions
- Q1: how to fix the error?
- Q2: what is the correct file name in
<form method="post" action="options.php">
? Is thatmhomepage_admin_menu.php
?