brasofilo

Detect Editing Area or Page Template

Mar 3rd, 2012
204
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function my_editor_style() {
  3.     global $current_screen;
  4.     switch ($current_screen->post_type) {
  5.     case 'post':
  6.     //echo '<script>alert("post");</script>';
  7.         break;
  8.     case 'page':
  9.         echo '<script type="text/javascript" src="'.get_bloginfo('template_directory') .'/custom-fields/options.js"></script>
  10.         <link rel="stylesheet" href="'.get_bloginfo('template_directory').'/custom-fields/editing.css" type="text/css" media="all" />';
  11.         break;
  12.     case 'acf': // CPT
  13.     //echo '<script>alert("post");</script>';
  14.         break;
  15.     }
  16.  
  17. /*
  18.     // GET BY PAGE TEMPLATE
  19.     // I couldn't make the add_editor_style work, so I used the above echo '<script>...';
  20.  
  21.     switch ($GLOBALS['post']-&gt;page_template) {
  22.     case 'page-two-column.php': // Change to your template filename
  23.             add_editor_style('editor-style-two-column.css');
  24.         break;
  25.     default:
  26.             add_editor_style('editor-style.css');
  27.         break;
  28. }
  29. */
  30. }
  31. add_action( 'admin_head', 'my_editor_style' );
RAW Paste Data