I've followed Otto's guide for making a plugin options page.
My problem now is, I need to find a way to tie this in to the code I'm using to add a stylesheet to the dashboard.
At the moment, the plugin basically alters the WP dashboard look by adding a stylesheet. I'd like the options page to allow the user to choose different colour schemes. My idea for this is that each stylesheet is in a dropdown and the user chooses from this and this then affects which stylesheet is loaded.
I'm not currently using wp_enqueue styles, but I plan to. My code so far is below but as I've explained currently the options page is not actually affecting the plugin and this is what I need to do.
Any ideas or help would be massively appreciated and I will fully credit anybody that helps.
<?php
/*
Plugin Name: Coffee Admin Theme
Plugin URI: http://michaelgunner.co.uk
Description: This theme gives the Wordpress dashboard a darker, sleeker look. This theme is only compatible with Wordpress 3.3.
Author: Michael Gunner
Version: 1.2.3
Author URI: http://michaelgunner.co.uk
*/
function coffee_admin_head() {
echo '<link rel="stylesheet" type="text/css" href="' .plugins_url('coffee-admin.css', __FILE__). '">';
}
add_action('admin_head', 'coffee_admin_head');
// add the admin options page
add_action('admin_menu', 'coffee_admin_add_page');
function coffee_admin_add_page() {
add_options_page('Coffee Admin Theme Page', 'Coffee Admin Theme Menu', 'manage_options', 'coffee-admin-theme', 'coffee_options_page');
}
function coffee_options_page() {
?>
<div><h2>Coffee Theme Settings</h2>
Change the appearance of your theme.
<form action="options.php" method="post">
<?php settings_fields('coffee_options'); ?>
<?php do_settings_sections('coffee-admin-theme'); ?>
<input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" >
</form>
</div>
<?php }?>
<?php //add admin settings
add_action('admin_init', 'coffee_admin_init');
function coffee_admin_init(){
register_setting('coffee_options', 'coffee_options', 'coffee_options_validate' );
add_settings_section('coffee_main', 'Main Settings', 'coffee_section_text', 'coffee-admin-theme');
}
function coffee_section_text() {
echo '<p>You options.</p>';
}
?>
This post has been edited by brightonmike: 23 January 2012 - 10:42 AM
Help



















