Error: options page not found when I try to save the changes made in my settings page
I'm developing a plugin... everything was fine but suddenly when I try to save the plugin settings... I found with the error that says the page options not found..
I was looking for some answer but not one fix my error... Following some code that makes the settings page and save the options in the database:
admin.php
?php
/**
*
* This file contains the necesary functions to display the admin area of the plugin
*
* @author Ezequiel Cattaneo [email protected]
*
* @link https://webstower.com.ar/wtdomcheck
* @since 1.0.0
*
**/
require_once WTDOMCHECK_PLUGIN_DIR.'admin/class/class-admin.php';
$wtdomadmin = '';
//All the magic is done here!
if ( class_exists('admin') ) {
$wtdomadmin = new admin();
$wtdomadmin-WTRegister();
}
?
class_admin.php
function __construct()
{
//Instantiate the API that will construct our admin pages
$this-settings = new ApiWpadmin();
//Array of pages to create
$this-pages = [
[
'page_title' = 'My plugin settings page',
'menu_title' = 'Settings page',
'capability' = 'manage_options',
'menu_slug' = 'wtdomaincheck',
'callback' = array($this, 'WTLoadSettingTemplate'),
'icon_url' = 'dashicons-admin-generic',
'position' = 117
]
];
//Register the settings in the database
add_action('admin_init', array($this, 'WTSaveSettings'));
}
//
// PARAM
// Register all the actions filters for wp-admin
//
public function WTRegister()
{
$this-settings-
WTAddPages( $this-pages ) -
WTWithSubPage( 'Dashboard' ) -
WTAddSubPages( $this-subpages ) -
WTRegister();
}
//
// PARAM
// Register the settings values in the database
//
public function WTSaveSettings()
{
$wt_options = array (
'display-on-free' = $_POST['display-on-free'],
'display-on-registered' = $_POST['display-on-registered'],
'display-on-invalid' = $_POST['display-on-invalid'],
'before-whois-output' = $_POST['before-whois-output'],
'after-whois-output' = $_POST['after-whois-output'],
'callurl' = $_POST['callurl'],
'varname' = $_POST['varname'],
'resp-free-domain' = $_POST['resp-free-domain'],
'resp-registered-domain'= $_POST['resp-registered-domain'],
'resp-invalid-domain' = $_POST['resp-invalid-domain'],
'custom-css' = $_POST['custom-css'],
'license-key' = $_POST['license-key'],
'style-box-bgcolor' = $_POST['style-box-bgcolor'],
'style-www-color' = $_POST['style-www-color'],
'style-button-color' = $_POST['style-button-color'],
'style-button-bgcolor' = $_POST['style-button-bgcolor'],
'style-result-color' = $_POST['style-result-color'],
'style-result-bgcolor' = $_POST['style-result-bgcolor']
);
if (isset($_POST['enable-multiple-search']))
$wt_options[] = array('enable-multiple-search' = $_POST['enable-multiple-search'] );
if (isset($_POST['show-www']))
$wt_options[] = array('show-www' = $_POST['show-www'] );
if (isset($_POST['show-whois-output']))
$wt_options[] = array('show-whois-output' = $_POST['show-whois-output'] );
update_option( 'wtdomaincheck', $wt_options );
}
//
// PARAM
// Loads the template that shows the settings page
//
public function WTLoadSettingTemplate()
{
require_once WTDOMCHECK_PLUGIN_DIR.'admin/html/settings.php';
}
?
settings.php
form method=post action=options.php
?php settings_fields( 'wtdomaincheck' ); ?
div class=row border
div class=col-3 border-right pt-3 pb-3
div id=pillTabs class=nav flex-column nav-pills id=v-pills-tab role=tablist aria-orientation=vertical
?php
//Build Pill Sections
echo $wtdomadmin-WTBuildPillTabs($sections);
?
/div
/div
div class=col-9 pt-3
div class=tab-content id=v-pills-tabContent
?php
//Build Pill Sections
echo $wtdomadmin-WTBuildPillPanes($sections);
?
/div
/div
/div
div class='form-group row mx-auto mt-3'
div class=col-lg-12 pr-0
input type=submit class=btn btn-primary float-right value=?php _e('Save Changes') ? /
/div
/div
/form
When I install the plugin, the options record is created in the wp_options table. The settings page is displayed.. but when I try to save the changes... is where the options page not found comes to the screen...
Any help will be appreciated.
Topic plugin-options settings-api Wordpress
Category Web