Skip to content

Instantly share code, notes, and snippets.

@Cheslab
Last active June 8, 2017 16:16
Show Gist options
  • Save Cheslab/5b71d2613ea35985846769f189934a41 to your computer and use it in GitHub Desktop.
Save Cheslab/5b71d2613ea35985846769f189934a41 to your computer and use it in GitHub Desktop.
wordpress plugin admin page style external file
// In order to use an external css file in the plugin's admin panel:
// 1. Copy following code to the main php file of your plugin (plugins/your_plugin/your_plugin_name.php)
// 2. Create admin.css (or adjust the name below)
function plugin_name_admin_css()
{
$siteurl = get_option('siteurl');
$url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/admin.css';
echo "<link rel='stylesheet' type='text/css' href='$url' />\n";
}
add_action('admin_head', 'plugin_name_admin_css');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment