Beispiel #1
0
 public function current_user_can_manage() {
   
   $cap = "manage_options";
   
   if (MasterPress::$cap_mode == "specific") {
     switch ($this->type) {
       case "p" :
         $cap = "edit_post_type_fields";
         break;
       case "x" :
         $cap = "edit_taxonomy_fields";
         break;
       case "t" :
         $cap = "edit_template_fields";
         break;
       case "s" :
         $cap = "edit_shared_fields";
         break;
       case "w" :
         $cap = "edit_site_fields";
         break;
     }
     
   } 
   
   return MasterPress::current_user_can($cap);
   
 }
Beispiel #2
0
  public function delete_field() {

    if (!MasterPress::current_user_can("delete_site_fields")) {
      wp_die(__("Sorry, you do not have the required capability to delete site fields.", MASTERPRESS_DOMAIN));
    }
 
    $this->delete( array(
        "cap_verified" => true,
        "model" => "field",
      )
    );
    
  }
  public function grid() {

    MPC::incl("post-types");
    MPV::incl("fields");
    MPV::incl("post-types");
    
    $info = MasterPress::$view;
    
    ?>
    
    
    <?php MPV::messages(); ?>


    <div class="grid-set">
    
    <?php $field_sets = MPM_SharedFieldSet::find( array("orderby" => "name ASC" ) ); ?>

    <?php MPV::field_set_icon_styles($field_sets); ?>

    <?php
    
    $has_actions = MasterPress::current_user_can("edit_shared_field_sets,delete_shared_field_sets,edit_shared_fields,delete_shared_fields");

    $can_edit = MasterPress::current_user_can("edit_shared_field_sets");
    $can_delete = MasterPress::current_user_can("delete_shared_field_sets");
    $can_create = MasterPress::current_user_can("create_shared_field_sets");

    $can_edit_fields = MasterPress::current_user_can("edit_shared_fields");
    $can_delete_fields = MasterPress::current_user_can("delete_shared_fields");
    $can_create_fields = MasterPress::current_user_can("create_shared_fields");

    $less = ($can_create_fields) ? 1 : 0;

    $colspan = ( $has_actions ? 7 : 6 ) - $less;
    
    foreach ($field_sets as $field_set) {

      if (MPC::is_deleting($field_set->id, "delete")) {
        
        $this->confirm_delete($field_set);
        
      } else {
        
        foreach ($field_set->fields() as $field) {
          
          if (MPC::is_deleting($field->id, "delete-field")) {
            $this->confirm_delete_field($field);
          }
          
        }
        
      }
      
    }
    
    ?>
    
    <?php if (count($field_sets)) : ?>
    
    <table cellspacing="0" class="grid grid-field-sets grid-shared-field-sets">

    <thead>
    <tr>
      <th class="first type"><i class="types"></i><span><?php _e("Type", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="label"><i class="label-string"></i><span><?php _e("Label", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="front-end-name"><i class="script-php"></i><span><?php _e("Front End Name", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="post-types"><i class="pins"></i><span><?php _e("Post Types", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="taxonomies"><i class="tags"></i><span><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="roles <?php echo $has_actions ? "" : "last" ?>"><i class="user-role"></i><span><?php _e("User Roles", MASTERPRESS_DOMAIN) ?></span></th>
      <?php if ($has_actions) : ?>
      <th class="actions last"><i class="buttons"></i><span><?php _e("Actions", MASTERPRESS_DOMAIN) ?></span></th>
      <?php endif; ?>
    </tr>
    </thead>
   
    <tbody>
    

    <?php $fg_count = 0; ?>
    <?php foreach ($field_sets as $field_set) : $fg_count++; ?>  
      
    <?php $display = $field_set->display_label(); ?>
    
    <?php
      
      $display_td = $display;
      
      if ($field_set->icon != "") {
        $display_td = WOOF_HTML::tag("span", array("class" => "with-icon field-set-".$field_set->id), $display);
      }
    
    ?>
    
    <?php 

      $deleting_class = MPC::is_deleting($field_set->id, "delete") ? 'deleting' : ''; 
      $editable_class = $can_edit ? " editable " : "";
      $meta = $can_edit ? "{ href: '".MasterPress::admin_url("shared-field-sets", "edit", array("id" => $field_set->id) )."' }" : "";

    ?>

    <?php $disabled = $field_set->disabled ? "disabled" : ""; $title = $field_set->disabled ? ' title="'.__("this field set is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?>

    <?php
    
    if (!$field_set->in_current_site()) {
      $disabled = "disabled";
      $title = ' title="'.__("field set is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" ';
    }
    
    ?>

        
    <tr id="field_set_<?php echo $field_set->name ?>" <?php echo $title ?> class="<?php echo $disabled ?> <?php echo $editable_class ?> <?php echo $deleting_class ?> <?php echo MPV::updated_class("edit,create", $field_set->id) ?> <?php echo $meta ?>">
      <?php if ($field_set->allow_multiple) : ?>
      <th class="first type icon"><i class="metabox-add-remove-large" title="<?php _e("Field Set (Multiple Items)", MASTERPRESS_DOMAIN) ?>"></i></th>
      <?php else : ?>
      <th class="first type icon"><i class="metabox-large" title="<?php _e("Field Set", MASTERPRESS_DOMAIN) ?>"></i></th>
      <?php endif; ?>
      <th class="label"><strong><?php echo $display_td ?></strong></th>
      <th class="front-end-name"><span class="tt"><?php echo $field_set->display_name() ?></span></th>
      <th class="post-types">
        
        <?php 
        
        $post_types = $field_set->post_types(); 

        $vis = $field_set->visibility;
        
        $vis_post_types = "";

        if (isset($vis["post_types"])) {
          $vis_post_types = $vis["post_types"];
        }
        
        if ($vis_post_types == "*") {
          $post_type_display = __("( All )", MASTERPRESS_DOMAIN);
          
        } else {

          $post_type_display = __("( None )", MASTERPRESS_DOMAIN);

          if (count($post_types)) {
            $post_type_links = array();

            foreach ($post_types as $post_type) {
              $post_type_links[] = $post_type->labels["name"];
            }

            $post_type_display = implode($post_type_links, ", ");
          }
        }
        
        echo $post_type_display;
        ?>
        
        
        
      </th>

      <th class="taxonomies">
        
        <?php 
        
        $vis = $field_set->visibility;
        
        
        $vis_tax = "";
        
        if (isset($vis["taxonomies"])) {
          $vis_tax = $vis["taxonomies"];
        }
        
        if ($vis_tax == "*") {
          $taxonomy_display = __("( All )", MASTERPRESS_DOMAIN);
          
        } else {
        
          $taxonomy_display = __("( None )", MASTERPRESS_DOMAIN);
          
          if ($vis_tax != "") {
            
            $tax_models = MPM_Taxonomy::find_by_name_in(explode(",", $vis_tax));
            
            $td = array();
            
            foreach ($tax_models as $tax) {
              $td[] = $tax->display_label();
            }
            
            $taxonomy_display = implode(", ", $td);
          }
        
        }
        
        echo $taxonomy_display;
        ?>
        
      </th>

      <th class="roles <?php echo $has_actions ? "" : "last" ?>">
        
        <?php 
        
        $vis = $field_set->visibility;
        
        $vis_roles = "";
        
        if (isset($vis["roles"])) {
          $vis_roles = $vis["roles"];
        }
        
        if ($vis_roles == "*") {
          $role_display = __("( All )", MASTERPRESS_DOMAIN);
          
        } else {
          
          if (is_null($vis_roles) || $vis_roles == "") {
            $role_display = __("( None )", MASTERPRESS_DOMAIN);
          } else {
            $role_display = implode(", ", explode(",", $vis_roles));
          }
        
        }
        
        echo $role_display;
        ?>
        
      </th>

      <?php if ($has_actions) : ?>
            
      <th class="actions last">
      <?php if (MPC::is_deleting($field_set->id, "delete")) : ?>
        <span class="confirm-action">&nbsp;</span>
      <?php else: ?>
      <div>
        <?php if ($can_edit) : ?>
          <?php echo MPV::action_button("shared-field-sets", "edit", self::__edit(), array("id" => $field_set->id), array("class" => "button button-edit") ); ?>
        <?php endif; ?>
        
        <?php if ($can_delete) : ?>
          <?php echo MPV::action_button("shared-field-sets", "delete", self::__delete(), array("id" => $field_set->id), array("class" => "button button-delete") ); ?>
        <?php endif; ?>
      </div>
      <?php endif; ?>
      </th>

      <?php endif; // has_actions ?>

    </tr>  
    
    
    <?php 
    
    $count = 0; 
    $fields = $field_set->fields();
    
    ?>
    
    <?php foreach ($fields as $field) : $count++; $first = $count == 1 ? 'first' : ''; $disabled = $field_set->disabled || $field->disabled ? "disabled" : ""; $title = $field_set->disabled || $field->disabled ? ' title="'.__("this field is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?>

    <?php
    if (!$field_set->in_current_site() || !$field->in_current_site()) {
      $disabled = "disabled";
      $title = ' title="'.__("field is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" ';
    }
    ?>
        
    <?php 
    
    $deleting_class = MPC::is_deleting($field_set->id, "delete") || MPC::is_deleting($field->id, "delete-field") ? 'deleting' : ''; 
    $editable_class = $can_edit_fields ? " editable " : "";
    $meta = $can_edit ? "{ href: '".MasterPress::admin_url("shared-field-sets", "edit-field", array("id" => $field->id, "parent" => $field_set->id) )."' }" : "";

    
    ?>
  
    <?php if ($type_class = MPFT::type_class($field->type)) : ?>

    <tr <?php echo $title ?> class="sub <?php echo $editable_class.$deleting_class ?> <?php echo $first ?> <?php echo $disabled ?> <?php echo $count % 2 == 0 ? "even" : "" ?> <?php echo MPV::updated_class("edit-field,create-field", $field->id) ?> <?php echo $meta ?>">
      <td class="type icon first" title="<?php echo call_user_func( array($type_class, "__s") ) ?>"><span class="mp-icon mp-icon-field-type-<?php echo $field->type ?>"></span></td>
      <td class="label"><strong><?php echo $field->display_label() ?></strong></td>
      <td class="front-end-name"><span class="tt"><span class="arrow">-&gt;&nbsp;</span><?php echo $field->display_name() ?></span></td>
      <td class="post-types">
        
        <?php 
        
        $vis = $field->visibility;
        
        $vis_post_types = "";

        if (isset($vis["post_types"])) {
          $vis_post_types = $vis["post_types"];
        }
        
        if ($vis_post_types == "*") {

          $post_type_display = '<span class="inherit">( '.__("same as set", MASTERPRESS_DOMAIN).' )</span>';

        } else {

          $post_types = $field->post_types(); 
          
          $post_type_display = MPV::note_none();
        
          if (count($post_types)) {
            $post_type_links = array();
          
            foreach ($post_types as $post_type) {
              $post_type_links[] = $post_type->labels["name"];
            }

            $post_type_display = implode($post_type_links, ", ");
          }
        
        }
        
        echo $post_type_display;
          
        ?>
        
      </td>

      <td class="taxonomies">
        
        <?php 
        
        $vis = $field->visibility;

        $vis_tax = "";
        
        if (isset($vis["taxonomies"])) {
          $vis_tax = $vis["taxonomies"];
        }
        
        if ($vis_tax == "*") {

          $tax_display = '<span class="inherit">( '.__("same as set", MASTERPRESS_DOMAIN).' )</span>';

        } else {

          $tax_display = MPV::note_none();
        
          if ($vis_tax != "") {
            
            $tax_models = MPM_Taxonomy::find_by_name_in(explode(",", $vis_taxonomies));
            
            $td = array();
            
            foreach ($tax_models as $tax) {
              $td[] = $tax->display_label();
            }
            
            $tax_display = implode(", ", $td);
          }
        
        }
        
        echo $tax_display;
          
        ?>
        
      </td>
      
      <td class="roles <?php echo $has_actions ? "" : "last" ?>">
        
        <?php 
        
        $vis = $field->visibility;
        
        $vis_roles = "";
        
        if (isset($vis["roles"])) {
          $vis_roles = $vis["roles"];
        }
        
        if ($vis_roles == "*") {

          $role_display = '<span class="inherit">( '.__("same as set", MASTERPRESS_DOMAIN).' )</span>';

        } else {

          $role_display = MPV::note_none();
        
          if ($vis_roles != "") {
            $role_display = implode(", ", explode(",", $vis_roles));
          }
        
        }
        
        echo $role_display;
          
        ?>
        
      </td>

      <?php if ($has_actions) : ?>

      <td class="actions last">
      <?php if (MPC::is_deleting($field->id, "delete-field")) : ?>
        <span class="confirm-action">&nbsp;</span>
      <?php else: ?>
      <div>
        <?php if ($can_edit_fields) : ?>
          <?php echo MPV::action_button("shared-field-sets", "edit-field", self::__edit(), array("id" => $field->id, "parent" => $field_set->id), array("class" => "button button-edit") ); ?>
        <?php endif; ?>

        <?php if ($can_delete_fields) : ?>
          <?php echo MPV::action_button("shared-field-sets", "delete-field", self::__delete(), array("id" => $field->id, "parent" => $field_set->id), array("class" => "button button-delete") ); ?>
        <?php endif; ?>
        
      </div>
      <?php endif; ?>
      
      </td>
      <?php endif; // has_actions ?>
    </tr>
    
    <?php endif; ?>
      
    <?php endforeach; ?>
  
    <tr class="summary <?php echo $can_create_fields ? "editable" : "" ?>">
      <?php if (count($fields)) : ?>
      <td colspan="<?php echo $colspan ?>" class="first <?php echo $can_create_fields ? "" : "last" ?>"><?php printf( __( "%s contains %s", MASTERPRESS_DOMAIN ), $display, MPU::__items( $field_set->field_count(), __("%d custom field", MASTERPRESS_DOMAIN), __("%d custom fields", MASTERPRESS_DOMAIN) ) ) ?></td>
      <?php else: ?>
      <?php if ($can_create_fields) : ?>
      <td colspan="<?php echo $colspan ?>" class="hl first last"><span><?php printf( __( "<strong>%s</strong> is not yet active as it contains <em>no custom fields</em>. Click here to create one", MASTERPRESS_DOMAIN ), $display ); ?></span></td>
      <?php endif; ?>
      <?php endif; ?>

      <?php if ($can_create_fields) : ?>
      <td class="last actions <?php echo count($fields) ? "" : "hl" ?>">
      <?php echo MPV::action_button("shared-field-sets", "create-field", self::__create(MPV_Fields::__s()), array("parent" => $field_set->id), array("class" => "button create-field")  ); ?>
      </td>
      <?php endif; ?>
    </tr>
    <tr class="gap <?php if ($fg_count == count($field_sets)) { echo "gap-last"; } ?>">
    <td colspan="7">&nbsp;</td>  
    </tr>
    
  
    <?php endforeach; ?>

    </tbody>
  
    </table>

    <?php if ($can_create) : ?>
    <div class="grid-foot-controls">
    <?php echo MPV::action_button("shared-field-sets", "create", MPV::__create( MPV_SharedFieldSets::__s() ), array() ); ?>
    </div>
    <?php endif; ?>
    
    <?php else: ?>
  
    <?php if ($can_create) : ?>
    <a href="<?php echo MasterPress::admin_url("shared-field-sets", "create") ?>" class="no-items-create">
	<i class="plus-circle"></i>
    <span><?php _e( "There are currently no Shared Field Sets. Click here to create one." ) ?></span>
    </a>
    <?php endif; ?>
  
    <?php endif; ?>

    
    </div>
  
  
    <?php

  } // end grid()
Beispiel #4
0
  public function grid($id = null) {

    MPV::incl("field-sets");
    MPV::incl("fields");
    MPV::incl("taxonomies");
    MPC::incl("taxonomies");
    
    $post_types = MPM_PostType::find("orderby=disabled,name ASC");
    
    $has_actions = MasterPress::current_user_can("edit_post_types,delete_post_types,manage_post_type_field_sets");
    $can_edit = MasterPress::current_user_can("edit_post_types");
    $can_delete = MasterPress::current_user_can("delete_post_types");
    $can_create = MasterPress::current_user_can("create_post_types");
    $can_manage_field_sets = MasterPress::current_user_can("manage_post_type_field_sets");

    $less = $can_create ? 1 : 0;
    $colspan = ( $has_actions ? 8 : 7 ) - $less;


  ?>

  <?php MPV::messages(); ?>
  
  <?php 
  foreach ($post_types as $post_type) {
    if (MPC::is_deleting($post_type->id)) {
      self::confirm_delete($post_type);
    }
  }
  
  ?>
  
  <table cellspacing="0" class="grid grid-post-types">
    <thead>
    <tr>
      <th class="first menu-icon"><i class="menu-icon" title="<?php _e("Menu Icon", MASTERPRESS_DOMAIN) ?>"></i><span class="ac"><?php _e("Menu Icon", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="menu-label"><i class="label-string"></i><span><?php _e("Label", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="post-type-name"><i class="script-php"></i><span><?php _e("Name", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="hierarchical"><i class="hierarchy"></i><span class="ac" title="<?php _e("Hierarchical?", MASTERPRESS_DOMAIN) ?>"><?php _e("Hierarchical?", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="field-sets"><i class="metaboxes"></i><span><?php _e("Field Sets", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="shared-field-sets"><i class="med share-metaboxes"></i><span><?php _e("Shared Field Sets", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="taxonomies <?php echo $has_actions ? "" : "last" ?>"><i class="tags"></i><span><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?></span></th>
      <?php if ($has_actions) : ?>
      <th class="actions last"><i class="buttons"></i><span><?php _e("Actions", MASTERPRESS_DOMAIN) ?></span></th>
      <?php endif; ?>
    </tr>
    </thead>
    <tbody>
    
    
    <?php $count = 0; ?>
    
    <?php foreach ($post_types as $post_type) : $disabled = ( $post_type->disabled ) ? "disabled" : "";  $title = $post_type->disabled ? ' title="'.__("this post type is disabled", MASTERPRESS_DOMAIN).'" ' : ""; 
    
    if (!$post_type->in_current_site()) {
      $disabled = "disabled";
      $title = ' title="'.__("this post type is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" ';
    }

    
    ?>
    
    <?php if ($post_type->still_registered()) : $count++; $first = $count == 1 ? 'first' : ''; ?>
      
    <?php 
    
    $deleting_class = MPC::is_deleting($post_type->id, "delete") ? 'deleting' : ''; 
    $editable_class = $can_edit ? " editable " : "";
    $meta = $can_edit ? "{ href: '".MasterPress::admin_url("post-types", "edit", "id=".$post_type->id)."' }" : "";
    
    ?>
    

    <tr <?php echo $title ?> class="<?php echo $first ?> <?php echo $editable_class.$deleting_class ?> <?php echo $disabled ?> <?php echo MPV::updated_class("edit,create", $post_type->id) ?> <?php echo $count % 2 == 0 ? "even" : "" ?> sub <?php echo $meta ?>">
      <td class="first menu-icon icon"><span class="mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>"></span></td>
      <td class="menu-label"><strong><?php echo $post_type->labels["menu_name"] ?></strong></td>
      <td class="post-type-name"><span class="tt"><?php echo $post_type->name ?></span></td>
      <td class="hierarchical"><?php echo $post_type->hierarchical ? '<i class="tick-small"></i><span class="ac" title="'.__("this post type is hierarchical", MASTERPRESS_DOMAIN).'">yes</span>' : '<span class="note" title="'.__("this post type is not hierarchical", MASTERPRESS_DOMAIN).'">&ndash;</span>' ?></td>

      <?php $field_sets = $post_type->field_sets("name ASC"); ?>

      <?php if ($post_type->show_ui) : ?>
        
      <td class="field-sets <?php echo $can_manage_field_sets ? "manage { href: '".MasterPress::admin_url( "post-types", "manage-field-sets", "parent=".$post_type->id)."' }" : "" ?>">
        <?php if ($can_manage_field_sets) : ?>
        <a href="<?php echo MasterPress::admin_url( "post-types", "manage-field-sets", "parent=".$post_type->id)?>" title="<?php echo strip_tags(self::__manage( MPV_FieldSets::__p() )) ?>">
		<i class="go"></i>
        <?php endif; ?>

        <?php 
        
        $field_set_display = MPV::note_none();
        
        if (count($field_sets)) {
          $field_set_links = array();
          
          foreach ($field_sets as $field_set) {
            if (!$field_set->is_shared()) {
              $field_set_links[] =  $field_set->display_label();
            }
          }

          if (count($field_set_links)) {
            $field_set_display = implode($field_set_links, ", ");
          }
        
        }
        
        echo $field_set_display;
        ?>
        <?php if ($can_manage_field_sets) : ?>
        </a>
        <?php endif; ?>
      </td>
      <?php else: ?>
      <td class="field-sets">
      <span title="<?php _e("This post type does not support field sets as the 'show ui' parameter is off", MASTERPRESS_DOMAIN); ?>"><i class="na"></i><?php _e("N/A", MASTERPRESS_DOMAIN); ?></span>  
      </td>
      <?php endif; ?>

      <?php if ($post_type->show_ui) : ?>
    
      <td class="shared-field-sets">
        
        <?php 
        
        $field_set_display = MPV::note_none();
      
        if (count($field_sets)) {
          $field_set_links = array();
          
          foreach ($field_sets as $field_set) {
            if ($field_set->is_shared()) {
              $field_set_links[] = $field_set->display_label(); 
            }
          }

          if (count($field_set_links)) {
            $field_set_display = implode($field_set_links, ", ");
          }
        
        }
        
        echo $field_set_display;
        ?>
        
      </td>
      
      <?php else: ?>
      <td class="shared-field-sets">
      <span title="<?php _e("This post type does not support shared field sets as the 'show ui' parameter is off", MASTERPRESS_DOMAIN); ?>"><i class="na"></i><?php _e("N/A", MASTERPRESS_DOMAIN); ?></span>  
      </td>
      <?php endif; ?>


      <td class="taxonomies <?php echo $has_actions ? "" : "last" ?>">
        <?php 
        $taxonomies = $post_type->taxonomies(); 
        
        $tax_display = MPV::note_none();
        
        if (count($taxonomies)) {
          $tax_links = array();
          
          foreach ($taxonomies as $tax) {
            $tax_links[] = $tax->labels["name"]; 
          }

          $tax_display = implode($tax_links, ", ");
        }
        
        echo $tax_display;
        ?>
      </td>      

      <?php if ($has_actions) : ?>

      <td class="actions last">
      <div>
        <?php if (MPC::is_deleting($post_type->id)) : ?>
        
        <span class="confirm-action"><?php _e("Please Confirm Delete Action", MASTERPRESS_DOMAIN) ?></span>
        
        <?php else: ?>

          <?php if ($can_manage_field_sets) : ?>

            <?php if ($post_type->show_ui) :  ?>
            <?php echo MPV::action_button("post-types", "manage-field-sets", self::__manage( MPV_FieldSets::__p_short() ), "parent=".$post_type->id, array("class" => "button button-manage")); ?>
            <?php else: ?>
            <?php echo MPV::action_button("post-types", "manage-field-sets", self::__manage( MPV_FieldSets::__p_short() ), "parent=".$post_type->id, array("title" => "This post type does not support field sets as the 'show ui' parameter is off", "disabled" => "disabled", "class" => "button button-manage")); ?>
            <?php endif; ?>
      
          <?php endif; ?>
        
          <?php if ($can_edit) : ?>
            <?php echo MPV::action_button("post-types", "edit", self::__edit( "" ), "id=".$post_type->id, array( "class" => "button primary button-edit" )); ?>
          <?php endif; ?>

          <?php if ($can_delete) : ?>
            <?php if ($post_type->_builtin) : ?>
            <span class="note" title="<?php _e("This post type cannot be deleted as it is built-in to WordPress", MASTERPRESS_DOMAIN) ?>"><?php _e("( Built-in )", MASTERPRESS_DOMAIN) ?></span>
            <?php elseif ($post_type->_external) : ?>
            <span class="note" title="<?php _e("This post type cannot be deleted as it was not created by MasterPress", MASTERPRESS_DOMAIN) ?>"><?php _e("( External )", MASTERPRESS_DOMAIN) ?></span>
            <?php else: ?>
        
            <?php echo MPV::action_button("post-types", "delete", self::__delete( "" ), "id=".$post_type->id, array( "class" => "button button-delete", "title" => "Delete - Requires Confirmation" )); ?>
            <?php endif; ?>
          <?php endif; ?>
      
        <?php endif; // has_actions ?>
      </div>
      </td>
      
      <?php endif; ?>
      
    </tr>
  
    <?php endif; ?>

    <?php endforeach; ?>

    <tr class="summary <?php echo $can_create ? "editable" : "" ?>">
      <td colspan="<?php echo $colspan ?>" class="first <?php echo $can_create ? "" : "last" ?>"><?php _e(  MPU::__items( $count, __("<strong>%d</strong> Post Type", MASTERPRESS_DOMAIN), __("%d Post Types", MASTERPRESS_DOMAIN)   ) ) ?></td>
      <?php if ($can_create) : ?>
      <td class="last">
      <?php echo MPV::action_button("post-types", "create", self::__create(MPV_PostTypes::__s()), "", array( "class" => "button button-create" ) ); ?>
      </td>
      <?php endif; ?>
    </tr>
    

    </tbody>
    </table>


    
    <?php
    


  } // end grid()
Beispiel #5
0
  public function delete_field() {

    if (!MasterPress::current_user_can("create_post_type_field_sets")) {
      wp_die(__("Sorry, you do not have the required capability to delete post type fields.", MASTERPRESS_DOMAIN));
    }

    $this->delete( array(
        "cap_verified" => true,
        "manage" => "manage-field-sets",
        "model" => "field",
      )
    );
    
  }
Beispiel #6
0
  public function edit($args = array()) {
    
    $model = null;

    $defaults = array(
      "init_model" => true,
      "view" => $this->view_key(), 
      "model" => $this->model_key(),
      "manage" => "manage",
      "title_args" => array(),
      "cap_verified" => false
    );

    $r = wp_parse_args($args, $defaults);

    if (!$r["cap_verified"] && !MasterPress::current_user_can($this->cap("edit"))) {
      wp_die(__("Sorry, you do not have the required capability to edit this item.", MASTERPRESS_DOMAIN));
    }


    MasterPress::$model_class = MasterPress::model_class($r["model"]);
    MasterPress::$view_class = MasterPress::view_class($r["view"]);

    $view_class = MasterPress::$view_class;
    $model_class = MasterPress::$model_class;

    MPV::incl($r["view"]);

    $manage = $r["manage"];
    
    if ($this->is_postback()) {
      
      $key = $this->key();
        
      if (isset($_REQUEST["return"])) {
        $key = $_REQUEST["return"];

        if ($key == "masterpress") {
          $key = "";
        } else {
          $key = str_replace("masterpress-", "", $key);
        }
      
      }
          
      if (apply_filters("mp_mpc_edit", $do = true)) {

        $model = $this->submit();
        MasterPress::$model = $model; 
      
        $valid = false;
      
        if ($model && is_object($model)) {
          $valid = $model->is_valid();
        } else {
          $valid = $model;
        } 
      
        if ( $valid ) {
          // hallelulah! we can now do proper redirects, rather than a fake action.
          // this prevents issues with refreshing the manage page after a save showing the form with "this item already exists"

          $qs = array("from" => MasterPress::$action);
        
          self::fill_redirect_parent($qs);

          if (is_object($model)) {
            $id = $model->id;
        
            if (isset($id)) {
              $qs["id"] = $id;
            }
          } else {
            $qs["id"] = MasterPress::$id;
          }
      
          if (isset($_REQUEST["mp_redirect"])) {
            wp_redirect( $_REQUEST["mp_redirect"] . "&def_updated=1" );
            exit;
          }
          
          wp_redirect( MasterPress::admin_url( $key, $manage, $qs, false ) );

          exit();
          return true;
        } else {
          if (is_object($model)) {
            $this->log_model_errors($model);
          }
        }
      
      } else {

        $qs = array( "id" => $_POST["id"], "from" => MasterPress::$action );

        self::fill_redirect_parent($qs);
        
        // submit disabled - simply redirect back to the manage screen
        wp_redirect( MasterPress::admin_url( $key, $manage, $qs, false ) );
        exit;
        
      } // apply_filters
      
    } else {
      
      if ($r["init_model"] && class_exists($model_class)) {
        $model = call_user_func_array( array($model_class, "find_by_id"), array(MasterPress::$id) );
        MasterPress::$model = $model;
      }
    }
      
    // set view variables

    $this->setup_view( 
      array(
        "view" => $r["view"],
        "title_args" => wp_parse_args($r["title_args"], array( "text" => MPV::__edit( call_user_func( array( $view_class, "__s" ) ) ), "actions" => "update", "info_panel" => false, "controller" => $this->key() )),
        "form" => true,
        "method" => "form",
        "method_args" => array( "type" => "edit" ),
      )
    );

    
    
  }
Beispiel #7
0
  public function grid() {

    MPC::incl("post-types");
    MPV::incl("fields");
    MPV::incl("post-types");
    
    $info = MasterPress::$view;
    
    $role_name = MasterPress::$parent;

    ?>
    
    <div class="title-info-panel">
      <div class="title-info-panel-lt">
        <h3><i class="user-role"></i><span class="label"><?php _e("User Role:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $role_name ?></span></h3> 
      </div>
    </div>
    

  
    <?php MPV::messages(); ?>
    
    <div class="grid-set">
    
    <?php $field_sets = MPM_RoleFieldSet::find_by_role( $role_name, "name" ); ?>

    <?php MPV::field_set_icon_styles($field_sets); ?>

    <?php
    
    $has_actions = MasterPress::current_user_can("edit_user_role_field_sets,delete_user_role_field_sets,edit_user_role_fields,delete_user_role_fields");

    $can_edit = MasterPress::current_user_can("edit_user_role_field_sets");
    $can_delete = MasterPress::current_user_can("delete_user_role_field_sets");
    $can_create = MasterPress::current_user_can("create_user_role_field_sets");

    $can_edit_fields = MasterPress::current_user_can("edit_user_role_fields");
    $can_delete_fields = MasterPress::current_user_can("delete_user_role_fields");
    $can_create_fields = MasterPress::current_user_can("create_user_role_fields");

    $less = ($can_create_fields) ? 1 : 0;

    $colspan = ( $has_actions ? 4 : 3 ) - $less;


    foreach ($field_sets as $field_set) {

      if (MPC::is_deleting($field_set->id, "delete-field-set")) {
        
        $this->confirm_delete($field_set);
        
      } else {
        
        foreach ($field_set->fields() as $field) {
          
          if (MPC::is_deleting($field->id, "delete-field")) {
            $this->confirm_delete_field($field);
          }
          
        }
        
      }
      
    }
    
    ?>
    
    <?php $fg_count = 0; ?>

    <?php if (count($field_sets)) : ?>

    <table cellspacing="0" class="grid grid-field-sets">

    <thead>
    <tr>
      <th class="first type"><i class="types"></i><span><?php _e("Type", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="label"><i class="label-string"></i><span><?php _e("Label", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="front-end-name <?php echo $has_actions ? "" : "last" ?>"><i class="script-php"></i><span><?php _e("Front End Name", MASTERPRESS_DOMAIN) ?></span></th>
      <?php if ($has_actions) : ?>
      <th class="actions last"><i class="buttons"></i><span><?php _e("Actions", MASTERPRESS_DOMAIN) ?></span></th>
      <?php endif; ?>
    </tr>
    </thead>
   
    <tbody>
   
    
    <?php foreach ($field_sets as $field_set) : $fg_count++; ?>  
      
    <?php 
    $display = $field_set->display_label(); 
    
      $display_td = $display;
      
      if ($field_set->icon != "") {
        $display_td = WOOF_HTML::tag("span", array("class" => "with-icon field-set-".$field_set->id), $display);
      }
    
    $deleting_class = MPC::is_deleting($field_set->id, "delete-field-set") ? 'deleting' : ''; 
    $editable_class = $can_edit ? " editable " : "";
    $meta = $can_edit ? "{ href: '".MasterPress::admin_url("roles", "edit-field-set", array("id" => $field_set->id, "parent" => $role_name) )."' }" : "";
    
    
    ?>
  
    <?php $disabled = $field_set->disabled ? "disabled" : ""; $title = $field_set->disabled ? ' title="'.__("this field set is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?>

    <?php
    if (!$field_set->in_current_site()) {
      $disabled = "disabled";
      $title = ' title="'.__("this field set is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" ';
    }
    ?>

    <tr <?php echo $title ?> class="<?php echo $disabled ?> <?php echo $editable_class.$deleting_class ?> <?php echo MPV::updated_class("edit-field-set,create-field-set", $field_set->id) ?> <?php echo $meta ?>">
      <?php if ($field_set->allow_multiple) : ?>
      <th class="first type icon"><i class="metabox-add-remove-large" title="<?php _e("Field Set (Multiple Items)", MASTERPRESS_DOMAIN) ?>"></i></th>
      <?php else : ?>
      <th class="first type icon"><i class="metabox-large" title="<?php _e("Field Set", MASTERPRESS_DOMAIN) ?>"></i></th>
      <?php endif; ?>
      <th class="label"><strong><?php echo $display_td ?></strong></th>
      <th class="front-end-name <?php echo $has_actions ? "" : "last" ?>"><span class="tt"><?php echo $field_set->display_name() ?></span></th>

      <?php if ($has_actions) : ?>
      
      <th class="actions last">
      <div>
      <?php if (MPC::is_deleting($field_set->id, "delete-field-set")) : ?>
        <span class="confirm-action">&nbsp;</span>
      <?php else: ?>
        <?php if ($can_edit) : ?>
          <?php echo MPV::action_button("roles", "edit-field-set", self::__edit(), array("id" => $field_set->id, "parent" => $role_name), array("class" => "button button-edit") ); ?>
        <?php endif; ?>

        <?php if ($can_delete) : ?>
          <?php echo MPV::action_button("roles", "delete-field-set", self::__delete(), array("id" => $field_set->id, "parent" => $role_name), array("class" => "button button-delete") ); ?>
        <?php endif; ?>
      <?php endif; ?>
      </div>
      </th>

      <?php endif; // has_actions ?>

    </tr>  
    
    <?php 
    
    $count = 0; 
    $fields = $field_set->fields();
    
    ?>
    
    <?php foreach ($fields as $field) : $count++; $first = $count == 1 ? 'first' : ''; $disabled = $field_set->disabled || $field->disabled ? "disabled" : ""; $title = $field_set->disabled ? ' title="'.__("this field is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?>

    <?php
    if (!$field_set->in_current_site() || !$field->in_current_site()) {
      $disabled = "disabled";
      $title = ' title="'.__("this field is not currenty available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" ';
    }
    ?>


    <?php 
    
    $deleting_class = MPC::is_deleting($field_set->id, "delete-field-set") || MPC::is_deleting($field->id, "delete-field") ? 'deleting' : ''; 
    $editable_class = $can_edit_fields ? " editable " : "";
    $meta = $can_edit ? "{ href: '".MasterPress::admin_url("roles", "edit-field", array("id" => $field->id, "gparent" => $_GET["parent"], "parent" => $field_set->id) )."' }" : "";

    ?>
      
    <?php if ($type_class = MPFT::type_class($field->type)) : ?>

    <tr <?php echo $title ?> class="sub <?php echo $editable_class.$deleting_class ?> <?php echo $disabled ?> <?php echo $first ?> <?php echo $count % 2 == 0 ? "even" : "" ?> <?php echo MPV::updated_class("edit-field,create-field", $field->id) ?> <?php echo $meta ?>">
      <td class="type icon first" title="<?php echo call_user_func( array($type_class, "__s") ) ?>"><span class="mp-icon mp-icon-field-type-<?php echo $field->type ?>"></span></td>
      <td class="label"><strong><?php echo $field->display_label() ?></strong></td>
      <td class="front-end-name <?php echo $has_actions ? "" : "last" ?>"><span class="tt"><span class="arrow">-&gt;&nbsp;</span><?php echo $field->display_name() ?></span></td>

      <?php if ($has_actions) : ?>

      <td class="actions last">
      <?php if (MPC::is_deleting($field->id, "delete-field")) : ?>
        <span class="confirm-action">&nbsp;</span>
      <?php else: ?>
      <div>
        <?php if ($can_edit_fields) : ?>
          <?php echo MPV::action_button("roles", "edit-field", self::__edit(), array("id" => $field->id, "gparent" => $_GET["parent"], "parent" => $field_set->id), array("class" => "button button-edit") ); ?>
        <?php endif; ?>

        <?php if ($can_delete_fields) : ?>
          <?php echo MPV::action_button("roles", "delete-field", self::__delete(), array("id" => $field->id, "gparent" => $_GET["parent"], "parent" => $role_name), array("class" => "button button-delete") ); ?>
        <?php endif; ?>

      </div>
      <?php endif; ?>

      </td>

      <?php endif; // has_actions ?>

    </tr>
    

    <?php endif; ?>
    
    <?php endforeach; ?>
  
    <tr class="summary <?php echo $can_create_fields ? "editable" : "" ?>">
      <?php if (count($fields)) : ?>
      <td colspan="<?php echo $colspan ?>" class="first <?php echo $can_create_fields ? "" : "last" ?>"><?php printf( __( "%s contains %s", MASTERPRESS_DOMAIN ), $display, MPU::__items( $field_set->field_count(), __("%d custom field", MASTERPRESS_DOMAIN), __("%d custom fields", MASTERPRESS_DOMAIN) ) ) ?></td>
      <?php else: ?>
      <td colspan="<?php echo $colspan ?>" class="hl first last"><span><?php printf( __( "<strong>%s</strong> is not yet active as it contains <em>no custom fields</em>. Click here to create one", MASTERPRESS_DOMAIN ), $field_set->display_label() ); ?></span></td>
      <?php endif; ?>

      <?php if ($can_create_fields) : ?>
      <td class="last actions <?php echo count($fields) ? "" : "hl" ?>">
      <?php echo MPV::action_button("roles", "create-field", self::__create(MPV_Fields::__s()), array("gparent" => $_GET["parent"], "parent" => $field_set->id), array("class" => "button create-field")  ); ?>
      </td>
      <?php endif; // can_create_fields ?>

    </tr>
    <tr class="gap <?php if ($fg_count == count($field_sets)) { echo "gap-last"; } ?>">
    <td colspan="4">&nbsp;</td>  
    </tr>
    
  
    <?php endforeach; ?>

    </tbody>
  
    </table>
  
    <?php if ($can_create) : ?>
    <div class="grid-foot-controls">
    <?php echo MPV::action_button("roles", "create-field-set", MPV::__create( MPV_RoleFieldSets::__s() ), array( "parent" => $role_name ) ); ?>
    </div>
    <?php endif; ?>
    
    <?php else: ?>
  
    <?php if ($can_create) : ?>
    <a href="<?php echo MasterPress::admin_url("roles", "create-field-set", array("parent" => MasterPress::$parent ) ) ?>" class="no-items-create">
	<i class="plus-circle"></i>
    <span><?php printf( __( "The '<em>%s</em>' role currently has <em>no field sets</em>. Click here to create one.", MASTERPRESS_DOMAIN ), $role_name  ) ?></span>
    </a>
    <?php endif; ?>
  
    <?php endif; ?>

    
    </div>
  

  
    <?php

  } // end grid()
Beispiel #8
0
	public static function init() {
    
    global $meow_provider;
    
    load_plugin_textdomain( MASTERPRESS_DOMAIN, false, "masterpress/languages" );
    
    do_action("mp_pre_init");

    self::$cap_mode = get_site_option("mp_cap", "standard");
    
    global $wf;
    
    global $wpdb;
    
    $snp = explode("/", $_SERVER["SCRIPT_NAME"]);
    
    self::$script = basename($snp[count($snp) - 1], ".php");
    
    
    // Register useful libraries separately, so they may be used by themes

    if (WP_DEBUG || MASTERPRESS_DEBUG) {
    
      // legacy picturefill
      wp_register_script('mp-matchmedia',      MASTERPRESS_URL.'js/src/matchmedia.js',                 array(), MASTERPRESS_VERSION);
      wp_register_script('mp-picturefill',     MASTERPRESS_URL.'js/src/picturefill.js',                array('jquery', 'mp-matchmedia'), MASTERPRESS_VERSION);
      

      wp_register_script('jquery-imageload', MASTERPRESS_URL.'js/src/jquery.imageload.js',             array('jquery'), MASTERPRESS_VERSION);
      // new jQuery picturefill
      wp_register_script('jquery-picturefill', MASTERPRESS_URL.'js/src/jquery.picturefill.js',         array('jquery', 'jquery-imageload'), MASTERPRESS_VERSION);

      wp_register_script('jquery-lazyload',    MASTERPRESS_URL.'js/src/jquery.lazyload.js',            array('jquery'), MASTERPRESS_VERSION);
      
      wp_register_script('jquery-fancybox',    MASTERPRESS_URL.'js/src/jquery.fancybox-1.3.4.js',      array('jquery'), MASTERPRESS_VERSION);
      wp_register_script('jquery-scroll-to',   MASTERPRESS_URL.'js/src/jquery.scroll-to.js',           array('jquery'), MASTERPRESS_VERSION);
      wp_register_script('jquery-metadata',    MASTERPRESS_URL.'js/src/jquery.metadata.js',            array('jquery'), MASTERPRESS_VERSION);
      wp_register_script('select2',            MASTERPRESS_URL.'js/src/select2.js',                    array('jquery'), MASTERPRESS_VERSION);
      
      wp_register_script('codemirror',         MASTERPRESS_URL.'js/src/codemirror.js',                 array(), MASTERPRESS_VERSION);
      wp_register_script('codemirror-modes',   MASTERPRESS_URL.'js/codemirror.modes.min.js',           array(), MASTERPRESS_VERSION);
      wp_register_script('mediaelement',      MASTERPRESS_URL.'js/src/mediaelement-and-player.js',     array(), MASTERPRESS_VERSION);
      wp_register_script('handlebars',         MASTERPRESS_URL.'js/src/handlebars-1.0.0.beta.6.js',    array(), MASTERPRESS_VERSION);
      wp_register_script('inflection',         MASTERPRESS_URL.'js/src/inflection.js',                 array(), MASTERPRESS_VERSION);
      wp_register_script('date-js',            MASTERPRESS_URL.'js/src/date.js',                       array(), MASTERPRESS_VERSION);
      
      wp_register_script('mp-iris',     	   MASTERPRESS_URL.'js/src/iris.js',                	   array('jquery', "jquery-ui-core", "jquery-ui-widget"), MASTERPRESS_VERSION);
    
    } else {

      // legacy picturefill (not enqueued)
      wp_register_script('mp-matchmedia',      MASTERPRESS_URL.'js/matchmedia.min.js',                 array(), MASTERPRESS_VERSION);
      wp_register_script('mp-picturefill',     MASTERPRESS_URL.'js/picturefill.min.js',                array('jquery', 'mp-matchmedia'), MASTERPRESS_VERSION);

      wp_register_script('jquery-imageload', MASTERPRESS_URL.'js/jquery.imageload.min.js',             array('jquery'), MASTERPRESS_VERSION);

      // new jQuery picturefill
      wp_register_script('jquery-picturefill', MASTERPRESS_URL.'js/jquery.picturefill.min.js',         array('jquery', 'jquery-imageload'), MASTERPRESS_VERSION);

      wp_register_script('jquery-lazyload',    MASTERPRESS_URL.'js/jquery.lazyload.min.js',            array('jquery'), MASTERPRESS_VERSION);

      wp_register_script('jquery-fancybox',    MASTERPRESS_URL.'js/jquery.fancybox-1.3.4.min.js',      array('jquery'), MASTERPRESS_VERSION);
      wp_register_script('jquery-scroll-to',   MASTERPRESS_URL.'js/jquery.scroll-to.min.js',           array('jquery'), MASTERPRESS_VERSION);
      wp_register_script('jquery-metadata',    MASTERPRESS_URL.'js/jquery.metadata.min.js',            array('jquery'), MASTERPRESS_VERSION);
      wp_register_script('select2',            MASTERPRESS_URL.'js/select2.min.js',                    array('jquery'), MASTERPRESS_VERSION);
      wp_register_script('date-js',            MASTERPRESS_URL.'js/date.min.js',                       array(), MASTERPRESS_VERSION);

      wp_register_script('mediaelement',       MASTERPRESS_URL.'js/mediaelement-and-player.min.js',    array(), MASTERPRESS_VERSION);
      wp_register_script('codemirror',         MASTERPRESS_URL.'js/codemirror.min.js',                 array(), MASTERPRESS_VERSION);
      wp_register_script('codemirror-modes',   MASTERPRESS_URL.'js/codemirror.modes.min.js',           array(), MASTERPRESS_VERSION);
      wp_register_script('handlebars',         MASTERPRESS_URL.'js/handlebars-1.0.0.beta.6.min.js',    array(), MASTERPRESS_VERSION);
      wp_register_script('inflection',         MASTERPRESS_URL.'js/inflection.min.js',                 array(), MASTERPRESS_VERSION);

      if (!self::has_iris()) {
        wp_register_script('mp-iris',     	   MASTERPRESS_URL.'js/iris.min.js',                	   array('jquery', "jquery-ui-core", "jquery-ui-widget"), MASTERPRESS_VERSION);
      }
    }
    
    
    wp_register_style('jquery-fancybox',       MASTERPRESS_URL.'css/fancybox.css',                    array(), MASTERPRESS_VERSION);
    wp_register_style('select2',               MASTERPRESS_URL.'css/select2.css',                     array(), MASTERPRESS_VERSION);
    wp_register_style('codemirror',            MASTERPRESS_URL.'css/codemirror.css',                  array(), MASTERPRESS_VERSION);
    wp_register_style('codemirror-themes',     MASTERPRESS_URL.'css/codemirror.themes.min.css',       array(), MASTERPRESS_VERSION);
    wp_register_style('mediaelement',          MASTERPRESS_URL.'css/mediaelementplayer.min.css',      array(), MASTERPRESS_VERSION);

    
    
    if ( is_admin() ) {

      // run an upgrade (if required)

      MasterPress::upgrade();

      if (defined('MASTERPRESS_NO_UPLOAD_DIR')) {

        MPV::err( 
          sprintf(  
            __( "<b>Important: </b>When trying to determine the location of your uploads directory, WordPress reported the following error: <code>%s</code>That is, your WordPress installation <b>does not currently contain a writable uploads directory</b>, so MasterPress will not function correctly as it cannot create its own required sub-folders.<br>To avoid further problems, you must correct this before creating or editing anything with MasterPress.<br>", MASTERPRESS_DOMAIN ),
            MASTERPRESS_NO_UPLOAD_DIR
          )
        );
        
      } else {
        self::create_directories();
      }
      
      add_action('admin_menu', array('MasterPress', 'admin_menu'));

      wp_enqueue_script("jquery-lazyload");
      wp_enqueue_script("jquery-imageload");
      wp_enqueue_script("jquery-picturefill");
      

      // Add filters for specific screens
      
      if (self::$script == "options-reading") {
        add_filter( 'get_pages',  array("MasterPress", 'add_front_page_supports' ) );
      }
      
      if (self::is_user_editor()) {
        add_filter( 'mce_external_plugins', array( "MasterPress", 'mce_plugins' ) );
        MPC::incl("user");
        add_action( 'show_user_profile', array("MPC_User", "field_sets" ));
        add_action( 'edit_user_profile', array("MPC_User", "field_sets" ));
      }
      
      if (self::is_term_editor() || self::is_term_manage()) {
        MPC::incl("term");
        if (isset($_GET["taxonomy"])) {
          $taxonomy = $_GET["taxonomy"];
        }
      }
      
      if (self::is_term_editor()) {
        add_filter( 'mce_external_plugins', array( "MasterPress", 'mce_plugins' ) );
        // add field UI hook
        add_action( $taxonomy."_edit_form_fields", array("MPC_Term", "field_sets"), 10, 2 );
      }

      if (self::is_term_manage()) {
        add_filter( 'mce_external_plugins', array( "MasterPress", 'mce_plugins' ) );
        // add field UI hook
        add_action( $taxonomy."_add_form_fields", array("MPC_Term", "field_sets"), 10, 2 );
      }
      
      if (self::is_site_content_editor()) {
        MPV::incl("meta");
        MPC::incl("meta");
        add_filter( 'mce_external_plugins', array( "MasterPress", 'mce_plugins' ) );
      }
      
      if (self::is_post_editor()) {
        add_filter( 'mce_external_plugins', array( "MasterPress", 'mce_plugins' ) );
			  add_action('add_meta_boxes', array('MPC_Post', 'post_editor_meta_boxes'));
        add_action('admin_init', array('MasterPress', 'admin_init'));
		  }

      if (self::is_post_manage()) {
        add_filter("manage_posts_columns", array("MPC_Post", "define_post_columns"));
        add_filter("manage_pages_columns", array("MPC_Post", "define_post_columns"));
        add_action("manage_posts_custom_column", array("MPC_Post", "post_column_content"));
        add_action("manage_pages_custom_column", array("MPC_Post", "post_column_content"));
        add_filter('parse_query', array("MPC_Post", "filter_manage_posts"));
        add_filter('request', array("MPC_Post", "request"));
        
        $meow_provider->set_optimize_mode( "post_list" );
        
      }
      
      
      // add save hooks
      
      add_action('edited_term', array("MPC_Meta", 'save_term_meta') );
      add_action('created_term', array("MPC_Meta", 'save_term_meta') );
      add_action('save_post', array("MPC_Meta", 'save_post_meta'));
      add_action('personal_options_update', array("MPC_Meta", 'save_user_meta'));
      add_action('edit_user_profile_update', array("MPC_Meta", 'save_user_meta'));
      

      add_action('save_post', array("MasterPress", 'save_post'));

      // add inline scripts
      
      add_action("admin_head", array("MasterPress", "inline_scripts"));
      add_action("admin_head", array("MasterPress", "inline_styles"));
      add_action("admin_head", array("MasterPress", "inline_meta"));

    }

    

    // cache the list of all post types
    
    
    $args = array();
    
    if (is_admin()) {
      // only order by menu positions in the admin, as the order doesn't matter on the front-end (slightly faster)
      $args = array("orderby" => "menu_position,menu_sub_position");
    }

    $post_types = MPM_PostType::find($args);
    
    MasterPress::$post_types = array();

    foreach ($post_types as $post_type) {
      MasterPress::$post_types[$post_type->name] = $post_type;
    }

    $taxonomies = MPM_Taxonomy::find( );

    MasterPress::$all_taxonomies = array();
    
    MasterPress::$taxonomies = array();
    
    foreach ($taxonomies as $tax) {
      if (!$tax->disabled) {
        MasterPress::$taxonomies[$tax->name] = $tax;
      }

      MasterPress::$all_taxonomies[$tax->name] = $tax;
    
    }
    

    // create necessary file directories
    
    if (is_admin()) {
    
      $combine = false;
      
      // check for a querystring force
      if (isset($_GET["mpft"])) {
        $combine = true;
      }
      
      // check if debug mode had been switched on, then off (javascript "make" still needs to be run manually)

      $opt_debug = get_option("mp_debug");
      
      if (!MASTERPRESS_DEBUG && $opt_debug != MASTERPRESS_DEBUG) {
        $combine = true;
      }

      if ($opt_debug != MASTERPRESS_DEBUG) {
        update_option("mp_debug", MASTERPRESS_DEBUG);
      }

      if (!file_exists(MASTERPRESS_CONTENT_MPFT_CACHE_DIR."mpft-all.css")) {
        $combine = true;
      }

      if (!file_exists(MASTERPRESS_CONTENT_MPFT_CACHE_DIR."mpft-all.js")) {
        $combine = true;
      }
      

      if ($combine) {
        MPU::combine_type_styles();
        MPU::combine_type_scripts();
      }
      
    }
  

    if (self::is_term_manage()) {
      
      MPC::incl("term");

      add_filter('get_terms_args', array("MPC_Term", "filter_manage_terms"));

      foreach (MasterPress::$taxonomies as $tax) {
        add_filter('manage_edit-'.$tax->name.'_columns', array("MPC_Term", "define_term_columns"));
        add_action('manage_'.$tax->name.'_custom_column', array("MPC_Term", "term_column_content"), 10, 3);
      }
    
    }

    // register post types based on database entries

    do_action('mp_pre_register_post_types');

    self::register_post_types();

    do_action('mp_register_post_types');

    // register taxonomies based on database entries

    do_action('mp_pre_register_taxonomies');

    self::register_taxonomies();

    do_action('mp_pre_register_taxonomies');

    // patch template support
    
    self::register_template_support();
    
    
    do_action('mp_register');

    // look for externally defined post types, and insert models for them in MasterPress.
    
    $reg_post_types = $wf->post_types();

    $rpt_keys = array();
    $pt_keys = array();
	
    foreach ($reg_post_types as $rpt) {
      if (!is_woof_silent($rpt)) {
        $rpt_keys[$rpt->name] = $rpt;
      }
    }
    
    foreach ($post_types as $pt) {
      $pt_keys[$pt->name] = $pt;
    }
    
    $ignore_keys = array("revision", "nav_menu_item");
    
    foreach ($rpt_keys as $key => $pt) {
      
      if (!isset($pt_keys[$key]) && !in_array($key, $ignore_keys)) {

        // create an external post type database entry
        
        $ept = new MPM_PostType();
        
        // ensure that unknown properties return "null", not "WOOF_Silent"
        $pt->set_property_mode("standard");
        
        $ept->set(      
          array( 
            "name" => $pt->name,
            "plural_name" => WOOF_Inflector::pluralize($pt->name),
            "disabled" => false,
            "labels" => $pt->labels,
            "description" => "",
            "publicly_queryable" => (bool) $pt->publicly_queryable,
            "exclude_from_search" => (bool) $pt->exclude_from_search,
            "show_ui" => (bool) $pt->show_ui,
            "show_in_menu" => (bool) $pt->show_in_menu,
            "menu_position" => (int) $pt->menu_position,
            "menu_sub_position" => 0,
            "menu_icon" => isset($pt->menu_icon) ? $pt->menu_icon : "",
            "manage_sort_order" => "post_date|desc",
            "capability_type" => $pt->capability_type,
            "capabilities" => $pt->cap_array(),
            "map_meta_cap" => (bool) $pt->map_meta_cap,
            "hierarchical" => (bool) $pt->hierarchical,
            "supports" => implode(",", $pt->supports_keys()),
            "permalink_epmask" => $pt->permalink_epmask,
            "has_archive" => (bool) $pt->has_archive,
            "rewrite" => $pt->rewrite,
            "query_var" => $pt->query_var,
            "can_export" => $pt->can_export,
            "show_in_nav_menus" => $pt->show_in_nav_menus,
            "_builtin" => false,
            "_external" => true,
            "visibility" => array("sites" => "*") 
          )
        );
        
        $ept->insert();
        
        
        
      }
    }
    
    // look for externally defined taxonomies, and insert models for them in MasterPress.
    
    $reg_tax = $wf->taxonomies();

    $rt_keys = array();
    $t_keys = array();

    foreach ($reg_tax as $tax) {
      $rt_keys[$tax->name] = $tax;
    }
    
    foreach ($taxonomies as $tax) {
      $t_keys[$tax->name] = $tax;
    }
    
    $ignore_keys = array("nav_menu", "link_category", "post_format");
    
    foreach ($rt_keys as $key => $tax) {
      if (!isset($t_keys[$key]) && !in_array($key, $ignore_keys)) {

        // create an external post type database entry
        
        $et = new MPM_Taxonomy();
        
        // ensure that unknown properties return "null", not "WOOF_Silent"
        $tax->set_property_mode("standard");
        
        
        $et->set(      
          array( 
            "name" => $tax->name,
            "plural_name" => WOOF_Inflector::pluralize($tax->name),
            "labels" => $tax->labels,
            "disabled" => false,
            "show_in_nav_menus" => (bool) $tax->show_in_nav_menus,
            "show_ui" => (bool) $tax->show_ui,
            "show_tagcloud" => (bool) $tax->show_tagcloud,
            "hierarchical" => (bool) $tax->hierarchical,
            "rewrite" => $tax->rewrite,
            "update_count_callback" => $tax->update_count_callback,
            "query_var" => $tax->query_var,
            "capabilities" => $tax->cap_array(),
            "object_type" => $tax->object_type,
            "_builtin" => false,
            "_external" => true
          )
        );

        $et->insert();
        
      }
    }
    

    
    if (is_admin()) {
      self::dispatch();
    }
    
    foreach ($wf->types() as $type) {
      if ($type->supports("top-level-slugs")) {
        add_filter("woof_".$type->name."_permalink", array("MasterPress", "woof_permalink"), 100, 2);
      }
    }
    
    // if anyone rewrites URLs, add ours to the queue
    add_filter( 'rewrite_rules_array', array("MasterPress", 'add_rewrite_rules' ));

    do_action('mp_rewrite_rules');
    do_action('mp_pre_flush_rewrite_rules');

    add_rewrite_tag("%mp_rest_endpoint%", '([^&]+)');

    if (is_admin()) {
      // flush rewrite rules (only if marked as needed)
      MasterPress::flush_rewrite_rules();
    }
  
    if (is_admin() && MasterPress::current_user_can("manage_mp_tools")) {
      self::tools_actions();
    }
    
    do_action('mp_init');

  }
Beispiel #9
0
  public function grid($id = null) {

    MPV::incl("field-sets");
    MPV::incl("fields");
    MPV::incl("taxonomies");
    MPC::incl("taxonomies");
    

    $has_actions = MasterPress::current_user_can("edit_templates,delete_templates,manage_template_field_sets");
    $can_edit = MasterPress::current_user_can("edit_templates");
    $can_delete = MasterPress::current_user_can("delete_templates");
    $can_create = MasterPress::current_user_can("create_templates");
    $can_manage_field_sets = MasterPress::current_user_can("manage_template_field_sets");

    $colspan = $has_actions ? 8 : 7;

    
  ?>


  <?php MPV::messages(); ?>
  
  <table cellspacing="0" class="grid grid-post-types">
    <thead>
    <tr>
      <th class="first file-name front-end-name"><i class="script-php"></i><span><?php _e("File Name", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="name"><i class="template"></i><span><?php _e("Template Name", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="field-sets"><i class="metaboxes"></i><span><?php _e("Field Sets", MASTERPRESS_DOMAIN) ?></span></th>
      <th class="post-types <?php echo $has_actions ? "" : "last" ?>"><i class="pins"></i><span><?php _e("Post Types", MASTERPRESS_DOMAIN) ?></span></th>
      <?php if ($has_actions) : ?>
      <th class="actions last"><i class="buttons"></i><span><?php _e("Actions", MASTERPRESS_DOMAIN) ?></span></th>
      <?php endif; ?>
    </tr>
    </thead>
    <tbody>
     
    <?php $count = 0; $disabled = ""; ?>
    
    <?php $templates = get_page_templates();  ?>
    
    <?php foreach ($templates as $template => $file) : $count++; $first = $count == 1 ? 'first' : ''; $model = MPM_Template::find_by_id($file);
    
    
    $editable_class = $can_edit ? " editable " : "";
    $meta = $can_edit ? "{ href: '".MasterPress::admin_url("templates", "edit", "id=".$file)."' }" : "";


    ?>
    
    <tr class="<?php echo $first ?> <?php echo $editable_class.$disabled ?> <?php echo MPV::updated_class("edit,create", $file) ?> <?php echo $count % 2 == 0 ? "even" : "" ?> sub <?php echo $meta ?>">
      <td class="first file-name"><strong><span class="tt"><?php echo $file ?></span></strong></td>
      <td class="name"><?php echo $template ?></td>
      <td class="field-sets <?php echo $can_manage_field_sets ? "manage" : "" ?>">
        <?php if ($can_manage_field_sets) : ?>
        <a href="<?php echo MasterPress::admin_url( "templates", "manage-field-sets", "parent=".$file)?>">
		<i class="go"></i>
        <?php endif; ?>
        
        <?php 
        
        $field_sets = MPM_TemplateFieldSet::find_by_template( $file ); 

        $field_set_display = MPV::note_none();
        
        if (count($field_sets)) {
          $field_set_links = array();
          
          foreach ($field_sets as $field_set) {
            if (!$field_set->is_shared()) {
              $field_set_links[] =  $field_set->display_label();
            }
          }

          if (count($field_set_links)) {
            $field_set_display = implode($field_set_links, ", ");
          }
        
        }
        
        echo $field_set_display;
        ?>
        <?php if ($can_manage_field_sets) : ?>
        </a>
        <?php endif; ?>

      </td>
      
      <td class="post-types <?php echo $has_actions ? "" : "last" ?>">
        
        <?php 
        
        $vis = $model->visibility;
        
        $vis_post_types = "";

        if (isset($vis["post_types"])) {
          $vis_post_types = $vis["post_types"];
        }
        
        if ($vis_post_types == "*") {

          $post_type_display = '<span class="inherit">( '.__("All", MASTERPRESS_DOMAIN).' )</span>';

        } else {
          
          if (is_null($vis_post_types) || $vis_post_types == "") {
          
            $post_type_display = __("( none )");
          
          } else {
            $post_types = $model->post_types(); 
          
            $post_type_display = MPV::note_none();
        
            if (count($post_types)) {
              $post_type_links = array();
          
              foreach ($post_types as $post_type) {
                $post_type_links[] = $post_type->labels["name"];
              }

              $post_type_display = implode($post_type_links, ", ");
            }
          }
        }
        
        echo $post_type_display;
          
        ?>
        
      </td>

      <?php if ($has_actions) : ?>

      <td class="actions last">
      <div>
        <?php if ($can_edit) : ?>
          <?php echo MPV::action_button("templates", "edit", self::__edit( ), "id=".$file, array("class" => "button button-edit")); ?>
        <?php endif; ?>

        <?php if ($can_manage_field_sets) : ?>
          <?php echo MPV::action_button("templates", "manage-field-sets", self::__manage( MPV_FieldSets::__p_short() ), "parent=".$file, array("class" => "button button-manage")); ?>
        <?php endif; ?>  
      </div>
      </td>

      <?php endif; // has_actions ?>

    </tr>
    
    <?php endforeach; ?>

    </tbody>
    </table>
    
    <?php
    
  } // end grid()
Beispiel #10
0
  function manage() {
    
    global $wf;
    
    ?>

    <?php MPV::messages() ?>
  
    <?php

    MPV::incl("post-types");
    MPV::incl("shared-field-sets");
    MPV::incl("templates");
    MPV::incl("taxonomies");
    MPV::incl("roles");
  
    $disabled = "";
  
    $view = MasterPress::$view;
    
    $post_types = MPM_PostType::find("orderby=disabled,name ASC");
    $taxonomies = MPM_Taxonomy::find("orderby=disabled,name ASC");
    $shared_field_sets = MPM_SharedFieldSet::find("orderby=disabled,name ASC");
    $templates = get_page_templates();
    $site_field_sets = MPM_SiteFieldSet::find("orderby=disabled,name ASC"); 
    $roles = $wf->roles(); 

    ?>

    <div class="fs fs-masterplan fs-with-tabs">
    
        
      <div class="fsc">
      <div class="fscb">
        
        <?php
            $tab = "";
            
            if (isset($_REQUEST["tab"])) {
              $tab = $_REQUEST["tab"];
            }
          ?>

          <?php 
            
            // check for restoreable backups

            
            $backups = array();
            
            if (file_exists(MASTERPRESS_CONTENT_MASTERPLANS_DIR)) {

            $iterator = new DirectoryIterator(MASTERPRESS_CONTENT_MASTERPLANS_DIR);
            
            foreach ($iterator as $file) {

              $file_name = $file->getFileName();
    
              if (substr($file_name, 0, 1) == ".") {
                continue;
              }
              
              if (preg_match("/\_backup\.(?:(.*)\.)?([0-9]+)\.masterplan\.zip/", $file_name, $matches)) {
                
                $tag = $matches[1];
                $date = $matches[2];
                
                $fdate = $wf->date_format("[date-time-long]", strtotime($date));
                
                $label = $fdate;
                
                if ($tag != "") {
                  $label = $fdate." ( ".$tag." )";
                }
                
                $backups[] = array("file" => $file_name, "label" => $label);
                
                
              }
              
            }
            
            }
          
          ?>
          
        <ul class="fs-tabs">
          <li><a href="#masterplan-overview" class="<?php echo $tab != '' ? '' : 'current' ?>"><span><i class="info"></i>Overview</span></a></li>
          <?php if (MasterPress::current_user_can("export_masterplan")) : ?>
          <li><a href="#masterplan-export" class="<?php echo $tab == "export" ? 'current' : '' ?>"><span><i class="arrow-curve-right"></i>Export</span></a></li>
          <?php endif; ?>
          <?php if (MasterPress::current_user_can("import_masterplan")) : ?>
          <li><a href="#masterplan-import" class="<?php echo $tab == "import" ? 'current' : '' ?>"><span class="import"><i class="arrow-curve-left"></i>Import</span></a></li>
          <?php endif; ?>
          <?php if (MasterPress::current_user_can("backup_masterplan")) : ?>
          <li><a href="#masterplan-backup" class="<?php echo $tab == "backup" ? 'current' : '' ?>"><span class="backup"><i class="buoy"></i>Backup</span></a></li>
          <?php endif; ?>
          <?php if (count($backups)) : ?>
          <?php if (MasterPress::current_user_can("restore_masterplan")) : ?>
          <li><a href="#masterplan-restore" class="<?php echo $tab == "restore" ? 'current' : '' ?>"><span class="restore"><i class="clock-history"></i>Restore</span></a></li>
          <?php endif; ?>
          <?php endif; ?>
        </ul>
    
<!-- OVERVIEW -->


        <div id="masterplan-overview" class="tab-panel <?php echo $tab != '' ? '' : 'current' ?>">
          
          <?php if (isset($_GET["import-complete"])) : ?>
          
          <ul class="mp-messages">
            <li class="success"><?php _e("Import Complete - your new site Masterplan is shown below.", MASTERPRESS_DOMAIN) ?></li>
          </ul>
          
          <?php endif; ?>

          <?php if (isset($_GET["restore-complete"])) : ?>
          
          <ul class="mp-messages">
            <li class="success"><?php _e("Restore Complete - your site Masterplan is shown below.", MASTERPRESS_DOMAIN) ?></li>
          </ul>
          
          <?php endif; ?>
        
          <div class="row first-row">
          
            <div class="col post-types">
            
              <?php 
              
              $count = 0;
              
              foreach ($post_types as $post_type) { 
                if ($post_type->still_registered()) {
                  $count++;
                }
              }
              
              ?>
                
              <h4><i class="pin"></i>
              <?php if (MasterPress::current_user_can("manage_post_types")) : ?>
              <a href="<?php echo MasterPress::admin_url("post-types", "manage") ?>" title="<?php _e("Manage Post Types", MASTERPRESS_DOMAIN) ?>" class="icon">
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>
              
              <?php echo WOOF::items_number( $count, __("<em>No</em> Post Types", MASTERPRESS_DOMAIN), __("<b>%d</b> Post Type", MASTERPRESS_DOMAIN), __("<b>%d</b> Post Types", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_post_types")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
            
              <div class="body">
              
                <ul class="count-<?php echo $count ?>">
                <?php foreach ($post_types as $post_type) : $default_icon = $post_type->menu_icon_exists() ? "" : "default-icon"; $field_sets = $post_type->post_type_field_sets(); $fsc = count($field_sets); $disabled = $post_type->disabled ? 'disabled ' : ''; $disabled_title = $post_type->disabled ? __('This post type is currently disabled', MASTERPRESS_DOMAIN) : ''; ?>
                  
                <?php if ($post_type->still_registered()) : ?>
                <li class="<?php echo $disabled ?>post-type-<?php echo $post_type->name ?> <?php echo $default_icon ?> linkify" data-name="<?php echo $post_type->name ?>" title="<?php echo $disabled_title ?>">
                  
                  <?php if (MasterPress::current_user_can("manage_post_types+edit_post_types")) : ?>
                  <a href="<?php echo MasterPress::admin_url("post-types", "edit", "id=".$post_type->id) ?>" class="item mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>">
                  <?php else: ?>
                  <div class="item mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>">  
                  <?php endif; ?>
                  
                  <?php echo WOOF::truncate($post_type->display_label(), "length=15&words=0") ?>

                  <?php if (MasterPress::current_user_can("manage_post_types+edit_post_types")) : ?>
                  </a>
                  <?php else: ?>
                  </div>  
                  <?php endif; ?>
                  
                  <?php if (MasterPress::current_user_can("manage_post_types+manage_post_type_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("post-types", "manage-field-sets", "parent=".$post_type->id) ?>" title="<?php _e("Manage Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></a>
                  <?php else : ?>
                  <div title="<?php _e("Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></div>
                  <?php endif; ?>
                    
                  <?php foreach ($post_type->taxonomies() as $tax) : ?> 
                  <span class="tax-link-<?php echo $tax->name ?> related-link asterisk"></span>
                  <?php endforeach; ?>

                  <?php foreach ($post_type->field_sets() as $fs) : ?>
                  <?php if ($fs->is_shared()) : ?>
                  <span class="shared-field-set-link-<?php echo $fs->name ?> related-link asterisk"></span>
                  <?php endif; ?>
                  <?php endforeach; ?>


                </li>
                <?php endif; ?>

                <?php endforeach; ?>
                
                <?php if (MasterPress::current_user_can("create_post_types")) : ?>
                <li class="divide"><a href="<?php echo MasterPress::admin_url("post-types", "create") ?>" class="create-link"><i></i><?php echo MPV::__create( MPV_PostTypes::__s() ) ?></a></li>
                <?php endif; ?>

                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->
          
          
            <div class="col taxonomies">
            
              <?php 
              
              $count = 0;
              
              foreach ($taxonomies as $tax) { 
                if ($tax->still_registered()) {
                  $count++;
                }
              }
              
              ?>
              
              <h4><i class="tag"></i>
              <?php if (MasterPress::current_user_can("manage_taxonomies")) : ?>
              <a href="<?php echo MasterPress::admin_url("taxonomies", "manage") ?>" title="<?php _e("Manage Taxonomies", MASTERPRESS_DOMAIN) ?>" class="icon">              
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>
              
              <?php echo WOOF::items_number( $count, __("<em>No</em> Taxonomies", MASTERPRESS_DOMAIN), __("<b>%d</b> Taxonomy", MASTERPRESS_DOMAIN), __("<b>%d</b> Taxonomies", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_taxonomies")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
              
              <div class="body">
              
                <ul class="count-<?php $count ?>">
                <?php foreach ($taxonomies as $tax) : $field_sets = $tax->taxonomy_field_sets(); $fsc = count($field_sets); $disabled = $tax->disabled ? 'disabled ' : ''; $disabled_title = $tax->disabled ? __('This taxonomy is currently disabled', MASTERPRESS_DOMAIN) : ''; ?>
                
                <?php if ($tax->still_registered()) : ?>

                <li class="<?php echo $disabled ?> linkify" data-name="<?php echo $tax->name ?>" title="<?php echo $disabled_title ?>">
                  
                  <?php if (MasterPress::current_user_can("manage_taxonomies+edit_taxonomies")) : ?>
                  <a href="<?php echo MasterPress::admin_url("taxonomies", "edit", "id=".$tax->id) ?>" class="item mp-icon-taxonomy mp-icon-taxonomy-<?php echo $tax->name ?>">
                  <?php else: ?>
                  <div class="item mp-icon-taxonomy mp-icon-taxonomy-<?php echo $tax->name ?>">  
                  <?php endif; ?>
                  
                  <?php echo WOOF::truncate($tax->display_label(), "length=15&words=0") ?>
                  
                  <?php if (MasterPress::current_user_can("manage_taxonomies+edit_taxonomies")) : ?>
                  </a>
                  <?php else: ?>
                  </div>  
                  <?php endif; ?>
                  
                  
                  <?php if (MasterPress::current_user_can("manage_taxonomies+manage_taxonomy_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("taxonomies", "manage-field-sets", "parent=".$tax->id) ?>" title="<?php _e("Manage Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></a>
                  <?php else : ?>
                  <div title="<?php _e("Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></div>
                  <?php endif; ?>


                  <?php foreach ($tax->post_types() as $pt) : ?> 
                  <span class="post-type-link-<?php echo $pt->name ?> related-link asterisk"></span>
                  <?php endforeach; ?>

                  <?php foreach ($tax->field_sets() as $fs) : ?>
                  <?php if ($fs->is_shared()) : ?>
                  <span class="shared-field-set-link-<?php echo $fs->name ?> related-link asterisk"></span>
                  <?php endif; ?>
                  <?php endforeach; ?>
                
                </li>
                
                <?php endif; ?>

                <?php endforeach; ?>
                
                <?php if (MasterPress::current_user_can("create_taxonomies")) : ?>
                <li class="divide"><a href="<?php echo MasterPress::admin_url("taxonomies", "create") ?>" class="create-link"><i></i><?php echo MPV::__create( MPV_Taxonomies::__s() ) ?></a></li>
                <?php endif; ?>
                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->
          
            <div class="col field-sets shared-field-sets">
            
            
              <h4><i class="metabox-share"></i>
              <?php if (MasterPress::current_user_can("manage_shared_field_sets")) : ?>
              <a href="<?php echo MasterPress::admin_url("shared-field-sets", "manage") ?>" title="<?php _e("Manage Shared Field Sets", MASTERPRESS_DOMAIN) ?>" class="icon">              
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>
              
              <?php echo WOOF::items_number( count($shared_field_sets), __("<em>No</em> Shared Field Sets", MASTERPRESS_DOMAIN), __("<b>%d</b> Shared Field Set", MASTERPRESS_DOMAIN), __("<b>%d</b> Shared Field Sets", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_shared_field_sets")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
            
              <div class="body">
              
                <ul class="count-<?php echo count($shared_field_sets) ?>">
                <?php foreach ($shared_field_sets as $field_set) : $multiple = $field_set->allow_multiple ? "allow-multiple" : ''; $disabled = $field_set->disabled ? 'disabled ' : ''; $disabled_title = $field_set->disabled ? __('This shared field set is currently disabled', MASTERPRESS_DOMAIN) : ''; ?>
                <li class="<?php echo $disabled ?>shared-field-set-<?php echo $field_set->name ?> linkify" data-name="<?php echo $field_set->name ?>" title="<?php echo $disabled_title ?>">



                  <?php if (MasterPress::current_user_can("manage_shared_field_sets+edit_shared_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("shared-field-sets", "edit", "id=".$field_set->id) ?>" title="<?php _e("Edit Shared Field Set", MASTERPRESS_DOMAIN) ?>" class="item <?php echo $multiple ?>">
                  <?php else: ?>
                  <div class="item <?php echo $multiple ?>">  
                  <?php endif; ?>

                  <?php if ($multiple) : ?>
                  <i class="metabox-add-remove"></i>
                  <?php else : ?>
                  <i class="metabox"></i>
                  <?php endif; ?>
                  
                  <?php echo $field_set->display_label() ?></a>
                  
                  <?php if (MasterPress::current_user_can("manage_shared_field_sets+edit_shared_field_sets")) : ?>
                  </a>
                  <?php else: ?>
                  </div>
                  <?php endif; ?>
                
                  <?php foreach ($field_set->post_types() as $post_type) : ?> 
                  <span class="post-type-link-<?php echo $post_type->name ?> related-link asterisk"></span>
                  <?php endforeach; ?>

                  <?php foreach ($field_set->taxonomies() as $tax) : ?> 
                  <span class="tax-link-<?php echo $tax->name ?> related-link asterisk"></span>
                  <?php endforeach; ?>
                
                  <?php foreach ($field_set->roles() as $role) : ?> 
                  <span class="role-link-<?php echo $role->id ?> related-link asterisk"></span>
                  <?php endforeach; ?>
                
                </li>
                <?php endforeach; ?>
                
                <?php if (MasterPress::current_user_can("create_shared_field_sets")) : ?>
                <li class="divide"><a href="<?php echo MasterPress::admin_url("shared-field-sets", "create") ?>" class="create-link"><i></i><?php echo MPV::__create( MPV_SharedFieldSets::__s() ) ?></a></li>
                <?php endif; ?>

                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->
          
          
          </div>
          <!-- /.row -->
        
          <div class="row">
          
          
          
            <div class="col templates">

              <h4><i class="template"></i>
              <?php if (MasterPress::current_user_can("manage_templates")) : ?>
              <a href="<?php echo MasterPress::admin_url("templates", "manage") ?>" title="<?php _e("Manage Templates", MASTERPRESS_DOMAIN) ?>" class="icon">              
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>
              
              <?php echo WOOF::items_number( count($templates), __("<em>No</em> Templates", MASTERPRESS_DOMAIN), __("<b>%d</b> Template", MASTERPRESS_DOMAIN), __("<b>%d</b> Templates", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_templates")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
              
              
              <div class="body">
              
                <ul class="count-<?php echo count($templates) ?>">
                <?php $count = 0; ?>
                <?php foreach ($templates as $template => $file) : $count++; 
              
                $fsc = count(MPM_TemplateFieldSet::find_by_template( $file ));
              
                ?>
                <li class="linkify" data-name="<?php echo $file ?>">

                  <?php if (MasterPress::current_user_can("manage_templates+edit_templates")) : ?>
                  <a href="<?php echo MasterPress::admin_url("templates", "edit", "id=".$file) ?>" class="item">
                  <?php else: ?>
                  <div class="item">  
                  <?php endif; ?>
                  
                  <?php echo WOOF::truncate($template, "length=20&words=0") ?>
                  
                  <?php if (MasterPress::current_user_can("manage_templates+edit_templates")) : ?>
                  </a>
                  <?php else: ?>
                  </div>  
                  <?php endif; ?>
                  
                  
                  <?php if (MasterPress::current_user_can("manage_templates+manage_template_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("templates", "manage-field-sets", "parent=".$file) ?>" title="<?php _e("Manage Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></a>
                  <?php else : ?>
                  <div title="<?php _e("Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></div>
                  <?php endif; ?>
                  
                </li>
                <?php endforeach; ?>
                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->
          
            <div class="col field-sets site-field-sets">
            
              <h4><i class="sitemap"></i>
              <?php if (MasterPress::current_user_can("manage_site_field_sets")) : ?>
              <a href="<?php echo MasterPress::admin_url("site-field-sets", "manage") ?>" title="<?php _e("Manage Site Field Sets", MASTERPRESS_DOMAIN) ?>" class="icon">
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>
              
              <?php echo WOOF::items_number( count($site_field_sets), __("<em>No</em> Site Field Sets", MASTERPRESS_DOMAIN), __("<b>%d</b> site Field Set", MASTERPRESS_DOMAIN), __("<b>%d</b> site Field Sets", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_site_field_sets")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
              
              <div class="body">
              
                <ul class="count-<?php echo count($site_field_sets) ?>">
                <?php foreach ($site_field_sets as $field_set) : $multiple = $field_set->allow_multiple ? "allow-multiple" : '';  $disabled = $field_set->disabled ? 'disabled ' : ''; $disabled_title = $field_set->disabled ? __('This site field set is currently disabled', MASTERPRESS_DOMAIN) : ''; ?>
                <li class="<?php echo $disabled ?>site-field-set-<?php echo $field_set->name ?> linkify" data-name="<?php echo $field_set->name ?>" title="<?php echo $disabled_title ?>">

                  <?php if (MasterPress::current_user_can("manage_site_field_sets+edit_site_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("site-field-sets", "edit", "id=".$field_set->id) ?>" title="<?php _e("Edit Site Field Set", MASTERPRESS_DOMAIN) ?>" class="item <?php echo $multiple ?>">
                  <?php else: ?>
                  <div class="item <?php echo $multiple ?>">  
                  <?php endif; ?>

                  <?php if ($multiple) : ?>
                  <i class="metabox-add-remove"></i>
                  <?php else : ?>
                  <i class="metabox"></i>
                  <?php endif; ?>

                  <?php echo $field_set->display_label() ?></a>
                  
                  <?php if (MasterPress::current_user_can("manage_site_field_sets+edit_site_field_sets")) : ?>
                  </a>
                  <?php else: ?>
                  </div>
                  <?php endif; ?>
                  

                </li>
                <?php endforeach; ?>
                <?php if (MasterPress::current_user_can("create_site_field_sets")) : ?>
                <li class="divide"><a href="<?php echo MasterPress::admin_url("site-field-sets", "create") ?>" class="create-link"><i></i><?php echo MPV::__create( __("Site Field Set", MASTERPRESS_DOMAIN) ) ?></a></li>
                <?php endif; ?>
                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->

            <div class="col roles">

              <h4><i class="user"></i>
              <?php if (MasterPress::current_user_can("manage_user_roles")) : ?>
              <a href="<?php echo MasterPress::admin_url("roles", "manage") ?>" title="<?php _e("Manage User Roles", MASTERPRESS_DOMAIN) ?>" class="icon">              
              <?php else : ?>
              <span class="icon">
              <?php endif; ?>

              <?php echo WOOF::items_number( count($roles), __("<em>No</em> User Roles", MASTERPRESS_DOMAIN), __("<b>%d</b> User Role", MASTERPRESS_DOMAIN), __("<b>%d</b> User Roles", MASTERPRESS_DOMAIN) ) ?>
              
              <?php if (MasterPress::current_user_can("manage_user_roles")) : ?>
              </a>
              <?php else : ?>
              </span>
              <?php endif; ?>
              </h4>
              
              
              <div class="body">
                
                <?php
                
                // cap checking has side-effects to the roles collection, causing an infinite loop. We need to cache the info here
                
                $role_cache = array();
                
                foreach ($roles as $role) {
                  $role_cache[] = array("name" => $role->name(), "id" => $role->id());
                  
                
                }
                
                ?>
                
                <ul class="count-<?php echo count($roles) ?>">
                <?php foreach ($role_cache as $role) : $count++; 
                $fsc = count(MPM_RoleFieldSet::find_by_role( $role["id"] ));
                ?>
                <li class="linkify" data-name="<?php echo $role["id"] ?>">
                  
                  <?php if (MasterPress::current_user_can("manage_user_roles+edit_user_roles")) : ?>
                  <a href="<?php echo MasterPress::admin_url("roles", "edit", "id=".$role["id"]) ?>" class="item">
                  <?php else: ?>
                  <div class="item">  
                  <?php endif; ?>
                                
                  <i class="user-role"></i>

                  <?php echo WOOF::truncate($role["name"], "length=20&words=0") ?>
                  
                  <?php if (MasterPress::current_user_can("manage_user_roles+edit_user_roles")) : ?>
                  </a>
                  <?php else: ?>
                  </div>  
                  <?php endif; ?>
                  
                  
                  <?php if (MasterPress::current_user_can("manage_user_roles+manage_user_role_field_sets")) : ?>
                  <a href="<?php echo MasterPress::admin_url("roles", "manage-field-sets", "parent=".$role["id"]) ?>" title="<?php _e("Manage Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></a>
                  <?php else : ?>
                  <div title="<?php _e("Field Sets", MASTERPRESS_DOMAIN) ?>" class="field-sets count-<?php echo $fsc ?>"><?php echo $fsc ?></div>
                  <?php endif; ?>
                  
                  
                  <?php foreach ($shared_field_sets as $fs) : ?>
                  <?php if ($fs->visible_in("roles", $role["id"])) : ?>
                  <span class="shared-field-set-link-<?php echo $fs->name ?> related-link asterisk"></span>
                  <?php endif; ?>
                  <?php endforeach; ?>
                
                </li>
                <?php endforeach; ?>
                <?php if (MasterPress::current_user_can("create_user_roles")) : ?>
                <li class="divide"><a href="<?php echo MasterPress::admin_url("roles", "create") ?>" class="create-link"><i></i><?php echo MPV::__create( __("User Role", MASTERPRESS_DOMAIN) ) ?></a></li>
                <?php endif; ?>
                </ul>
            
              </div>
              <!-- /.body -->
            
            </div>
            <!-- /.col -->
                    
          </div>
          <!-- /.row -->
        
        </div>
        <!-- /#masterplan-overview -->


<!-- EXPORT -->

      <?php if (MasterPress::current_user_can("export_masterplan")) : ?>

        <div id="masterplan-export" class="masterplan-export tab-panel <?php echo $tab == "export" ? 'current' : '' ?>">

        <?php MPV::form_open() ?>

          <div id="export-progress" class="progress">
            <?php _e("Exporting Masterplan. Please wait&hellip;", MASTERPRESS_DOMAIN) ?>
          </div>
          <!-- /#export-progress -->
          
          <div id="export-summary" class="summary">
            
            <div id="export-download">

              <p><?php _e("Export completed successfully", MASTERPRESS_DOMAIN) ?></p>
              <a id="export-file-download" href="#" data-message="<?php _e( "Download %s", MASTERPRESS_DOMAIN) ?>"><?php printf( __( "Download %s", MASTERPRESS_DOMAIN ), "file.zip" ) ?></a>
              
            </div>
            <!-- /#export-download -->
            
            
            <div id="extras-summary" class="extras-summary">
              
              <p>
                <?php _e("Note: the following dependent files were included in the Masterplan package", MASTERPRESS_DOMAIN) ?>
              </p>
                
              <div id="extras-icons">
                <h4><?php _e("Icons", MASTERPRESS_DOMAIN); ?></h4>
                
                <ul>
                  
                </ul>
              </div>
              <!-- /#extras-icons -->

              <div id="extras-types">
                <h4><?php _e("Field Types", MASTERPRESS_DOMAIN); ?></h4>
                
                <ul>
                  
                </ul>
              </div>
              <!-- /#extras-field-types -->
              
              
            </div>
            
          </div>
          <!-- /#export-summary -->

          <div id="export-ui">
            
          <div id="export-package">
            
            <div class="title">
              <h4 class="package-file"><i class="zip"></i><?php _e("Package File", MASTERPRESS_DOMAIN) ?></h4>
              <button id="button-export" type="submit" class="button-export simple-primary">Export</button>
            </div>
            <!-- /.title -->
            
            <div id="f-export-filename" class="f">
            
              <label for="export_filename"><?php _e("Name:", MASTERPRESS_DOMAIN) ?></label>
            
              <div class="fw">
                <input id="export_filename" spellcheck="false" name="export_filename" type="text" value="<?php echo $wf->sanitize( $wf->site_name() ) ?>" class="text" />
                <span id="export_filename_extension" class="note"><?php echo ".".$wf->format_date("[date-time-sortable]") ?>.masterplan.zip</span>
              </div>
              <!-- /.fw -->
            
            </div>
            <!-- /.f -->

          </div>
          <!-- /#export-package -->
          
          <div id="export-readme">
            
            <h4 class="readme"><i class="document-text"></i><?php _e('Read Me<span> - this Markdown-formatted text will be stored in <span class="tt">README.markdown</span> inside the Masterplan package</span>', MASTERPRESS_DOMAIN); ?></h4>
            
            <div id="f-export_readme">
<textarea id="export_readme" name="export_readme">
# Masterplan for <?php echo $wf->sites()->first()->name ?> #

+ By: <?php echo $wf->the_user()->fullname() ?>

+ Created: <?php echo $wf->format_date("[date-time-long]") ?>


-------------------------------------------------

</textarea>
          </div>
          
          </div>
          <!-- /#export-readme -->
          
          <div id="export-items">
            
            <div class="title-buttons">
              <h4 class="export-items"><i class="hand-point"></i><?php _e("Export Items<span> - check the items you wish to include in the Masterplan package</span>", MASTERPRESS_DOMAIN); ?></h4>
              <div class="buttons">
                <button id="export-select-all" type="button" class="button">Select <span class="all">All</span></button>
                <button id="export-select-none" type="button" class="button">Select <span class="none">None</span></button>
              </div>
              
            </div>
            <!-- /.title-buttons -->
            
            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="post-types"><i class="pin"></i><?php _e("Post Types", MASTERPRESS_DOMAIN) ?></h4>
                <input id="post-types-check" name="post-types-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                <ul class="object-tree post-types">
                <?php foreach ($post_types as $post_type) : ?>
                  
                <?php if ($post_type->still_registered()) : ?>

                <li class="post-type-<?php echo $post_type->name ?>">
                  <input id="ref-post-type-<?php echo $post_type->name ?>" name="ref[post_types][<?php echo $post_type->name ?>][selected]" checked="checked" value="true" type="hidden" />
                  <input id="export-post-type-<?php echo $post_type->name ?>" name="export[post_types][<?php echo $post_type->name ?>][selected]" checked="checked" value="true" type="checkbox" class="checkbox" />
                  <label for="export-post-type-<?php echo $post_type->name ?>" class="mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>"><?php echo $post_type->display_label() ?></label>

                <?php $field_sets = $post_type->post_type_field_sets() ?>
                
                <?php if (count($field_sets)) : ?>
                  <ul class="field-sets">
                  <?php foreach ($field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                  <li class="field-set<?php echo $class ?>">
                    <input id="export-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>" checked="checked" name="export[post_types][<?php echo $post_type->name ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="checkbox" class="checkbox" />
                    <input id="ref-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>" name="ref[post_types][<?php echo $post_type->name ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                    <label for="export-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>
                    
                    <?php $fields = $field_set->fields() ?>
                
                    <?php if (count($fields)) : ?>
                      <ul class="fields">
                      <?php foreach ($fields as $field) : ?>
                      <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                      <li class="field">
                        <input id="export-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[post_types][<?php echo $post_type->name ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                        <input id="ref-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="ref[post_types][<?php echo $post_type->name ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                        <label for="export-post-type-<?php echo $post_type->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                      </li>  
                      <?php endif; ?>
                      <?php endforeach; ?>
                      </ul>
                    <?php endif; ?>
                
                  </li>  
                  <?php endforeach; ?>
                  </ul>
                <?php endif; ?>
                
                </li>
                
                <?php endif; ?>
                
                <?php endforeach; ?>  
                </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
            
            
            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="taxonomies"><i class="tag"></i><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?></h4>
                <input id="taxonomies-check" name="taxonomies-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                <ul class="object-tree taxonomies">
                <?php foreach ($taxonomies as $tax) : ?>

                <?php if ($tax->still_registered()) : ?>

                <li>
                  <input id="ref-taxonomy-<?php echo $tax->name ?>" name="ref[taxonomies][<?php echo $tax->name ?>][selected]" value="true" type="hidden" />
                  <input id="export-taxonomy-<?php echo $tax->name ?>" name="export[taxonomies][<?php echo $tax->name ?>][selected]" checked="checked" value="true" type="checkbox" class="checkbox" />
                  <label for="export-taxonomy-<?php echo $tax->name ?>" class="mp-icon-taxonomy mp-icon-taxonomy-<?php echo $tax->name ?>"><?php echo $tax->display_label() ?></label>

                <?php $field_sets = $tax->taxonomy_field_sets() ?>
                
                <?php if (count($field_sets)) : ?>
                  <ul class="field-sets">
                  <?php foreach ($field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                  <li class="field-set<?php echo $class ?>">
                    <input id="ref-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>" name="ref[taxonomies][<?php echo $tax->name ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                    <input id="export-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>" name="export[taxonomies][<?php echo $tax->name ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" checked="checked" type="checkbox" class="checkbox" />
                    <label for="export-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>

                    <?php $fields = $field_set->fields() ?>
                
                    <?php if (count($fields)) : ?>
                      <ul class="fields">
                      <?php foreach ($fields as $field) : ?>
                      <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                      <li class="field">
                        <input id="ref-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" name="ref[taxonomies][<?php echo $tax->name ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                        <input id="export-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[taxonomies][<?php echo $tax->name ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                        <label for="export-taxonomy-<?php echo $tax->name ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>"  class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                      </li>  
                      <?php endif; ?>
                      <?php endforeach; ?>
                      </ul>
                    <?php endif; ?>
                
                  </li>  
                  <?php endforeach; ?>
                  </ul>
                <?php endif; ?>
                
                </li>
                <?php endif; ?>

                <?php endforeach; ?>  
                </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
            <?php if (count($shared_field_sets)) : ?>

            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="shared-field-sets"><i class="metabox-share"></i><?php _e("Shared Field Sets", MASTERPRESS_DOMAIN) ?></h4>
                <input id="shared-field-sets-check" name="shared-field-sets-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                <ul class="object-tree shared-field-sets field-sets">
                <?php foreach ($shared_field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                <li class="field-set<?php echo $class ?>">
                  <input id="ref-shared-field-set-<?php echo $field_set->id ?>" name="ref[shared_field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                  <input id="export-shared-field-set-<?php echo $field_set->id ?>" name="export[shared_field_sets][<?php echo $field_set->id ?>][selected]" value="true" checked="checked" type="checkbox" class="checkbox" />
                  <label for="export-shared-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>

                  <?php $fields = $field_set->fields() ?>
              
                  <?php if (count($fields)) : ?>
                    <ul class="fields">
                    <?php foreach ($fields as $field) : ?>
                    <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                    <li class="field">
                      <input id="ref-shared-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="ref[shared_field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                      <input id="export-shared-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[shared_field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                      <label for="export-shared-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                    </li>  
                    <?php endif; ?>
                    <?php endforeach; ?>
                    </ul>
                  <?php endif; ?>
              
                </li>  
                <?php endforeach; ?>
                </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
            <?php endif; ?>
          
          
            <?php if (count($site_field_sets)) : ?>

            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="site-field-sets"><i class="sitemap"></i><?php _e("Site Field Sets", MASTERPRESS_DOMAIN) ?></h4>
                <input id="site-field-sets-check" name="site-field-sets-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                  <ul class="object-tree site-field-sets field-sets">
                  <?php foreach ($site_field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                  <li class="field-set<?php echo $class ?>">
                    <input id="ref-site-field-set-<?php echo $field_set->id ?>" name="ref[site_field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                    <input id="export-site-field-set-<?php echo $field_set->id ?>" name="export[site_field_sets][<?php echo $field_set->id ?>][selected]" value="true" checked="checked" type="checkbox" class="checkbox" />
                    <label for="export-site-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>

                    <?php $fields = $field_set->fields() ?>
                
                    <?php if (count($fields)) : ?>
                      <ul class="fields">
                      <?php foreach ($fields as $field) : ?>
                      <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                      <li class="field">
                        <input id="ref-site-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="ref[site_field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                        <input id="export-site-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[site_field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                        <label for="export-site-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                      </li>  
                      <?php endif; ?>
                      <?php endforeach; ?>
                      </ul>
                    <?php endif; ?>
                
                  </li>  
                  <?php endforeach; ?>
                  </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
            <?php endif; ?>
            
          
          
            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="templates"><i class="template"></i><?php _e("Templates", MASTERPRESS_DOMAIN) ?></h4>
                <input id="templates-check" name="templates-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                <ul class="object-tree">
              

                <?php foreach ($templates as $template => $file) : $id = $wf->sanitize($file); ?>
                <li class="template-<?php echo $id ?>">

                  <input id="ref-template-<?php echo $wf->sanitize($file) ?>" name="ref[templates][<?php echo $file ?>][selected]" checked="checked" value="true" type="hidden" />
                  <input id="export-template-<?php echo $wf->sanitize($file) ?>" name="export[templates][<?php echo $file ?>][selected]" checked="checked" value="true" type="checkbox" class="checkbox" />
                  <label for="export-template-<?php echo $wf->sanitize($file) ?>" class="template"><i class="template"></i><?php echo $template ?></label>


                  <?php $field_sets = MPM_TemplateFieldSet::find_by_template( $file ); ?>

                <?php if (count($field_sets)) : ?>
                  <ul class="field-sets">
                  <?php foreach ($field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                  <li class="field-set<?php echo $class ?>">
                    <input id="ref-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" name="ref[templates][<?php echo $file ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                    <input id="export-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" checked="checked" name="export[templates][<?php echo $file ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="checkbox" class="checkbox" />
                    <label for="export-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>
                    
                    <?php $fields = $field_set->fields(); ?>
                
                    <?php if (count($fields)) : ?>
                      <ul class="fields">
                      <?php foreach ($fields as $field) : ?>
                      <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                      <li class="field">
                        <input id="ref-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" name="ref[templates][<?php echo $file ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                        <input id="export-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[templates][<?php echo $file ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                        <label for="export-template-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                      </li>  
                      <?php endif; ?>
                      <?php endforeach; ?>
                      </ul>
                    <?php endif; ?>
                
                  </li>  
                  <?php endforeach; ?>
                  </ul>
                <?php endif; ?>
                
                </li>

                <?php endforeach; ?>  

                </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
            
            
            <div class="fsi">
            <div class="fsibv">
              <div class="fsit">
                <h4 class="roles"><i class="user-role"></i><?php _e("User Roles", MASTERPRESS_DOMAIN) ?></h4>
                <input id="roles-check" name="roles-all" type="checkbox" class="checkbox" checked="checked" />
              </div>
              
              <div class="fsic">
                
                <ul class="object-tree">
              

                <?php foreach ($roles as $role) : $id = $role->id() ?>
                <li>
                  <input id="ref-role-<?php echo $id ?>" name="ref[roles][<?php echo $id ?>][selected]" checked="checked" value="true" type="hidden" />
                  <input id="export-role-<?php echo $id ?>" name="export[roles][<?php echo $id ?>][selected]" checked="checked" value="true" type="checkbox" class="checkbox" />
                  <label for="export-role-<?php echo $id ?>" class="role"><i class="user-role"></i><?php echo $role->name ?></label>


                <?php $field_sets = MPM_RoleFieldSet::find_by_role( $id ) ?>

                <?php if (count($field_sets)) : ?>
                  <ul class="field-sets">
                  <?php foreach ($field_sets as $field_set) : $class = $field_set->allow_multiple ? 'metabox-add-remove-large' : 'metabox-large'; ?>
                  <li class="field-set<?php echo $class ?>">
                    <input id="ref-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" checked="checked" name="ref[roles][<?php echo $id ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="hidden" />
                    <input id="export-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" checked="checked" name="export[roles][<?php echo $id ?>][field_sets][<?php echo $field_set->id ?>][selected]" value="true" type="checkbox" class="checkbox" />
                    <label for="export-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>" class="field-set"><i class="<?php echo $class ?>"></i><?php echo $field_set->display_label() ?></label>
                    
                    <?php $fields = $field_set->fields(); ?>
                
                    <?php if (count($fields)) : ?>
                      <ul class="fields">
                      <?php foreach ($fields as $field) : ?>
                      <?php if ($type_class = MPFT::type_class($field->type)) : ?>
                      <li class="field">
                        <input id="ref-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" name="ref[roles][<?php echo $id ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="hidden" />
                        <input id="export-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" checked="checked" name="export[roles][<?php echo $id ?>][field_sets][<?php echo $field_set->id ?>][fields][<?php echo $field->id ?>]" value="true" type="checkbox" class="checkbox" />
                        <label for="export-role-<?php echo $id ?>-field-set-<?php echo $field_set->id ?>-field-<?php echo $field->id ?>" class="mp-icon-field-type-<?php echo $field->type ?>"><?php echo $field->display_label() ?></label>
                      </li>  
                      <?php endif; ?>
                      <?php endforeach; ?>
                      </ul>
                    <?php endif; ?>
                
                  </li>  
                  <?php endforeach; ?>
                  </ul>
                <?php endif; ?>
                
                </li>

                <?php endforeach; ?>  

                </ul>
                
                
              </div>
              <!-- /.fsic -->
              
            </div>
            </div>
            <!-- /.fsi -->
            
          
          
            
          </div>
          <!-- /#export-items -->
          
          
          </div>
          <!-- /#export-ui -->

          
          
        <?php MPV::form_close() ?>

              
        </div>
        <!-- /#masterplan-export -->
        
      <?php endif; ?>


      <?php if (MasterPress::current_user_can("import_masterplan")) : ?>

        <div id="masterplan-import" class="tab-panel <?php echo $tab == "import" ? 'current' : '' ?>">

          <?php if (!MPV::is_postback()) : ?>

          <?php MPV::form_open() ?>
            
          <div id="import-file-wrap">
            
            <div class="title">
              <h4 class="upload"><i class="upload"></i><?php _e("Package Upload", MASTERPRESS_DOMAIN) ?></h4>
            </div>
            <!-- /.title -->

            
            <label id="label-import_file" for="import_file"><?php _e("Upload a Masterplan zip package to begin.<br  /><b>Note:</b> you will be able to review the contents of the package before going ahead with the import.") ?></label>
          
            <div id="import-file-uploader" class="file-uploader { allowedExtensions: ['zip'], ids: { drop: 'import_file_drop_area' }, input: '#import_file', inputName: 'import_file_ul', base_url: '<?php echo MASTERPRESS_GLOBAL_CONTENT_URL ?>', params: { dir: 'tmp/' }, limit: 1, lang: { buttonReplace: '<?php _e("Select a Different File&hellip;") ?>', buttonChoose: '<?php _e("Choose from Computer&hellip;", MASTERPRESS_DOMAIN) ?>'} }">
            
              <div id="import_file_drop_area" class="drop-area"><?php _e("Drop file here to upload", MASTERPRESS_DOMAIN) ?></div>

              <?php 
            
              $file_name = __("( None )", MASTERPRESS_DOMAIN);
              $file_class = "name-none";

              ?>
            
              <div class="file">
                <span class="preview"></span><span data-none="<?php echo __("( None )", MASTERPRESS_DOMAIN) ?>" class="name <?php echo $file_class ?>"><?php echo $file_name ?></span>
              </div>
            
              <input id="import_file" name="import_file" value="" type="hidden" />
              <div class="uploader-ui"></div>
            
            </div>
            <!-- /.file-uploader -->
          
          </div>
          <!-- /#import-file-wrap -->
          
          <p id="import-fetching-summary"><?php _e("Fetching Masterplan info - Please wait&hellip;", MASTERPRESS_DOMAIN); ?></p>
          

          <div id="import-confirmation">
            
            <div class="title">
              <h4 class="upload"><i class="tick-circle"></i><?php _e("Confirmation", MASTERPRESS_DOMAIN) ?> - <span><?php _e("select import options and review the uploaded package", MASTERPRESS_DOMAIN) ?></span></h4>
              <button id="button-import" type="submit" class="button-import simple-primary">Import</button>
            </div>
            <!-- /.title -->
                
            <div class="content">
                        
              <div class="f">
                <div class="fw">
                  <input id="import-backup" name="import_backup" value="yes" checked="checked" type="checkbox" class="checkbox" />
                  <label for="import-backup" class="checkbox"><?php _e("<strong>Backup the existing setup</strong> before importing ( highly recommended )", MASTERPRESS_DOMAIN); ?></label>
                </div>
              </div>
              <!-- /.f -->

              <div id="f-types-overwrite" class="f">
                <div class="fw">
                  <input id="import-types-overwrite" name="import_types_overwrite" value="yes" checked="checked" type="checkbox" class="checkbox" />
                  <label for="import-types-overwrite" class="checkbox"><?php _e("<strong>Overwrite</strong> existing field type extensions with those included in the imported package", MASTERPRESS_DOMAIN); ?></label>
                </div>
              </div>
              <!-- /.f -->
            
              <div class="f f-mode">
                <p>
                  <?php _e("When items are present in the existing setup, but not in the imported Masterplan:", MASTERPRESS_DOMAIN) ?>
                </p>
                
                <div class="fw">
                  <input id="import-mode-replace" name="import_mode" value="replace" checked="checked" type="radio" class="radio" />
                  <label for="import-mode-replace" class="radio"><?php _e('Remove the items from the existing setup ( <strong class="replace">completely replace</strong> the existing setup )', MASTERPRESS_DOMAIN); ?></label>
                </div>

                <div class="fw">
                  <input id="import-mode-append" name="import_mode" value="append" type="radio" class="radio" />
                  <label for="import-mode-append" class="radio"><?php _e('Keep the items in the existing setup ( <strong class="append">append to</strong> the existing setup )', MASTERPRESS_DOMAIN); ?></label>
                </div>

                
              </div>
              <!-- /.f -->
            
            
            </div>
            <!-- /.content -->
            
          </div>
                  

          
          <div id="import-preview" class="import-preview">

            <input type="hidden" name="tab" value="import" />
            <input id="import-masterplan" type="hidden" name="import_masterplan" value="" />
            
            
            <?php
            
            // build a template list for the importer, since get_page_templates() is not available early in execution
            
            foreach (get_page_templates() as $template => $file) :
              ?>
              <input name="templates[<?php echo $file ?>]" type="hidden" value="<?php echo $template ?>" />
            <?php endforeach; ?>
            
            <div id="import-rep">
              
              <div class="fsi post-types">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="post-types"><i class="pin"></i><?php _e("Post Types", MASTERPRESS_DOMAIN) ?></h4>
                </div>
              
                <div class="fsic">
                
                  <ul class="object-tree post-types">
                 
                  </ul>
                
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
            
            
            
              <div class="fsi taxonomies">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="taxonomies"><i class="tag"></i><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?></h4>
                </div>
              
                <div class="fsic">
                
                  <ul class="object-tree taxonomies">
                
                  </ul>
                
                
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
            
              <div class="fsi shared-field-sets">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="shared-field-sets"><i class="metabox-share"></i><?php _e("Shared Field Sets", MASTERPRESS_DOMAIN) ?></h4>
                </div>
              
                <div class="fsic">
                  <ul class="object-tree shared-field-sets field-sets">
                  </ul>
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
          
              <div class="fsi site-field-sets">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="site-field-sets"><i class="sitemap"></i><?php _e("Site Field Sets", MASTERPRESS_DOMAIN) ?></h4>
                </div>
              
                <div class="fsic">
                
                    <ul class="object-tree site-field-sets field-sets">
                    </ul>
                
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
          
          
              <div class="fsi templates">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="templates"><i class="template"></i><?php _e("Templates", MASTERPRESS_DOMAIN) ?></h4>
                </div>
              
                <div class="fsic">
                
                  <ul class="object-tree">
                  </ul>
                
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
            
            
            
              <div class="fsi roles">
              <div class="fsibv">
                <div class="fsit">
                  <h4 class="roles"><i class="user-role"></i><?php _e("User Roles", MASTERPRESS_DOMAIN) ?></h4>
                </div>
                
                <div class="fsic">
                
                  <ul class="object-tree">
                  </ul>
                
                </div>
                <!-- /.fsic -->
              
              </div>
              </div>
              <!-- /.fsi -->
            
              
            </div>
            <!-- /#import-rep -->
              

          </div>
          <!-- /#import-summary -->

          <?php MPV::form_close() ?>
          
          <?php else: ?>
          
          
          
          <?php endif; ?>
        
        </div>
        <!-- /#masterplan-import -->
        
      <?php endif; ?>

      <?php if (MasterPress::current_user_can("backup_masterplan")) : ?>
        
        <div id="masterplan-backup" class="masterplan-export tab-panel" style="display: none;">
          
          <ul class="mp-messages">
            <li class="notification"><?php _e("Note - this utility does <b>not</b> backup your WordPress content.", MASTERPRESS_DOMAIN) ?></li>
          </ul>
          
          
          <?php MPV::form_open() ?>

            <div id="backup-progress" class="progress">
              <?php _e("Backing up Masterplan. Please wait&hellip;", MASTERPRESS_DOMAIN) ?>
            </div>
            <!-- /#backup-progress -->

            <div id="backup-summary" class="summary">

              <div id="backup-message">
                <p><?php _e("Backup created successfully", MASTERPRESS_DOMAIN) ?></p>
              </div>
              <!-- /#backup-message -->


              <div id="backup-extras-summary" class="extras-summary">
                <p>
                  <?php _e("Note: the following dependent files were included in the Masterplan package", MASTERPRESS_DOMAIN) ?>
                </p>

                <div id="backup-extras-icons">
                  <h4><?php _e("Icons", MASTERPRESS_DOMAIN); ?></h4>

                  <ul>

                  </ul>
                </div>
                <!-- /#backup-extras-icons -->

                <div id="backup-extras-types">
                  <h4><?php _e("Field Types", MASTERPRESS_DOMAIN); ?></h4>

                  <ul>

                  </ul>
                </div>
                <!-- /#backup-extras-field-types -->

              </div>
              <!-- /#backup-extras-summary -->

            </div>

            <div id="backup-ui">

            <div class="title">
              <h4 class="package-file"><i class="zip"></i><?php _e("Package File", MASTERPRESS_DOMAIN) ?></h4>
              <button id="button-backup" type="submit" class="button-export simple-primary">Backup</button>
            </div>
            <!-- /.title -->

            <div id="f-backup-filename" class="f">
              
              <label for="backup_filename"><?php _e("Name:", MASTERPRESS_DOMAIN) ?></label>

              <div class="fw">
                <span id="backup_filename_prefix" class="note">_backup.</span>
                <input id="backup_filename" spellcheck="false" name="backup_filename" type="text" value="" class="text" />
                <input id="backup_filename_suffix" spellcheck="false" name="backup_filename_suffix" type="hidden" value="<?php echo ".".$wf->format_date("[date-time-sortable]") ?>.masterplan.zip" class="text" />
                <span id="backup_filename_extension" class="note"><?php echo ".".$wf->format_date("[date-time-sortable]") ?>.masterplan.zip</span>
              </div>
              <!-- /.fw -->

              <p id="backup_note"><?php _e("Use the editable field as a way to tag the backup for reference later ( optional )") ?></p>

            </div>
            <!-- /.f -->


            <div id="backup-readme">

              <h4 class="readme"><i class="document-text"></i><?php _e('Read Me<span> - this Markdown-formatted text will be stored in <span class="tt">README.markdown</span> inside the Masterplan backup</span>', MASTERPRESS_DOMAIN); ?></h4>

              <div id="f-backup_readme">
<textarea id="backup_readme" name="backup_readme">
# Masterplan Backup for <?php echo $wf->sites()->first()->name ?> #

+ By: <?php echo $wf->the_user()->fullname() ?>

+ Created: <?php echo $wf->format_date("[date-time-long]") ?>


-------------------------------------------------

</textarea>
            </div>

            </div>
            <!-- /#backup-readme -->
          
          </div>
          
          <?php MPV::form_close() ?>
          
        </div>
        <!-- /#masterplan-backup -->

      <?php endif; ?>

      <?php if (MasterPress::current_user_can("restore_masterplan")) : ?>
        
        <?php if (count($backups)) : ?>

        <div id="masterplan-restore" class="tab-panel <?php echo $tab == "restore" ? 'current' : '' ?>">

        <?php MPV::form_open() ?>

          <div class="title">
            <h4 class="package-file"><i class="zip"></i><?php _e("Package Selection", MASTERPRESS_DOMAIN) ?> - <span><?php _e("select a backup package to restore from", MASTERPRESS_DOMAIN) ?></span></h4>
            <button id="button-restore" type="submit" class="button-restore simple-primary">Restore</button>
          </div>
          <!-- /.title -->

          <div id="f-restore-file" class="f">
           
          <label for="restore-masterplan" class="select"><?php _e("File:", MASTERPRESS_DOMAIN) ?></label>
          
          <div class="fw">
          
          <select id="restore-masterplan" data-empty="<?php _e("Please Select a Masterplan to restore", MASTERPRESS_DOMAIN) ?>" name="restore_masterplan">
            <option value=""><?php _e("Select a backup package") ?></option>
            <?php foreach ( $backups as $backup ) : ?>
            <option value="<?php echo $backup["file"] ?>"><?php echo $backup["label"] ?></option>
            <?php endforeach; ?>
          </select>
               
                   
          </div>
                 
        
          <?php MPV::form_close() ?>
  
        </div>
        <!-- /#masterplan-restore -->
        
        <?php endif; ?>
      
      <?php endif; ?>
      
      </div>
      </div>

    </div>
    <!-- /.fs .fs-masterplan -->
    


  <?php
  }