public function manage_field_sets() { if (!MasterPress::current_user_can("manage_taxonomy_field_sets")) { wp_die(__("Sorry, you do not have the required capability to manage taxonomy field sets.", MASTERPRESS_DOMAIN)); } MPV::incl("taxonomy-field-sets"); $actions = array(); if (MasterPress::current_user_can("create_taxonomy_field_sets")) { $actions = array( MPV::action_button( $this->key(), "create-field-set", MPV::__create( "" ), array("parent" => MasterPress::$parent), array('class' => 'add-new-h2') ) ); } $this->setup_view( array( "cap_verified" => true, "view" => "taxonomy-field-sets", "method" => "grid", "title_args" => array( "actions" => $actions, "info_panel" => true, "text" => MPV_TaxonomyFieldSets::__p() ) ) ); }
public function grid($id = null) { // include controllers to obtain correct URLs for actions MPV::incl("field-sets"); MPV::incl("taxonomy-field-sets"); MPV::incl("post-types"); MPC::incl("post-types"); $taxonomies = MPM_Taxonomy::find("orderby=disabled,name ASC"); $has_actions = MasterPress::current_user_can("edit_taxonomies,delete_taxonomies,manage_taxonomy_field_sets"); $can_edit = MasterPress::current_user_can("edit_taxonomies"); $can_delete = MasterPress::current_user_can("delete_taxonomies"); $can_create = MasterPress::current_user_can("create_taxonomies"); $can_manage_field_sets = MasterPress::current_user_can("manage_taxonomy_field_sets"); $less = ($can_create) ? 1 : 0; $colspan = ( $has_actions ? 8 : 7 ) - $less; foreach ($taxonomies as $tax) { if (MPC::is_deleting($tax->id)) { self::confirm_delete($tax); } } ?> <?php MPV::messages(); ?> <table cellspacing="0" class="grid grid-taxonomies"> <thead> <tr> <th class="first title-icon"><i class="image-small"></i><span class="ac" title="<?php _e("Title Icon", MASTERPRESS_DOMAIN) ?>"><?php _e("Title Icon", MASTERPRESS_DOMAIN) ?></span></th> <th class="menu-label"><i class="label-string"></i><span><?php _e("Menu Label", MASTERPRESS_DOMAIN) ?></span></th> <th class="taxonomy-name"><i class="tag"></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="share-metaboxes"></i><span><?php _e("Shared 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; ?> <?php foreach ($taxonomies as $tax) : $disabled = $tax->disabled ? "disabled" : ""; $title = $tax->disabled ? ' title="'.__("this taxonomy is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?> <?php if (!$tax->in_current_site()) { $disabled = "disabled"; $title = ' title="'.__("this taxonomy is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" '; } ?> <?php $deleting_class = MPC::is_deleting($tax->id, "delete") ? 'deleting' : ''; $editable_class = $can_edit ? " editable " : ""; $meta = $can_edit ? "{ href: '".MasterPress::admin_url("taxonomies", "edit", "id=".$tax->id)."' }" : ""; ?> <?php if ($tax->still_registered()) : $count++; $first = $count == 1 ? 'first' : ''; ?> <tr <?php echo $title ?> class="<?php echo $first ?> <?php echo $editable_class.$deleting_class ?> <?php echo $disabled ?> <?php echo MPV::updated_class("edit,create", $tax->id) ?> <?php echo $count % 2 == 0 ? "even" : "" ?> sub <?php echo $meta ?>"> <td class="first menu-icon icon"><span class="mp-icon-taxonomy mp-icon-taxonomy-<?php echo $tax->name ?>"></span></td> <td class="menu-label"><strong><?php echo $tax->labels["menu_name"] ?></strong></td> <td class="taxonomy-name"><span class="tt"><?php echo $tax->name ?></span></td> <td class="hierarchical"><?php echo $tax->hierarchical ? '<i class="tick-small"></i><span class="ac">yes</span>' : '<span class="note">–</span>' ?></td> <?php $field_sets = $tax->field_sets(); ?> <?php if ($tax->show_ui) : ?> <td class="field-sets <?php echo $can_manage_field_sets ? "manage { href: '".MasterPress::admin_url( "taxonomies", "manage-field-sets", "parent=".$tax->id)."' }" : "" ?>"> <?php if ($can_manage_field_sets) : ?> <a href="<?php echo MasterPress::admin_url( "taxonomies", "manage-field-sets", "parent=".$tax->id)?>" title="<?php echo strip_tags(self::__manage( MPV_TaxonomyFieldSets::__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 taxonomy 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 ($tax->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 taxonomy 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="post-types <?php echo $has_actions ? "" : "last" ?>"> <?php $post_types = $tax->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 $field_sets = $tax->field_sets(); ?> <?php if ($has_actions) : ?> <td class="actions last"> <div> <?php if (MPC::is_deleting($tax->id)) : ?> <span class="confirm-action"> </span> <?php else: ?> <?php if ($can_manage_field_sets) : ?> <?php if ($tax->show_ui) : ?> <?php echo MPV::action_button("taxonomies", "manage-field-sets", self::__manage( MPV_FieldSets::__p_short() ), "parent=".$tax->id, array("class" => "button button-manage")); ?> <?php else: ?> <?php echo MPV::action_button("taxonomies", "manage-field-sets", self::__manage( MPV_FieldSets::__p_short() ), "parent=".$tax->id, array("title" => "This taxonomy 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("taxonomies", "edit", self::__edit( "" ), "id=".$tax->id, array( "class" => "button primary button-edit" )); ?> <?php endif; ?> <?php if ($can_delete) : ?> <?php if ($tax->_builtin) : ?> <span class="note" title="<?php _e("This taxonomy cannot be deleted as it is built-in to WordPress", MASTERPRESS_DOMAIN) ?>"><?php _e("( Built-in )", MASTERPRESS_DOMAIN) ?></span> <?php elseif ($tax->_external) : ?> <span class="note" title="<?php _e("This taxonomy 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("taxonomies", "delete", self::__delete( "" ), "id=".$tax->id, array( "class" => "button button-delete" )); ?> <?php endif; ?> <?php endif; ?> <?php endif; ?> </div> </td> <?php endif; // has_actions ?> </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, __("%d Taxonomies", MASTERPRESS_DOMAIN), __("%d Taxonomies", MASTERPRESS_DOMAIN) ) ) ?></td> <?php if ($can_create) : ?> <td class="last actions"> <?php echo MPV::action_button("taxonomies", "create", self::__create(MPV_Taxonomies::__s()), "", array( "class" => "button button-create" )); ?> </td> <?php endif; ?> </tr> </tbody> </table> <?php } // end grid()