Ejemplo n.º 1
0
  public static function field_set_icon_styles($field_sets) {
  ?>
    <style type="text/css">
    
    <?php foreach ($field_sets as $field_set) : ?>
    <?php if ($field_set->icon != "") : ?>
    span.field-set-<?php echo $field_set->id ?> { background-image: url(<?php echo MPU::field_set_icon_url($field_set->icon) ?>) }
    <?php endif; ?>
    <?php endforeach; ?>
    
    <?php MPU::mq2x_start(); ?>

    <?php foreach ($field_sets as $field_set) : ?>
    <?php if ($field_set->icon != "") : ?>
    span.field-set-<?php echo $field_set->id ?> { background-image: url(<?php echo MPU::field_set_icon_2x_url($field_set->icon); ?>); background-size: 16px 16px; }
    <?php endif; ?>
    <?php endforeach; ?>
    
    <?php MPU::mq2x_end(); ?>
    </style>
    
    <?php
  }
Ejemplo n.º 2
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 

  }
Ejemplo n.º 3
0
  public static function inline_head($sets, $object) {
    
    global $typenow;
    
    ?>
    <!-- inline styles to change the padding of specific metaboxes, since WordPress has no hook to class them -->
    
    <style type="text/css">
    
    <?php 
        
    $metabox_inside_rules = "padding: 0; margin: 0;"; 

    $field_types_loaded = array();
    
    $object_type_name = "";
    
    $object_type = self::type_key($object);
    
    if ($object_type == "term" && isset($_GET["taxonomy"])) {
      $object_type_name = $_GET["taxonomy"];
    }
    
    
    foreach ($sets as $set) {
      echo "#field-set-".$set->html_id()." .inside { ".$metabox_inside_rules." } "; 
    }
    
    // include the field types, and setup color icon rollover states
    foreach (MPFT::type_keys() as $type) {

      if ($type_class = MPFT::type_class($type)) {
        // echo field type icons
        echo ".mp-set-summary .mpft-".$type."-summary .empty h4 i { background-image: url(".MPU::type_icon_url($type, false)."); } ";
        echo ".mp-set-summary .mpft-".$type."-summary h4 i { background-image: url(".MPU::type_icon_url($type, true)."); } ";
        
        MPU::mq2x_start();
        
        echo ".mp-set-summary .mpft-".$type."-summary .empty h4 i { background-image: url(".MPU::type_image($type, "icon-gray.png", "")->resize("w=32&h=32")->url."); background-size: 16px 16px; } ";
        echo ".mp-set-summary .mpft-".$type."-summary h4 i { background-image: url(".MPU::type_image($type, "icon-color.png", "")->resize("w=32&h=32")->url."); background-size: 16px 16px; } ";
        
        MPU::mq2x_end();
        
      }
      
    }
      
    ?>
    
    </style>

    <script type="text/javascript">
      jQuery.mp.object_id = <?php echo $object->id() ?>;
      jQuery.mp.object_type = '<?php echo self::type_key($object) ?>';
      jQuery.mp.object_type_name = '<?php echo $object_type_name ?>';
      
      jQuery.mp.lang.check_all_items = '<?php echo esc_js(__("Check All Items", MASTERPRESS_DOMAIN)) ?>';
      jQuery.mp.lang.uncheck_all_items = '<?php echo esc_js(__("Uncheck All Items", MASTERPRESS_DOMAIN)) ?>';
      jQuery.mp.lang.remove_checked_items = '<?php echo esc_js(__("Remove Checked Items", MASTERPRESS_DOMAIN)) ?>';
      jQuery.mp.lang.confirm_remove_checked_items = '<?php echo esc_js(__("Remove Checked Items: Are You Sure?", MASTERPRESS_DOMAIN)) ?>';
    </script>
    
    <script type="text/javascript">
    
    jQuery.mpft_lang = {};
    
    <?php 
    
    $field_types_loaded = array();

    foreach ($sets as $set) {

      // include the field types, and setup color icon rollover states
      foreach ($set->fields() as $field) {
        
        if (!in_array($field->type, $field_types_loaded)) {

          $field_types_loaded[] = $field->type;

          if ($ftc = MPFT::type_class($field->type)) {
            $lang = call_user_func( array($ftc, "ui_lang" ) );
            
            if (count($lang)) {
            ?>
            jQuery.mpft_lang['<?php echo $field->type ?>'] = <?php echo json_encode($lang) ?>;
            <?php
            
            }
          }
        
        }
        
      }
    
    }
    
    ?>
    
    </script>
    
    <script id="mp-set-preview-multiple-template" type="text/html">
    
    <?php
    $expand_all = __("Expand All", MASTERPRESS_DOMAIN);
    $check_all_items = __("Check All Items", MASTERPRESS_DOMAIN);
    $collapse_all = __("Collapse All", MASTERPRESS_DOMAIN);
    $check_all_items = __("Check All Items", MASTERPRESS_DOMAIN);
    
    $label_one_item = __("One Item", MASTERPRESS_DOMAIN);
    $label_n_items = __("%d Items", MASTERPRESS_DOMAIN);
    $label_no_items = __("No Items", MASTERPRESS_DOMAIN);

    
    ?>
    
    <div class="mpv mp-set preview multiple { lang: { item: '<?php echo $label_one_item ?>', items: '<?php echo $label_n_items ?>', no_items: '<?php echo $label_no_items ?>' } }">
  
    <div class="mp-set-inner">
    
    <div class="mp-set-head">
    
    <ul class="mp-controls lt">
    </ul>
    
    <ul class="mp-controls rt">
    <li class="control-expand-all"><button type="button" class="icon ir expand-all" title="<?php echo $expand_all ?>"><?php echo $expand_all ?></button></li>
    <li title="<?php echo $check_all_items ?>" class="control-check-all"><input type="checkbox" class="checkbox check-all" /></li>
    <li class="control-collapse-all"><button type="button" class="icon ir collapse-all" title="<?php echo $collapse_all ?>"><?php echo $collapse_all ?></button></li>
    </ul>
    
    </div>
    
    <div class="mp-set-items"></div>
    
    </div>
    
    </div>
    
    </script>
    
    
    <script id="mp-set-preview-template" type="text/html">
    
    <div class="mpv mp-set preview read-only single"><div class="mp-set-inner"></div></div>
    
    </script>
    
    
    <script id="mp-postbox-template" type="text/html">
    <div id="{{id}}" class="postbox">
      <div class="handlediv" title="<?php _e("Click to toggle") ?>"><br></div><h3 class="hndle"><span>{{title}}</span></h3>
      <div class="inside">
      {{{html}}}
      </div>
    </div>
    </script>
    
    <script id="invalid-fields-publish-message-template" type="text/html">
    <p id="invalid-fields-publish-message" class="publish-message invalid"><i class="error-circle"></i><span><?php echo __("Some required fields are missing. Please provide values for any fields marked in red, and try again", MASTERPRESS_DOMAIN); ?></span></p>
    </script>

    <script id="title-publish-message-template" type="text/html">
    <p id="title-publish-message" class="publish-message invalid"><i class="error-circle"></i><span><?php echo __("The title for this item must be entered. Please provide a title and try again", MASTERPRESS_DOMAIN); ?></span></p>
    </script>
    
    <?php 
    
    // output the script and link tags for each loaded field type

    $include_pe_style = true;
    $include_pe_script = true;
    
    if (!(MASTERPRESS_DEBUG || WP_DEBUG)) {

      // try to get the combined file

      $mpft_css_url = MPU::type_styles_file_url();
      
      if ($mpft_css_url) {
        $include_pe_style = false; // no separate scripts
        // include the file
        ?>
        <link rel="stylesheet" type="text/css" href="<?php echo $mpft_css_url ?>" />
        <?php
      }


      $mpft_js_url = MPU::type_scripts_file_url();
      
      if ($mpft_js_url) {
        $include_pe_script = false; // no separate scripts
        // include the file
        ?>
        <script type="text/javascript" src="<?php echo $mpft_js_url ?>"></script>
        <?php
      }


      
    } 
    
    
    foreach (MPFT::type_keys() as $type) {
      if ($include_pe_style) {
        MPFT::meta_style($type);
      }
      
      if ($include_pe_script) {
        MPFT::meta_script($type);
      }
    }
  
    // output the handlebars templates for sets and fields 
  
    foreach ($sets as $set) {
      if ($set->allow_multiple) {
        self::get_set_templates($object, $set);
      }
    }
    
    echo implode(" ", self::$queued_templates);
    self::$queued_templates = array();
  }