public function manage() { global $meow_provider, $wf; $this->setup_view( array( "title_args" => array( "text" => __("Site Content", MASTERPRESS_DOMAIN) ) ) ); $site = $wf->site(); MasterPress::$view->sets = self::assigned_field_sets(); MPC::incl("meta"); MPV::incl("meta"); if (MPC::is_postback()) { // save the meta - this code should be moved into the controller at some stage MPC_Meta::save_site_meta($site->id()); // redirect back to here wp_redirect( MasterPress::admin_url( "site-content", "manage", array("updated" => "true"), false ) ); exit(); } }
public function delete($args) { global $wf; if (isset($args)) { parent::delete($args); } else { MPV::incl("roles"); if ($this->is_postback()) { // delete the role $role = $wf->role(MasterPress::$id); if ($role && !is_woof_silent($role)) { remove_role($role->id); wp_redirect( MasterPress::admin_url( "roles", "manage", array("id" => MasterPress::$id), false ) ); exit; } } else { $this->setup_view( array( "view" => "roles", "title_args" => array( "text" => MPV_Roles::__p() ) ) ); $this->manage(); } } }
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"> </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">-> </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"> </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"> </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()
public function manage_url($set) { $url = ""; switch ($set->type) { case "p" : // Post type $pt = MPM_PostType::find_by_name($set->vis("post_types")); if (!$pt) { return ''; } $url = MasterPress::admin_url("post-types", "edit-field", array("id" => $this->id, "gparent" => $pt->id, "parent" => $set->id ) ); break; case "t" : // Template $url = MasterPress::admin_url("templates", "edit-field", array("id" => $this->id, "gparent" => $set->vis("templates"), "parent" => $set->id) ); break; case "x" : // taXonomy $tax = MPM_Taxonomy::find_by_name($set->vis("taxonomies")); if (!$tax) { return ''; } $url = MasterPress::admin_url("taxonomies", "edit-field", array("id" => $this->id, "gparent" => $tax->id, "parent" => $set->id) ); break; case "s" : // Shared $url = MasterPress::admin_url("shared-field-sets", "edit-field", array("id" => $this->id, "parent" => $set->id) ); break; case "r" : // Role $url = MasterPress::admin_url("roles", "edit-field", array("id" => $this->id, "gparent" => $set->vis("roles"), "parent" => $set->id) ); break; case "w" : // site-Wide $url = MasterPress::admin_url("site-field-sets", "edit-field", array("id" => $this->id, "parent" => $set->id) ); break; } return $url; }
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).'">–</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()
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" ), ) ); }
public function import() { global $wf; $base_dir = MASTERPRESS_TMP_DIR; $base_url = MASTERPRESS_TMP_URL; $restore = false; if (isset($_POST["import_masterplan"])) { $masterplan = $_POST["import_masterplan"]; } else { if (isset($_POST["restore_masterplan"])) { $masterplan = $_POST["restore_masterplan"]; $base_dir = MASTERPRESS_CONTENT_MASTERPLANS_DIR; $base_url = MASTERPRESS_CONTENT_MASTERPLANS_URL; $restore = true; } } $view = MasterPress::$view; if (isset($masterplan)) { extract(self::open_masterplan($masterplan, true, $base_dir, $base_url)); if ($rep) { $icon_dest = MASTERPRESS_CONTENT_MENU_ICONS_DIR; $icon_src = $dir.WOOF_DIR_SEP."icons".WOOF_DIR_SEP; $field_type_dest = MASTERPRESS_EXTENSIONS_FIELD_TYPES_DIR; $field_type_src = $dir.WOOF_DIR_SEP."field-types".WOOF_DIR_SEP; // install field type extensions foreach ($field_types as $field_type) { $dest = $field_type_dest.$field_type["name"]; $src = $field_type_src.$field_type["name"]; if (!(file_exists($dest) && !isset($_POST["import_types_overwrite"]))) { MPU::copyr($src, $dest); } } $info = array("log" => array()); $mode = $_REQUEST["import_mode"]; if ($restore) { $mode = "replace"; } $log = &$info["log"]; $backup = isset($_REQUEST["import_backup"]); $view->rep = $rep; $view->backup = $backup; $view->mode = $mode; // first obtain the current representation $current = self::get_current_rep(); $view->current = $current; if ($backup) { // build the backup (a rollback point) $backup_filename = "_backup.pre-import.".$wf->format_date("[date-time-sortable]").".masterplan.zip"; $backup_readme = "# Backup Masterplan for ".$wf->sites()->first()->name." # + Created: ".$wf->format_date("[date-time-long]"); $backup_rep = $this->export_rep($current); $package = $this->build_package($backup_rep, $backup_filename, $backup_readme); if ($package) { $info["backup_package"] = $package; $info["backup_url"] = MASTERPRESS_CONTENT_MASTERPLANS_URL.$backup_filename; $info["backup_filename"] = $backup_filename; } } // process the representation // store all objects by key to look them up for potential removal (if mode is replace) $import = array( "post_types" => array(), "taxonomies" => array(), "shared_field_sets" => array(), "site_field_sets" => array(), "templates" => array(), "roles" => array() ); $taxonomies_by_key = array(); $shared_field_sets_by_key = array(); $shared_field_sets_by_key = array(); if (isset($rep["post_types"])) { foreach ($rep["post_types"] as $post_type) { $data = $post_type; unset($data["field_sets"], $data["id"], $data["sites"]); $name = $post_type["name"]; $insert = true; if ($model = MPM_PostType::find_by_name($name)) { $insert = false; } else { $model = new MPM_PostType(); } $model->set($data, true); if ($insert) { $model->insert(); } else { $model->update(); } // install icons if ($post_type["_builtin"] == "0" && !is_null($post_type["menu_icon"]) && $post_type["menu_icon"] != "") { copy($icon_src.$post_type["menu_icon"], $icon_dest.$post_type["menu_icon"]); } $import["post_types"][$name] = $post_type; // now run through the field sets, taking care to preserve $import["post_types"][$name]["field_sets"] = self::import_field_sets($post_type["field_sets"], " AND `type` = 'p' AND ".MPM::visibility_rlike("post_types", $name), $dir); } } if (isset($rep["taxonomies"])) { foreach ($rep["taxonomies"] as $tax) { $data = $tax; unset($data["field_sets"], $data["id"], $data["sites"]); $name = $tax["name"]; $insert = true; if ($model = MPM_Taxonomy::find_by_name($name)) { $insert = false; } else { $model = new MPM_Taxonomy(); } $model->set($data, true); if ($insert) { $model->insert(); } else { $model->update(); } // install icons if ($tax["_builtin"] == "0" && !is_null($tax["title_icon"]) && $tax["title_icon"] != "") { copy($icon_src.$tax["title_icon"], $icon_dest.$tax["title_icon"]); } $import["taxonomies"][$name] = $tax; $import["taxonomies"][$name]["field_sets"] = self::import_field_sets($tax["field_sets"], " AND `type` = 'x' AND ".MPM::visibility_rlike("taxonomies", $name), $dir); } } if (isset($rep["shared_field_sets"])) { $import["shared_field_sets"] = self::import_field_sets($rep["shared_field_sets"], " AND `type` = 's' ", $dir); } if (isset($rep["site_field_sets"])) { $import["site_field_sets"] = self::import_field_sets($rep["site_field_sets"], " AND `type` = 'w' ", $dir); } if (isset($rep["templates"])) { foreach ($rep["templates"] as $template) { $id = $template["id"]; // template models are self-creating, so no need for special handling here $model = MPM_Template::find_by_id($id); $data = $template; unset($data["field_sets"]); $model->set($data, true); $model->update(); $import["templates"][$id] = $template; if (isset($template["field_sets"])) { $import["templates"][$id]["field_sets"] = self::import_field_sets($template["field_sets"], " AND `type` = 't' AND ".MPM::visibility_rlike("templates", $id), $dir); } } } if (isset($rep["roles"])) { foreach ($rep["roles"] as $role) { if (isset($role["field_sets"])) { $name = $role["name"]; $import["roles"][$name] = $role; $import["roles"][$name]["field_sets"] = self::import_field_sets($role["field_sets"], " AND `type` = 'r' AND ".MPM::visibility_rlike("roles", $name), $dir); } } } if ($mode == "replace") { // we now need to remove anything in the current setup that ISN'T in the imported masterplan if (isset($current["post_types"])) { foreach ($current["post_types"] as $post_type) { $name = $post_type["name"]; $builtin = $post_type["_builtin"] == "1"; if (!isset($import["post_types"][$name]) && !$builtin) { $model = MPM_PostType::find_by_name($name); if ($model) { $model->delete( array( "posts" => "leave", "posts_reassign_type" => "", "field_sets" => "delete", "field_data" => "keep" )); } } else { if (isset($post_type["field_sets"])) { self::replace_field_sets($post_type["field_sets"], $import["post_types"][$name]["field_sets"]); } } } } if (isset($current["taxonomies"])) { foreach ($current["taxonomies"] as $tax) { $name = $tax["name"]; $builtin = $tax["_builtin"] == "1"; if (!isset($import["taxonomies"][$name]) && !$builtin) { $model = MPM_Taxonomy::find_by_name($name); if ($model) { $model->delete( array( "existing_terms" => "leave", "existing_terms_reassign_taxonomy" => "", "field_sets" => "delete", "field_data" => "leave" )); } } else { if (isset($tax["field_sets"])) { self::replace_field_sets($tax["field_sets"], $import["taxonomies"][$name]["field_sets"]); } } } } if (isset($current["shared_field_sets"])) { self::replace_field_sets($current["shared_field_sets"], $import["shared_field_sets"]); } if (isset($current["site_field_sets"])) { self::replace_field_sets($current["site_field_sets"], $import["site_field_sets"]); } if (isset($current["templates"])) { foreach ($current["templates"] as $template) { $id = $template["id"]; if (isset($import["templates"][$id])) { if (isset($template["field_sets"])) { self::replace_field_sets($template["field_sets"], $import["templates"][$id]["field_sets"]); } } } } if (isset($current["roles"])) { foreach ($current["roles"] as $name => $role) { if (isset($import["roles"][$name])) { if (isset($role["field_sets"])) { self::replace_field_sets($role["field_sets"], $import["roles"][$name]["field_sets"]); } } } } } // mode = replace // cleanup the unzipped folder MPU::rmdir_r($dir); if ($restore) { wp_redirect( MasterPress::admin_url( $this->key(), "manage", array("restore-complete" => "1"), false ) ); } else { wp_redirect( MasterPress::admin_url( $this->key(), "manage", array("import-complete" => "1"), false ) ); } $view->info = $info; } else { self::ajax_error(__("The Masterplan is no longer valid. Please try another file", MASTERPRESS_DOMAIN)); } } else { self::ajax_error(__("The Masterplan is no longer valid. Please try another file", MASTERPRESS_DOMAIN)); } }
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"> </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">-> </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"> </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"> </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()
public static function admin_bar_menu() { global $wp_admin_bar, $wf; $caps = array( "manage_masterplan" => MasterPress::get_cap_key("manage_masterplan"), "manage_post_types" => MasterPress::get_cap_key("manage_post_types"), "manage_taxonomies" => MasterPress::get_cap_key("manage_taxonomies"), "manage_templates" => MasterPress::get_cap_key("manage_templates"), "manage_user_roles" => MasterPress::get_cap_key("manage_user_roles"), "manage_site_field_sets" => MasterPress::get_cap_key("manage_site_field_sets"), "manage_shared_field_sets" => MasterPress::get_cap_key("manage_shared_field_sets"), "manage_mp_settings" => MasterPress::get_cap_key("manage_mp_settings") ); $menu_items = array( array( 'id' => 'masterpress', 'title' => 'Masterplan', 'href' => admin_url('admin.php?page=masterpress') ) ); if (self::current_user_can('manage_mp_tools')) { $menu_items[] = array( 'id' => 'masterpress-tools', 'parent' => 'masterpress', 'title' => __('Tools', MASTERPRESS_DOMAIN), 'href' => '#', 'meta' => array('class' => "secondary") ); $menu_items[] = array( "id" => "masterpress-flush-rewrite-rules", "title" => __("Flush Rewrite Rules"), 'parent' => 'masterpress-tools', "href" => add_query_arg( array("mp_rewrite" => 1), $wf->current_url() ) ); $menu_items[] = array( "id" => "masterpress-image-cache-site", "title" => __("Clear Image Cache (Site)"), 'parent' => 'masterpress-tools', "href" => add_query_arg( array("mp_image_cache_site" => 1), $wf->current_url() ) ); $menu_items[] = array( "id" => "masterpress-image-cache-admin", "title" => __("Clear Image Cache (Admin)"), 'parent' => 'masterpress-tools', "href" => add_query_arg( array("mp_image_cache_admin" => 1), $wf->current_url() ) ); } if (self::current_user_can('manage_post_types')) { $menu_items[] = array( 'id' => 'masterpress-post-types', 'parent' => 'masterpress', 'title' => __('Post Types', MASTERPRESS_DOMAIN), 'href' => wp_nonce_url(admin_url('admin.php?page=masterpress-post-types'), 'masterpress') ); } if (self::current_user_can('edit_post_types')) { foreach (self::$post_types as $post_type) { if ($post_type->still_registered()) { $menu_items[] = array( 'id' => 'masterpress-post-type-'.$post_type->name, 'parent' => 'masterpress-post-types', 'title' => '<b class="mp-icon mp-icon-post-type mp-icon-post-type-'.$post_type->name.'">'.$post_type->display_label().'</b>', 'href' => MasterPress::admin_url("post-types", "edit", "id=".$post_type->id) ); } } } if (self::current_user_can('manage_taxonomies')) { $menu_items[] = array( 'id' => 'masterpress-taxonomies', 'parent' => 'masterpress', 'title' => __('Taxonomies', MASTERPRESS_DOMAIN), 'href' => wp_nonce_url(admin_url('admin.php?page=masterpress-taxonomies'), 'masterpress') ); } if (self::current_user_can('edit_taxonomies')) { foreach (self::$taxonomies as $tax) { if ($tax->still_registered()) { $menu_items[] = array( 'id' => 'masterpress-post-type-'.$tax->name, 'parent' => 'masterpress-taxonomies', 'title' => '<b class="mp-icon mp-icon-taxonomy mp-icon-taxonomy-'.$tax->name.'">'.$tax->display_label().'</b>', 'href' => MasterPress::admin_url("taxonomies", "edit", "id=".$tax->id) ); } } } if (self::current_user_can('manage_templates')) { $menu_items[] = array( 'id' => 'masterpress-templates', 'parent' => 'masterpress', 'title' => __('Templates', MASTERPRESS_DOMAIN), 'href' => wp_nonce_url(admin_url('admin.php?page=masterpress-templates'), 'masterpress') ); } if (self::current_user_can('manage_shared_field_sets')) { $menu_items[] = array( 'id' => 'masterpress-shared-field-sets', 'parent' => 'masterpress', 'title' => __('Shared Field Sets', MASTERPRESS_DOMAIN), 'href' => wp_nonce_url(admin_url('admin.php?page=masterpress-shared-field-sets'), 'masterpress') ); } if (self::current_user_can('manage_user_roles')) { $menu_items[] = array( 'id' => 'masterpress-roles', 'parent' => 'masterpress', 'title' => __('User Roles', MASTERPRESS_DOMAIN), 'href' => wp_nonce_url(admin_url('admin.php?page=masterpress-roles'), 'masterpress') ); } if (self::current_user_can('manage_site_field_sets')) { $menu_items[] = array( 'id' => 'masterpress-site-field-sets', 'parent' => 'masterpress', 'title' => __('Site Field Sets', MASTERPRESS_DOMAIN), 'href' => wp_nonce_url(admin_url('admin.php?page=masterpress-site-field-sets'), 'masterpress') ); } $add_menu_items = array( array( 'id' => 'masterpress-add-new', 'parent' => 'masterpress', 'title' => __('Add New', MASTERPRESS_DOMAIN), 'href' => '#', 'meta' => array('class' => "secondary") ) ); if (self::current_user_can('create_post_types')) { $add_menu_items[] = array( 'id' => 'masterpress-add-new-post-type', 'parent' => 'masterpress-add-new', 'title' => __('Post Type', MASTERPRESS_DOMAIN), 'href' => MasterPress::admin_url("post-types", "create") ); } if (self::current_user_can('create_taxonomies')) { $add_menu_items[] = array( 'id' => 'masterpress-add-new-taxonomy', 'parent' => 'masterpress-add-new', 'title' => __('Taxonomy', MASTERPRESS_DOMAIN), 'href' => MasterPress::admin_url("taxonomies", "create") ); } if (self::current_user_can('create_user_roles')) { $add_menu_items[] = array( 'id' => 'masterpress-add-new-user-role', 'parent' => 'masterpress-add-new', 'title' => __('User Role', MASTERPRESS_DOMAIN), 'href' => MasterPress::admin_url("roles", "create") ); } if (self::current_user_can('create_shared_field_sets')) { $add_menu_items[] = array( 'id' => 'masterpress-add-new-shared-field-set', 'parent' => 'masterpress-add-new', 'title' => __('Shared Field Set', MASTERPRESS_DOMAIN), 'href' => MasterPress::admin_url("shared-field-sets", "create") ); } if (self::current_user_can('create_site_field_sets')) { $add_menu_items[] = array( 'id' => 'masterpress-add-new-site-field-set', 'parent' => 'masterpress-add-new', 'title' => __('Site Field Set', MASTERPRESS_DOMAIN), 'href' => MasterPress::admin_url("site-field-sets", "create") ); } if (count($add_menu_items) > 1) { $menu_items = array_merge($menu_items, $add_menu_items); } if (count($menu_items) > 1) { foreach ($menu_items as $menu_item) { $wp_admin_bar->add_menu($menu_item); } } }
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()
public static function action_link( $controller, $action, $text, $qs = array(), $args = array(), $entities = true) { $def_args = array(); $r = wp_parse_args($args, $def_args); $def_qs = array(); $q = wp_parse_args($qs, $def_qs); $tag = '<a href="'.MasterPress::admin_url( $controller, $action, $qs, $entities ).'"'; foreach ($r as $key => $value) { $tag .= ' '.$key.'="'.esc_attr($value).'" '; } if (!isset($r["title"])) { $tag .= ' title="'.strip_tags($text).'"'; } $tag .= ">"; $tag .= $text.'</a>'; return $tag; }
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…", 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…") ?>', buttonChoose: '<?php _e("Choose from Computer…", 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…", 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…", 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 }