public function grid() { MPV::incl("fields"); $info = MasterPress::$view; ?> <?php MPV::messages(); ?> <div class="grid-set"> <?php $field_sets = MPM_SiteFieldSet::find( array("orderby" => "name ASC" ) ); ?> <?php MPV::field_set_icon_styles($field_sets); ?> <?php $has_actions = MasterPress::current_user_can("edit_site_field_sets,delete_site_field_sets,edit_site_fields,delete_site_fields"); $can_edit = MasterPress::current_user_can("edit_site_field_sets"); $can_delete = MasterPress::current_user_can("delete_site_field_sets"); $can_create = MasterPress::current_user_can("create_site_field_sets"); $can_edit_fields = MasterPress::current_user_can("edit_site_fields"); $can_delete_fields = MasterPress::current_user_can("delete_site_fields"); $can_create_fields = MasterPress::current_user_can("create_site_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")) { $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 <?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 $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("site-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 <?php echo $title ?> class="<?php echo $disabled ?> <?php echo $editable_class.$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 <?php echo $has_actions ? "" : "last" ?>"><span class="tt"><?php echo $field_set->display_name() ?></span></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("site-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("site-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("site-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 <?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("site-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("site-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: ?> <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 if ($can_create_fields) : ?> <td class="last actions <?php echo count($fields) ? "" : "hl" ?>"> <?php echo MPV::action_button("site-field-sets", "create-field", self::__create(MPV_Fields::__s()), array("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("site-field-sets", "create", MPV::__create( MPV_SiteFieldSets::__s() ), array() ); ?> </div> <?php endif; ?> <?php else: ?> <?php if ($can_create) : ?> <a href="<?php echo MasterPress::admin_url("site-field-sets", "create") ?>" class="no-items-create"> <i class="plus-circle"></i> <span><?php _e( "There are currently no Site Field Sets. Click here to create one." ) ?></span> </a> <?php endif; ?> <?php endif; ?> </div> <?php } // end grid()
public function get_current_rep() { global $wf; $rep = array( "post_types" => array(), "taxonomies" => array(), "shared_field_sets" => array(), "site_field_sets" => array(), "roles" => array() ); foreach (MPM_PostType::find() as $post_type) { $rep["post_types"][$post_type->name] = $post_type->rep(); } foreach (MPM_Taxonomy::find() as $tax) { $rep["taxonomies"][$tax->name] = $tax->rep(); } foreach (MPM_SharedFieldSet::find() as $set) { $rep["shared_field_sets"][$set->id] = $set->rep(); } foreach (MPM_SiteFieldSet::find() as $set) { $rep["site_field_sets"][$set->id] = $set->rep(); } $templates = isset( $_POST["templates"] ) ? $_POST["templates"] : array(); foreach ($templates as $file => $template) { $model = MPM_Template::find_by_id($file); $rep["templates"][$file] = $model->rep(); } $roles = $wf->roles(); $rep["roles"] = array(); foreach ($roles as $role) { $role_id = $role->id(); if (!isset($rep["roles"][$role_id])) { $rep["roles"][$role_id] = array( "id" => $role_id, "name" => $role->name, "capabilities" => $role->capabilities() ); } foreach (MPM_RoleFieldSet::find_by_role($role_id, "id ASC") as $set) { $r = $set->rep(); $rep["roles"][$role_id]["field_sets"][] = $r; } } return $rep; }
public function form() { $model = MasterPress::$model; $info = MasterPress::$view; $parent = $info->parent; global $wf; $prefix = ""; $default_key = "edit_posts"; $keys = array(); ?> <div class="mpv-field-sets-form"> <?php if (isset(MasterPress::$parent)) : ?> <div class="title-info-panel"> <div class="title-info-panel-lt"> <?php if (get_class($parent) == "MPM_PostType") : ?> <?php $post_type = $parent; $prefix = $post_type->name."_"; $default_key = "edit_".$post_type->capability_type."s"; $keys = array($default_key); ?> <h3 class="post-type"><i class="mp-icon mp-icon-post-type mp-icon-post-type-<?php echo $post_type->name ?>"></i><span class="label"><?php _e("Post Type:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $parent->labels["name"] ?></span></h3> <input id="post_type_name" type="hidden" value="<?php echo $parent->name ?>" /> <?php elseif ($model->template) : ?> <?php $file = MasterPress::$parent; $page_templates = array_flip(get_page_templates()); $template_name = $page_templates[$file]; ?> <input id="templates" name="templates" type="hidden" value="<?php echo $file ?>" /> <h3><i class="template"></i><span class="label"><?php _e("Template:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $template_name ?></span></h3> <?php elseif ($model->role) : ?> <?php $role_name = MasterPress::$parent; $prefix = $role_name."_"; ?> <input id="roles" name="roles" type="hidden" value="<?php echo $role_name ?>" /> <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> <?php elseif ($model->taxonomy) : ?> <?php $taxonomy_id = MasterPress::$parent; $tax = MPM_Taxonomy::find_by_id($taxonomy_id); $prefix = $tax->name."_"; $default_key = $tax->capabilities["edit_terms"]; $keys = array( $tax->capabilities["manage_terms"], $tax->capabilities["edit_terms"], $tax->capabilities["assign_terms"] ); ?> <input id="taxonomies" name="taxonomies" type="hidden" value="<?php echo $tax->name ?>" /> <h3><i class="mp-icon mp-icon-taxonomy mp-icon-taxonomy-<?php echo $tax->name ?>"></i><span class="label"><?php _e("Taxonomy:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $tax->display_label() ?></span></h3> <?php endif; ?> </div> </div> <?php endif; ?> <?php MPV::messages(); ?> <div class="mpv-field-sets-form"> <div class="f"> <label for="name" class="icon"><i class="script-php"></i><?php _e("Name", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <input id="name_original" name="name_original" type="hidden" class="text mono key" maxlength="20" value="<?php echo $model->name ?>" /> <input id="name_last" name="name_last" type="hidden" class="text mono key" maxlength="20" value="<?php echo $model->name ?>" /> <input id="name" name="name" type="text" class="text mono key" maxlength="255" value="<?php echo $model->name ?>" /><em class="required">(required)</em> <p> <?php _e("This is a unique identifier for the field set used in the MasterPress API. Since it can be used as a PHP variable name, it is restricted to being a lowercase string with words separated by underscores.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div id="f-singular_name" class="f"> <label for="singular_name" class="icon" maxlength="255"><i class="script-php"></i><?php _e("<strong>Singular</strong> Name", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <input id="singular_name" name="singular_name" type="text" value="<?php echo $model->singular_name ?>" class="text mono key" /><em class="required">(required)</em> <p> <?php _e("The singular form of <em>Name</em>, following the same naming conventions", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="allow_multiple" class="icon"><i class="add-remove"></i><?php _e("Allow Multiple Items", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="allow_multiple" name="allow_multiple" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->allow_multiple ) ?> class="checkbox" /> <p id="name_warning" class="warning"> <i class="error-circle"></i> <?php _e("For multiple-item field sets, <em>Name</em> should be specified in <strong>plural form</strong>. Please verify that this is correct above.", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> <div class="f clearfix"> <label id="label-icon" for="icon" class="icon"><i class="image-small"></i><?php _e("Title Icon (16 x 16)", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <div id="icon-file-uploader" class="icon-uploader file-uploader { ids: { drop: 'icon_drop_area' }, input: '#icon', inputName: 'icon_ul', base_url: '<?php echo MASTERPRESS_GLOBAL_CONTENT_URL ?>', params: { dir: 'menu-icons/' }, limit: 1, lang: { buttonChoose: '<?php _e("Choose from Computer…", MASTERPRESS_DOMAIN) ?>', buttonReplace: '<?php _e("Replace file…", MASTERPRESS_DOMAIN) ?>' } }"> <div id="icon_drop_area" class="drop-area"><?php _e("Drop file here to upload", MASTERPRESS_DOMAIN) ?></div> <?php $file_name = $model->icon; $file_class = ""; $clear_class = ""; $preview_class = ""; if ($file_name == "") { $file_name = __("( None )", MASTERPRESS_DOMAIN); $file_class = "name-none"; $preview_class = "preview-none"; $style = ""; $clear_class = "hidden"; } else { $style = ' style="background-image: url('.MPU::field_set_icon_url($model->icon).')" '; } ?> <div class="file"> <span class="preview <?php echo $preview_class ?>" <?php echo $style ?>></span><span data-none="<?php echo __("( None )", MASTERPRESS_DOMAIN) ?>" class="name <?php echo $file_class ?>"><?php echo $file_name ?></span> <button type="button" class="<?php echo $clear_class ?> clear ir" title="<?php _e("Clear", MASTERPRESS_DOMAIN) ?>">Clear</button> </div> <input id="icon" name="icon" value="<?php echo $model->icon ?>" type="hidden" /> <div class="uploader-ui"></div> </div> <!-- /.file-uploader --> <?php MPV::icon_select($model->icon, "menu-icon-select", "icon_select", "icon-file-uploader"); ?> </div> </div> <!-- /.f --> <div class="f"> <label for="expanded" class="icon"><i class="expand"></i><?php _e("Expanded", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="expanded" name="expanded" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->expanded ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#expanded' }"> <?php _e("this field set will be expanded (not summarised) by default in the edit post screen, but can still be collapsed. It is recommended that this is <strong>unchecked if <em>Allow Multiple Items</em> is checked.</strong>", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php if (!$model->role) : ?> <div class="f"> <label for="sidebar" class="icon"><i class="sidebar"></i><?php _e("Show in Sidebar", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="sidebar" name="sidebar" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->sidebar ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#sidebar' }"> <?php _e("this field set will be positioned in the sidebar of the edit post screen by default (but may still be dragged across to the main content area by users)", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php endif; ?> <div class="f"> <label for="disabled" class="icon"><i class="slash"></i><?php _e("Disabled", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="disabled" name="disabled" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->disabled ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#disabled' }"> <?php _e("disabling a field set will keep its definition in the database but it will not be available in any post editing screens in WordPress, which may be <strong>preferable to deleting it</strong> completely.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="versions_store" class="icon"><i class="metabox-versions size-20"></i><?php _e("Version Limit", MASTERPRESS_DOMAIN) ?></label> <div class="fw"> <input id="versions" name="versions" type="text" value="<?php echo $model->versions ?>" class="text" /> <p class="note"> <?php _e("Set a <b>maximum number of versions</b> of content based on this field set to retain.<br />Versions can be used to restore previous revisions of content at a later time.<br />Set this value to 0 if you do not wish to retain previous versions.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="fs fs-labels"> <div class="fst"> <div class="fstb"> <h3><i class="label-string"></i><strong><?php _e("Labels", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("displayed in the <em>Edit Post</em> and MasterPress admin screens", MASTERPRESS_DOMAIN) ?></h3> <div class="buttons"> <button id="autofill-labels" class="button button-autofill" type="button"><?php _e('<strong>Auto-Fill</strong> Labels', MASTERPRESS_DOMAIN) ?></button> </div> </div> </div> <div class="fsc fscs"> <div class="fscb"> <div class="scroll"> <div class="f"> <label for="label_name"><?php _e("Set Label", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_name" name="labels[name]" value="<?php echo $model->labels["name"] ?>" type="text" class="text { tmpl: '{{plural_name}}' }" /> <em class="recommended">(recommended)</em> </div> </div> <!-- /.f --> <div class="f"> <label for="label_description"><?php _e("Description", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <textarea id="label_description" name="labels[description]"><?php echo $model->label("description") ?></textarea> <p> <?php _e("Displayed on the Create / Edit Post screen in the info area above the fields in this set.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php if ($model->shared) : ?> <div class="f"> <label for="label_description_user"><?php _e("Description (User)", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <textarea id="label_description_user" name="labels[description_user]"><?php echo $model->label("description_user") ?></textarea> <p> <?php _e("Displayed on the Create / Edit User and Profile screen in the info area above the fields in this set.<br />If not specified, the standard <em>Description</em> label will be used (if available)", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="label_description_term"><?php _e("Description (Term)", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <textarea id="label_description_term" name="labels[description_term]"><?php echo $model->label("description_term") ?></textarea> <p> <?php _e("Displayed on the Edit (Taxonomy) Term in the info area above the fields in this set.<br />If not specified, the standard <em>Description</em> label will be used (if available)", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php endif; ?> <div class="f f-allow-multiple"> <label for="label_singular_name"><?php _e("<em>Singular</em> Name", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_singular_name" name="labels[singular_name]" value="<?php echo $model->label("singular_name") ?>" type="text" class="text { tmpl: '{{singular_name}}' }" /> <em class="recommended">(recommended)</em> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_add"><?php _e("Add", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_add" name="labels[add]" value="<?php echo $model->label("add") ?>" type="text" class="text { tmpl: '<?php _e("Add {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_add_another"><?php _e("Add Another", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_add_another" name="labels[add_another]" value="<?php echo $model->label("add_another") ?>" type="text" class="text { tmpl: '<?php _e("Add Another {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_remove"><?php _e("Remove", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_remove" name="labels[remove]" value="<?php echo $model->label("remove") ?>" type="text" class="text { tmpl: '<?php _e("Remove {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_click_to_add"><?php _e("Click to Add", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_click_to_add" name="labels[click_to_add]" value="<?php echo $model->label("click_to_add") ?>" type="text" class="text { tmpl: '<?php _e("Click to add {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_one_item"><?php _e("1 Item", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_one_item" name="labels[one_item]" value="<?php echo $model->label("one_item") ?>" type="text" class="text { tmpl: '<?php _e("1 {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_n_items"><?php _e("n Items", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_n_items" name="labels[n_items]" value="<?php echo $model->label("n_items") ?>" type="text" class="text { tmpl: '<?php _e("%d {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f f-allow-multiple"> <label for="label_no_items"><?php _e("No Items", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_no_items" name="labels[no_items]" value="<?php echo $model->label("no_items") ?>" type="text" class="text { tmpl: '<?php _e("No {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> </div> </div> </div> </div> <!-- /.fs --> <div class="fs fs-capability-keys clearfix"> <div class="fst"> <div class="fstb"> <h3><i class="key"></i><strong><?php _e("Capabilities", MASTERPRESS_DOMAIN) ?></strong> - <?php _e('the keys used to control access to this field set', MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb clearfix"> <div class="f f-capabilities f-capabilities-editable clearfix"> <label for="label-capabilities-editable"><?php _e("Editable", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <?php $val = $model->capability("editable", false); $caps = array_unique(array_merge($keys, array("edit_posts", "edit_pages"))); $caps = array( __("-- None (Always Editable) --", MASTERPRESS_DOMAIN) => "" ) + $caps; if (MPC::is_edit()) { $caps[] = "edit_".$prefix.$model->name; } $custom_val = ""; if (!in_array($val, $caps)) { $custom_val = $val; } echo WOOF_HTML::select( array("id" => "capabilities-editable", "name" => "capabilities[editable]", "class" => "capabilities" ), $caps, $val ); ?> <label for="capabilities-editable-custom" class="capabilities-custom"><?php _e("OR custom value") ?></label> <input id="capabilities-editable-custom" name="capabilities_custom[editable]" value="<?php echo $custom_val ?>" type="text" class="text mono capabilities-custom" /> <p class="note"> <?php _e("All fields in this set will be read-only for users without this capability.<br />Individual fields may override this with their own capabilities.", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> <div class="f f-capabilities f-capabilities-visible clearfix"> <label for="label-capabilities-visible"><?php _e("Visible", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <?php $val = $model->capability("visible", false); $caps = array_unique(array_merge($keys, array("edit_posts", "edit_pages"))); $caps = array( __("-- None (Always Visible) --", MASTERPRESS_DOMAIN) => "" ) + $caps; if (MPC::is_edit()) { $caps[] = "view_".$prefix.$model->name; } $custom_val = ""; if (!in_array($val, $caps)) { $custom_val = $val; } echo WOOF_HTML::select( array("id" => "capabilities-visible", "name" => "capabilities[visible]", "class" => "capabilities" ), $caps, $val ); ?> <label for="capabilities-visible-custom" class="capabilities-custom"><?php _e("OR custom value") ?></label> <input id="capabilities-visible-custom" name="capabilities_custom[visible]" value="<?php echo $custom_val ?>" type="text" class="text mono capabilities-custom" /> <p class="note"> <?php _e("This field set will be invisible for users without this capability", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs --> <?php $args = array(); $args["supports"] = array(); if (is_multisite() && MASTERPRESS_MULTISITE_SHARING) { $args["supports"] = array("multisite"); } if ($model->is_shared()) { $args["supports"][] = "post_types"; } if (!isset($info->is_template_set) && $model->is_shared() ) { $args["supports"][] = "templates"; } if (!isset($info->is_role_set) && $model->is_shared() ) { $args["supports"][] = "roles"; } if (!isset($info->is_taxonomy_set) && $model->is_shared() ) { $args["supports"][] = "taxonomies"; } $args["labels"] = array( "title" => __("control the visibility of this field set within WordPress", MASTERPRESS_DOMAIN), "title_multisite" => __("specify the sites in the multisite network that this field set is available in", MASTERPRESS_DOMAIN), "title_post_types" => __("specify the post types that this field set is available in", MASTERPRESS_DOMAIN), "title_templates" => __("specify the templates that this field set is available in", MASTERPRESS_DOMAIN), "title_roles" => __("specify the roles that users must have for this field set to be available in their profile edit screen", MASTERPRESS_DOMAIN), "multisite_all" => __( "All Sites" ), "post_types_all" => __( "All Post Types" ), "templates_all" => __( "All Templates" ) ); $args["defaults"] = array( "post_types" => "all" ); if ($model->type == "p") { $post_type = $parent; $templates = $post_type->templates(); if (count($templates)) { $args["supports"][] = "templates"; $args["templates"] = array(); $all = array_flip(get_page_templates()); foreach ($templates as $t) { $name = $all[$t->id]; $args["templates"][$name] = $t->id; } } } if (isset($parent) && is_multisite()) { $site_options = array(); foreach ($parent->sites() as $site) { $site_options[$site->full_path()] = $site->id(); } $args["sites"] = $site_options; }; MPV::fs_visibility( $model, $args ); ?> <?php if ($info->is_template_set) : ?> <input id="visibility-templates" name="visibility[templates]" type="hidden" value="<?php echo $file ?>" /> <?php endif; ?> <?php if ($info->is_role_set) : ?> <input id="visibility-roles" name="visibility[roles]" type="hidden" value="<?php echo $role_name ?>" /> <?php endif; ?> <?php if ($info->is_taxonomy_set) : ?> <input id="visibility-taxonomies" name="visibility[taxonomies]" type="hidden" value="<?php echo $tax->name ?>" /> <?php endif; ?> <?php if ($model->is_post_type() && isset($parent)) : ?> <input id="visibility-post-types" name="visibility[post_types]" type="hidden" value="<?php echo $parent->name ?>" /> <?php endif; ?> <div id="f-position" class="f clearfix"> <label for="position" class="icon"><i class="sort"></i><?php _e("Set Position", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <div class="sortable-list sortable-list-fields"> <span class="arrow"></span> <?php // build a field list $field_sets = array(); if ($model->shared) { $field_sets = MPM_SharedFieldSet::find( array( "orderby" => "position ASC" ) ); } else if ($model->template) { $field_sets = MPM_TemplateFieldSet::find_by_template( MasterPress::$parent ); } else if ($model->role) { $field_sets = MPM_RoleFieldSet::find_by_role( MasterPress::$parent ); } else if ($model->taxonomy) { $field_sets = MPM_TaxonomyFieldSet::find_by_taxonomy( $tax ); } else if ($model->site) { $field_sets = MPM_SiteFieldSet::find( array( "orderby" => "position ASC" ) ); } else { $sql = "SELECT * FROM ".MPU::table("field-sets")." WHERE ( type = 'p' ) AND ".MPM::visibility_rlike("post_types", $parent->name)." ORDER BY position"; $field_sets = MPM::get_models("field-set", $sql); } $sort_field_sets = array(); // now build a representable list of field_sets $icon = $model->shared ? MPU::img_url("icon-shared-field-set.png") : MPU::img_url("icon-field-set-small.png"); $icon_class = $model->shared ? "metabox-share" : "metabox"; foreach ($field_sets as $field_set) { $position = $field_set->position; if (isset($_POST["other_position"]) && $_POST["other_position"][$field_set->id]) { $position = $_POST["other_position"][$field_set->id]; } $sort_field_sets[] = array( "position" => $position, "disabled" => $field_set->disabled, "current" => $field_set->id == $model->id, "label" => $field_set->display_label(), "icon_class" => $icon_class, "icon" => $icon, "id" => $field_set->id ); } if (MPC::is_create()) { $label = $model->display_label(); if (!$label || $label == "") { $label = "?"; } $sort_field_sets[] = array( "position" => $model->position, "disabled" => $model->disabled, "current" => true, "label" => $model->display_label(), "icon" => $icon, "icon_class" => $icon_class ); } $count = 0; ?> <ul> <?php foreach ($sort_field_sets as $f) : $count++; $first = $count == 1 ? "first " : ""; $current = $f["current"] ? 'current ' : ''; ?> <?php $disabled = $f["disabled"] ? 'disabled' : ''; $disabled_title = $f["disabled"] ? __("This field set is disabled", MASTERPRESS_DOMAIN) : ''; ?> <li class="<?php echo $first.$current ?> <?php echo $disabled ?>" title="<?php echo $disabled_title ?>"> <i class="<?php echo $icon_class ?>"></i> <?php if ($f["current"]) : ?> <span class="inline fill { src: '#label_name,#label_singular_name'}"><?php echo $f["label"] ?></span> <input id="position" name="position" value="<?php echo $f["position"] ?>" type="hidden" class="text" /> <?php else: ?> <span class="inline"><?php echo $f["label"] ?></span> <input id="other_position" name="other_position[<?php echo $f["id"] ?>]" value="<?php echo $f["position"] ?>" type="hidden" /> <?php endif; ?> </li> <?php endforeach; ?> </ul> </div> <!-- /.sortable-list --> <p> <?php _e("Drag set to the desired <em>default</em> position in the WordPress <em>Create / Edit Post</em> screen.<br />Note: Field sets are displayed in a standard WordPress UI panel (metabox), which can be dragged around by the user to also influence the order.", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> </div> <!-- /.mpv-field-sets-form --> <?php }
public static function admin_menu() { global $wf; // we need to hide built-in types foreach (MasterPress::$post_types as $post_type) { if ($post_type->name == "post" && ($post_type->disabled || !$post_type->in_current_site())) { remove_menu_page('edit.php'); } else if ($post_type->name == "page" && ($post_type->disabled || !$post_type->in_current_site())) { remove_menu_page('edit.php?post_type=page'); } else if ($post_type->name == "attachment" && ($post_type->disabled || !$post_type->in_current_site())) { remove_menu_page('upload.php'); } } $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"), "manage_mp_tools" => MasterPress::get_cap_key("manage_mp_tools") ); if ($wf->the_user->is_an("Administrator")) { // ensure that user roles can be accessed by admins! $caps["manage_user_roles"] = "manage_options"; $caps["edit_user_roles"] = "manage_options"; $caps["manage_mp_settings"] = "manage_options"; } // main menu $page = add_menu_page( __( 'Masterplan', "masterpress" ), __( 'Masterplan', "masterpress" ), $caps['manage_masterplan'], 'masterpress', array('MasterPress', 'render'), self::menu_icon( "masterpress", MPU::plugin_image("menu-icon-masterpress.sprite.png"), "", true ), "85.5" ); add_action("load-$page", array("MasterPress", "add_help_tabs")); // sub menus $sm = add_submenu_page( 'masterpress', __('Post Types', MASTERPRESS_DOMAIN), MPU::options_menu('post-types', __( 'Post Types', MASTERPRESS_DOMAIN )), $caps['manage_post_types'], 'masterpress-post-types', array('MasterPress', 'render') ); add_action("load-$sm", array("MasterPress", "add_help_tabs")); $sm = add_submenu_page( 'masterpress', __('Taxonomies', MASTERPRESS_DOMAIN), MPU::options_menu('taxonomies', __( 'Taxonomies', MASTERPRESS_DOMAIN )), $caps['manage_taxonomies'], 'masterpress-taxonomies', array('MasterPress', 'render') ); add_action("load-$sm", array("MasterPress", "add_help_tabs")); $sm = add_submenu_page( 'masterpress', __('Templates', MASTERPRESS_DOMAIN), MPU::options_menu('page-templates', __( 'Templates', MASTERPRESS_DOMAIN )), $caps['manage_templates'], 'masterpress-templates', array('MasterPress', 'render') ); add_action("load-$sm", array("MasterPress", "add_help_tabs")); $sm = add_submenu_page( 'masterpress', __('User Roles' ), MPU::options_menu('roles', __( 'User Roles', MASTERPRESS_DOMAIN )), $caps['manage_user_roles'], 'masterpress-roles', array('MasterPress', 'render') ); add_action("load-$sm", array("MasterPress", "add_help_tabs")); $sm = add_submenu_page( 'masterpress', __('Site Field Sets', MASTERPRESS_DOMAIN), MPU::options_menu('site-field-sets', __( 'Site Field Sets', MASTERPRESS_DOMAIN )), $caps['manage_site_field_sets'], 'masterpress-site-field-sets', array('MasterPress', 'render') ); add_action("load-$sm", array("MasterPress", "add_help_tabs")); $sm = add_submenu_page( 'masterpress', __('Shared Field Sets', MASTERPRESS_DOMAIN), MPU::options_menu('shared-field-sets', __( 'Shared Field Sets', MASTERPRESS_DOMAIN )), $caps['manage_shared_field_sets'], 'masterpress-shared-field-sets', array('MasterPress', 'render') ); add_action("load-$sm", array("MasterPress", "add_help_tabs")); // add settings page for MasterPress add_options_page( __('MasterPress', MASTERPRESS_DOMAIN), __('MasterPress', MASTERPRESS_DOMAIN), 'manage_options', 'masterpress-settings', array("MasterPress", "render")); add_action("load-$sm", array("MasterPress", "add_help_tabs")); $sfs = MPM_SiteFieldSet::find(); if (count($sfs)) { $page = add_menu_page( __("Site Content", MASTERPRESS_DOMAIN), __("Site Content", MASTERPRESS_DOMAIN), 'publish_posts', 'masterpress-site-content', array('MasterPress', 'render'), self::menu_icon( "masterpress-site-content", MPU::plugin_image("menu-icon-site-content.png") ), "3" ); add_action("load-$page", array("MasterPress", "add_help_tabs")); } } // create_menu
public function site_field_sets($orderby = "position ASC") { global $wf; $args = array($orderby); if (is_null($ret = $this->property_cache_args("site_field_sets", $args ))) { $this->field_types = array(); global $wpdb; $field_sets_table = MPM::table("field-sets"); $fields_table = MPM::table("fields"); $select_list = $this->assigned_select_list(); $sql = " SELECT $select_list FROM $field_sets_table s INNER JOIN $fields_table f ON s.id = f.`field_set_id` WHERE (s.type = 'w') AND f.disabled = 0 AND s.disabled = 0 ORDER BY set_type, set_position, field_position; "; $field_sets = array(); $fields_by_set = array(); $results = $wpdb->get_results($sql); foreach ($results as $result) { $set_name = $result->set_name; $set_type = $result->set_type; $use_set = true; $use_field = true; if ($use_set) { $field_sets[$set_name] = $this->set_data_from_result($result); } // now record the field too if ($use_field) { if (!in_array($result->field_type, $this->field_types)) { $this->field_types[] = $result->field_type; } $fields_by_set[$set_name][$result->field_name] = $this->field_data_from_result($result); } } // endforeach $field_set_models = array(); foreach ($field_sets as $field_set) { $field_set_model = new MPM_SiteFieldSet(); $field_set_model->set_from_row($field_set); $field_models = array(); $fields = $fields_by_set[$field_set["name"]]; if (is_array($fields) && count($fields)) { foreach ($fields as $field) { $field_model = new MPM_Field(); $field_model->set_from_row($field); if ($field_model->in_current_site()) { $field_models[$field["name"]] = $field_model; } } $field_set_model->set_fields($field_models); } if ($field_set_model->in_current_site()) { $field_set_models[$field_set_model->name] = $field_set_model; } } $ret = $this->property_cache_args("site_field_sets", $args, $field_set_models ); } return $ret; }
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 }