Skip to content

Instantly share code, notes, and snippets.

@xafarali
Created June 9, 2013 23:39
Show Gist options
  • Save xafarali/5745730 to your computer and use it in GitHub Desktop.
Save xafarali/5745730 to your computer and use it in GitHub Desktop.
Custom Style sheet for admin Panel
/*----------- Print Stylesheet -------------*/
/* =====================================
Print Stylesheet and script from
my theme folder to Admin Panel
=======================================*/
add_action("admin_init", "custom_post_assets");
function custom_post_assets() {
global $post_type;
if (!empty($_GET['post'])) {
$post = get_post($_GET['post']);
$currentType = $post->post_type;
if ($currentType == "project") {
project_admin_css();
project_admin_scripts();
}
}
/*
if (($_GET['post_type'] == 'project') || ($post_type == 'project')) {
// code
add_action('admin_print_scripts', 'project_admin_scripts');
add_action('admin_print_styles', 'project_admin_styles');
}
*/
}
function project_admin_css() {
wp_enqueue_style('thickbox');
wp_register_style('admin-styles', get_bloginfo('stylesheet_directory') . '/assets/admin-custom.css');
wp_enqueue_style('admin-styles');
}
function project_admin_scripts() {
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
# register custom script in WP
wp_register_script('admin-script', get_bloginfo('stylesheet_directory') . '/assets/admin-custom-script.js', array(
'jquery',
'media-upload',
'thickbox'
));
wp_enqueue_script('admin-script');
}
/*----------- Print Stylesheet -------------*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment