示例#1
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();
  }