Ejemplo n.º 1
0
  public static function inline_styles() {
    global $wf;

    $action = "";
    
    if (isset($_REQUEST["action"])) {
      $action = $_REQUEST["action"];
    }
  
    
    $the_type = $wf->the->type();
    
    ?>
    <style type="text/css">
    <?php 

  
    // insert styles to show the menu icons adjacent to the headers, instead of the default post icon
    
    if (self::is_post_editor()) {
      
      if ($the_type->supports("mp-page-attributes")) {
        // make sure the standard meta box is hidden!
        ?>
        #pageparentdiv { display: none; }
        <?php
      }
      
      if (!$the_type->supports("editor") && self::use_new_media()) {
        // the margin below the title is too large when the post body is hidden
        ?>
        #post-body-content { 
          margin-bottom: 9px; 
        }

        .wrap div.updated, .wrap div.error {
        margin: 5px 0 8px;
        }  

        <?php
      }
      
    }
    

    foreach (MasterPress::$post_types as $post_type) {

      $menu_icon = MPU::menu_icon($post_type->menu_icon, false);
      
      if ($menu_icon && $menu_icon->exists()) {
        
        $margin = "";
        
        if ($post_type->menu_icon != "" && ! ( ($post_type->name == "post" && $post_type->menu_icon == "menu-icon-posts.png") || ($post_type->name == "page" && $post_type->menu_icon == "menu-icon-pages.png") ) ) {
          $margin = "margin-right: 0px;"; 
            
          $icon_url = MPU::sprite_menu_icon_url($post_type->menu_icon);
          
          $menu_id = "#menu-posts-".$post_type->name;
          
          if ($post_type->name == "post") {
            $menu_id = "#menu-posts";
          } else if ($post_type->name == "page") {
            $menu_id = "#menu-pages";
          }
          
          // image_get_user_option("admin_color") == "classic" ? MPU::blue_menu_icon_url($post_type->menu_icon, false) : MPU::gray_menu_icon_url($post_type->menu_icon, false),
            

          $admin_color = get_user_option("admin_color");
          
          $offset = "6";
          
          if ($admin_color == "classic") {
            $offset = "-594";
          } else if ($admin_color == "bbpress") {
            $offset = "-894";
          }
          
          // output our post type icons
          
          // child post types meta box
          echo '#poststuff #detail-post-type-' . $post_type->name . ' h3 em, #your-profile #field-set-post-type-' . $post_type->name . ' h3 em, #createuser #field-set-post-type-' . $post_type->name . ' h3 em, #edittag #field-set-post-type-' . $post_type->name . ' { padding-left: 25px; background-image: url(' . $menu_icon->url() . '); } ';
          
          echo '#poststuff #detail-post-type-' . $post_type->name . ' .inside { padding: 0; margin: 0 } '; 
          
          echo '#adminmenu '.$menu_id.' .wp-menu-image { background: url('.$icon_url.') no-repeat '.$offset.'px 6px !important; } ';
          echo '.admin-color-mp6 #adminmenu '.$menu_id.' .wp-menu-image { background: url('.$icon_url.') no-repeat '.($offset + 2).'px 8px !important; } ';
          
          echo '#adminmenu '.$menu_id.'.wp-has-current-submenu .wp-menu-image, #adminmenu '.$menu_id.':hover .wp-menu-image { background-position: -294px 6px !important; } ';

          echo '.admin-color-mp6 #adminmenu '.$menu_id.'.wp-has-current-submenu .wp-menu-image, .admin-color-mp6 #adminmenu '.$menu_id.':hover .wp-menu-image { background-position: -292px 8px !important; } ';

          echo '#adminmenu '.$menu_id.' .wp-menu-image img { display: none; } ';
          
          if (self::is_post_manage() || self::is_post_editor()) {
          
            echo "#wpbody-content .wrap .icon32-posts-".$post_type->name." { background: url(".$menu_icon->url.") no-repeat center center !important; background-size: 16px 16px !important; ".$margin." } \n";
            
            // MP6 integration
            echo "body.admin-color-mp6 #wpbody-content .wrap .icon32-posts-".$post_type->name." { display: block;  margin-left: -6px; } \n";
  
                  
            if ($menu_icon->width() <= 16) {
              echo "#wpbody-content .wrap .icon32-posts-".$post_type->name." { background-position: 8px 8px !important; width: 36px; } \n";
            }

          }
          
          
        
        }
        
        // output a general post type icon class, which can be hooked into by field type UIs :)
      
        echo ".mp-icon-post-type-".$post_type->name." { background-image: url(".$menu_icon->url().") !important; } \n";

      }
      
      
    }


    MPU::mq2x_start();


    foreach (MasterPress::$post_types as $post_type) {

      $menu_icon = MPU::menu_icon($post_type->menu_icon, false);
      
      if ($menu_icon && $menu_icon->exists()) {
        
        $margin = "";
        
        if ($post_type->menu_icon != "" && ! ( ($post_type->name == "post" && $post_type->menu_icon == "menu-icon-posts.png") || ($post_type->name == "page" && $post_type->menu_icon == "menu-icon-pages.png") ) ) {
          
          $offset = "6";
          
          if ($admin_color == "classic") {
            $offset = "-294";
          } else if ($admin_color == "bbpress") {
            $offset = "-444";
          }

          // child post types meta box
          echo '#poststuff #detail-post-type-' . $post_type->name . ' h3 em, #your-profile #field-set-post-type-' . $post_type->name . ' h3 em, #createuser #field-set-post-type-' . $post_type->name . ' h3 em, #edittag #field-set-post-type-' . $post_type->name . ' { padding-left: 25px; background-size: 16px 16px !important; background-image: url(' . $menu_icon->resize("w=32&h=32")->url() . '); } ';
          
          
          echo '#adminmenu '.$menu_id.' .wp-menu-image { background-position: '.$offset.'px -26px !important; background-size: auto 56px !important; } ';
          echo '#adminmenu '.$menu_id.'.wp-has-current-submenu .wp-menu-image, #adminmenu '.$menu_id.':hover .wp-menu-image { background-position: -144px -26px !important; } ';
          echo '#adminmenu '.$menu_id.' .wp-menu-image img { display: none; } ';

          if (self::is_post_manage() || self::is_post_editor()) {
            echo "#wpbody-content .wrap .icon32-posts-".$post_type->name." { background: url(".$menu_icon->resize("w=32&h=32")->url.") no-repeat center center !important; background-size: 16px 16px !important; ".$margin." } \n";
          }
        
        
        }
        
      }
    
    

    }

    echo ".mp-icon-post-type-".$post_type->name." { background-image: url(".$menu_icon->resize("w=32&h=32")->url.") !important; background-size: 16px 16px; } \n";

    MPU::mq2x_end();
          
    
    ?>
    
    .edit-tags-php .icon32 {
      background: url(<?php echo MPU::img_url('icon-tag.png') ?>) 7px 8px no-repeat !important;
      width: 24px;
    }
    
    
    
    <?php foreach (MPFT::type_keys() as $key) : ?>
    .mp-icon-field-type-<?php echo $key ?> { background-image: url(<?php echo MPU::type_icon_url($key) ?>); }
    <?php endforeach; ?>

    <?php MPU::mq2x_start(); ?>
    <?php foreach (MPFT::type_keys() as $key) : ?>
    <?php $url = MPU::type_image($key, "icon-color.png", "")->resize("w=32&h=32")->url; ?>
    .mp-icon-field-type-<?php echo $key ?> { background-image: url(<?php echo $url ?>); background-size: 16px 16px; }
    <?php endforeach; ?>
    <?php MPU::mq2x_end(); ?>
    

    <?php
    

    foreach (MasterPress::$all_taxonomies as $tax) {

      if ($tax->title_icon) {

        $title_icon = MPU::menu_icon($tax->title_icon);
        
        if ($title_icon && $title_icon->exists()) {
          
          if (self::is_term_manage() || self::is_term_editor()) {
          
            if (isset($_GET["taxonomy"]) && $_GET["taxonomy"] == $tax->name) {
              echo ".edit-tags-php .icon32 { background: url(".$title_icon->url().") no-repeat 7px 8px !important; width: 36px; margin-right: 0px;  }";


              // MP6 integration
              echo " body.admin-color-mp6.edit-tags-php .icon32 { display: block; margin-left: -4px; } \n";

            }
        
          }

          // output a general taxonomy icon class, which can be hooked into by field type UIs :)
          echo " .mp-icon-taxonomy-".$tax->name." { background-image: url(".$title_icon->url().") !important; }";
        
        }

        
      } else {

        // output a general taxonomy icon class, which can be hooked into by field type UIs :)
        echo " .mp-icon-taxonomy-".$tax->name." { background-image: url(".MPU::img_url('icon-tag.png').") !important; }";
        
      }
      
    }
    
        
    MPU::mq2x_start();
    
    foreach (MasterPress::$all_taxonomies as $tax) {

      if ($tax->title_icon) {

        $title_icon = MPU::menu_icon($tax->title_icon);
        
        if ($title_icon && $title_icon->exists()) {
          
          // output 2x nearest neighbor scaled icons
          echo "\n.mp-icon-taxonomy-".$tax->name." { background-image: url(".$title_icon->resize("w=32&h=32")->url().") !important; background-size: 16px 16px; }";

          if (self::is_term_manage() || self::is_term_editor()) {
          
            if (isset($_GET["taxonomy"]) && $_GET["taxonomy"] == $tax->name) {
              echo "\n.edit-tags-php .icon32 { background: url(".$title_icon->resize("w=32&h=32")->url().") no-repeat 7px 8px !important; background-size: 16px 16px !important; width: 36px; margin-right: 0px;  }";
            }
        
          }
        
        }
        
      }
      
    }
    
    MPU::mq2x_end();

    

    ?>
    
    </style>
    <!--[if lte IE 7]><link rel="stylesheet" href="<?php echo MASTERPRESS_URL."css/mpv.ie7.css" ?>" type="text/css" /><![endif]-->
    <!--[if IE 8]><link rel="stylesheet" href="<?php echo MASTERPRESS_URL."css/mpv.ie8.css" ?>" type="text/css" /><![endif]-->
    
    <?php 

  }