I am new in plugin development. I created a plugin with the help of http://codex.wordpress.org/Creating_Options_Pages
<?php
/*
Plugin Name: 1pluginframework
Plugin URI:
Description: Custom plugin for lendingbig website.
Version: 1.0
Author: Jahur Ahmed
Author URI:
License: GPLv2 or later
*/
// create custom plugin settings menu
add_action('admin_menu', 'baw_create_menu');
function baw_create_menu() {
//create new top-level menu
add_menu_page('BAW Plugin Settings', 'BAW Settings', 'administrator', __FILE__, 'baw_settings_page',plugins_url('/images/icon.png', __FILE__));
//call register settings function
add_action( 'admin_init', 'register_mysettings' );
}
function register_mysettings() {
//register our settings
register_setting( 'baw-settings-group', 'new_option_name' );
register_setting( 'baw-settings-group', 'some_other_option' );
register_setting( 'baw-settings-group', 'option_etc' );
}
function baw_settings_page() {
?>
<div class="wrap">
<h2>Your Plugin Name</h2>
<form method="post" action="options.php">
<?php settings_fields( 'baw-settings-group' ); ?>
<?php do_settings_sections( 'baw-settings-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">New Option Name</th>
<td><input type="text" name="new_option_name" value="<?php echo get_option('new_option_name'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Some Other Option</th>
<td><input type="text" name="some_other_option" value="<?php echo get_option('some_other_option'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Options, Etc.</th>
<td><input type="text" name="option_etc" value="<?php echo get_option('option_etc'); ?>" /></td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php echo get_option('new_option_name'); ?>
<?php } ?>
I put this code in theme's header.php
<?php echo get_option('new_option_name'); ?>
When I deactivate this plugin, the value of <?php echo get_option('new_option_name'); ?>
is not disappeared. But this value must show when plugin is activated and will not show when it is deactivated.
Any suggestion is highly appreciated.
Thanks in advance to all.