I am not sure how to formulate the question so I start saying that in my plugin folder I have 2 files:
1 - "index.php"
add_action( 'wp_enqueue_scripts', 'register_plugin_styles' );
function my_admin_setting() {
include('includes/my_admin.php');
include('css/wp-admin.php');
}
function custom_admin_actions() {
add_menu_page("Customise-Admin", "Custom-Admin", 1, "Custom_Admin", "my_admin_setting");
add_submenu_page('Custom_Admin', 'About', 'About', 1, 'info', "my_admin_info");
}
function my_admin_theme_style() {
wp_register_style('my-admin-theme', plugins_url('css/wp-admin.php', __FILE__));
wp_enqueue_style('my-admin-theme');
}
add_action('admin_enqueue_scripts', 'my_admin_theme_style');
add_action('login_enqueue_scripts', 'my_admin_theme_style');
add_action('admin_menu', 'custom_admin_actions');
add_option( 'my_adminbar_color', 'red' );
2 - wp_admin.php (style)
<?php header('Content-type: text/css');
?>
<?php
$blue = '#0e70d1';
$dkgray = '#333';
$dkgreen = '#008400';
?>
<?php $myplugin_color = get_option( 'my_adminbar_color' ); ?>
#wpadminbar {
background-color: <?php echo $myplugin_color;?> !important;
}
The problem here is that I am trying to pass an option to a php style. When I don't insert the "get_option" function my custom style is visible however, as soon as I pass the value the style is not rendered anymore.
I can see that the option is passed to the style file as the css code get printed in the plugin page, instead of running the code as CSS seems that it becomes formatted as normal text.
Could someone explain to me why this happens? And How could I pass the option to my style file?
Aucun commentaire:
Enregistrer un commentaire