public function init() { $action = MasterPress::$action; // inform the view what to render in the info panel MasterPress::$view->is_role_set = true; if ($action == "edit-field" || $action == "create-field") { // inform the view what to render in the info panel MasterPress::$view->parent = MPM_FieldSet::find_by_id(MasterPress::$parent); // enqueue the field type CSS $type = MasterPress::$model->type; MPFT::options_admin_head($type); // enqueue dependent scripts for all field types (could improve this in the future) foreach (MPFT::type_keys() as $type) { if ($ftc = MPFT::type_class($type)) { call_user_func( array($ftc, "enqueue") ); } } } if ($action == "create-field") { MasterPress::$model->field_set_id = MasterPress::$parent; MasterPress::$model->infer_position(); } }
public function dispatch() { $type = str_replace("_", "-", $_REQUEST["type"]); $method = $_REQUEST["type_method"]; if ($ftc = MPFT::type_class($type)) { if (method_exists($ftc, $method)) { return call_user_func( array($ftc, $method) ); } else { self::ajax_error( sprintf(__("The method '%s' could not be called in the PHP Field Type Class '%s'. Please check that the method exists.", MASTERPRESS_DOMAIN), $method, $ftc) ); } } else { self::ajax_error( sprintf(__("AJAX method '%s' could not be called as the PHP Field Type Class '%s' could not be found for type key '%s'. Please check that everything is setup correctly in this field type.", MASTERPRESS_DOMAIN), $ftc, $type)); } }
function __construct($name, $object, $info) { $this->name = $name; // a full name (set.field) $this->set_index = 0; $this->object = $object; $this->info = $info; if ($this->exists()) { if ($type_class = MPFT::type_class($this->info->type)) { // instantiate the delegate $this->type_delegate = new $type_class($this->info, $this); } else { $this->type_delegate = new MPFT($this->info, $this); } } }
public static function extension_type_keys($sort = true) { if (!self::$extension_type_keys) { self::$extension_type_keys = MPU::file_list( MPU::extension_type_dir() ); } return self::$extension_type_keys; }
public function delete_meta() { global $wpdb; // get a list of meta values bound to this field. $sql = "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE meta_key LIKE '%:field_id' AND meta_value = '".$this->id."'"; $rows = $wpdb->get_results($sql); foreach ($rows as $row) { list($set_name, $field_name, $prop_name) = MPFT::parse_meta_key($row->meta_key); // note that we delete the properties too, but only count the main fields. $sql = "DELETE FROM $wpdb->postmeta WHERE post_id = ".$row->post_id." AND ( meta_key = '".MPFT::meta_key($set_name, $field_name)."' OR meta_key LIKE '".MPFT::meta_key($set_name, $field_name).":%' )"; $wpdb->query($sql); } }
public function call($name, $arguments) { if (method_exists($this->file, $name)) { return call_user_func_array (array($this->file, $name), $arguments); } return parent::call($name, $arguments); }
public static function options_form( $options ) { $html = ""; $limit = self::get_filesize_limit(); $limit_mb = WOOF_File::format_filesize($limit, "MB", false); $defaults = array( "filename_case" => "lowercase", "filename_sanitize" => "dashes", "allowed_types" => array("ogg","mp3","wav") ); $options = wp_parse_args( $options, $defaults ); $p = self::type_prefix(__CLASS__); $allowed_maxsize = self::option_value($options, "allowed_maxsize"); $allowed_types = self::option_value($options, "allowed_types"); $allowed_field = implode(",", $allowed_types); $allowed_types_label = __("Allowed File Types:", MASTERPRESS_DOMAIN); $allowed_maxsize_label = __("Maximum Size:", MASTERPRESS_DOMAIN); $allowed_field_label = __("More Allowed Types:", MASTERPRESS_DOMAIN); $allowed_field_note = __("Separate file extensions that you would like to allow with commas.<br /><strong>Important:</strong> in the interests of security, take care to avoid file types that are executable on your server that may be exploitable by malicious users.<br /><br />Alternatively, you can populate the list by selecting from the list of typical field types below:", MASTERPRESS_DOMAIN); $filename_label = __("File Name Handling", MASTERPRESS_DOMAIN); $filename_label_note = __("specify how file names should be sanitized on upload", MASTERPRESS_DOMAIN); $filename_sanitize_label = __("Sanitize file name:", MASTERPRESS_DOMAIN); $filename_sanitize_note = __("Sanitization removes special characters and replaces word boundaries with the specified character", MASTERPRESS_DOMAIN); $filename_case_label = __("Change case to:", MASTERPRESS_DOMAIN); $filename_case_select = WOOF_HTML::select( array("id" => $p."filename_case", "name" => "type_options[filename_case]"), array( "lower-case" => "lowercase", "Title-Case" => "titlecase", "UPPER-CASE" => "uppercase", "Preserve (No Change)" => "none" ), $options["filename_case"] ); $filename_sanitize_select = WOOF_HTML::select( array("id" => $p."filename_sanitize", "name" => "type_options[filename_sanitize]"), array( __("With Dashes ( - )", MASTERPRESS_DOMAIN) => "dashes", __("With Underscores ( _ )", MASTERPRESS_DOMAIN) => "underscores", __("None (Don't Sanitize)", MASTERPRESS_DOMAIN) => "none" ), $options["filename_sanitize"] ); $allowed_maxsize_note = __("( MB )", MASTERPRESS_DOMAIN); $allowed_maxsize_blank_note = sprintf(__("This value <strong>cannot exceed</strong> the maximum upload size<br />for your server, which is currently set to <strong>%s</strong>.", MASTERPRESS_DOMAIN), WOOF_File::format_filesize($limit, "MB", true, " ")); $allowed_label = __("File Restrictions", MASTERPRESS_DOMAIN); $allowed_label_note = __("restrict allowable files by type and file size", MASTERPRESS_DOMAIN); // setup variables to insert into the heredoc string // (this is required where we cannot call functions within heredoc strings) MPFT::incl("file"); foreach (array("aac","aif","aiff","m4a", "ogg", "mid", "mp3", "mp4", "mpa", "wav", "wma") as $ext) { $file_types_items[ MPFT_File::file_type_label($ext) ] = $ext; } $allowed_types_checkboxes = WOOF_HTML::input_checkbox_group( "type_options[allowed_types][]", $p."allowed-types-", $file_types_items, $options["allowed_types"], WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")); $html .= <<<HTML <div class="filename-handling-wrap"> <h4><i class="highlighter"></i>{$filename_label}<span> - {$filename_label_note}</span></h4> <div class="f"> <label for="{$p}filename_sanitize">{$filename_sanitize_label}</label> <div id="fw-{$p}filename_sanitize" class="fw"> {$filename_sanitize_select} <p class="note">{$filename_sanitize_note}</p> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}filename_case">{$filename_case_label}</label> <div id="fw-{$p}filename_case" class="fw"> {$filename_case_select} </div> </div> <!-- /.f --> </div> <div class="allowed-wrap divider"> <h4><i class="warning-shield"></i>{$allowed_label}<span> - {$allowed_label_note}</span></h4> <div class="f"> <label for="{$p}allowed_maxsize">{$allowed_maxsize_label}</label> <div id="fw-{$p}allowed_maxsize" class="fw"> <input id="{$p}allowed_maxsize" name="type_options[allowed_maxsize]" type="text" maxlength="4" value="{$allowed_maxsize}" class="text" /><span class="note">{$allowed_maxsize_note}</span> <p class="note">{$allowed_maxsize_blank_note}</p> </div> </div> <!-- /.f --> <div class="f f-allowed-types"> <p class="label">{$allowed_types_label}</p> <div class="fw"> {$allowed_types_checkboxes} <div class="controls"><button type="button" class="button button-small select-all">Select All</button><button type="button" class="button button-small select-none">Select None</button></div> <p class="note">{$allowed_types_note}</p> </div> </div> <!-- /.f --> </div> HTML; return $html; }
public function reassign_posts($new_post_type_name, $field_sets_action = "keep") { global $wpdb; $post_type_name = $this->name; if ($new_post_type_name) { // get the list of post ids for the existing type, which we'll need for later $post_ids = $wpdb->get_col("SELECT post_id FROM $wpdb->posts WHERE post_type = '$post_type_name'"); // update the posts $wpdb->query("UPDATE $wpdb->posts SET post_type = '$new_post_type_name' WHERE post_type = '$post_type_name'"); if ($field_sets_action == "keep") { // update the link tables for this post type // need to check if there are any clashes for field sets named the same thing $sql = "SELECT id, name, visibility FROM ".MPU::table("field-sets")." WHERE type = 'p' AND ".MPM::visibility_rlike("post_types", $this->name); $post_type_sets = $wpdb->get_results($sql); $sql = "SELECT id, name, visibility FROM ".MPU::table("field-sets")." WHERE type = 'p' AND ".MPM::visibility_rlike("post_types", $this->name); $new_post_type_sets = $wpdb->get_results($sql); $clashes = array(); foreach ($post_type_sets as $post_type_set) { foreach ($new_post_type_sets as $new_post_type_set) { if ($post_type_set->name == $new_post_type_set->name) { // a set with this name already exists, so we'll rename this one to "_2" $sql = "UPDATE ".MPU::table("field-sets")." SET name = CONCAT(name, '_2'), singular_name = CONCAT(singular_name, '_2') WHERE id = ".$post_type_set->id; $wpdb->query($sql); // now we need to update the meta keys for any meta values that were bound to this set // now get the fields inside this clashing set $field_ids = $wpdb->get_col("SELECT id FROM ".MPU::table("fields")." WHERE field_set_id = ".$post_type_set->id); if (count($field_ids)) { // get a list of meta values bound to the fields in this clashing set. $sql = "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE meta_key LIKE '%:field_id' AND meta_value IN (".implode(",", $field_ids).")"; $rows = $wpdb->get_results($sql); // this will need some serious testing! foreach ($rows as $row) { list($set_name, $field_name, $prop_name) = MPFT::parse_meta_key($row->meta_key); $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = REPLACE(meta_key, '".$set_name."', '".$set_name."_2') WHERE post_id = ".$row->post_id." AND ( meta_key = '".MPFT::meta_key($set_name, $field_name)."' OR meta_key LIKE '".MPFT::meta_key($set_name, $field_name).":%' ) "); } } } } } foreach ($post_type_sets as $set) { $visibility = MPU::db_decode($set->visibility); $visibility["post_types"] = $new_post_type_name; $sql = "UPDATE ".MPU::table("field-sets")." SET visibility = '".MPU::db_encode($visibility)."' WHERE id = ".$set->id; $wpdb->query($sql); } } else { $this->delete_field_sets(); } } }
public static function ui( MEOW_Field $field ) { return MPFT::select_ui( $field, __CLASS__ ); }
function update() { if ($this->dirty && $this->exists()) { $this->dirty = false; // do this now in case of any SQL errors $this->updated = true; global $wpdb; global $wf, $meow_provider; $value_type = null; $object_type = $meow_provider->type_key($this->object); $object_id = $this->object->id(); if ($object_type == "term") { $tax = $this->object->taxonomy->name(); if ($tax && !is_woof_silent($tax)) { $value_type = $tax; } } /* Delete the old post meta */ $this->object->switch_site(); $set_name = $this->name; foreach ( $this->info->fields as $field) { if (!$field->disabled && $field->in_current_site()) { $meta_name = $set_name.".".$field->name; MPC_Meta::delete_object_meta($object_type, $object_id, $meta_name); // now go through the properties too $dont_care = MPFT::type_class($field->type); foreach (MPFT::type_properties($field->type) as $prop) { MPC_Meta::delete_object_meta($object_type, $object_id, $meta_name.":".$prop); } } } $model_id_prop_stored = array(); // Create the new values foreach( $this->_items as $set_index => $set_item ) { foreach ($this->info->fields as $field) { if (!$field->disabled && $field->in_current_site()) { // here the field type should prepare the value, if necessary // grab the type $model_id = $field->id; $model = $field; $field_item = $this->field($field->name, $set_index); if ($field_item->exists()) { $value = $field_item->raw(); $val = MPU::db_encode($value); if ($type_class = MPFT::type_class($model->type)) { $val = MPU::db_encode( call_user_func_array( array($type_class, "value_for_save"), array($value, $model)) ); } // create the post meta $meta_name = MPFT::meta_key($set_name, $field->name); //echo "would add $object_type, $object_id, $meta_name, $val<br>"; if (! (!$this->info->allow_multiple && $val == "") ) { // don't record blank entries for non-multiple field sets, as this is wasteful MPC_Meta::add_object_meta($object_type, $object_id, "{$meta_name}", $val, $value_type); // now store the properties foreach (MPFT::type_properties($model->type) as $prop) { if ($prop == "field_id" && !isset($model_id_prop_stored[$model_id])) { $model_id_prop_stored[$model_id] = true; MPC_Meta::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $model_id, $value_type); } else { $prop_value = $field_item->prop_val($prop); if (!isset($prop_value)) { $prop_value = ""; } if ($prop != "field_id") { MPC_Meta::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $prop_value, $value_type); } } // $prop = field_id } // foreach MPFT::type_properties } // if (!allow_multiple) } // if (field_item->exists) } // if (!field->disabled) } // endforeach $fields } // endforeach ($this->items) $this->object->restore_site(); } // if ($dirty) }
function value() { $val = parent::value(); if (isset($val) && $val != '') { return true; } return false; }
public function form() { global $wf; $model = MasterPress::$model; $info = MasterPress::$view; $parent = $info->parent; $post_type = null; $post_type = $info->post_type; $prefix = ""; $default_key = ""; $keys = array(); ?> <?php if (is_object($parent)) : ?> <div class="title-info-panel"> <div class="title-info-panel-lt"> <?php if ($parent->type == 's') : ?> <h3><i class="metabox-share"></i><span class="label"><?php _e("Shared Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php elseif ($parent->type == 'w') : ?> <h3><i class="metabox-sitemap-large"></i><span class="label"><?php _e("Site Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php elseif ($parent->type == "p") : ?> <?php $prefix = $post_type->name."_"; $keys = array("edit_".$post_type->capability_type."s"); ?> <h3><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 $post_type->display_label() ?></span></h3> <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php elseif ($parent->type == 't') : ?> <?php $file = $parent->visibility["templates"]; $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> <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php elseif ($parent->type == 'r') : ?> <?php $role_name = $parent->visibility["roles"]; $prefix = $role_name."_"; ?> <input id="templates" name="templates" 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> <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php elseif ($parent->type == 'x') : ?> <?php $taxonomy_name = $parent->visibility["taxonomies"]; $prefix = $taxonomy_name."_"; $tax = MPM_Taxonomy::find_by_name($taxonomy_name); $keys = array( $tax->capabilities["manage_terms"], $tax->capabilities["edit_terms"], $tax->capabilities["assign_terms"] ); ?> <input id="taxonomies" name="taxonomies" type="hidden" value="<?php echo $taxonomy_name ?>" /> <h3><i class="mp-icon mp-icon-taxonomy-<?php echo $taxonomy_name ?>"></i><span class="label"><?php _e("Taxonomy:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $tax->display_label() ?></span></h3> <h3><i class="divide"></i><i class="metabox"></i><span class="label"><?php _e("Field Set", MASTERPRESS_DOMAIN) ?>:</span><span class="value"> <?php echo $parent->display_label() ?></span></h3> <?php endif; ?> </div> </div> <?php endif; ?> <?php MPV::messages(); ?> <div class="mpv-fields-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 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-type" class="f clearfix"> <label for="type" class="icon"><i class="types"></i><?php _e("Field Type", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <select id="type" name="type" class="with-icons select2-source" data-icon="mp-icon mp-icon-field-type-<?php echo $model->type ?>"> <?php foreach (MPFT::types_by_category() as $category => $types) : ?> <?php if (count($types)) : ?> <optgroup label="<?php echo $category ?>"> <?php foreach ($types as $type) : ?> <?php $type_class = MPFT::type_class($type); ?> <option data-icon="mp-icon mp-icon-field-type-<?php echo $type ?>" <?php echo WOOF_HTML::selected_attr($type == $model->type) ?> data-description="<?php echo addslashes(call_user_func( array($type_class, "__description") ) ) ?>" value="<?php echo $type ?>"><?php echo call_user_func( array($type_class, "__s") ) ?></option> <?php endforeach; ?> </optgroup> <?php endif; ?> <?php endforeach; ?> </select> <p id="field-type-description"></p> </div> </div> <!-- /.f --> <div class="f"> <label for="required" class="icon"><i class="warning-octagon"></i><?php _e("Required", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="required" name="required" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->required ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#required' }"> <?php _e("A field value must be specified by the user, or the content editing form will not submit.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div id="f-disabled" 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 will hide it from all content editing screens in WordPress, which may be <strong>preferable to deleting it</strong> completely.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php $options_form = ""; $type_options = $model->type_options; if (isset($_POST["type_options"])) { $type_options = $_POST["type_options"]; } if ($type_class = MPFT::type_class($model->type)) { $options_form = call_user_func_array( array($type_class, "options_form"), array(MPM::array_stripslashes($type_options)) ); } ?> <div class="fs fs-field-type-options" <?php echo $options_form == "" ? ' style="display:none;"' : '' ?>> <div class="fst"> <div class="fstb"> <h3><i class="switch"></i><strong><?php _e("Field Type Options", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("defines the user-interface for this field", MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb"> <div id="field-type-loading" class="fs-loading">Please wait…</div> <div id="field-type-options-content"> <?php if ($type_class = MPFT::type_class($model->type)): ?> <div id="mpft-<?php echo $model->type ?>-options" class="mpft-options"> <?php echo $options_form ?> </div> <?php endif; ?> </div> <!-- /#field-type-options-content --> </div> </div> </div> <!-- /.fs --> <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 throughout the WordPress administration UI", MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb"> <div class="f"> <label for="label_name"><?php _e("Field Label", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="label_name" name="labels[name]" value="<?php echo stripslashes($model->labels["name"]) ?>" type="text" class="text { tmpl: '{{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"> <input id="label_description" name="labels[description]" type="text" maxlength="50" value="<?php echo stripslashes($model->label("description")) ?>" class="text" /> <p> <?php _e("Appears adjacent to the label in brackets to provide a little extra information about the field.<br />For more extensive information, use <em>Tooltip Help</em>.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="label_tooltip_help"><?php _e("Tooltip Help", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <textarea id="label_tooltip_help" name="labels[tooltip_help]"><?php echo stripslashes($model->label("tooltip_help")) ?></textarea> <p> <?php _e("Provides more extensive help for this field through a tooltip, revealed by mousing over a question-mark badge adjacent to the field label", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs .fs-labels --> <?php $args = array(); $args["supports"] = array(); // $args["supports"][] = "fields"; COMING SOON $fields = $parent->fields(); $fields_to_use = array(); foreach ($fields as $field) { if ($field->id != $model->id) { $fields_to_use[] = $field; } } $args["fields"] = $fields_to_use; if (is_multisite()) { $args["supports"][] = "multisite"; } if ($parent->is_shared()) { $args["supports"][] = "post_types"; $args["supports"][] = "roles"; $args["supports"][] = "taxonomies"; $args["supports"][] = "templates"; } $args["labels"] = array( "title" => __("control the visibility of this field within WordPress", MASTERPRESS_DOMAIN), "title_multisite" => __("specify the sites in the multisite network that this field is available in", MASTERPRESS_DOMAIN), "title_post_types" => __("specify the post types that this field is available in", MASTERPRESS_DOMAIN), "templates_all" => sprintf( __( "All Templates <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ), "multisite_all" => sprintf( __( "All Sites <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ), "post_types_all" => sprintf( __( "All Post Types <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ), "roles_all" => sprintf( __( "All User Roles <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ), "taxonomies_all" => sprintf( __( "All Taxonomies <span>( that the <em>%s</em> field set is available in )</span>" ), $parent->display_label() ) ); $args["defaults"] = array( "taxonomies" => "all", "roles" => "all", "post_types" => "all", "multisite" => "all" ); $args["post_types"] = $parent->post_types(); if (isset($parent) && is_multisite()) { $site_options = array(); foreach ($parent->sites() as $site) { $site_options[$site->full_path()] = $site->id(); } $args["sites"] = $site_options; }; // filter the available roles $roles = $parent->vis("roles"); if ($roles != "" && $roles != "*") { $role_names = explode(",", $roles); $rc = array(); foreach ($role_names as $role_name) { $rc[] = $wf->role($role_name); } $args["roles"] = new WOOF_Collection($rc); } MPV::fs_visibility( $model, $args ); ?> <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', 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); $custom_val = ""; $caps = array_unique(array_merge($keys, array("edit_posts", "edit_pages", "edit_".$prefix.$parent->name))); $caps = array( __("-- None (Same as Field Set) --", MASTERPRESS_DOMAIN) => "" ) + $caps; if (MPC::is_edit()) { $caps[] = "edit_".$prefix.$parent->name."_".$model->name; } 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("This field will be read-only for users without this capability", 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", "view_".$prefix.$parent->name))); $caps = array( __("-- None (Same as Field Set) --", MASTERPRESS_DOMAIN) => "" ) + $caps; if (MPC::is_edit()) { $caps[] = "view_".$prefix.$parent->name."_".$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 will be invisible for users without this capability", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs --> <div class="fs fs-summary-options clearfix"> <div class="fst"> <div class="fstb"> <h3><i class="set-summary"></i><strong><?php _e("Summary Options", MASTERPRESS_DOMAIN) ?></strong> - <?php _e('settings for the collapsed summary display', MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb clearfix"> <div class="f"> <label for="summary_options_emphasise"><?php _e("Emphasise", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="summary_options_emphasise" name="summary_options[emphasise]" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( isset($model->summary_options["emphasise"]) && $model->summary_options["emphasise"] ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#summary_options_emphasise' }"> <?php _e("Show the summary for this field in <strong>bold text</strong>, which may often be appropriate for the first field in a set, or for other important fields in your content.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f f-summary_width"> <label for="summary_options_width"><?php _e("Block Width", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="summary_options_width" name="summary_options[width]" type="text" maxlength="1" value="<?php echo isset($model->summary_options["width"]) ? $model->summary_options["width"] : "" ?>" class="text" /> <p class="note"> <?php _e("Override block width of the summary, when the field's set is collapsed (min value 1, max value 5)<br />Leave this value empty to use the block width recommended by the field type<br />The pixel width of the summary will be the value here x 150.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f clearfix"> <label id="label-icon" for="icon"><?php _e("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 = ""; $preview_class = ""; $clear_class = ""; if ($file_name == "") { $file_name = __("( None )", MASTERPRESS_DOMAIN); $file_class = "name-none"; $preview_class = "preview-none"; $clear_class = "hidden"; $style = ""; } 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> </div> </div> <!-- /.fs --> <?php // build a field list $fields = $parent->fields(); ?> <?php if ( ( MPC::is_edit() && count($fields) > 1) || (MPC::is_create() && count($fields) > 0) ) : ?> <div id="f-position" class="f clearfix"> <p class="label label-icon icon position"><?php _e("Position in set", MASTERPRESS_DOMAIN)?>:</p> <div class="fw"> <div class="sortable-list sortable-list-fields"> <span class="arrow"></span> <?php // build a field list $sort_fields = array(); // now build a representable list of fields foreach ($fields as $field) { $position = $field->position; if (isset($_POST["other_position"]) && isset($_POST["other_position"][$field->id])) { $position = $_POST["other_position"][$field->id]; } if ($ftc = MPFT::type_class($field->type)) { $sort_fields[] = array( "position" => $position, "disabled" => (bool) $field->disabled, "current" => $field->id == $model->id, "label" => $field->display_label(), "type" => $field->type, "id" => $field->id ); } } if (MPC::is_create()) { $label = $model->display_label(); if (!$label || $label == "") { $label = "?"; } $sort_fields[] = array( "position" => $model->position, "disabled" => (bool) $field->disabled, "current" => true, "label" => $model->display_label(), "type" => $model->type ); } $count = 0; ?> <ul> <?php foreach ($sort_fields as $f) : $count++; $first = $count == 1 ? "first " : ""; $current = $f["current"] ? 'current ' : ''; ?> <?php $disabled = $f["disabled"] ? 'disabled' : ''; $disabled_title = $f["disabled"] ? __("This field is disabled", MASTERPRESS_DOMAIN) : ''; ?> <li class="<?php echo $first.$current ?> <?php echo $disabled ?>" title="<?php echo $disabled_title ?>"> <span class="icon mp-icon mp-icon-field-type-<?php echo $f["type"] ?>"></span> <?php if ($f["current"]) : ?> <span class="fill { src: '#label_name'}"><?php echo $f["label"] ?></span> <input id="position" name="position" value="<?php echo $f["position"] ?>" type="hidden" /> <?php else: ?> <span><?php echo $f["label"] ?></span> <input id="other_position_<?php echo $f["id"] ?>" 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 printf(__("Drag field to the desired position in the %s set.<br />Note: changes to the positions of other fields will also be saved.", MASTERPRESS_DOMAIN), '<em>'.$parent->display_label().'</em>') ?> </p> </div> </div> <!-- /.f --> <?php else: ?> <input id="position" name="position" value="1" type="hidden" /> <?php endif; ?> </div> <!-- /.mpv-fields-form --> <?php } // end form()
public static function value_for_save( $value, MPM_Field $field ) { return MPFT::one_or_more_value_for_save( $value, $field ); }
public function load_prop($name, $value, $field) { if ($type_class = MPFT::type_class($field->type)) { return MPU::db_decode( call_user_func_array( array($type_class, "prop_from_load"), array($name, $value, $field)) ); } return MPU::db_decode($value); }
public static function save_meta($object_id, $object_type) { global $wpdb, $meow_provider; global $wf; do_action("mp_pre_save_meta", $object_id, $object_type); if (apply_filters("mp_do_save_meta", $do = true, $object_id, $object_type)) { MPM::incl("field"); $object_type_type = ""; $current_data = array(); if ($object_type == "post") { // check the edit post meta cap for this type $cap = "edit_post"; $post = $wf->post($object_id); if ($post->exists()) { $type = $post->type(); $cap = $type->cap("edit_post", "edit_post"); // update the template meta if ($type->supports("mp-page-attributes")) { if (isset($_POST["page_template"])) { $template = $_POST["page_template"]; if ($template == "") { delete_post_meta($object_id, "_wp_page_template"); } else { update_post_meta($object_id, "_wp_page_template", $template); } } } } if ( !current_user_can( $cap, $object_id ) ) { return $object_id; } } else if ($object_type == "term") { // check the edit terms cap for the taxonomy $cap = "manage_categories"; $taxonomy_name = self::infer_taxonomy_name(); $tax = $wf->taxonomy($taxonomy_name); $object_type_type = $taxonomy_name; if ($tax->exists()) { $cap = $tax->cap("edit_terms", "manage_categories"); } if ( !current_user_can( $cap ) ) { return $object_id; } } else if ($object_type == "user") { if ( !current_user_can( 'edit_users' ) ) { return $object_id; } } else if ($object_type == "site") { if ( !current_user_can( 'edit_posts' ) ) { return $object_id; } } $meta = self::post_val('mp_meta', array()); $meta_order = self::post_val('mp_meta_order', array()); $meta_model = self::post_val('mp_meta_model', array()); $meta_prop = self::post_val('mp_meta_prop', array()); $meta_field_ids = self::post_val('mp_meta_field_ids', array()); $meta_dirty = self::post_val('mp_meta_dirty', array()); $meta_versions = self::post_val('mp_meta_versions', array()); $field_models = array(); if (is_array($meta_field_ids)) { $meta_field_ids = array_unique($meta_field_ids); $results = MPM_Field::find_by_id_in($meta_field_ids); foreach ($results as $field) { $field_models[$field->id] = $field; } } $wpdb->show_errors(); if (isset($_POST["mp_meta_model"])) { if ($object_type == "post") { if ( $the_post = wp_is_post_revision( $object_id ) ) { $object_id = $the_post; } } try { $meow_provider->create_version($object_id, $object_type, $object_type_type, "initial", $meta_versions); } catch( Exception $e) { // silently catch, we REALLY don't want this to prevent a data save if something goes wrong! } /* Delete the old post meta */ foreach ( $meta_model as $set_name => $fields ) { foreach ($fields as $field_name => $model_id) { $field = $field_models[$model_id]; $meta_name = $set_name.".".$field_name; self::delete_object_meta($object_type, $object_id, $meta_name); // now go through the properties too $dont_care = MPFT::type_class($field->type); foreach (MPFT::type_properties($field->type) as $prop) { self::delete_object_meta($object_type, $object_id, $meta_name.":".$prop); } } } $model_id_prop_stored = array(); // Create the new values foreach( $meta as $set_name => $set_items ) { $set_index = 0; if (is_array($set_items)) { foreach ($set_items as $fields) { $set_index++; foreach ($fields as $field_name => $value) { // here the field type should prepare the value, if necessary // grab the type $model_id = $meta_model[$set_name][$field_name]; $model = $field_models[$model_id]; $val = MPU::db_encode($value); if ($model) { if ($type_class = MPFT::type_class($model->type)) { $val = MPU::db_encode(call_user_func_array( array($type_class, "value_for_save"), array($value, $model))); } // create the post meta $meta_name = MPFT::meta_key($set_name, $field_name); self::add_object_meta($object_type, $object_id, "{$meta_name}", $val); // now store the properties foreach (MPFT::type_properties($model->type) as $prop) { if ($prop == "field_id" && !isset($model_id_prop_stored[$model_id])) { $model_id_prop_stored[$model_id] = true; self::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $model_id); } else { $prop_set_index = $meta_order[$set_name][$set_index]; if (isset($meta_prop[$set_name][(int) $prop_set_index][$field_name][$prop])) { $prop_value = $meta_prop[$set_name][(int) $prop_set_index][$field_name][$prop]; } if (isset($prop_value)) { self::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $prop_value); } } } } } // endforeach $fields // fill in blanks for any values that weren't submitted (this happens with checkboxes that are not checked) foreach ($meta_model[$set_name] as $field_name => $model_id) { if (!isset($fields[$field_name])) { $meta_name = MPFT::meta_key($set_name, $field_name); self::add_object_meta($object_type, $object_id, "{$meta_name}", ""); // now store the properties for blanks (if required) foreach (MPFT::type_properties($field->type) as $prop) { if ($prop == "field_id" && !isset($model_id_prop_stored[$model_id])) { $model_id_prop_stored[$model_id] = true; self::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $model_id); } else { if (isset($meta_prop[$set_name][$set_index][$field_name][$prop])) { $prop_value = $meta_prop[$set_name][$set_index][$field_name][$prop]; self::add_object_meta($object_type, $object_id, "{$meta_name}:{$prop}", $prop_value); } } } } } } } // endif is_array(set_items) } // foreach $set_name => $set_items // create the current content version if (!self::$version_saved) { try { $meow_provider->create_version($object_id, $object_type, $object_type_type, $meta_dirty, $meta_versions); } catch( Exception $e) { // silently catch, we REALLY don't want this to prevent a data save if something goes wrong! } self::$version_saved = true; } } // isset $_POST["mp_meta_model"] } do_action("mp_after_save_meta", $object_id, $object_type); }
public static function fs_visibility($model, $args = array()) { global $wf; $first = true; $r = array( "sites" => null, "templates" => null, "post_types" => null, "taxonomies" => null, "fields" => null, "roles" => null ); $r["labels"] = wp_parse_args( $args["labels"], array( "title" => __("control the visibility of this object in your site", MASTERPRESS_DOMAIN), "title_multisite" => __("specify the network sites that this object is available in", MASTERPRESS_DOMAIN), "title_post_types" => __("specify the post types that this object is available in", MASTERPRESS_DOMAIN), "title_templates" => __("specify the templates that this object is available in", MASTERPRESS_DOMAIN), "title_roles" => __("specify the user roles that this object is available in", MASTERPRESS_DOMAIN), "title_taxonomies" => __("specify the taxonomies that this object is available in", MASTERPRESS_DOMAIN), "title_fields" => __("control display of this field based on the value of another field in the set", MASTERPRESS_DOMAIN), "radio_multisite" => __("Make avalable in:", MASTERPRESS_DOMAIN), "multisite_all" => __('<em class="all">All</em> sites in the network', MASTERPRESS_DOMAIN), "multisite_allow" => __( '<em class="allow">Include</em> only in specific Sites'), "multisite_deny" => __( '<em class="deny">Exclude</em> from specific Sites'), "multisite_allow_note" => "", "multisite_deny_note" => "", "post_types_all" => __('<em class="all">All</em> Post Types', MASTERPRESS_DOMAIN), "post_types_none" => __('<em class="none">No</em> Post Types', MASTERPRESS_DOMAIN), "post_types_allow" => __('<em class="allow">Include</em> only in specific Post Types', MASTERPRESS_DOMAIN), "post_types_deny" => __('<em class="deny">Exclude</em> from specific Post Types', MASTERPRESS_DOMAIN), "templates_all" => __('<em class="all">All</em> Templates', MASTERPRESS_DOMAIN), "templates_allow" => __('<em class="allow">Include</em> only in specific Templates', MASTERPRESS_DOMAIN), "templates_deny" => __('<em class="deny">Exclude</em> from specific Templates', MASTERPRESS_DOMAIN), "roles_all" => __('<em class="all">All</em> User Roles', MASTERPRESS_DOMAIN), "roles_none" => __('<em class="none">No</em> User Roles', MASTERPRESS_DOMAIN), "roles_allow" => __('<em class="allow">Include</em> only in specific Roles', MASTERPRESS_DOMAIN), "roles_deny" => __('<em class="deny">Exclude</em> from specific Roles', MASTERPRESS_DOMAIN), "taxonomies_all" => __('<em class="all">All</em> Taxonomies', MASTERPRESS_DOMAIN), "taxonomies_none" => __('<em class="none">No</em> Taxonomies', MASTERPRESS_DOMAIN), "taxonomies_allow" => __('<em class="allow">Include</em> only in specific Taxonomies', MASTERPRESS_DOMAIN), "taxonomies_deny" => __('<em class="deny">Exclude</em> from specific Taxonomies', MASTERPRESS_DOMAIN), "fields_all" => __('No conditions', MASTERPRESS_DOMAIN), "fields_allow" => __('When another field <em class="allow">has a specific value</em>', MASTERPRESS_DOMAIN), "fields_deny" => __('When another field <em class="deny">does not have a specific value</em>', MASTERPRESS_DOMAIN) ) ); $r["supports"] = wp_parse_args($args["supports"], array()); $r["defaults"] = wp_parse_args( $args["defaults"], array( "multisite" => "all", "post_types" => "none", "templates" => "all", "roles" => "none", "taxonomies" => "none", "fields" => "all" ) ); if (isset($args["sites"])) { $r["sites"] = $args["sites"]; } if (isset($args["templates"])) { $r["templates"] = $args["templates"]; } if (isset($args["post_types"])) { $r["post_types"] = $args["post_types"]; } if (isset($args["taxonomies"])) { $r["taxonomies"] = $args["taxonomies"]; } if (isset($args["roles"])) { $r["roles"] = $args["roles"]; } if (isset($args["fields"])) { $r["fields"] = $args["fields"]; } if (is_array($r["sites"])) { $r["sites"] = implode(",", $r["sites"]); } if (is_array($r["templates"])) { //$r["templates"] = implode(",", $r["templates"]); } $supports = $r["supports"]; $labels = $r["labels"]; if ($r["supports"] && count($r["supports"])) : ?> <div class="fs fs-visibility clearfix"> <div class="fst"> <div class="fstb"> <h3><i class="light-globe"></i><strong><?php _e("Availability", MASTERPRESS_DOMAIN) ?></strong> - <?php echo $labels["title"] ?></h3> </div> </div> <div class="fsc"> <div class="fscb clearfix"> <?php if (in_array("fields", $supports)) : ?> <?php $mode = self::visibility_mode($model->visibility, "fields", $r["defaults"]["fields"]); ?> <?php $fo = array(""); $fo_attr = array(array()); foreach ($r["fields"] as $field) { if ($type_class = MPFT::type_class($field->type)) { $fo[$field->display_label()] = $field->name; $fo_attr[] = array("class" => "mp-icon field-type-".$field->type); } } $fields_select = WOOF_HTML::select(array("style" => "max-width: 280px", "id" => "visibility-fields", "name" => "visibility_fields", "class" => "with-icons select2-source", "data-placeholder" => __("-- Select a Field --", MASTERPRESS_DOMAIN)), $fo, "", $fo_attr); ?> <div class="fsg fsg-fields <?php echo $first ? "" : "divider" ?>"> <h4><i class="question-octagon"></i><?php _e("Conditional Display", MASTERPRESS_DOMAIN) ?><span> - <?php echo $labels["title_fields"] ?></span></h4> <div class="f clearfix"> <div class="fsg-radios"> <div class="fw fwl fw-all"> <input id="visibility-type-fields-all" name="visibility_type[fields]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" /> <label for="visibility-type-fields-all" class="radio"><?php echo $labels["fields_all"] ?></label> </div> <!-- /.fw --> <div class="fw fwl fw-none"> <input id="visibility-type-fields-allow" name="visibility_type[fields]" type="radio" value="none" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" /> <label for="visibility-type-fields-allow" class="radio"><?php echo $labels["fields_allow"] ?></label> </div> <!-- /.fw --> <div class="fw fwl fw-none"> <input id="visibility-type-fields-deny" name="visibility_type[fields]" type="radio" value="none" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" /> <label for="visibility-type-fields-deny" class="radio"><?php echo $labels["fields_deny"] ?></label> </div> <!-- /.fw --> </div> <!-- /.fsg-radios --> <div id="visibility-fields-options"> <div id="fw-field" class="fw"> <label for="visibility-fields" class="select2"><?php _e("Field:", MASTERPRESS_DOMAIN) ?></label> <?php echo $fields_select ?> </div> <div id="fw-value" class="fw"> <label for="visibility-fields-value"><?php _e("Value:", MASTERPRESS_DOMAIN) ?></label> <textarea name="visibility_fields_value" class="mono"></textarea> </div> </div> </div> <!-- /.f --> </div> <!-- /.fsg --> <?php $first = false; ?> <?php endif; ?> <?php if (in_array("post_types", $supports)) : ?> <?php if (is_null($r["post_types"])) { $available_post_types = MPM_PostType::find(array("orderby" => "name ASC")); } else { $available_post_types = $r["post_types"]; } $mode = self::visibility_mode($model->visibility, "post_types", $r["defaults"]["post_types"]); ?> <div class="fsg fsg-post-types <?php echo $first ? "" : "divider" ?>"> <h4><i class="pins"></i><?php _e("Post Types", MASTERPRESS_DOMAIN) ?><span> - <?php echo $labels["title_post_types"] ?></span></h4> <div class="f clearfix"> <div class="fsg-radios"> <div class="fw fwl fw-all"> <input id="visibility-type-post-types-all" name="visibility_type[post_types]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" /> <label for="visibility-type-post-types-all" class="radio"><?php echo $labels["post_types_all"] ?></label> </div> <!-- /.fw --> <div class="fw fwl fw-none"> <input id="visibility-type-post-types-none" name="visibility_type[post_types]" type="radio" value="none" <?php echo WOOF_HTML::checked_attr( $mode == "none" ) ?> class="radio" /> <label for="visibility-type-post-types-none" class="radio"><?php echo $labels["post_types_none"] ?></label> </div> <!-- /.fw --> <?php if (count($available_post_types)) : ?> <div class="fw fwl"> <input id="visibility-type-post-types-allow" name="visibility_type[post_types]" type="radio" value="allow" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" /> <label for="visibility-type-post-types-allow" class="radio"><?php echo $labels["post_types_allow"] ?></label> </div> <!-- /.fw --> <div class="fw fwl"> <input id="visibility-type-post-types-deny" name="visibility_type[post_types]" type="radio" value="deny" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" /> <label for="visibility-type-post-types-deny" class="radio"><?php echo $labels["post_types_deny"] ?></label> </div> <!-- /.fw --> </div> <!-- /.fsg-radios --> <div id="visibility-post-types-list" class="list checkbox-list"> <div class="items"> <?php foreach ($available_post_types as $post_type) : $disabled = $post_type->disabled ? ' disabled' : ''; $disabled_title = $post_type->disabled ? __("This post type is disabled", MASTERPRESS_DOMAIN) : ''; $builtin = $post_type->_builtin ? ' '.__('(Built-in)', MASTERPRESS_DOMAIN) : ''; ?> <?php $linked_to_post_type = false; // todo, update this code to use visibility if (MPC::is_edit()) { $linked_to_post_type = $model->linked_to_post_type($post_type); } $checked = $linked_to_post_type; if ($mode == "deny") { $checked = !$checked; } ?> <?php if ($post_type->still_registered()) : ?> <div class="fw"> <input id="visibility-post-types-<?php echo $post_type->name ?>" name="visibility_post_types[]" value="<?php echo $post_type->name ?>" type="checkbox" <?php echo WOOF_HTML::checked_attr( $checked || MPV::in_post_array("post_types", $post_type->name) ) ?> class="checkbox" /> <label for="visibility-post-types-<?php echo $post_type->name ?>" class="checkbox <?php echo $disabled ?>" title="<?php echo $disabled_title ?>"><?php echo $post_type->labels["name"] ?><span><?php echo $builtin ?></span></label> </div> <!-- /.fw --> <?php endif; ?> <?php endforeach; ?> </div> <!-- /.items --> <div class="controls"> <button type="button" class="button list-select-all"><?php _e("Select All", MASTERPRESS_DOMAIN) ?></button> <button type="button" class="button list-select-none"><?php _e("Select None", MASTERPRESS_DOMAIN) ?></button> </div> <!-- /.controls --> </div> <!-- /#visibility-post-types --> <?php endif; ?> </div> <!-- /.f --> </div> <!-- /#fsg-post-types --> <?php $first = false; ?> <?php endif; // supports post_types ?> <?php if (in_array("templates", $supports)) : ?> <?php if (is_null($r["templates"])) { $available_templates = array_merge( array("Page" => "page.php"), get_page_templates() ); } else { $available_templates = $r["templates"]; } $mode = self::visibility_mode($model->visibility, "templates", $r["defaults"]["templates"]); ?> <div class="fsg fsg-templates <?php echo $first ? "" : "divider" ?>"> <h4><i class="template"></i><?php _e("Templates", MASTERPRESS_DOMAIN) ?><span> - <?php echo $labels["title_templates"] ?></span></h4> <div class="f clearfix"> <div class="fsg-radios"> <div class="fw fwl fw-all"> <input id="visibility-type-templates-all" name="visibility_type[templates]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" /> <label for="visibility-type-templates-all" class="radio"><?php echo $labels["templates_all"] ?></label> </div> <!-- /.fw --> <div class="fw fwl"> <input id="visibility-type-templates-allow" name="visibility_type[templates]" type="radio" value="allow" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" /> <label for="visibility-type-templates-allow" class="radio"><?php echo $labels["templates_allow"] ?></label> </div> <!-- /.fw --> <div class="fw fwl"> <input id="visibility-type-templates-deny" name="visibility_type[templates]" type="radio" value="deny" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" /> <label for="visibility-type-templates-deny" class="radio"><?php echo $labels["templates_deny"] ?></label> </div> <!-- /.fw --> </div> <!-- /.fsg-radios --> <div id="visibility-templates-list" class="list checkbox-list"> <?php if (count($available_templates)) : ?> <div class="items"> <?php $templates = $model->vis("templates"); $not_templates = $model->vis("not_templates"); ?> <?php foreach ($available_templates as $name => $file) : ?> <?php if ($mode == "deny") { $checked = MPV::in_csv($file, $not_templates); } else { $checked = MPV::in_csv($file, $templates); } ?> <div class="fw"> <input id="templates_<?php echo WOOF_Inflector::underscore($file) ?>" name="visibility_templates[]" value="<?php echo $file ?>" type="checkbox" <?php echo WOOF_HTML::checked_attr( $checked ) ?> class="checkbox" /> <label for="templates_<?php echo WOOF_Inflector::underscore($file) ?>" class="checkbox"><span class="tt"><?php echo $file ?></span></label> </div> <?php endforeach; ?> </div> <!-- /.items --> <div class="controls"> <button type="button" class="button list-select-all"><?php _e("Select All", MASTERPRESS_DOMAIN) ?></button> <button type="button" class="button list-select-none"><?php _e("Select None", MASTERPRESS_DOMAIN) ?></button> </div> <!-- /.controls --> <?php else: ?> <span class="soft-warning"><i class="warning-triangle"></i><?php sprintf( __("The Field Set <em>%s</em> is not yet associated with <em>any</em> field types, so this option is not yet available", MASTERPRESS_DOMAIN), $parent->display_label() ); ?></span> <?php endif; ?> </div> <!-- /#visibility-templates --> </div> <!-- /.f --> </div> <!-- /#fsg-templates --> <?php $first = false; ?> <?php endif; // supports templates ?> <?php if (in_array("taxonomies", $supports)) : ?> <?php if (is_null($r["taxonomies"])) { $available_taxonomies = MPM_Taxonomy::find(); } else { $available_taxonomies = $r["taxonomies"]; } $mode = self::visibility_mode($model->visibility, "taxonomies", $r["defaults"]["taxonomies"]); ?> <div class="fsg fsg-taxonomies <?php echo $first ? "" : "divider" ?>"> <h4><i class="tags"></i><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?><span> - <?php echo $labels["title_taxonomies"] ?></span></h4> <div class="f clearfix"> <div class="fsg-radios"> <div class="fw fwl fw-all"> <input id="visibility-type-taxonomies-all" name="visibility_type[taxonomies]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" /> <label for="visibility-type-taxonomies-all" class="radio"><?php echo $labels["taxonomies_all"] ?></label> </div> <!-- /.fw --> <div class="fw fwl fw-all"> <input id="visibility-type-taxonomies-none" name="visibility_type[taxonomies]" type="radio" value="none" <?php echo WOOF_HTML::checked_attr( $mode == "none" ) ?> class="radio" /> <label for="visibility-type-taxonomies-none" class="radio"><?php echo $labels["taxonomies_none"] ?></label> </div> <!-- /.fw --> <div class="fw fwl"> <input id="visibility-type-taxonomies-allow" name="visibility_type[taxonomies]" type="radio" value="allow" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" /> <label for="visibility-type-taxonomies-allow" class="radio"><?php echo $labels["taxonomies_allow"] ?></label> </div> <!-- /.fw --> <div class="fw fwl"> <input id="visibility-type-taxonomies-deny" name="visibility_type[taxonomies]" type="radio" value="deny" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" /> <label for="visibility-type-taxonomies-deny" class="radio"><?php echo $labels["taxonomies_deny"] ?></label> </div> <!-- /.fw --> </div> <!-- /.fsg-radios --> <div id="visibility-taxonomies-list" class="list checkbox-list"> <?php if (count($available_taxonomies)) : ?> <?php $taxonomies = $model->vis("taxonomies"); $not_taxonomies = $model->vis("not_taxonomies"); ?> <div class="items"> <?php foreach ($available_taxonomies as $tax) : ?> <?php $tax_name = $tax->name; if ($mode == "deny") { $checked = MPV::in_csv($tax_name, $not_taxonomies); } else { $checked = MPV::in_csv($tax_name, $taxonomies); } ?> <?php if ($tax->still_registered()) : ?> <div class="fw"> <input id="taxonomies_<?php echo WOOF_Inflector::underscore($tax_name) ?>" name="visibility_taxonomies[]" value="<?php echo $tax_name ?>" type="checkbox" <?php echo WOOF_HTML::checked_attr( $checked ) ?> class="checkbox" /> <label for="taxonomies_<?php echo WOOF_Inflector::underscore($tax_name) ?>" class="checkbox"><span class="tt"><?php echo $tax->display_label() ?></span></label> </div> <?php endif; ?> <?php endforeach; ?> </div> <!-- /.items --> <div class="controls"> <button type="button" class="button list-select-all"><?php _e("Select All", MASTERPRESS_DOMAIN) ?></button> <button type="button" class="button list-select-none"><?php _e("Select None", MASTERPRESS_DOMAIN) ?></button> </div> <!-- /.controls --> <?php endif; ?> </div> <!-- /#visibility-taxonomies --> </div> <!-- /.f --> </div> <!-- /#fsg-taxonomies --> <?php $first = false; ?> <?php endif; // supports taxonomies ?> <?php if (in_array("roles", $supports)) : ?> <?php if (is_null($r["roles"])) { $available_roles = $wf->roles(); } else { $available_roles = $r["roles"]; } $mode = self::visibility_mode($model->visibility, "roles", $r["defaults"]["roles"]); ?> <div class="fsg fsg-roles <?php echo $first ? "" : "divider" ?>"> <h4><i class="user-role"></i><?php _e("User Profiles", MASTERPRESS_DOMAIN) ?><span> - <?php echo $labels["title_roles"] ?></span></h4> <div class="f clearfix"> <div class="fsg-radios"> <div class="fw fwl fw-all"> <input id="visibility-type-roles-all" name="visibility_type[roles]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" /> <label for="visibility-type-roles-all" class="radio"><?php echo $labels["roles_all"] ?></label> </div> <!-- /.fw --> <div class="fw fwl fw-none"> <input id="visibility-type-roles-none" name="visibility_type[roles]" type="radio" value="none" <?php echo WOOF_HTML::checked_attr( $mode == "none" ) ?> class="radio" /> <label for="visibility-type-roles-none" class="radio"><?php echo $labels["roles_none"] ?></label> </div> <!-- /.fw --> <div class="fw fwl"> <input id="visibility-type-roles-allow" name="visibility_type[roles]" type="radio" value="allow" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" /> <label for="visibility-type-roles-allow" class="radio"><?php echo $labels["roles_allow"] ?></label> </div> <!-- /.fw --> <div class="fw fwl"> <input id="visibility-type-roles-deny" name="visibility_type[roles]" type="radio" value="deny" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" /> <label for="visibility-type-roles-deny" class="radio"><?php echo $labels["roles_deny"] ?></label> </div> <!-- /.fw --> </div> <!-- /.fsg-radios --> <div id="visibility-roles-list" class="list checkbox-list"> <div class="items"> <?php if (count($available_roles)) : ?> <?php $roles = $model->vis("roles"); $not_roles = $model->vis("not_roles"); ?> <?php foreach ($available_roles as $role) : ?> <?php $role_name = $role->id(); if ($mode == "deny") { $checked = MPV::in_csv($role_name, $not_roles); } else { $checked = MPV::in_csv($role_name, $roles); } ?> <div class="fw"> <input id="roles_<?php echo WOOF_Inflector::underscore($role_name) ?>" name="visibility_roles[]" value="<?php echo $role_name ?>" type="checkbox" <?php echo WOOF_HTML::checked_attr( $checked ) ?> class="checkbox" /> <label for="roles_<?php echo WOOF_Inflector::underscore($role_name) ?>" class="checkbox"><span class="tt"><?php echo $role_name ?></span></label> </div> <?php endforeach; ?> </div> <!-- /.items --> <div class="controls"> <button type="button" class="button list-select-all"><?php _e("Select All", MASTERPRESS_DOMAIN) ?></button> <button type="button" class="button list-select-none"><?php _e("Select None", MASTERPRESS_DOMAIN) ?></button> </div> <!-- /.controls --> <?php endif; ?> </div> <!-- /#visibility-roles --> </div> <!-- /.f --> </div> <!-- /#fsg-roles --> <?php $first = false; ?> <?php endif; // supports roles ?> <?php if (in_array("multisite", $supports) && is_multisite() && MASTERPRESS_MULTISITE_SHARING ) : ?> <?php $sites = $model->vis("sites"); ?> <?php $not_sites = $model->vis("not_sites"); ?> <?php $mode = self::visibility_mode($model->visibility, "sites", $r["defaults"]["multisite"]); global $blog_id; $sites_args = array("public_only" => false); if (!is_null($r["sites"])) { $sites_args["include_id"] = $r["sites"]; } $sites_options = array(); $sites_options_attr = array(); $the_site = $wf->site(); // build the sites options foreach ($wf->sites( $sites_args ) as $site) { $attr = array(); if ($site->id() == $the_site->id()) { $attr["class"] = "hl"; $attr["title"] = __("This is the current site", MASTERPRESS_DOMAIN); } $sites_options_attr[] = $attr; $sites_options[$site->full_path()] = $site->id(); } ?> <div class="fsg fsg-multisite <?php echo $first ? "" : "divider" ?>"> <h4><i class="globe"></i><?php _e("Multi-site", MASTERPRESS_DOMAIN) ?><span> - <?php echo $labels["title_multisite"] ?></span></h4> <div class="f clearfix"> <div class="fsg-radios"> <div class="fw fw-all"> <input id="visibility-type-sites-all" name="visibility_type[sites]" type="radio" value="all" <?php echo WOOF_HTML::checked_attr( $mode == "all" ) ?> class="radio" /> <label for="visibility-type-sites-all" class="radio"><?php echo $labels["multisite_all"] ?></label> </div> <div class="fw"> <input id="visibility-type-sites-allow" name="visibility_type[sites]" type="radio" value="allow" <?php echo WOOF_HTML::checked_attr( $mode == "allow" ) ?> class="radio" /> <label for="visibility-type-sites-allow" class="radio"><?php echo $labels["multisite_allow"] ?></label> </div> <div class="fw"> <input id="visibility-type-sites-deny" name="visibility_type[sites]" type="radio" value="deny" <?php echo WOOF_HTML::checked_attr( $mode == "deny" ) ?> class="radio" /> <label for="visibility-type-sites-deny" class="radio"><?php echo $labels["multisite_deny"] ?></label> </div> </div> <!-- /.fsg-radios --> <div id="visibility-sites-list" class="sites-list"> <?php if ($mode == "allow") { $selected_sites = explode(",", $sites); } else if ($mode == "deny") { $selected_sites = explode(",", $not_sites); } else { $selected_site_objects = $wf->sites(array("public_only" => false)); $selected_sites = $selected_site_objects->extract("id"); } echo WOOF_HTML::select( array("multiple" => "multiple", "id" => "visibility-sites", "name" => "visibility_sites[]"), $sites_options, $selected_sites, $sites_options_attr ); ?> <?php if ($labels["multisite_allow_note"] != "") : ?> <p class="note"><?php echo $labels["multisite_allow_note"] ?></p> <?php endif; ?> </div> <!-- /#visibility-sites-list --> </div> <!-- /.f --> </div> <!-- /#fsg-multisite --> <?php $first = false; ?> <?php endif; // supports multisite ?> </div> </div> </div> <!-- /.fs --> <?php endif; // count support }
public static function options_form( $options ) { $p = self::type_prefix(__CLASS__); $defaults = array(); if (MPC::is_create()) { $defaults = array("step" => 1, "min" => 0, "format" => "0", "maxwidth" => 100, $negative_red = "yes"); } $options = wp_parse_args( $options, $defaults ); $negative_red_label = __("Show Negative in red?:", MASTERPRESS_DOMAIN); $min_label = __("Minimum Value:", MASTERPRESS_DOMAIN); $max_label = __("Maximum Value:", MASTERPRESS_DOMAIN); $default_label = __("Default Value:", MASTERPRESS_DOMAIN); $step_label = __("Step By:", MASTERPRESS_DOMAIN); $step_note = __("Enter a numeric step amount for the up / down buttons or arrow keys.", MASTERPRESS_DOMAIN); $format_label = __("Number Format:", MASTERPRESS_DOMAIN); $format_note = __("Enter a numeric format to use made up of zeros (0), hashes (#), commas (,) a decimal point, and other symbols.<br />0 represents a decimal that will always be present (generally only used on either side of a decimal point).<br /># is a decimal that is present if needed, and commas and other symbols are placed into the same position.<br />Example: $#,###,###,##0.00 is a currency amount with 2 decimal places always shown,<br />and a leading zero always in front of the decimal point.", MASTERPRESS_DOMAIN); $negative_red = self::option_value($options, "negative_red"); $negative_red_checked_attr = WOOF_HTML::checked_attr($negative_red == "yes"); $min = self::option_value($options, "min"); $default = self::option_value($options, "default"); $max = self::option_value($options, "max"); $step = self::option_value($options, "step"); $format = self::option_value($options, "format"); $maxwidth = MPFT::options_maxwidth( $p, $options ); $html = <<<HTML <div class="f"> <label for="{$p}min">{$min_label}</label> <div id="fw-{$p}min" class="fw"> <input id="{$p}min" name="type_options[min]" type="text" value="{$min}" class="text" /> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}max">{$max_label}</label> <div id="fw-{$p}max" class="fw"> <input id="{$p}max" name="type_options[max]" type="text" value="{$max}" class="text" /> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}default">{$default_label}</label> <div id="fw-{$p}default" class="fw"> <input id="{$p}default" name="type_options[default]" type="text" value="{$default}" class="text" /> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}step">{$step_label}</label> <div id="fw-{$p}step" class="fw"> <input id="{$p}step" name="type_options[step]" type="text" value="{$step}" class="text" /> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}format">{$format_label}</label> <div id="fw-{$p}format" class="fw"> <input id="{$p}format" name="type_options[format]" type="text" value="{$format}" class="text" /> <p class="note">{$format_note}</p> </div> </div> <!-- /.f --> {$maxwidth} <div class="f"> <label for="{$p}negative_red">{$negative_red_label}</label> <div id="fw-{$p}negative_red" class="fw"> <input id="{$p}negative_red" name="type_options[negative_red]" type="checkbox" {$negative_red_checked_attr} value="yes" class="checkbox" /> </div> </div> <!-- /.f --> HTML; return $html; }
public function form($type) { global $wf, $meow_provider; $model = MasterPress::$model; ?> <?php MPV::messages(); ?> <input type="hidden" name="_builtin" value="<?php echo $model->_builtin ? "true" : "false" ?>" /> <input type="hidden" name="_external" value="<?php echo $model->_external ? "true" : "false" ?>" /> <div class="f"> <label for="name" class="icon"><i class="script-php"></i><?php _e("<strong>Singular</strong> 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" <?php echo MPV::read_only_attr($model->_builtin || MPC::is_edit()) ?> class="<?php echo MPV::read_only_class($model->_builtin || $model->_external) ?> text mono key" maxlength="20" value="<?php echo $model->name ?>" /><?php if (!$model->_builtin && !$model->_external) { ?><em class="required"><?php _e("(required)", MASTERPRESS_DOMAIN) ?></em><?php } ?> <p> <?php _e("This is a unique identifier for the custom post type in the WordPress and MasterPress APIs. It is not displayed, and by convention it <strong>must</strong> be a singular form, lowercase string with underscores to separate words.", MASTERPRESS_DOMAIN); ?> </p> </div> <p id="name_warning" class="warning"> <i class="error-circle"></i><?php _e("Note: check that you have definitely entered a <strong>singular word</strong> here, as the singular form of <em>Plural Name</em> is currently different to this value.", MASTERPRESS_DOMAIN) ?> </p> </div> <!-- /.f --> <div class="f"> <label for="plural_name" class="icon"><i class="script-php"></i><?php _e("<strong>Plural</strong> Name", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <input id="plural_name" name="plural_name" <?php echo MPV::read_only_attr($model->_builtin || MPC::is_edit()) ?> type="text" value="<?php echo $model->plural_name ?>" class="<?php echo MPV::read_only_class($model->_builtin || $model->_external) ?> text mono key" /> <?php if (!$model->_builtin && !$model->_external) { ?><em class="required">(required)</em><?php } ?> <?php if (MPC::is_edit() && !$model->_builtin && !$model->_external) : ?> <button id="plural_name_suggest" type="button" class="button button-small"><?php _e("Suggest", MASTERPRESS_DOMAIN) ?></button> <?php endif; ?> <p> <?php _e("The plural form of <em>Singular Name</em>, following the same naming conventions", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f clearfix"> <label id="label-menu_icon" for="menu_icon" class="icon"><i class="image-small"></i><?php _e("Icon (16 x 16)", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <div id="icon-file-uploader" class="icon-uploader file-uploader { ids: { drop: 'menu_icon_drop_area' }, input: '#menu_icon', inputName: 'menu_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="menu_icon_drop_area" class="drop-area"><?php _e("Drop file here to upload", MASTERPRESS_DOMAIN) ?></div> <?php $file_name = $model->menu_icon; $file_class = ""; $clear_class = ""; if ($file_name == "") { $file_name = __("( None )", MASTERPRESS_DOMAIN); $file_class = "name-none"; $clear_class = "hidden"; } ?> <div class="file"> <span class="preview" style="background-image: url('<?php echo MPU::menu_icon_url($model->menu_icon, true, "post_type", true) ?>');"></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="menu_icon" name="menu_icon" value="<?php echo $model->menu_icon ?>" type="hidden" /> <div class="uploader-ui"></div> </div> <!-- /.file-uploader --> <?php MPV::icon_select($model->menu_icon, "menu-icon-select", "menu_icon_select", "icon-file-uploader"); ?> </div> </div> <!-- /.f --> <?php if (!$model->_external) : ?> <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 if ($model->_builtin) : _e("Since this post type is built-in, disabling it may render some WordPress themes unusable.<br />This is only recommended for sites that are highly customised.", MASTERPRESS_DOMAIN); else: _e("disabling a post type will keep its definition in the database but it will not be registered in WordPress, which will often be <strong>preferable to deleting it</strong> entirely.", MASTERPRESS_DOMAIN); endif; ?> </p> </div> </div> <!-- /.f --> <?php endif; ?> <?php if (!$model->_builtin && !$model->_external) : ?> <div class="f"> <label for="description" class="icon"><i class="metabox-text"></i><?php _e("Description", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <textarea id="description" name="description" rows="4" cols="100"><?php echo $model->description ?></textarea> </div> </div> <!-- /.f --> <div class="f"> <label for="hierarchical" class="icon"><i class="hierarchy"></i><?php _e("Hierarchical", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="hierarchical" name="hierarchical" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->hierarchical ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#hierarchical' }"> <?php _e("hierarchical post types behave like <strong>pages</strong> in WordPress, where each post can have parent and child posts", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="show_ui" class="icon"><i class="metabox-menu"></i><?php _e("Show UI", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="show_ui" name="show_ui" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->show_ui ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#show_ui' }"> <?php _e("uncheck this to internalize this post type, which will cause many other features to be unsupported", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="show_in_nav_menus" class="icon"><i class="menu-gray"></i><?php _e("Show in Nav Menus", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="show_in_nav_menus" name="show_in_nav_menus" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->show_in_nav_menus ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#show_in_nav_menus' }"> <?php _e("allow selection of posts of this type in WordPress custom menus", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="show_in_menu" class="icon"><i class="menu-icon"></i><?php _e("Show in Admin Menu", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="show_in_menu" name="show_in_menu" type="checkbox" <?php echo WOOF_HTML::checked_attr( $model->show_in_menu ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#show_in_menu' }"> <?php _e("show this post type in the WordPress admin menu", MASTERPRESS_DOMAIN); ?> </p> </div> <!-- /.fw --> </div> <div class="f"> <label for="manage_sort_order" class="icon"><i class="sort-a-z"></i><?php _e("Default Manage Order", MASTERPRESS_DOMAIN) ?></label> <div class="fw"> <?php $options = array( "post_date|desc" => "Post Date, Descending", "title|asc" => "Title, Ascending", "menu_order|asc" => "Menu Order, Ascending", "post_date|asc" => "Post Date, Ascending", "title|desc" => "Title, Descending", "menu_order|desc" => "Menu Order, Descending" ); ?> <select id="manage_sort_order" name="manage_sort_order"> <?php foreach ($options as $value => $text) : ?> <option <?php echo WOOF_HTML::selected_attr($value == $model->manage_sort_order) ?> value="<?php echo $value ?>"><?php echo $text ?></option> <?php endforeach; ?> </select> <p class="note"> <?php _e("Specify the default sort order in the manage post screen (for when the user hasn't yet clicked on a table header to manually sort). For chronological types (such as blog posts) a descending date order is appropriate, but for other post types a title or menu order (user-defined) sort might be better.", MASTERPRESS_DOMAIN); ?> </p> </div> <!-- /.fw --> </div> <?php endif; ?> <?php if (is_multisite() && MASTERPRESS_MULTISITE_SHARING) { $args["supports"] = array("multisite"); $args["labels"] = array( "title" => __("control the visibility of this Post Type within WordPress", MASTERPRESS_DOMAIN), "title_multisite" => __("specify the sites in the multisite network that this Post Type is available in", MASTERPRESS_DOMAIN), "multisite_all" => __( "All Sites" ) ); MPV::fs_visibility( $model, $args ); } ?> <?php if (!$model->_external) : ?> <div class="fs fs-taxonomies"> <div class="fst"> <div class="fstb"> <h3><i class="tags"></i><strong><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("attach taxonomies to this post type", MASTERPRESS_DOMAIN) ?></h3> <div class="buttons"> <button class="button button-small button-select-all" type="button"><?php _e('Select <strong class="all">All</strong>', MASTERPRESS_DOMAIN) ?></button> <button class="button button-small button-select-none" type="button"><?php _e('Select <strong class="none">None</strong>', MASTERPRESS_DOMAIN) ?></button> </div> </div> </div> <div class="fsc"> <div class="fscb"> <?php $taxonomies = MPM_Taxonomy::find(array("orderby" => "name ASC")); ?> <?php foreach ($taxonomies as $tax) : $disabled = $tax->disabled ? ' disabled' : ''; $disabled_title = $tax->disabled ? __("This taxonomy is disabled", MASTERPRESS_DOMAIN) : ''; $builtin = $tax->_builtin ? ' '.__('(Built-in)', MASTERPRESS_DOMAIN) : ''; ?> <?php if ($tax->still_registered()) : ?> <div class="fw"> <input id="taxonomies_<?php echo $tax->name ?>" data-builtin="<?php echo $tax->_builtin ?>" data-title="<?php echo $tax->display_label() ?>" name="taxonomies[]" value="<?php echo $tax->name ?>" type="checkbox" <?php echo WOOF_HTML::checked_attr( $tax->linked_to_post_type($model) || MPV::in_post_array("taxonomies", $tax->name) ) ?> class="checkbox" /> <label for="taxonomies_<?php echo $tax->name ?>" class="checkbox <?php echo $disabled ?>" title="<?php echo $disabled_title ?>"><?php echo $tax->labels["name"] ?><span><?php echo $builtin ?></span></label> </div> <!-- /.fw --> <?php endif; ?> <?php endforeach; ?> </div> </div> </div> <!-- /.fs --> <div class="fs fs-supports"> <div class="fst"> <div class="fstb"> <h3><i class="gear"></i><strong><?php _e("Supports", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("controls the user interface for creating and editing posts of this type", MASTERPRESS_DOMAIN) ?></h3> <div class="buttons"> <button class="button button-small button-select-all" type="button"><?php _e('Select <strong class="all">All</strong>', MASTERPRESS_DOMAIN) ?></button> <button class="button button-small button-select-none" type="button"><?php _e('Select <strong class="none">None</strong>', MASTERPRESS_DOMAIN) ?></button> </div> </div> </div> <div class="fsc"> <div class="fscb"> <input id="supports_pb" name="supports_pb" type="hidden" value="true" /> <div id="fs-supports-1"> <?php $title_disabled = !($model->_builtin || $model->_external); $title_title = ""; $title_suffix = ""; if ($title_disabled) { $title_title = ' title="'.__("The title feature must be enabled", MASTERPRESS_DOMAIN).'" '; } $dis = WOOF_HTML::disabled_attr($title_disabled); if (!($model->_builtin || $model->_external)) { $checked = WOOF_HTML::checked_attr( true ); } else { $checked = WOOF_HTML::checked_attr( MPV::in_csv("title", $model->supports) ); } ?> <div class="fw"> <input id="supports_title" name="supports[]" value="title" <?php echo $dis ?> <?php echo $title_title ?> <?php echo $checked ?> type="checkbox" class="checkbox { tags: ['title'] }" /> <?php if ($title_disabled) : ?> <input id="supports_title_val" name="supports[]" value="title" type="hidden" /> <?php endif; ?> <label for="supports_title" class="checkbox"><?php _e("Title", MASTERPRESS_DOMAIN); ?><span> - <?php _e("show a text input to edit the post title", MASTERPRESS_DOMAIN) ?></span></label> </div> <!-- /.fw --> <div class="fw"> <input id="supports_editor" name="supports[]" value="editor" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("editor", $model->supports) ) ?> type="checkbox" class="checkbox { tags: ['auto_excerpt'] }" /> <label for="supports_editor" class="checkbox"><?php _e("Editor", MASTERPRESS_DOMAIN); ?><span> - <?php _e("show the main content box", MASTERPRESS_DOMAIN) ?></span></label> </div> <!-- /.fw --> <div class="fw"> <input id="supports_comments" name="supports[]" value="comments" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("comments", $model->supports) ) ?> type="checkbox" class="checkbox { tags: ['comment_count'] }" /> <label for="supports_comments" class="checkbox"><?php _e("Comments", MASTERPRESS_DOMAIN); ?><span> - <?php _e("the <em>ability</em> to allow / disallow comments on posts of this type", MASTERPRESS_DOMAIN) ?></span></label> </div> <!-- /.fw --> <div class="fw"> <input id="supports_trackbacks" name="supports[]" value="trackbacks" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("trackbacks", $model->supports) ) ?> type="checkbox" class="checkbox { tags: ['trackback_count'] }" /> <label for="supports_trackbacks" class="checkbox"><?php _e("Trackbacks", MASTERPRESS_DOMAIN); ?><span> - <?php _e("the <em>ability</em> to allow / disallow trackbacks to posts of this type", MASTERPRESS_DOMAIN) ?></span></label> </div> <!-- /.fw --> <div class="fw"> <input id="supports_post_formats" name="supports[]" value="post-formats" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("post-formats", $model->supports)) ?> type="checkbox" class="checkbox { tags: ['post_format'] }" /> <label for="supports_post_formats" class="checkbox"><?php _e("Post Formats", MASTERPRESS_DOMAIN); ?><span> - <?php _e("used by themes to change the display of posts of this type", MASTERPRESS_DOMAIN); ?></span></label> </div> <!-- /.fw --> <div class="fw"> <input id="supports_front_page" name="supports[]" value="front-page" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("front-page", $model->supports)) ?> type="checkbox" class="checkbox { tags: ['front_page'] }" /> <label for="supports_front_page" class="checkbox"><?php _e("Front Page", MASTERPRESS_DOMAIN); ?><span> - <?php _e("allow posts of this type to be selected as the front page", MASTERPRESS_DOMAIN); ?></span></label> </div> <!-- /.fw --> </div> <!-- /.fs-supports-1 --> <div id="fs-supports-2"> <div class="fw"> <input id="supports_revisions" name="supports[]" value="revisions" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("revisions", $model->supports)) ?> type="checkbox" class="checkbox" /> <label for="supports_revisions" class="checkbox"><?php _e("Revisions", MASTERPRESS_DOMAIN); ?><span> - <?php _e("allow revisions for posts of this type", MASTERPRESS_DOMAIN) ?></span></label> </div> <!-- /.fw --> <div class="fw"> <input id="supports_author" name="supports[]" value="author" type="checkbox" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("author", $model->supports)) ?> class="checkbox" /> <label for="supports_author" class="checkbox"><?php _e("Author", MASTERPRESS_DOMAIN); ?><span> - <?php _e("show a select box for changing the author", MASTERPRESS_DOMAIN) ?></span></label> </div> <!-- /.fw --> <div class="fw"> <input id="supports_excerpt" name="supports[]" value="excerpt" type="checkbox" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("excerpt", $model->supports)) ?> class="checkbox { tags: ['excerpt'] }" /> <label for="supports_excerpt" class="checkbox"><?php _e("Excerpt", MASTERPRESS_DOMAIN); ?><span> - <?php _e("show a text area for writing a custom excerpt", MASTERPRESS_DOMAIN) ?></span></label> </div> <!-- /.fw --> <div class="fw"> <input id="supports_page_attributes" name="supports[]" value="page-attributes" type="checkbox" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("page-attributes", $model->supports) ) ?> class="checkbox" /> <label for="supports_page_attributes" class="checkbox"><?php _e("Type Attributes", MASTERPRESS_DOMAIN); ?><span> - <?php _e("Show the UI for editing Template, Menu Order and Parent", MASTERPRESS_DOMAIN); ?></span></label> </div> <!-- /.fw --> <div class="fw"> <input id="supports_thumbnail" name="supports[]" value="thumbnail" type="checkbox" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("thumbnail", $model->supports) ) ?> class="checkbox { tags: ['thumbnail'] }" /> <label for="supports_thumbnail" class="checkbox"><?php _e("Thumbnail", MASTERPRESS_DOMAIN); ?><span> - <?php _e("show the <em>standard</em> thumbnail upload for posts of this type", MASTERPRESS_DOMAIN) ?></span></label> </div> <!-- /.fw --> </div> <!-- /.fs-supports-2 --> </div> </div> </div> <!-- /.fs --> <?php else : ?> <?php endif; ?> <script id="custom-column-template" type="text/html"> <li class="column clearfix"> <div class="head"> <input name="columns[{{index}}][title]" value="Column" type="text" class="text" /> <input name="columns[{{index}}][disabled]" value="" type="hidden" class="disabled" /> <span class="handle"></span> </div> <div class="body"> <textarea name="columns[{{index}}][content]" class="column-content mono editable"></textarea> </div> <div class="foot"> <div> <button class="text remove"><i></i><?php _e("Remove") ?></button> </div> </div> </li> </script> <script id="tax-add-button-template" type="text/html"> <div class="control taxonomy-control {{taxonomy}}"> <button data-taxonomy="{{taxonomy}}" data-title="{{title}}" type="button" class="text add taxonomy taxonomy-{{taxonomy}}"><?php printf( __('<em class="create">Add</em> <b>%s</b> Column', MASTERPRESS_DOMAIN ), "{{title}}" ) ?></button> </div> </script> <?php if ($model->show_ui) : ?> <div class="fs fs-column-builder clearfix"> <div class="fst"> <div class="fstb"> <h3><i class="grid"></i><strong><?php _e("Columns") ?></strong> - <?php _e("specify the columns shown in the manage listing for posts of this type") ?></h3> </div> </div> <div class="fsc clearfix"> <div class="fscb clearfix"> <div class="columns-clip"> <div class="columns-wrap clearfix"> <ul class="columns clearfix"> <?php $count = 0; $core_enabled = array(); ?> <?php foreach ($model->columns() as $column) : ?> <?php $class = array("column clearfix"); $disabled = ""; $core = ""; $title = isset($column["title"]) ? $column["title"] : ""; $content = ""; if (isset($column["content"])) { $content = stripslashes($column["content"]); } if (isset($column["core"])) { $core = $column["core"]; $content = "{{col.".$core."}}"; } if (isset($column["disabled"])) { $disabled = $column["disabled"]; } if ($core != "") { $class[] = "core"; $class[] = $core; $data_core = ' data-core="'.$core.'" '; } if ($core == "cb") { $class[] = "checkbox nosort"; } if ($disabled == "yes") { $class[] = "disabled"; } else { if ($core != "") { $core_enabled[] = $core; } } ?> <li <?php echo $data_core ?> class="<?php echo implode(" ", $class) ?>"> <div class="head"> <?php if ($core == "cb") : ?> <input type="checkbox" /> <input name="columns[<?php echo $count ?>][core]" value="cb" type="hidden" /> <?php else: ?> <?php if ($core == "comments") : ?> <span class="icon"></span> <input name="columns[<?php echo $count ?>][title]" value="<?php echo $title ?>" type="text" class="text hidden" /> <?php else: ?> <input name="columns[<?php echo $count ?>][title]" value="<?php echo $title ?>" type="text" class="text" /> <?php endif; ?> <?php if ($core != "") : ?> <input name="columns[<?php echo $count ?>][core]" value="<?php echo $core ?>" type="hidden" /> <?php endif; ?> <input name="columns[<?php echo $count ?>][disabled]" value="<?php echo $disabled ?>" type="hidden" class="disabled" /> <span class="handle"></span> <?php endif; ?> </div> <!-- /.head --> <div class="body clearfix"> <?php if ($core == "cb") : ?> <input type="checkbox" /> <?php else: ?> <?php if ($core == "comments") : ?> <span class="icon"></span> <textarea name="columns[<?php echo $count ?>][content]" readonly="true" class="content mono readonly hidden"></textarea> <?php elseif ($core != "") : ?> <textarea name="columns[<?php echo $count ?>][content]" title="<?php _e("Content cannot be changed as this is a built-in column") ?>" readonly="true" class="content mono readonly"><?php echo $content ?></textarea> <?php else : ?> <textarea name="columns[<?php echo $count ?>][content]" class="content mono editable" style="z-index: <?php echo 200 - $count ?>"><?php echo $content ?></textarea> <?php endif; ?> <?php endif; ?> </div> <div class="foot"> <div> <?php if ($core != "cb" && $core != "title") : ?> <button type="button" class="text remove"><i></i><?php _e("Remove") ?></button> <?php endif; ?> </div> </div> </li> <?php $count++; ?> <?php endforeach; ?> </ul> </div> <!-- /.columns-wrap --> <div class="core-columns"> <div class="f"> <p class="label"><i class="wall"></i><?php _e("Built-in columns:", MASTERPRESS_DOMAIN) ?></p> <?php $core_columns = array( "Author" => "author", "Categories" => "categories", "Tags" => "tags", "Comments" => "comments", "Date" => "date" ); ?> <?php foreach ($core_columns as $label => $key) : ?> <?php $checked_attr = WOOF_HTML::checked_attr(in_array($key, $core_enabled)); $style = ""; $supports = explode(",", $model->supports); if ($key == "categories" && !$model->linked_to_taxonomy_name("category")) { $style = 'style="display: none" '; } else if ($key == "tags" && !$model->linked_to_taxonomy_name("post_tag")) { $style = 'style="display: none" '; } else if ($key == "author" && !in_array("author", $supports)) { $style = 'style="display: none" '; } else if ($key == "comments" && !in_array("comments", $supports)) { $style = 'style="display: none" '; } ?> <div <?php echo $style ?> id="fw-core-column-<?php echo $key ?>" class="fw"> <input id="core-column-<?php echo $key ?>" <?php echo $checked_attr ?> value="<?php echo $key ?>" type="checkbox" class="checkbox" /> <label for="core-column-<?php echo $key ?>" class="checkbox"><?php echo $label ?></label> </div> <!-- /.fw --> <?php endforeach; ?> </div> </div> <!-- /.core-columns --> <?php if (MPC::is_edit()) : ?> <style type="text/css"> <?php foreach (MPFT::type_keys() as $key) : ?> .select2-results .field-type-<?php echo $key ?>, .select2-container .field-type-<?php echo $key ?> { background-repeat: no-repeat; background-image: url(<?php echo MPU::type_icon_url($key) ?>); } <?php endforeach; ?> </style> <div id="dialog-fields" data-title="<?php _e("Select a Field to Display in the Column", MASTERPRESS_DOMAIN) ?>"> <?php $fs = $meow_provider->post_type_field_sets($model->name); $field_options = array(); $field_options[""] = ""; $field_options_attr = array(""); foreach ($fs as $set) { $fo = array(); $fo_attr = array(); foreach ($set->fields() as $field) { $fo[$field->display_label()] = $set->name.".".$field->name; $fo_attr[] = $field_options_attr[] = array("data-icon" => "mp-icon field-type-".$field->type); } $field_options[$set->display_label()] = array("options" => $fo, "options_attr" => $fo_attr); } echo WOOF_HTML::select(array("id" => "add-field-column-field-sets", "name" => "add-field-column-field-sets", "class" => "with-icons select2-source", "data-placeholder" => __("-- Select a Field --", MASTERPRESS_DOMAIN)), $field_options, "", $field_options_attr); ?> </div> <!-- /#dialog-fields --> <?php endif; ?> <div class="custom-columns"> <?php if (MPC::is_edit() && count($field_options) > 1) : ?> <div class="control"> <button id="add-field-column" type="button" class="text add field"><i></i><?php _e('<em class="create">Add</em> <b>Field</b> Column', MASTERPRESS_DOMAIN) ?></button> </div> <?php endif; ?> <div class="control"> <button id="add-custom-column" type="button" class="text add"><i></i><?php _e('<em class="create">Add</em> <b>Custom</b> Column', MASTERPRESS_DOMAIN) ?></button> </div> <?php $taxonomies = $model->taxonomies(); ?> <?php foreach ($model->taxonomies() as $tax) : ?> <div class="control taxonomy-control <?php echo $tax->name ?>"> <button data-taxonomy="<?php echo $tax->name ?>" data-title="<?php echo $tax->display_label() ?>" type="button" class="text add taxonomy taxonomy-<?php echo $tax->name ?>"><i></i><?php printf( __('<em class="create">Add</em> <b>%s</b> Column', MASTERPRESS_DOMAIN ), $tax->display_label() ) ?></button> </div> <?php endforeach; ?> </div> <!-- /.custom-columns --> </div> <!-- /.columns-clip --> </div> </div> </div> <!-- /.fs --> <?php endif; ?> <?php if (!$model->_builtin && !$model->_external) : ?> <div class="fs fs-menu-options clearfix"> <div class="fst"> <div class="fstb"> <h3><i class="menu-icon"></i><strong><?php _e("Admin Menu", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("controls where your post type appears in the WordPress administration menu", MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc clearfix"> <div class="fscb clearfix"> <div class="f clearfix"> <label for="menu_position" class="label-sortable-list"><?php _e("Position", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <?php // Build a menu, which we'll co-populate with info from the post types and then sort by menu position and sub position $post_post_type = MPM_PostType::find_by_name("post"); $page_post_type = MPM_PostType::find_by_name("page"); $menus = array( array( "label" => __("Posts", MASTERPRESS_DOMAIN), "class" => "icon16 icon-post", "disabled" => ( (bool) $post_post_type->disabled ), "built_in" => true, "position" => 5, "sub_position" => 0 ), array( "label" => __("Media", MASTERPRESS_DOMAIN), "class" => "icon16 icon-media", "built_in" => true, "position" => 10, "sub_position" => 0 ), array( "label" => __("Links", MASTERPRESS_DOMAIN), "class" => "icon16 icon-links", "built_in" => true, "position" => 15, "sub_position" => 0 ), array( "label" => __("Pages", MASTERPRESS_DOMAIN), "class" => "icon16 icon-page", "disabled" => ( (bool) $page_post_type->disabled ), "built_in" => true, "position" => 20, "sub_position" => 0 ), array( "label" => __("Comments", MASTERPRESS_DOMAIN), "class" => "icon16 icon-comments", "built_in" => true, "position" => 25, "sub_position" => 0 ), array( "divider" => true, "position" => 64, "sub_position" => 0 ), array( "label" => __("Plugins", MASTERPRESS_DOMAIN), "class" => "icon16 icon-plugins", "built_in" => true, "position" => 65, "sub_position" => 0 ), array( "label" => __("Users", MASTERPRESS_DOMAIN), "class" => "icon16 icon-users", "built_in" => true, "position" => 70, "sub_position" => 0 ), array( "label" => __("Tools", MASTERPRESS_DOMAIN), "class" => "icon16 icon-tools", "built_in" => true, "position" => 75, "sub_position" => 0 ), array( "label" => __("Settings", MASTERPRESS_DOMAIN), "class" => "icon16 icon-settings", "built_in" => true, "position" => 80, "sub_position" => 0 ), array( "divider" => true, "position" => 100, "sub_position" => 0 ) ); // Splice with post-types data (non built-in) $post_types = MPM_PostType::find( array( "where" => "_builtin = 0 AND name <> '{$model->name}'", "orderby" => "menu_position,menu_sub_position") ); foreach ($post_types as $post_type) { if ($post_type->show_in_menu) { if (!$post_type->_external) { // if post variables are set for these positions, use those instead of the DB values --> $position = $post_type->menu_position; $sub_position = $post_type->menu_sub_position; if (isset($_POST["other_menu_position"]) && isset($_POST["other_menu_position"][$post_type->name])) { $position = $_POST["other_menu_position"][$post_type->name]; } if (isset($_POST["other_menu_sub_position"]) && isset($_POST["other_menu_sub_position"][$post_type->name])) { $sub_position = $_POST["other_menu_sub_position"][$post_type->name]; } $bi = false; $menus[] = array( "name" => $post_type->name, "label" => $post_type->labels["menu_name"], "disabled" => $post_type->disabled, "icon" => MPU::menu_icon_url($post_type->menu_icon, true, "post_type", true), "built_in" => $bi, "position" => (int) $position, "sub_position" => (int) $sub_position ); } } } // Finally, add the post type currently being created / edited $menus[] = array( "disabled" => $model->disabled, "current" => true, "name" => $model->name == "" ? "?" : $model->name, "label" => $model->labels["menu_name"], "icon" => $model->menu_icon == "" ? MPU::img_url("icon-no-icon.png") : MPU::menu_icon_url($model->menu_icon), "built_in" => false, "position" => (int) $model->menu_position, "sub_position" => (int) $model->menu_sub_position ); // MPU::img_url("icon-no-icon.png") function mp_menu_sort($a, $b) { if ($a["position"] == $b["position"]) { if ($a["sub_position"] == $b["sub_position"]) { return 0; } else { return $a["sub_position"] > $b["sub_position"] ? 1 : -1; } } else if ($a["position"] > $b["position"]) { return 1; } else { return -1; } return 0; } usort($menus, "mp_menu_sort"); // MPV::dump($menus); $count = 0; ?> <div class="sortable-list sortable-list-menu"> <span class="arrow"></span> <div class="lists clearfix"> <ul> <?php foreach ($menus as $menu) : $count++; $first = $count == 1 ? "first " : ""; ?> <?php $disabled = ''; $disabled_title = ''; if (isset($menu["disabled"]) && $menu["disabled"]) { $disabled = 'disabled'; $disabled_title = __("This post type is disabled", MASTERPRESS_DOMAIN); } ?> <?php if (isset($menu["divider"])) : ?> <li class="divide nomove"></li> <?php elseif (isset($menu["built_in"]) && $menu["built_in"]) : ?> <li class="<?php echo $first ?> <?php echo $disabled ?> bi nomove { base_pos: <?php echo $menu["position"] ?>}" title="<?php echo $disabled_title ?>"> <span class="icon <?php echo $menu["class"] ?>"></span> <span><?php echo $menu["label"] ?></span> </li> <?php elseif (isset($menu["current"])) : ?> <li class="current <?php echo $disabled ?>" title="<?php echo $disabled_title ?>"> <input id="menu_position" name="menu_position" value="<?php echo $menu["position"] ?>" type="hidden" class="pos" /> <input id="menu_sub_position" name="menu_sub_position" value="<?php echo $menu["sub_position"] ?>" type="hidden" class="sub_pos" /> <span class="icon mp-icon mp-icon-post-type mp-icon-post-type-<?php echo $menu["name"] ?>"></span> <span class="fill { src: '#label_menu_name' }">?</span> </li> <?php else: ?> <li class="<?php echo $disabled ?>" title="<?php echo $disabled_title ?>"> <input id="other_menu_position_<?php echo $menu["name"] ?>" name="other_menu_position[<?php echo $menu["name"] ?>]" value="<?php echo $menu["position"] ?>" type="hidden" class="pos" /> <input id="other_menu_sub_position_<?php echo $menu["name"] ?>" name="other_menu_sub_position[<?php echo $menu["name"] ?>]" value="<?php echo $menu["sub_position"] ?>" type="hidden" class="sub_pos" /> <span class="icon mp-icon mp-icon-post-type mp-icon-post-type-<?php echo $menu["name"] ?>"></span> <span><?php echo $menu["label"] ?></span> </li> <?php endif; ?> <?php endforeach; ?> <li class="nomove holder"></li> </ul> </div> <!-- /.lists --> <div class="help"> <p> <?php _e("Drag post type to the desired position in the admin menu.", MASTERPRESS_DOMAIN) ?> </p> <p> <?php _e("Note: You cannot adjust the positions of the built-in menus, but you can position items before and after them (with the exception that items must be positioned after <em>Posts</em>).", MASTERPRESS_DOMAIN); ?> </p> <p> <em><?php _e("The menu presented here is a representation only, and does not include other menus registered by your theme and other plug-ins.", MASTERPRESS_DOMAIN); ?></em> </p> </div> </div> <!-- /.sortable-list --> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs --> <?php endif; ?> <?php if (!$model->_builtin && !$model->_external) : ?> <div class="fs fs-url-options clearfix"> <div class="fst"> <div class="fstb"> <h3><i class="globe"></i><strong><?php _e("URL Options", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("controls how your post type is accessible via URLs in your site", MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc clearfix"> <div class="fscb clearfix"> <div class="f"> <label for="rewrite_slug" class="text"><?php _e("Rewrite Slug", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="rewrite_slug" name="rewrite[slug]" type="text" value="<?php echo $model->rewrite["slug"] ?>" class="text mono" /> <p> <?php _e("The slug your post types will sit underneath in the URL structure.", MASTERPRESS_DOMAIN); ?><br /> <?php _e("The default value follows the popular convention of using the lowercase sanitized version of <em>Plural Name</em>.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="fw clearfix"> <input id="has_archive" name="has_archive" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->has_archive ) ?> class="checkbox" /> <label for="has_archive" class="checkbox"><?php printf( __("Has Archive Page? - <span>allows an archive page for this post type, using the template named %s", MASTERPRESS_DOMAIN ), 'archive-<em class="post-type-name fill { src: \'#name\', format: \'dasherize\' }\">'.$model->name.'</em>.php</span>') ?></label> </div> <div class="fw clearfix"> <input id="rewrite_with_front" name="rewrite[with_front]" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->rewrite["with_front"] ) ?> class="checkbox" /> <label for="rewrite_with_front" class="checkbox"><?php _e("With Front? - <span>Append the above slug to the top level URL set in your permalink settings.</span>", MASTERPRESS_DOMAIN); ?></label> </div> <!-- /.fw --> <div class="fw"> <input id="rewrite_feeds" name="rewrite[feeds]" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->rewrite["feeds"] ) ?> class="checkbox" /> <label for="rewrite_feeds" class="checkbox"><?php _e("Has Feeds? - <span>Create RSS / ATOM feeds for this post type.</span>", MASTERPRESS_DOMAIN); ?></label> </div> <!-- /.fw --> <div class="f clearfix"> <label for="permalink_epmask" class="text"><?php _e("Permalink End-Point Mask", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <?php //$options = array("EP_PERMALINK", "EP_ATTACHMENT", "EP_DATE", "EP_YEAR", "EP_MONTH", "EP_DAY", "EP_ROOT", "EP_COMMENTS", "EP_SEARCH", "EP_CATEGORIES", "EP_TAGS", "EP_AUTHORS", "EP_PAGES", "EP_ALL"); //echo WOOF_HTML::select( array("multiple" => "multiple", "id" => "permalink_epmask", "name" => "permalink_epmask"), $options, $model->permalink_epmask ); ?> <input id="permalink_epmask" name="permalink_epmask" type="text" value="<?php echo $model->permalink_epmask ?>" class="text mono" /> <p> <?php _e('Separate multiple end-point constants with a pipe. e.g. <span class="tt">EP_PAGES | EP_TAGS</span>', MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="fw clearfix"> <input id="supports_top_level_slugs" name="supports[]" value="top-level-slugs" <?php echo WOOF_HTML::checked_attr( MPV::in_csv("top-level-slugs", $model->supports) ) ?> type="checkbox" class="checkbox" /> <label for="supports_top_level_slugs" class="checkbox"><?php _e("Allow Rewrite Slug to be ommitted?", MASTERPRESS_DOMAIN); ?><span> - <?php _e("allows you to also access posts of this type <em>without</em> the rewrite slug in the URL.<br/>Be careful with this setting - it may affect site performance, and pages with the same slug as a post of this type will no longer be accessible.", MASTERPRESS_DOMAIN) ?></span></label> </div> <!-- /.fw --> </div> </div> </div> <!-- /.fs --> <div class="fs fs-query-data-options"> <div class="fst"> <div class="fstb"> <h3><i class="database"></i><strong><?php _e("Query & Data Options", MASTERPRESS_DOMAIN) ?></strong> - <?php _e(" controls the visibility of this post type in database queries and site searches, and exportability", MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb"> <div class="fw fw"> <input id="publicly_queryable" name="publicly_queryable" value="true" <?php echo WOOF_HTML::checked_attr( $model->publicly_queryable ) ?> type="checkbox" class="checkbox" /> <label for="publicly_queryable" class="checkbox"><?php _e("Publicly Queryable? - <span>Allow queries on this post type from the front-end WordPress API</span>", MASTERPRESS_DOMAIN); ?></label> </div> <!-- /.fw --> <div class="f"> <label for="query_var" class="text"><?php _e("Query Variable", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="query_var" name="query_var" type="text" value="<?php echo $model->query_var ?>" class="text mono" /> <p> <?php _e('Enter the query variable used to query posts of this type with <span class="tt">query_posts</span> or <span class="tt">WP_Query</span>. Generally this should simply be the default value of the <em>Singular Name</em>, unless you have a good reason to change it.', MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> <div class="fw"> <input id="exclude_from_search" name="exclude_from_search" value="true" <?php echo WOOF_HTML::checked_attr( $model->exclude_from_search ) ?> type="checkbox" class="checkbox" /> <label for="exclude_from_search" class="checkbox"><?php _e("Exclude from Search? - <span>Hide items of this post type in site search results</span>", MASTERPRESS_DOMAIN); ?></label> </div> <!-- /.fw --> <div class="fw"> <input id="can_export" name="can_export" value="true" <?php echo WOOF_HTML::checked_attr( $model->can_export ) ?> type="checkbox" class="checkbox" /> <label for="can_export" class="checkbox"><?php _e("Exportable? - <span>Allow this post type to be exported via the WordPress Export Tool</span>", MASTERPRESS_DOMAIN); ?></label> </div> <!-- /.fw --> </div> </div> </div> <!-- /.fs --> <?php endif; ?> <?php if (!$model->_external) : ?> <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 throughout the WordPress administration UI", 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"> <div class="fscb"> <div class="f"> <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->labels["singular_name"] ?>" type="text" class="text { tmpl: '{{singular_name}}' }" /> <em class="recommended">(<?php _e("recommended", MASTERPRESS_DOMAIN) ?>)</em> </div> </div> <!-- /.f --> <div class="f"> <label for="label_name"><?php _e("<em>Plural</em> Name:", 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">(<?php _e("recommended", MASTERPRESS_DOMAIN) ?>)</em> </div> </div> <!-- /.f --> <div class="f"> <label for="label_menu_name"><?php _e("Menu Name:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_menu_name" name="labels[menu_name]" value="<?php echo $model->labels["menu_name"] ?>" type="text" class="text { tmpl: '<?php _e("{{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("The name to give menu items", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_add_new"><?php _e("Add New:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_add_new" name="labels[add_new]" value="<?php echo $model->labels["add_new"] ?>" type="text" class="text { tmpl: '<?php _e("Add New", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Menu label for creating a post of this type", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_all_items"><?php _e("All Items:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_all_items" name="labels[all_items]" value="<?php echo $model->label("all_items") ?>" type="text" class="text { tmpl: '<?php _e("All {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("The all items text used in the menu", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_add_new_item"><?php _e("Add New Item:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_add_new_item" name="labels[add_new_item]" value="<?php echo $model->labels["add_new_item"] ?>" type="text" class="text { tmpl: '<?php _e("Add New {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Header shown when creating a new item of this type", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_edit"><?php _e("Edit:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_edit" name="labels[edit]" value="<?php echo $model->labels["edit"] ?>" type="text" class="text { tmpl: '<?php _e("Edit", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Menu label for editing posts of this type", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_edit_item"><?php _e("Edit Item:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_edit_item" name="labels[edit_item]" value="<?php echo $model->labels["edit_item"] ?>" type="text" class="text { tmpl: '<?php _e("Edit {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Header shown when editing posts of this type", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_new_item"><?php _e("New Item Label:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_new_item" name="labels[new_item]" value="<?php echo $model->labels["new_item"] ?>" type="text" class="text { tmpl: '<?php _e("New {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Shown in the favorites menu in the admin header", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_view"><?php _e("View:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_view" name="labels[view]" value="<?php echo $model->labels["view"] ?>" type="text" class="text { tmpl: '<?php _e("View {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Used as text in links to view posts of this type", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_view_item"><?php _e("View Item:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_view_item" name="labels[view_item]" value="<?php echo $model->labels["view_item"] ?>" type="text" class="text { tmpl: '<?php _e("View {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Text for the button alongside the permalink on the edit post screen", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_search_items"><?php _e("Search Items:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_search_items" name="labels[search_items]" value="<?php echo $model->labels["search_items"] ?>" type="text" class="text { tmpl: '<?php _e("Search {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Button text for the search box on the edit post screen", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_not_found"><?php _e("Not Found:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_not_found" name="labels[not_found]" value="<?php echo $model->labels["not_found"] ?>" type="text" class="text { lowercase: true, tmpl: '<?php _e("No {{plural_name}} found", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Text to display when no posts of this type are found through search in the admin", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_not_found_in_trash"><?php _e("Not Found In Trash:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_not_found_in_trash" name="labels[not_found_in_trash]" value="<?php echo $model->labels["not_found_in_trash"] ?>" type="text" class="text { lowercase: true, tmpl: '<?php _e("No {{plural_name}} found in Trash", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Text to display when no posts of this type are in the trash", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f hierarchical-only"> <label for="label_parent_item_colon"><?php _e("Parent Item (Colon):", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_parent_item_colon" name="labels[parent_item_colon]" value="<?php echo $model->labels["parent_item_colon"] ?>" type="text" class="text { tmpl: '<?php _e("Parent {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("The label for the parent selector on the edit posts screen (hierarchical only)", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_no_posts"><?php _e("No Posts:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_no_posts" name="labels[no_posts]" value="<?php echo $model->label("no_posts") ?>" type="text" class="text { tmpl: '<?php _e("No {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Used when listing posts in a master-detail relationship", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_one_post"><?php _e("One Post:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_one_post" name="labels[one_post]" value="<?php echo $model->label("one_post") ?>" type="text" class="text { tmpl: '<?php _e("1 {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Used when listing posts in a master-detail relationship", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_n_posts"><?php _e("n Posts:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_n_posts" name="labels[n_posts]" value="<?php echo $model->label("n_posts") ?>" type="text" class="text { tmpl: '<?php _e("%d {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Used when listing posts in a master-detail relationship", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> <div class="f"> <label for="label_remove_post"><?php _e("Remove Post:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_remove_post" name="labels[remove_post]" value="<?php echo $model->label("remove_post") ?>" type="text" class="text { tmpl: '<?php _e("Remove {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> <span class="fdesc"><?php _e("Used when listing posts in a master-detail relationship", MASTERPRESS_DOMAIN); ?></span> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs --> <?php endif; ?> <?php if (!$model->_builtin && !$model->_external) : ?> <div class="fs fs-capability-keys"> <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 post type.', MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb"> <div class="fw fwl"> <input id="capability_type_post" name="capability_type" value="post" <?php echo WOOF_HTML::checked_attr( $model->capability_type == "post" ) ?> type="radio" class="radio" /> <label for="capability_type_post" class="radio"><?php _e('<em>Post</em> style, based on the partial key <span class="tt">post</span>', MASTERPRESS_DOMAIN) ?></label> <div class="eg"> <p><strong><?php _e("primitive capabilities", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">edit_posts, edit_others_posts, publish_posts, read_private_posts</span></p> <p><strong><?php _e("meta capabilities", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">edit_post, read_post, delete_post, read, delete_posts, delete_private_posts, delete_published_posts, delete_others_posts, edit_private_posts, edit_published_posts</span></p> </div> </div> <!-- /.fw --> <div class="fw fwl"> <input id="capability_type_page" name="capability_type" value="page" <?php echo WOOF_HTML::checked_attr( $model->capability_type == "page" ) ?> type="radio" class="radio" /> <label for="capability_type_page" class="radio"><?php _e('<em>Page</em> style, based on the partial key <span class="tt">page</span>', MASTERPRESS_DOMAIN) ?></label> <div class="eg"> <p><strong><?php _e("primitive capabilities", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">edit_pages, edit_others_pages, publish_pages, read_private_pages</span></p> <p><strong><?php _e("meta capabilities", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">edit_page, read_page, delete_page, read, delete_pages, delete_private_pages, delete_published_pages, delete_others_pages, edit_private_pages, edit_published_pages</span></p> </div> </div> <!-- /.fw --> <div class="fw fwl"> <input id="capability_type_specific" name="capability_type" value="specific" <?php echo WOOF_HTML::checked_attr( $model->capability_type == "specific" || $model->capability_type == $model->name ) ?> type="radio" class="radio" /> <label for="capability_type_specific" class="radio"><?php _e("<em>Specific</em>, based on <em>Singular Name</em>", MASTERPRESS_DOMAIN) ?></label> <div class="eg"> <p><strong><?php _e("primitive capabilities", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">edit_<span class="fill { src: '#name' }">?</span>s, edit_others_<span class="fill { src: '#name' }">?</span>s, publish_<span class="fill { src: '#name' }">?</span>s, read_private_<span class="fill { src: '#name' }">?</span>s</span></p> <p><strong><?php _e("meta capabilities", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">edit_<span class="fill { src: '#name' }">?</span>, read_<span class="fill { src: '#name' }">?</span>, delete_<span class="fill { src: '#name' }">?</span>, read, delete_<span class="fill { src: '#name' }">?</span>s, delete_private_<span class="fill { src: '#name' }">?</span>s, delete_published_<span class="fill { src: '#name' }">?</span>s, delete_others_<span class="fill { src: '#name' }">?</span>s, edit_private_<span class="fill { src: '#name' }">?</span>s, edit_published_<span class="fill { src: '#name' }">?</span>s</span></p> </div> </div> <!-- /.fw --> <div id="fw_capability_type_custom" class="fw fwl"> <?php $custom_value = ""; $custom_checked = false; if ($model->capability_type != $model->name && $model->capability_type != "post" && $model->capability_type != "page") { $custom_checked = true; $custom_value = $model->capability_type; } ?> <input id="capability_type_custom" name="capability_type" value="custom" <?php echo WOOF_HTML::checked_attr( $custom_checked ) ?> type="radio" class="radio" /> <label id="label-capability_custom_value" for="capability_type_custom" class="radio"><?php _e("<em>Custom</em>, based on the partial key (singular)", MASTERPRESS_DOMAIN) ?>:</label> <input id="capability_type_custom_value" name="capability_type_custom_value" value="<?php echo $custom_value ?>" type="text" class="text mono" /> <div class="eg"> <p><strong><?php _e("primitive capabilities", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">edit_<span class="custom-fill { src: '#capability_type_custom_value', format: 'pluralize' }">?</span>, edit_others_<span class="custom-fill { src: '#capability_type_custom_value', format: 'pluralize' }">?</span>, publish_<span class="custom-fill { src: '#capability_type_custom_value', format: 'pluralize' }">?</span>, read_private_<span class="custom-fill { src: '#capability_type_custom_value', format: 'pluralize' }">?</span></span></p> <p><strong><?php _e("meta capabilities", MASTERPRESS_DOMAIN) ?>:</strong> <span class="tt">edit_<span class="custom-fill { src: '#capability_type_custom_value' }">?</span>, read_<span class="custom-fill { src: '#capability_type_custom_value' }">?</span>, delete_<span class="custom-fill { src: '#capability_type_custom_value' }">?</span>, read, delete_<span class="custom-fill { src: '#capability_type_custom_value', format: 'pluralize' }">?</span>, delete_private_<span class="custom-fill { src: '#capability_type_custom_value', format: 'pluralize' }">?</span>, delete_published_<span class="custom-fill { src: '#capability_type_custom_value', format: 'pluralize' }">?</span>, delete_others_<span class="custom-fill { src: '#capability_type_custom_value', format: 'pluralize' }">?</span>, edit_private_<span class="custom-fill { src: '#capability_type_custom_value', format: 'pluralize' }">?</span>, edit_published_<span class="custom-fill { src: '#capability_type_custom_value', format: 'pluralize' }">?</span></span></p> </div> </div> <!-- /.fw --> <div class="fw"> <input id="map_meta_cap" name="map_meta_cap" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->map_meta_cap ) ?> class="checkbox" /> <label for="map_meta_cap" class="checkbox"><?php printf( __('Map Meta Capabilities? - <span>whether to use the internal default meta capability handling. See the section on the <span class="tt">capabilities</span> argument %s</span>', MASTERPRESS_DOMAIN ), '<a href="http://codex.wordpress.org/Function_Reference/register_post_type#Arguments" target="_blank">'.__(" here", MASTERPRESS_DOMAIN).'</a>') ?></label> </div> </div> </div> </div> <!-- /.fs --> <?php endif; // !$model->_builtin ?> <?php } // end form
public function options() { // construct the HTML for the options UI $id = ""; $type = ""; if (isset($_REQUEST["type"])) { $type = $_REQUEST["type"]; } if (isset($_GET["id"])) { $id = $_GET["id"]; } // if the id is present, load a model if ($id && $id != "") { MPM::incl("field"); $model = MPM_Field::find_by_id($id); } if ($type != "") { if ($type_class = MPFT::type_class($type)) { $type_options = array(); if (isset($model) && isset($model->type_options)) { $type_options = $model->type_options; } $form = call_user_func_array( array($type_class, "options_form"), array(MPM::array_stripslashes($type_options)) ); } $css_url = ""; $css_file = MPU::type_file_path($type, "mpft-$type.options.css"); if (file_exists($css_file)) { $css_url = MPU::type_file_url($type, "mpft-$type.options.css")."?".filemtime($css_file); } $js_file = MPU::type_file_path($type, "mpft-$type.options.js"); if (file_exists($js_file)) { $js_url = MPU::type_file_url($type, "mpft-$type.options.js")."?".filemtime($js_file); } $ret = array( "form" => $form, "css_file" => $css_url, "type" => $type ); if (isset($js_url)) { $ret["js_file"] = $js_url; } self::ajax_success( $ret ); } else { self::ajax_error( __("field type options could not be loaded", MASTERPRESS_DOMAIN) ); } }
function field($name, $set_index = 1, $object = NULL, $object_type = NULL) { global $wf; if (is_null($object)) { $object = $this->object(); } list($set_name, $field_name, $prop_name) = MPFT::parse_meta_key($name); $set = $this->set($set_name); $set_item = $set[$set_index]; return new MEOW_Field($name, $set_index, $object, $set_item); }
public static function options_form( $options ) { $mfs = WOOF_File::to_bytes(ini_get('upload_max_filesize')); $mps = WOOF_File::to_bytes(ini_get('post_max_size')); $html = ""; $limit = self::get_filesize_limit(); $limit_mb = WOOF_File::format_filesize($limit, "MB", false); $defaults = array( "filename_case" => "lowercase", "filename_sanitize" => "dashes", "filename_dashes_underscores" => "dashes", "allowed_maxsize" => $limit_mb, "allowed_types" => array("jpg","jpeg","png","gif") ); $options = wp_parse_args( $options, $defaults ); $p = self::type_prefix(__CLASS__); $allowed_types_label = __("Allowed File Types:", MASTERPRESS_DOMAIN); $allowed_maxsize_label = __("Maximum Size:", MASTERPRESS_DOMAIN); $filename_label = __("File Name Handling", MASTERPRESS_DOMAIN); $filename_label_note = __("specify how file names should be sanitized on upload", MASTERPRESS_DOMAIN); $filename_sanitize_label = __("Sanitize file name:", MASTERPRESS_DOMAIN); $filename_sanitize_note = __("Sanitization removes special characters and replaces word boundaries with the specified character", MASTERPRESS_DOMAIN); $filename_case_label = __("Change case to:", MASTERPRESS_DOMAIN); $filename_case_select = WOOF_HTML::select( array("id" => $p."filename_case", "name" => "type_options[filename_case]"), array( "lower-case" => "lowercase", "Title-Case" => "titlecase", "UPPER-CASE" => "uppercase", "Preserve (No Change)" => "none" ), $options["filename_case"] ); $filename_sanitize_select = WOOF_HTML::select( array("id" => $p."filename_sanitize", "name" => "type_options[filename_sanitize]"), array( __("With Dashes ( - )", MASTERPRESS_DOMAIN) => "dashes", __("With Underscores ( _ )", MASTERPRESS_DOMAIN) => "underscores", __("None (Don't Sanitize)", MASTERPRESS_DOMAIN) => "none" ), $options["filename_sanitize"] ); $allowed_maxsize_note = __("( MB )", MASTERPRESS_DOMAIN); $allowed_maxsize_blank_note = sprintf(__("This value <strong>cannot exceed</strong> the maximum upload size<br />for your server, which is currently set to <strong>%s</strong>.", MASTERPRESS_DOMAIN), WOOF_File::format_filesize($limit, "MB", true, " ")); $allowed_label = __("File Restrictions", MASTERPRESS_DOMAIN); $allowed_label_note = __("restrict allowable files by type and file size", MASTERPRESS_DOMAIN); $allowed_types_note = __("The image field type is intended only for images that are displayable on a website.<br />For other image types, use the <em>file</em> field type instead", MASTERPRESS_DOMAIN); MPFT::incl("file"); foreach (array("jpg","jpeg","png","gif") as $ext) { $file_types_items[ MPFT_File::file_type_label($ext) ] = $ext; } $allowed_types_checkboxes = WOOF_HTML::input_checkbox_group( "type_options[allowed_types][]", $p."allowed-types-", $file_types_items, $options["allowed_types"], WOOF_HTML::open("div", "class=fwi"), WOOF_HTML::close("div")); // setup variables to insert into the heredoc string // (this is required where we cannot call functions within heredoc strings) $html .= <<<HTML <div class="filename-handling-wrap"> <h4><i class="highlighter"></i>{$filename_label}<span> - {$filename_label_note}</span></h4> <div class="f"> <label for="{$p}filename_sanitize">{$filename_sanitize_label}</label> <div id="fw-{$p}filename_sanitize" class="fw"> {$filename_sanitize_select} <p class="note">{$filename_sanitize_note}</p> </div> </div> <!-- /.f --> <div class="f"> <label for="{$p}filename_case">{$filename_case_label}</label> <div id="fw-{$p}filename_case" class="fw"> {$filename_case_select} </div> </div> <!-- /.f --> </div> <div class="allowed-wrap divider"> <h4><i class="warning-shield"></i>{$allowed_label}<span> - {$allowed_label_note}</span></h4> <div class="f"> <label for="{$p}allowed_maxsize">{$allowed_maxsize_label}</label> <div id="fw-{$p}allowed_maxsize" class="fw"> <input id="{$p}allowed_maxsize" name="type_options[allowed_maxsize]" type="text" maxlength="4" value="{$options['allowed_maxsize']}" class="text" /><span class="note">{$allowed_maxsize_note}</span> <p class="note">{$allowed_maxsize_blank_note}</p> </div> </div> <!-- /.f --> <div class="f f-allowed-types"> <p class="label">{$allowed_types_label}</p> <div class="fw"> {$allowed_types_checkboxes} <div class="controls"><button type="button" class="button button-small select-all">Select All</button><button type="button" class="button button-small select-none">Select None</button></div> <p class="note">{$allowed_types_note}</p> </div> </div> <!-- /.f --> </div> HTML; return $html; }
public function form($type) { $model = MasterPress::$model; global $meow_provider; ?> <?php MPV::messages(); ?> <input type="hidden" name="_builtin" value="<?php echo $model->_builtin ? "true" : "false" ?>" /> <input type="hidden" name="_external" value="<?php echo $model->_external ? "true" : "false" ?>" /> <div class="f"> <label for="name" class="icon"><i class="script-php"></i><?php _e("<strong>Singular</strong> 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" <?php MPV::read_only_attr($model->_builtin || $model->_external || MPC::is_edit()) ?> type="text" class="text mono key <?php echo MPV::read_only_class($model->_builtin || $model->_external) ?>" maxlength="20" value="<?php echo $model->name ?>" /><?php if (!$model->_builtin && !$model->_external) { ?><em class="required">(required)</em><?php } ?> <p> <?php _e("This is a unique identifier for the taxonomy in the WordPress API. It is not displayed, and by convention it <strong>must</strong> be a singular form, lowercase string with underscores to separate words.", MASTERPRESS_DOMAIN); ?> </p> </div> <p id="name_warning" class="warning"> <i class="error-circle"></i> <?php _e("Note: check that you have definitely entered a <strong>singular word</strong> here, as the singular form of <em>Plural Name</em> is currently different to this value.", MASTERPRESS_DOMAIN) ?> </p> </div> <!-- /.f --> <div class="f"> <label for="plural_name" class="icon"><i class="script-php"></i><?php _e("<strong>Plural</strong> Name", MASTERPRESS_DOMAIN)?>:</label> <div class="fw"> <input id="plural_name" name="plural_name" <?php MPV::read_only_attr($model->_builtin || $model->_external || MPC::is_edit()) ?> type="text" value="<?php echo $model->plural_name ?>" class="text mono key <?php echo MPV::read_only_class($model->_builtin || $model->_external) ?>" /><?php if (!$model->_builtin && !$model->_external) { ?><em class="required">(required)</em><?php } ?> <p> <?php _e("The plural form of <em>Singular Name</em>, following the same naming conventions", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f clearfix"> <label id="label-title_icon" for="title_icon" class="icon"><i class="image-small"></i><?php _e("Icon", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <div id="icon-file-uploader" class="icon-uploader file-uploader { ids: { drop: 'menu_icon_drop_area' }, input: '#title_icon', inputName: 'title_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="menu_icon_drop_area" class="drop-area"><?php _e("Drop file here to upload", MASTERPRESS_DOMAIN) ?></div> <?php $file_name = $model->title_icon; $file_class = ""; $clear_class = ""; if ($file_name == "") { $file_name = __("( None )", MASTERPRESS_DOMAIN); $file_class = "name-none"; $clear_class = "hidden"; } ?> <div class="file"> <span class="preview" style="background-image: url('<?php echo MPU::menu_icon_url($model->title_icon, true, "taxonomy") ?>');"></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="title_icon" name="title_icon" value="<?php echo $model->title_icon ?>" type="hidden" /> <div class="uploader-ui"></div> </div> <!-- /.file-uploader --> <?php MPV::icon_select($model->title_icon, "title-icon-select", "title_icon_select", "icon-file-uploader"); ?> </div> </div> <!-- /.f --> <?php if (!$model->_external) : ?> <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 taxonomy will keep its definition in the database but it will not be registered in WordPress, which will often be <strong>preferable to deleting it</strong> entirely.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php endif; ?> <?php if (!$model->_builtin && !$model->_external) : ?> <div class="f"> <label for="hierarchical" class="icon"><i class="hierarchy"></i><?php _e("Hierarchical", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="hierarchical" name="hierarchical" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->hierarchical ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#hierarchical' }"> <?php _e("hierarchical taxonomies are like WordPress <em>Categories</em>, whereas non-hierarchical taxonomies are like WordPress <em>Tags</em>.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="show_ui" class="icon"><i class="metabox-menu"></i><?php _e("Show UI", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="show_ui" name="show_ui" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->show_ui ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#show_ui' }"> <?php _e("unchecking this will internalize this taxonomy, hiding it from both the admin menus and the edit post interface", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="hide_term_ui" class="icon"><i class="metabox-tags-small"></i><?php _e("Hide Standard Terms UI", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="hide_term_ui" name="hide_term_ui" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->hide_term_ui ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#hide_term_ui' }"> <?php _e("hides the standard interface for assigning terms from this taxonomy to posts.<br>This may be useful if you are solely using this taxonomy to provide the values<br>for a <em>Related Terms</em> field.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="show_in_nav_menus" class="icon"><i class="menu-gray"></i><?php _e("Show in Nav Menus", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="show_in_nav_menus" name="show_in_nav_menus" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->show_in_nav_menus ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#show_in_nav_menus' }"> <?php _e("allows this taxonomy to be selected in navigation menus", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="show_tagcloud" class="icon"><i class="tag-cloud size-20"></i><?php _e("Show Tag Cloud", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="show_tagcloud" name="show_tagcloud" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->show_tagcloud ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#show_tagcloud' }"> <?php _e("check to allow the Tag Cloud widget to use this taxonomy", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="show_manage_filter" class="icon"><i class="funnel"></i><?php _e("Show Manage Filter", MASTERPRESS_DOMAIN) ?>?</label> <div class="fw"> <input id="show_manage_filter" name="show_manage_filter" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->show_manage_filter ) ?> class="checkbox" /> <p class="checkbox-alt-label { for_el: '#show_manage_filter' }"> <?php _e("show a drop-down filter list of terms above post listings attached to this taxonomy", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <?php endif; // !$model->_builtin ?> <?php if (!$model->_external) : ?> <div class="fs fs-post-types"> <div class="fst"> <div class="fstb"> <h3><i class="pins"></i><strong><?php _e("Post Types", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("associate post types with this taxonomy", MASTERPRESS_DOMAIN) ?></h3> <div class="buttons"> <button class="button button-small button-select-all" type="button"><?php _e('Select <strong class="all">All</strong>', MASTERPRESS_DOMAIN) ?></button> <button class="button button-small button-select-none" type="button"><?php _e('Select <strong class="none">None</strong>', MASTERPRESS_DOMAIN) ?></button> </div> </div> </div> <div class="fsc"> <div class="fscb"> <?php $post_types = MPM_PostType::find(array("orderby" => "name ASC")); ?> <?php foreach ($post_types as $post_type) : $disabled = $post_type->disabled ? ' disabled' : ''; $disabled_title = $post_type->disabled ? __("This post type is disabled", MASTERPRESS_DOMAIN) : ''; $builtin = $post_type->_builtin ? ' '.__('(Built-in)', MASTERPRESS_DOMAIN) : ''; ?> <div class="fw"> <input id="post_types_<?php echo $post_type->name ?>" name="post_types[]" value="<?php echo $post_type->name ?>" type="checkbox" <?php echo WOOF_HTML::checked_attr( $model->linked_to_post_type($post_type) || MPV::in_post_array("post_types", $post_type->name) ) ?> class="checkbox" /> <label for="post_types_<?php echo $post_type->name ?>" class="checkbox <?php echo $disabled ?>" title="<?php echo $disabled_title ?>"><?php echo $post_type->labels["name"] ?><span><?php echo $builtin ?></span></label> </div> <!-- /.fw --> <?php endforeach; ?> </div> </div> </div> <!-- /.fs --> <?php endif; ?> <script id="custom-column-template" type="text/html"> <li class="column clearfix"> <div class="head"> <input name="columns[{{index}}][title]" value="Column" type="text" class="text" /> <input name="columns[{{index}}][disabled]" value="" type="hidden" class="disabled" /> <span class="handle"></span> </div> <div class="body"> <textarea name="columns[{{index}}][content]" class="column-content mono editable"></textarea> </div> <div class="foot"> <div> <button class="text remove"><i></i><?php _e("Remove") ?></button> </div> </div> </li> </script> <div class="fs fs-column-builder"> <div class="fst"> <div class="fstb"> <h3><i class="grid"></i><strong><?php _e("Columns") ?></strong> - <?php _e("specify the columns shown in the manage listing for terms in this taxonomy") ?></h3> </div> </div> <div class="fsc"> <div class="fscb"> <div class="columns-clip"> <div class="columns-wrap clearfix"> <ul class="columns clearfix"> <?php $count = 0; $core_enabled = array(); ?> <?php foreach ($model->columns() as $column) : ?> <?php $class = array("column clearfix"); $disabled = ""; $core = ""; $title = ""; $title_readonly = ""; if (isset($column["title"])) { $title = $column["title"]; } $content = ""; if (isset($column["title_readonly"])) { $title_readonly = ' readonly="true" title="'.__("This title cannot be changed, as it dynamically displays the active post type").'" '; } if (isset($column["content"])) { $content = stripslashes($column["content"]); } if (isset($column["core"])) { $core = $column["core"]; $content = "{{col.".$core."}}"; } if (isset($column["disabled"])) { $disabled = $column["disabled"]; } if ($core != "") { $class[] = "core"; $class[] = $core; $data_core = ' data-core="'.$core.'" '; } if ($core == "cb") { $class[] = "checkbox nosort"; } if ($disabled == "yes") { $class[] = "disabled"; } else { if ($core != "") { $core_enabled[] = $core; } } ?> <li <?php echo $data_core ?> class="<?php echo implode(" ", $class) ?>"> <div class="head"> <?php if ($core == "cb") : ?> <input type="checkbox" /> <input name="columns[<?php echo $count ?>][core]" value="cb" type="hidden" /> <?php else: ?> <input name="columns[<?php echo $count ?>][title]" <?php echo $title_readonly ?> value="<?php echo $title ?>" type="text" class="text" /> <?php if ($core != "") : ?> <input name="columns[<?php echo $count ?>][core]" value="<?php echo $core ?>" type="hidden" /> <?php endif; ?> <input name="columns[<?php echo $count ?>][disabled]" value="<?php echo $disabled ?>" type="hidden" class="disabled" /> <span class="handle"></span> <?php endif; ?> </div> <!-- /.head --> <div class="body clearfix"> <?php if ($core == "cb") : ?> <input type="checkbox" /> <?php else: ?> <?php if ($core == "comments") : ?> <span class="icon"></span> <textarea name="columns[<?php echo $count ?>][content]" readonly="true" class="content mono readonly hidden"></textarea> <?php elseif ($core != "") : ?> <textarea name="columns[<?php echo $count ?>][content]" title="<?php _e("Content cannot be changed as this is a built-in column") ?>" readonly="true" class="content mono readonly"><?php echo $content ?></textarea> <?php else : ?> <textarea name="columns[<?php echo $count ?>][content]" class="content mono editable" style="z-index: <?php echo 200 - $count ?>"><?php echo $content ?></textarea> <?php endif; ?> <?php endif; ?> </div> <div class="foot"> <div> <?php if ($core != "cb" && $core != "title") : ?> <button type="button" class="text remove"><i></i><?php _e("Remove") ?></button> <?php endif; ?> </div> </div> </li> <?php $count++; ?> <?php endforeach; ?> </ul> </div> <!-- /.columns-wrap --> <div class="core-columns"> <div class="f"> <p class="label"><i class="wall"></i><?php _e("Built-in columns:", MASTERPRESS_DOMAIN) ?></p> <?php $core_columns = array( "Name" => "name", "Description" => "description", "Slug" => "slug", "[Post Type]" => "posts", ); ?> <?php foreach ($core_columns as $label => $key) : ?> <?php $checked_attr = WOOF_HTML::checked_attr(in_array($key, $core_enabled)); $style = ""; $supports = explode(",", $model->supports); if ($key == "categories" && !$model->linked_to_taxonomy_name("category")) { $style = 'style="display: none" '; } else if ($key == "tags" && !$model->linked_to_taxonomy_name("post_tag")) { $style = 'style="display: none" '; } else if ($key == "author" && !in_array("author", $supports)) { $style = 'style="display: none" '; } else if ($key == "comments" && !in_array("comments", $supports)) { $style = 'style="display: none" '; } ?> <div <?php echo $style ?> id="fw-core-column-<?php echo $key ?>" class="fw"> <input id="core-column-<?php echo $key ?>" <?php echo $checked_attr ?> value="<?php echo $key ?>" type="checkbox" class="checkbox" /> <label for="core-column-<?php echo $key ?>" class="checkbox"><?php echo $label ?></label> </div> <!-- /.fw --> <?php endforeach; ?> </div> </div> <!-- /.core-columns --> <?php if (MPC::is_edit()) : ?> <style type="text/css"> <?php foreach (MPFT::type_keys() as $key) : ?> .select2-results .field-type-<?php echo $key ?>, .select2-container .field-type-<?php echo $key ?> { background-repeat: no-repeat; background-image: url(<?php echo MPU::type_icon_url($key) ?>); } <?php endforeach; ?> </style> <div id="dialog-fields" data-title="<?php _e("Select a Field to Display in the Column", MASTERPRESS_DOMAIN) ?>"> <?php $fs = $meow_provider->taxonomy_field_sets($model->name); $field_options = array(); $field_options[""] = ""; $field_options_attr = array(""); foreach ($fs as $set) { $fo = array(); $fo_attr = array(); foreach ($set->fields() as $field) { $fo[$field->display_label()] = $set->name.".".$field->name; $fo_attr[] = $field_options_attr[] = array("data-icon" => "mp-icon field-type-".$field->type); } $field_options[$set->display_label()] = array("options" => $fo, "options_attr" => $fo_attr); } echo WOOF_HTML::select(array("id" => "add-field-column-field-sets", "name" => "add-field-column-field-sets", "class" => "with-icons select2-source", "data-placeholder" => __("-- Select a Field --", MASTERPRESS_DOMAIN)), $field_options, "", $field_options_attr); ?> </div> <!-- /#dialog-fields --> <?php endif; ?> <div class="custom-columns"> <?php if (MPC::is_edit() && count($field_options) > 1) : ?> <div class="control"> <button id="add-field-column" type="button" class="text add field"><i></i><?php _e('<em class="create">Add</em> <b>Field</b> Column', MASTERPRESS_DOMAIN) ?></button> </div> <?php endif; ?> <div class="control"> <button id="add-custom-column" type="button" class="text add"><i></i><?php _e('<em class="create">Add</em> Custom Column', MASTERPRESS_DOMAIN) ?></button> </div> </div> <!-- /.custom-columns --> </div> <!-- /.columns-clip --> </div> </div> </div> <!-- /.fs --> <?php if (is_multisite() && MASTERPRESS_MULTISITE_SHARING) { $args["supports"] = array("multisite"); $args["labels"] = array( "title" => __("control the visibility of this Taxonomy within WordPress", MASTERPRESS_DOMAIN), "title_multisite" => __("specify the sites in the multisite network that this Taxonomy is available in", MASTERPRESS_DOMAIN), "multisite_all" => __( "All Sites" ) ); MPV::fs_visibility( $model, $args ); } ?> <?php if (!$model->_builtin && !$model->_external) : ?> <div class="fs fs-url-options"> <div class="fst"> <div class="fstb"> <h3><i class="globe"></i><strong><?php _e("URL Options", MASTERPRESS_DOMAIN) ?></strong> - <?php _e("controls how your taxonomy is accessible via URLs in your site", MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb"> <div class="f"> <label for="rewrite_slug" class="text"><?php _e("Rewrite Slug", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="rewrite_slug" name="rewrite[slug]" type="text" value="<?php echo $model->rewrite["slug"] ?>" class="text mono" /> <p> <?php _e("The slug prepended to posts attached to this taxonomy in the URL structure.", MASTERPRESS_DOMAIN); ?><br /> <?php _e("The default value follows the WordPress of using the lowercase sanitized version of <em>Singular Name</em>.", MASTERPRESS_DOMAIN); ?> </p> </div> </div> <!-- /.f --> <div class="fw"> <input id="rewrite_with_front" name="rewrite[with_front]" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->rewrite["with_front"] ) ?> class="checkbox" /> <label for="rewrite_with_front" class="checkbox"><?php _e("With Front? - <span>Append the above slug to the top level URL set in your permalink settings.</span>", MASTERPRESS_DOMAIN); ?></label> </div> <!-- /.fw --> <div class="fw hierarchical-only"> <input id="rewrite_hierarchical" name="rewrite[hierarchical]" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->rewrite["hierarchical"] ) ?> class="checkbox" /> <label for="rewrite_hierarchical" class="checkbox"><?php _e("Hierarchical? - <span>Allow hierarchical urls, mirroring the hierarchy of the taxonomy.</span>", MASTERPRESS_DOMAIN); ?></label> </div> <!-- /.fw --> </div> </div> </div> <!-- /.fs --> <div class="fs fs-query-data-options"> <div class="fst"> <div class="fstb"> <h3><i class="database"></i><strong><?php _e("Query & Data Options", MASTERPRESS_DOMAIN) ?></strong> - <?php _e(" controls API access to this taxonomy in database queries and site searches", MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb"> <div class="fw"> <input id="query_allowed" name="query_allowed" type="checkbox" value="true" <?php echo WOOF_HTML::checked_attr( $model->meta("query_allowed") ) ?> class="checkbox" /> <label for="query_allowed" class="checkbox"><?php _e("Allow Queries? - <span>Allow this taxonomy to be queried in the database.</span>", MASTERPRESS_DOMAIN); ?></label> </div> <!-- /.fw --> <div class="f"> <label for="query_var" class="text"><?php _e("Query Variable", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="query_var" name="query_var" type="text" value="<?php echo $model->query_var ?>" class="text mono" /> <p> <?php _e('Enter the query variable used to query this taxonomy with <span class="tt">query_posts</span> or <span class="tt">WP_Query</span>. Generally this should simply be the default value of the <em>Singular Name</em>, unless you have a good reason to change it.', MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="update_count_callback" class="text"><?php _e("Update Count Callback", MASTERPRESS_DOMAIN) ?>:</label> <div class="fw"> <input id="update_count_callback" name="update_count_callback" type="text" value="<?php echo $model->update_count_callback ?>" class="text mono" /> <p> <?php _e("The name of a function that will be called to update the count of an associated post type.", MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs --> <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 throughout the WordPress administration UI", 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"> <div class="fscb"> <div class="f"> <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->labels["singular_name"] ?>" type="text" class="text { tmpl: '{{singular_name}}' }" /> <em class="recommended">(<?php _e("recommended", MASTERPRESS_DOMAIN) ?>)</em> </div> </div> <!-- /.f --> <div class="f"> <label for="label_name"><?php _e("<em>Plural</em> Name:", 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">(<?php _e("recommended", MASTERPRESS_DOMAIN) ?>)</em> </div> </div> <!-- /.f --> <div class="f"> <label for="label_menu_name"><?php _e("Menu Name:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_menu_name" name="labels[menu_name]" value="<?php echo $model->labels["menu_name"] ?>" type="text" class="text { tmpl: '<?php _e("{{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="label_add_new"><?php _e("Search Items:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_search_items" name="labels[search_items]" value="<?php echo $model->labels["search_items"] ?>" type="text" class="text { tmpl: '<?php _e("Search {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="label_popular_items"><?php _e("Popular Items:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_popular_items" name="labels[popular_items]" value="<?php echo $model->labels["popular_items"] ?>" type="text" class="text { tmpl: '<?php _e("Popular {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="label_all_items"><?php _e("All Items:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_all_items" name="labels[all_items]" value="<?php echo $model->labels["all_items"] ?>" type="text" class="text { tmpl: '<?php _e("All {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f hierarchical-only"> <label for="label_parent_item"><?php _e("Parent Item:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_parent_item" name="labels[parent_item]" value="<?php echo $model->labels["parent_item"] ?>" type="text" class="text { tmpl: '<?php _e("Parent {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f hierarchical-only"> <label for="label_parent_item_colon"><?php _e("Parent Item Colon:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_parent_item_colon" name="labels[parent_item_colon]" value="<?php echo $model->labels["parent_item_colon"] ?>" type="text" class="text { tmpl: '<?php _e("Parent {{singular_name}}:", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="label_edit_item"><?php _e("Edit Item:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_edit_item" name="labels[edit_item]" value="<?php echo $model->labels["edit_item"] ?>" type="text" class="text { tmpl: '<?php _e("Edit {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="label_update_item"><?php _e("Update Item:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_update_item" name="labels[update_item]" value="<?php echo $model->labels["update_item"] ?>" type="text" class="text { tmpl: '<?php _e("Update {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="label_add_new_item"><?php _e("Add New Item:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_add_new_item" name="labels[add_new_item]" value="<?php echo $model->labels["add_new_item"] ?>" type="text" class="text { tmpl: '<?php _e("Add New {{singular_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="label_new_item_name"><?php _e("New Item Name:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_new_item_name" name="labels[new_item_name]" value="<?php echo $model->labels["new_item_name"] ?>" type="text" class="text { tmpl: '<?php _e("New {{singular_name}} Name", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="label_separate_items_with_commas"><?php _e("Separate Items With Commas:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_separate_items_with_commas" name="labels[separate_items_with_commas]" value="<?php echo $model->labels["separate_items_with_commas"] ?>" type="text" class="text { tmpl: '<?php _e("Separate {{plural_name}} with commas", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="label_add_or_remove_items"><?php _e("Add or remove items:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_add_or_remove_items" name="labels[add_or_remove_items]" value="<?php echo $model->labels["add_or_remove_items"] ?>" type="text" class="text { tmpl: '<?php _e("Add or remove {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> <div class="f"> <label for="label_choose_from_most_used"><?php _e("Choose from most used:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="label_choose_from_most_used" name="labels[choose_from_most_used]" value="<?php echo $model->labels["choose_from_most_used"] ?>" type="text" class="text { tmpl: '<?php _e("Choose from most used {{plural_name}}", MASTERPRESS_DOMAIN) ?>' }" /> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs --> <div class="fs fs-capability-keys"> <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 taxonomy", MASTERPRESS_DOMAIN) ?></h3> </div> </div> <div class="fsc"> <div class="fscb"> <div class="f"> <label for="capability_manage_terms"><?php _e("Manage Terms:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="capability_manage_terms" name="capabilities[manage_terms]" value="<?php echo $model->capabilities["manage_terms"] ?>" type="text" class="text mono" /> <p class="note"> <?php _e('<span class="tt">manage_categories</span> is the typical value', MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="capability_edit_terms"><?php _e("Edit Terms:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="capability_edit_terms" name="capabilities[edit_terms]" value="<?php echo $model->capabilities["edit_terms"] ?>" type="text" class="text mono" /> <p class="note"> <?php _e('<span class="tt">manage_categories</span> is the typical value', MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="capability_delete_terms"><?php _e("Delete Terms:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="capability_delete_terms" name="capabilities[delete_terms]" value="<?php echo $model->capabilities["delete_terms"] ?>" type="text" class="text mono" /> <p class="note"> <?php _e('<span class="tt">manage_categories</span> is the typical value', MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> <div class="f"> <label for="capability_assign_terms"><?php _e("Assign Terms:", MASTERPRESS_DOMAIN); ?></label> <div class="fw"> <input id="capability_assign_terms" name="capabilities[assign_terms]" value="<?php echo $model->capabilities["assign_terms"] ?>" type="text" class="text mono" /> <p class="note"> <?php _e('<span class="tt">edit_posts</span> is the typical value', MASTERPRESS_DOMAIN) ?> </p> </div> </div> <!-- /.f --> </div> </div> </div> <!-- /.fs --> <?php endif; // !$model->_builtin ?> <?php } // end form
public function prop($name = null, $value = null) { if (is_null($name)) { return $this->data->prop; } if ($this->type_delegate) { if (!is_null($value)) { if (method_exists($this->type_delegate, "set_prop")) { $this->type_delegate->set_prop($name, $value); } else { $this->data->prop[$name] = $value; if ($type_class = MPFT::type_class($this->info->type)) { // re-instantiate the delegate $this->type_delegate = new $type_class($this->info, $this); } else { $this->type_delegate = new MPFT($this->info, $this); } } $this->mark_dirty(); return $this->data->prop[$name]; } else { if (method_exists($this->type_delegate, "get_prop")) { return $this->type_delegate->get_prop($name); } if (isset($this->data->prop[$name])) { return $this->data->prop[$name]; } } } if (!is_null($value)) { $this->data->prop[$name] = $value; } if (isset($this->data->prop[$name])) { return $this->data->prop[$name]; } return null; }
public static function set_item_template_data(MEOW_FieldSet &$set, $args = array()) { $r = wp_parse_args( $args, array("preview" => false, "readonly" => !$set->is_editable(), "id_base" => "mp_meta_", "name_base" => "mp_meta", "order_base" => "mp_meta_order", "summary_preview_base" => "mp_summary_preview_", "summary_base" => "mp_summary_" ) ); $d = array(); $set_item_classes = array(); $set_fields_classes = array(); $set_summary_classes = array(); $d["allow_remove"] = true; if ($r["preview"]) { $d["preview"] = true; $d["allow_remove"] = false; } if ($r["readonly"]) { $d["readonly"] = true; $d["allow_remove"] = false; } $info = $set->info(); if ($info->expanded) { $d["toggle_class"] = "collapse"; $set_item_classes[] = "expanded"; $set_summary_classes[] = "hidden"; } else { $d["toggle_class"] = "expand"; $set_item_classes[] = "collapsed"; $set_fields_classes[] = "hidden"; } if (isset($args["versions_select"])) { $d["versions_select"] = $args["versions_select"]; } $d["lang_are_you_sure"] = esc_js(__("Are you sure?", MASTERPRESS_DOMAIN)); $d["label_collapse"] = __("Collapse", MASTERPRESS_DOMAIN); $d["set_item_classes"] = implode(" ", $set_item_classes); $d["set_fields_classes"] = implode(" ", $set_fields_classes); $d["description"] = trim( $info->label("description") ); $d["allow_multiple"] = $info->allow_multiple; $d["labels_toggle"] = __("Toggle", MASTERPRESS_DOMAIN); $d["set_labels_remove_plain"] = strip_tags($info->label("remove")); $d["set_labels_remove"] = $info->label("remove"); $d["fields"] = array(); if ( WOOF::is_true_arg($args, "creator") ) { $i = "!!set_index!!"; } else if ($set->creator) { // leave a placeholder for Handlebars to render into $i = "{{set_index}}"; } else { $i = $set->index(); } $d["set_index"] = $i; $set_id = $r["id_base"]."{$info->name}_$i"; $set_name = $r["name_base"]."[{$info->name}][$i]"; if (WOOF::is_true_arg($r, "nested")) { $d["order_name"] = $r["order_base"]."[$i]"; } else { $d["order_name"] = $r["order_base"]."[{$info->name}][$i]"; } $d["fields"] = array(); $fields = $info->fields(); $fi = 0; $fc = 0; foreach ($fields as $field) { if ($type_class = MPFT::type_class($field->type)) { $fc++; } } foreach ($fields as $field) { if ($field->current_user_can_see()) { $field_id = "{$set_id}_{$field->name}"; $field_name = "{$set_name}[{$field->name}]"; if ($r["preview"]) { $field_summary_id = $r["summary_preview_base"]."{$info->name}_{$field->name}"; } else { $field_summary_id = $r["summary_base"]."{$info->name}_{$field->name}"; } $fd = array(); // the field data if ($ftc = MPFT::type_class($field->type)) { $fi++; $fd["model_id"] = $field->id; $fd["readonly"] = false; // reset $fd["label_is_header"] = call_user_func_array( array($ftc, "label_is_header"), array($field->type_options)); $fd["type"] = $field->type; $fd["type_widget"] = "mpft_".str_replace("-", "_", $field->type); $fd["label"] = $field->display_label(); $fd["esc_label"] = esc_attr($field->display_label()); $fd["label_suffix"] = call_user_func( array($ftc, "label_suffix") ); $fd["field_path"] = $info->name."-".$field->name; $fd["prop_list"] = implode(",", MPFT::type_properties($field->type)); $fd["description"] = trim( $field->label("description") ); $fd["pos_class"] = WOOF_HTML::pos_class_1($fi, $fc, " mp-field-"); if ($field->current_user_can_manage()) { $mu = $field->manage_url($info); $mu .= "&mp_redirect=".urlencode($_SERVER["REQUEST_URI"]); if ($mu) { $fd["go"] = '<a href="'.$mu.'" class="mp-go with-mptt" data-tooltip="'.__("Edit Field Definition", MASTERPRESS_DOMAIN).'">'.__("Edit Field Definition").'</a>'; } } $field_classes = array("mpft-".$field->type); if ($fi == $fc) { $field_classes[] = "mp-field-last"; } $field_summary_classes = array(); if ($field->required) { $field_classes[] = "required"; $field_summary_classes[] = "required"; } if (isset($field->summary_options["emphasise"])) { $field_summary_classes[] = "em"; } $fd["name"] = $field->name; $fd["template_id"] = "{$info->name}_{$field->name}"; $fd["summary_id"] = $field_summary_id."_".$i; $fd["field_id"] = $field_id; $fd["id_first"] = $field_id; $opts = call_user_func( array($ftc, "ui_options") ); $ui = array(); if (count($opts) ) { $ui = call_user_func_array( array($ftc, "extract_options"), array($field->type_options, $opts) ); $ui = call_user_func_array( array($ftc, "normalize_options"), array($ui) ); } $ui_parts = array(); if (count($ui)) { foreach( $ui as $key => $value ) { $ui_parts[] = "'$key':'".esc_attr(esc_js($value))."'"; } } // $fd["lang"] = "{".implode(",", $lang_parts)."}"; $fd["ui"] = "{".implode(",", $ui_parts)."}"; if (isset($field->labels["tooltip_help"])) { $tooltip_help = trim($field->label("tooltip_help")); if ($tooltip_help != "") { $fd["label_tooltip"] = "#mptt_".$info->id."_".$field->id; } } if (!$field->current_user_can_edit($set->is_editable()) && !$r["preview"]) { $fd["readonly"] = true; } $strip_whitespace = !call_user_func( array($ftc, "ui_preserve_whitespace") ); $ftd_args = $r; if ($set->creator) { $meow_field = new MEOW_FieldCreator($field->name, null, $field); call_user_func_array( array($ftc, "apply_default"), array($meow_field, $set, $ftc) ); $field_ui_data = self::field_ui_template_data($set, $meow_field, $ftd_args); $field_ui = WOOF::render_template( self::field_ui_template(), $field_ui_data, $strip_whitespace ); } else { // here we regard the actual field value, and build the UI from that $meow_field = $set->field($field->name); $action = ""; if (isset($_GET["action"])) { $action = $_GET["action"]; } if (!$info->allow_multiple && $action != "edit") { call_user_func_array( array($ftc, "apply_default"), array($meow_field, $set, $ftc) ); } $field_ui_data = self::field_ui_template_data($set, $meow_field, $ftd_args); $field_ui = WOOF::render_template( self::field_ui_template(), $field_ui_data, $strip_whitespace ); } if ($fi == $fc) { if ($meow_field->blank()) { $set_summary_classes[] = "last-empty"; } } $fd["field_ui"] = $field_ui; // now build out the summary info $fd["summary_width"] = call_user_func( array($ftc, "summary_width") ); if (isset($field->summary_options["width"])) { $sw = (int) $field->summary_options["width"]; if ($sw >= 1 && $sw <= 5) { $fd["summary_width"] = $sw; } } $max_length = ( $fd["summary_width"] * 138 ) / 10; $fd["label_truncated"] = WOOF::truncate_basic( $fd["label"], $max_length, "<span>…</span>" ); if ($fd["label"] != $fd["label_truncated"]) { $fd["label_title"] = strip_tags($fd["label"]); } $label_classes = array(); if (method_exists($ftc, "summary_label_classes")) { $label_classes = call_user_func_array( array($ftc, "summary_label_classes"), array($meow_field) ); } $fd["label_classes"] = implode(" ", $label_classes); $empty = $meow_field->blank(); $fd["empty_summary"] = call_user_func_array( array($ftc, "empty_summary"), array($meow_field) ); $fd["summary"] = call_user_func_array( array($ftc, "summary"), array($meow_field) ); if ($empty) { $field_summary_classes[] = "empty"; } else { $fd["is_edit"] = "is-edit"; } $fd["classes"] = implode(" ", $field_classes); $fd["summary_classes"] = implode(" ", $field_summary_classes); // add the field data to the main data array $d["fields"][] = $fd; } // endif class_exists($ftc) } // current user can see } // endforeach $d["set_summary_classes"] = implode(" ", $set_summary_classes); return $d; }
public function grid() { MPC::incl("post-types"); MPV::incl("fields"); MPV::incl("post-types"); $info = MasterPress::$view; ?> <?php MPV::messages(); ?> <div class="grid-set"> <?php $field_sets = MPM_SharedFieldSet::find( array("orderby" => "name ASC" ) ); ?> <?php MPV::field_set_icon_styles($field_sets); ?> <?php $has_actions = MasterPress::current_user_can("edit_shared_field_sets,delete_shared_field_sets,edit_shared_fields,delete_shared_fields"); $can_edit = MasterPress::current_user_can("edit_shared_field_sets"); $can_delete = MasterPress::current_user_can("delete_shared_field_sets"); $can_create = MasterPress::current_user_can("create_shared_field_sets"); $can_edit_fields = MasterPress::current_user_can("edit_shared_fields"); $can_delete_fields = MasterPress::current_user_can("delete_shared_fields"); $can_create_fields = MasterPress::current_user_can("create_shared_fields"); $less = ($can_create_fields) ? 1 : 0; $colspan = ( $has_actions ? 7 : 6 ) - $less; foreach ($field_sets as $field_set) { if (MPC::is_deleting($field_set->id, "delete")) { $this->confirm_delete($field_set); } else { foreach ($field_set->fields() as $field) { if (MPC::is_deleting($field->id, "delete-field")) { $this->confirm_delete_field($field); } } } } ?> <?php if (count($field_sets)) : ?> <table cellspacing="0" class="grid grid-field-sets grid-shared-field-sets"> <thead> <tr> <th class="first type"><i class="types"></i><span><?php _e("Type", MASTERPRESS_DOMAIN) ?></span></th> <th class="label"><i class="label-string"></i><span><?php _e("Label", MASTERPRESS_DOMAIN) ?></span></th> <th class="front-end-name"><i class="script-php"></i><span><?php _e("Front End Name", MASTERPRESS_DOMAIN) ?></span></th> <th class="post-types"><i class="pins"></i><span><?php _e("Post Types", MASTERPRESS_DOMAIN) ?></span></th> <th class="taxonomies"><i class="tags"></i><span><?php _e("Taxonomies", MASTERPRESS_DOMAIN) ?></span></th> <th class="roles <?php echo $has_actions ? "" : "last" ?>"><i class="user-role"></i><span><?php _e("User Roles", MASTERPRESS_DOMAIN) ?></span></th> <?php if ($has_actions) : ?> <th class="actions last"><i class="buttons"></i><span><?php _e("Actions", MASTERPRESS_DOMAIN) ?></span></th> <?php endif; ?> </tr> </thead> <tbody> <?php $fg_count = 0; ?> <?php foreach ($field_sets as $field_set) : $fg_count++; ?> <?php $display = $field_set->display_label(); ?> <?php $display_td = $display; if ($field_set->icon != "") { $display_td = WOOF_HTML::tag("span", array("class" => "with-icon field-set-".$field_set->id), $display); } ?> <?php $deleting_class = MPC::is_deleting($field_set->id, "delete") ? 'deleting' : ''; $editable_class = $can_edit ? " editable " : ""; $meta = $can_edit ? "{ href: '".MasterPress::admin_url("shared-field-sets", "edit", array("id" => $field_set->id) )."' }" : ""; ?> <?php $disabled = $field_set->disabled ? "disabled" : ""; $title = $field_set->disabled ? ' title="'.__("this field set is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?> <?php if (!$field_set->in_current_site()) { $disabled = "disabled"; $title = ' title="'.__("field set is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" '; } ?> <tr id="field_set_<?php echo $field_set->name ?>" <?php echo $title ?> class="<?php echo $disabled ?> <?php echo $editable_class ?> <?php echo $deleting_class ?> <?php echo MPV::updated_class("edit,create", $field_set->id) ?> <?php echo $meta ?>"> <?php if ($field_set->allow_multiple) : ?> <th class="first type icon"><i class="metabox-add-remove-large" title="<?php _e("Field Set (Multiple Items)", MASTERPRESS_DOMAIN) ?>"></i></th> <?php else : ?> <th class="first type icon"><i class="metabox-large" title="<?php _e("Field Set", MASTERPRESS_DOMAIN) ?>"></i></th> <?php endif; ?> <th class="label"><strong><?php echo $display_td ?></strong></th> <th class="front-end-name"><span class="tt"><?php echo $field_set->display_name() ?></span></th> <th class="post-types"> <?php $post_types = $field_set->post_types(); $vis = $field_set->visibility; $vis_post_types = ""; if (isset($vis["post_types"])) { $vis_post_types = $vis["post_types"]; } if ($vis_post_types == "*") { $post_type_display = __("( All )", MASTERPRESS_DOMAIN); } else { $post_type_display = __("( None )", MASTERPRESS_DOMAIN); if (count($post_types)) { $post_type_links = array(); foreach ($post_types as $post_type) { $post_type_links[] = $post_type->labels["name"]; } $post_type_display = implode($post_type_links, ", "); } } echo $post_type_display; ?> </th> <th class="taxonomies"> <?php $vis = $field_set->visibility; $vis_tax = ""; if (isset($vis["taxonomies"])) { $vis_tax = $vis["taxonomies"]; } if ($vis_tax == "*") { $taxonomy_display = __("( All )", MASTERPRESS_DOMAIN); } else { $taxonomy_display = __("( None )", MASTERPRESS_DOMAIN); if ($vis_tax != "") { $tax_models = MPM_Taxonomy::find_by_name_in(explode(",", $vis_tax)); $td = array(); foreach ($tax_models as $tax) { $td[] = $tax->display_label(); } $taxonomy_display = implode(", ", $td); } } echo $taxonomy_display; ?> </th> <th class="roles <?php echo $has_actions ? "" : "last" ?>"> <?php $vis = $field_set->visibility; $vis_roles = ""; if (isset($vis["roles"])) { $vis_roles = $vis["roles"]; } if ($vis_roles == "*") { $role_display = __("( All )", MASTERPRESS_DOMAIN); } else { if (is_null($vis_roles) || $vis_roles == "") { $role_display = __("( None )", MASTERPRESS_DOMAIN); } else { $role_display = implode(", ", explode(",", $vis_roles)); } } echo $role_display; ?> </th> <?php if ($has_actions) : ?> <th class="actions last"> <?php if (MPC::is_deleting($field_set->id, "delete")) : ?> <span class="confirm-action"> </span> <?php else: ?> <div> <?php if ($can_edit) : ?> <?php echo MPV::action_button("shared-field-sets", "edit", self::__edit(), array("id" => $field_set->id), array("class" => "button button-edit") ); ?> <?php endif; ?> <?php if ($can_delete) : ?> <?php echo MPV::action_button("shared-field-sets", "delete", self::__delete(), array("id" => $field_set->id), array("class" => "button button-delete") ); ?> <?php endif; ?> </div> <?php endif; ?> </th> <?php endif; // has_actions ?> </tr> <?php $count = 0; $fields = $field_set->fields(); ?> <?php foreach ($fields as $field) : $count++; $first = $count == 1 ? 'first' : ''; $disabled = $field_set->disabled || $field->disabled ? "disabled" : ""; $title = $field_set->disabled || $field->disabled ? ' title="'.__("this field is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?> <?php if (!$field_set->in_current_site() || !$field->in_current_site()) { $disabled = "disabled"; $title = ' title="'.__("field is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" '; } ?> <?php $deleting_class = MPC::is_deleting($field_set->id, "delete") || MPC::is_deleting($field->id, "delete-field") ? 'deleting' : ''; $editable_class = $can_edit_fields ? " editable " : ""; $meta = $can_edit ? "{ href: '".MasterPress::admin_url("shared-field-sets", "edit-field", array("id" => $field->id, "parent" => $field_set->id) )."' }" : ""; ?> <?php if ($type_class = MPFT::type_class($field->type)) : ?> <tr <?php echo $title ?> class="sub <?php echo $editable_class.$deleting_class ?> <?php echo $first ?> <?php echo $disabled ?> <?php echo $count % 2 == 0 ? "even" : "" ?> <?php echo MPV::updated_class("edit-field,create-field", $field->id) ?> <?php echo $meta ?>"> <td class="type icon first" title="<?php echo call_user_func( array($type_class, "__s") ) ?>"><span class="mp-icon mp-icon-field-type-<?php echo $field->type ?>"></span></td> <td class="label"><strong><?php echo $field->display_label() ?></strong></td> <td class="front-end-name"><span class="tt"><span class="arrow">-> </span><?php echo $field->display_name() ?></span></td> <td class="post-types"> <?php $vis = $field->visibility; $vis_post_types = ""; if (isset($vis["post_types"])) { $vis_post_types = $vis["post_types"]; } if ($vis_post_types == "*") { $post_type_display = '<span class="inherit">( '.__("same as set", MASTERPRESS_DOMAIN).' )</span>'; } else { $post_types = $field->post_types(); $post_type_display = MPV::note_none(); if (count($post_types)) { $post_type_links = array(); foreach ($post_types as $post_type) { $post_type_links[] = $post_type->labels["name"]; } $post_type_display = implode($post_type_links, ", "); } } echo $post_type_display; ?> </td> <td class="taxonomies"> <?php $vis = $field->visibility; $vis_tax = ""; if (isset($vis["taxonomies"])) { $vis_tax = $vis["taxonomies"]; } if ($vis_tax == "*") { $tax_display = '<span class="inherit">( '.__("same as set", MASTERPRESS_DOMAIN).' )</span>'; } else { $tax_display = MPV::note_none(); if ($vis_tax != "") { $tax_models = MPM_Taxonomy::find_by_name_in(explode(",", $vis_taxonomies)); $td = array(); foreach ($tax_models as $tax) { $td[] = $tax->display_label(); } $tax_display = implode(", ", $td); } } echo $tax_display; ?> </td> <td class="roles <?php echo $has_actions ? "" : "last" ?>"> <?php $vis = $field->visibility; $vis_roles = ""; if (isset($vis["roles"])) { $vis_roles = $vis["roles"]; } if ($vis_roles == "*") { $role_display = '<span class="inherit">( '.__("same as set", MASTERPRESS_DOMAIN).' )</span>'; } else { $role_display = MPV::note_none(); if ($vis_roles != "") { $role_display = implode(", ", explode(",", $vis_roles)); } } echo $role_display; ?> </td> <?php if ($has_actions) : ?> <td class="actions last"> <?php if (MPC::is_deleting($field->id, "delete-field")) : ?> <span class="confirm-action"> </span> <?php else: ?> <div> <?php if ($can_edit_fields) : ?> <?php echo MPV::action_button("shared-field-sets", "edit-field", self::__edit(), array("id" => $field->id, "parent" => $field_set->id), array("class" => "button button-edit") ); ?> <?php endif; ?> <?php if ($can_delete_fields) : ?> <?php echo MPV::action_button("shared-field-sets", "delete-field", self::__delete(), array("id" => $field->id, "parent" => $field_set->id), array("class" => "button button-delete") ); ?> <?php endif; ?> </div> <?php endif; ?> </td> <?php endif; // has_actions ?> </tr> <?php endif; ?> <?php endforeach; ?> <tr class="summary <?php echo $can_create_fields ? "editable" : "" ?>"> <?php if (count($fields)) : ?> <td colspan="<?php echo $colspan ?>" class="first <?php echo $can_create_fields ? "" : "last" ?>"><?php printf( __( "%s contains %s", MASTERPRESS_DOMAIN ), $display, MPU::__items( $field_set->field_count(), __("%d custom field", MASTERPRESS_DOMAIN), __("%d custom fields", MASTERPRESS_DOMAIN) ) ) ?></td> <?php else: ?> <?php if ($can_create_fields) : ?> <td colspan="<?php echo $colspan ?>" class="hl first last"><span><?php printf( __( "<strong>%s</strong> is not yet active as it contains <em>no custom fields</em>. Click here to create one", MASTERPRESS_DOMAIN ), $display ); ?></span></td> <?php endif; ?> <?php endif; ?> <?php if ($can_create_fields) : ?> <td class="last actions <?php echo count($fields) ? "" : "hl" ?>"> <?php echo MPV::action_button("shared-field-sets", "create-field", self::__create(MPV_Fields::__s()), array("parent" => $field_set->id), array("class" => "button create-field") ); ?> </td> <?php endif; ?> </tr> <tr class="gap <?php if ($fg_count == count($field_sets)) { echo "gap-last"; } ?>"> <td colspan="7"> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php if ($can_create) : ?> <div class="grid-foot-controls"> <?php echo MPV::action_button("shared-field-sets", "create", MPV::__create( MPV_SharedFieldSets::__s() ), array() ); ?> </div> <?php endif; ?> <?php else: ?> <?php if ($can_create) : ?> <a href="<?php echo MasterPress::admin_url("shared-field-sets", "create") ?>" class="no-items-create"> <i class="plus-circle"></i> <span><?php _e( "There are currently no Shared Field Sets. Click here to create one." ) ?></span> </a> <?php endif; ?> <?php endif; ?> </div> <?php } // end grid()
public static function inline_styles() { global $wf; $action = ""; if (isset($_REQUEST["action"])) { $action = $_REQUEST["action"]; } $the_type = $wf->the->type(); ?> <style type="text/css"> <?php // insert styles to show the menu icons adjacent to the headers, instead of the default post icon if (self::is_post_editor()) { if ($the_type->supports("mp-page-attributes")) { // make sure the standard meta box is hidden! ?> #pageparentdiv { display: none; } <?php } if (!$the_type->supports("editor") && self::use_new_media()) { // the margin below the title is too large when the post body is hidden ?> #post-body-content { margin-bottom: 9px; } .wrap div.updated, .wrap div.error { margin: 5px 0 8px; } <?php } } foreach (MasterPress::$post_types as $post_type) { $menu_icon = MPU::menu_icon($post_type->menu_icon, false); if ($menu_icon && $menu_icon->exists()) { $margin = ""; if ($post_type->menu_icon != "" && ! ( ($post_type->name == "post" && $post_type->menu_icon == "menu-icon-posts.png") || ($post_type->name == "page" && $post_type->menu_icon == "menu-icon-pages.png") ) ) { $margin = "margin-right: 0px;"; $icon_url = MPU::sprite_menu_icon_url($post_type->menu_icon); $menu_id = "#menu-posts-".$post_type->name; if ($post_type->name == "post") { $menu_id = "#menu-posts"; } else if ($post_type->name == "page") { $menu_id = "#menu-pages"; } // image_get_user_option("admin_color") == "classic" ? MPU::blue_menu_icon_url($post_type->menu_icon, false) : MPU::gray_menu_icon_url($post_type->menu_icon, false), $admin_color = get_user_option("admin_color"); $offset = "6"; if ($admin_color == "classic") { $offset = "-594"; } else if ($admin_color == "bbpress") { $offset = "-894"; } // output our post type icons // child post types meta box echo '#poststuff #detail-post-type-' . $post_type->name . ' h3 em, #your-profile #field-set-post-type-' . $post_type->name . ' h3 em, #createuser #field-set-post-type-' . $post_type->name . ' h3 em, #edittag #field-set-post-type-' . $post_type->name . ' { padding-left: 25px; background-image: url(' . $menu_icon->url() . '); } '; echo '#poststuff #detail-post-type-' . $post_type->name . ' .inside { padding: 0; margin: 0 } '; echo '#adminmenu '.$menu_id.' .wp-menu-image { background: url('.$icon_url.') no-repeat '.$offset.'px 6px !important; } '; echo '.admin-color-mp6 #adminmenu '.$menu_id.' .wp-menu-image { background: url('.$icon_url.') no-repeat '.($offset + 2).'px 8px !important; } '; echo '#adminmenu '.$menu_id.'.wp-has-current-submenu .wp-menu-image, #adminmenu '.$menu_id.':hover .wp-menu-image { background-position: -294px 6px !important; } '; echo '.admin-color-mp6 #adminmenu '.$menu_id.'.wp-has-current-submenu .wp-menu-image, .admin-color-mp6 #adminmenu '.$menu_id.':hover .wp-menu-image { background-position: -292px 8px !important; } '; echo '#adminmenu '.$menu_id.' .wp-menu-image img { display: none; } '; if (self::is_post_manage() || self::is_post_editor()) { echo "#wpbody-content .wrap .icon32-posts-".$post_type->name." { background: url(".$menu_icon->url.") no-repeat center center !important; background-size: 16px 16px !important; ".$margin." } \n"; // MP6 integration echo "body.admin-color-mp6 #wpbody-content .wrap .icon32-posts-".$post_type->name." { display: block; margin-left: -6px; } \n"; if ($menu_icon->width() <= 16) { echo "#wpbody-content .wrap .icon32-posts-".$post_type->name." { background-position: 8px 8px !important; width: 36px; } \n"; } } } // output a general post type icon class, which can be hooked into by field type UIs :) echo ".mp-icon-post-type-".$post_type->name." { background-image: url(".$menu_icon->url().") !important; } \n"; } } MPU::mq2x_start(); foreach (MasterPress::$post_types as $post_type) { $menu_icon = MPU::menu_icon($post_type->menu_icon, false); if ($menu_icon && $menu_icon->exists()) { $margin = ""; if ($post_type->menu_icon != "" && ! ( ($post_type->name == "post" && $post_type->menu_icon == "menu-icon-posts.png") || ($post_type->name == "page" && $post_type->menu_icon == "menu-icon-pages.png") ) ) { $offset = "6"; if ($admin_color == "classic") { $offset = "-294"; } else if ($admin_color == "bbpress") { $offset = "-444"; } // child post types meta box echo '#poststuff #detail-post-type-' . $post_type->name . ' h3 em, #your-profile #field-set-post-type-' . $post_type->name . ' h3 em, #createuser #field-set-post-type-' . $post_type->name . ' h3 em, #edittag #field-set-post-type-' . $post_type->name . ' { padding-left: 25px; background-size: 16px 16px !important; background-image: url(' . $menu_icon->resize("w=32&h=32")->url() . '); } '; echo '#adminmenu '.$menu_id.' .wp-menu-image { background-position: '.$offset.'px -26px !important; background-size: auto 56px !important; } '; echo '#adminmenu '.$menu_id.'.wp-has-current-submenu .wp-menu-image, #adminmenu '.$menu_id.':hover .wp-menu-image { background-position: -144px -26px !important; } '; echo '#adminmenu '.$menu_id.' .wp-menu-image img { display: none; } '; if (self::is_post_manage() || self::is_post_editor()) { echo "#wpbody-content .wrap .icon32-posts-".$post_type->name." { background: url(".$menu_icon->resize("w=32&h=32")->url.") no-repeat center center !important; background-size: 16px 16px !important; ".$margin." } \n"; } } } } echo ".mp-icon-post-type-".$post_type->name." { background-image: url(".$menu_icon->resize("w=32&h=32")->url.") !important; background-size: 16px 16px; } \n"; MPU::mq2x_end(); ?> .edit-tags-php .icon32 { background: url(<?php echo MPU::img_url('icon-tag.png') ?>) 7px 8px no-repeat !important; width: 24px; } <?php foreach (MPFT::type_keys() as $key) : ?> .mp-icon-field-type-<?php echo $key ?> { background-image: url(<?php echo MPU::type_icon_url($key) ?>); } <?php endforeach; ?> <?php MPU::mq2x_start(); ?> <?php foreach (MPFT::type_keys() as $key) : ?> <?php $url = MPU::type_image($key, "icon-color.png", "")->resize("w=32&h=32")->url; ?> .mp-icon-field-type-<?php echo $key ?> { background-image: url(<?php echo $url ?>); background-size: 16px 16px; } <?php endforeach; ?> <?php MPU::mq2x_end(); ?> <?php foreach (MasterPress::$all_taxonomies as $tax) { if ($tax->title_icon) { $title_icon = MPU::menu_icon($tax->title_icon); if ($title_icon && $title_icon->exists()) { if (self::is_term_manage() || self::is_term_editor()) { if (isset($_GET["taxonomy"]) && $_GET["taxonomy"] == $tax->name) { echo ".edit-tags-php .icon32 { background: url(".$title_icon->url().") no-repeat 7px 8px !important; width: 36px; margin-right: 0px; }"; // MP6 integration echo " body.admin-color-mp6.edit-tags-php .icon32 { display: block; margin-left: -4px; } \n"; } } // output a general taxonomy icon class, which can be hooked into by field type UIs :) echo " .mp-icon-taxonomy-".$tax->name." { background-image: url(".$title_icon->url().") !important; }"; } } else { // output a general taxonomy icon class, which can be hooked into by field type UIs :) echo " .mp-icon-taxonomy-".$tax->name." { background-image: url(".MPU::img_url('icon-tag.png').") !important; }"; } } MPU::mq2x_start(); foreach (MasterPress::$all_taxonomies as $tax) { if ($tax->title_icon) { $title_icon = MPU::menu_icon($tax->title_icon); if ($title_icon && $title_icon->exists()) { // output 2x nearest neighbor scaled icons echo "\n.mp-icon-taxonomy-".$tax->name." { background-image: url(".$title_icon->resize("w=32&h=32")->url().") !important; background-size: 16px 16px; }"; if (self::is_term_manage() || self::is_term_editor()) { if (isset($_GET["taxonomy"]) && $_GET["taxonomy"] == $tax->name) { echo "\n.edit-tags-php .icon32 { background: url(".$title_icon->resize("w=32&h=32")->url().") no-repeat 7px 8px !important; background-size: 16px 16px !important; width: 36px; margin-right: 0px; }"; } } } } } MPU::mq2x_end(); ?> </style> <!--[if lte IE 7]><link rel="stylesheet" href="<?php echo MASTERPRESS_URL."css/mpv.ie7.css" ?>" type="text/css" /><![endif]--> <!--[if IE 8]><link rel="stylesheet" href="<?php echo MASTERPRESS_URL."css/mpv.ie8.css" ?>" type="text/css" /><![endif]--> <?php }
public function init() { global $wf; // check if we're in a child theme $template_dir = get_template_directory(); $stylesheet_dir = get_stylesheet_directory(); // check if there are any templates that have the same name, which can cause confusion $names = array(); $dupes = array(); self::get_names($template_dir, $names, $dupes); if ($stylesheet_dir != $template_dir) { self::get_names($stylesheet_dir, $names, $dupes); } if (count($dupes)) { $msg = WOOF_HTML::tag("p", array(), __("<strong>Warning:</strong> your theme appears to contain multiple template files with the same <b>Template Name</b>.<br />This may cause some templates to become invisible to both WordPress and MasterPress.<br />Please verify the following, and make changes to your template files as necessary:", MASTERPRESS_DOMAIN)); $msg .= WOOF_HTML::open("ul"); foreach ($dupes as $template_name => $file_name) { $msg .= WOOF_HTML::tag("li", array(), sprintf( __('<span class="tt">%s</span> is called <b>%s</b>, which is already used by <span class="tt">%s</span>', MASTEPRESS_DOMAIN), $file_name, $template_name, $names[$template_name]) ); } $msg .= WOOF_HTML::close("ul"); MPV::warn($msg); } $action = MasterPress::$action; // inform the view what to render in the info panel MasterPress::$view->is_template_set = true; if ($action == "edit-field" || $action == "create-field") { // inform the view what to render in the info panel MasterPress::$view->parent = MPM_FieldSet::find_by_id(MasterPress::$parent); // enqueue the field type CSS $type = MasterPress::$model->type; MPFT::options_admin_head($type); // enqueue dependent scripts for all field types (could improve this in the future) foreach (MPFT::type_keys() as $type) { if ($ftc = MPFT::type_class($type)) { call_user_func( array($ftc, "enqueue") ); } } } if ($action == "create-field") { MasterPress::$model->field_set_id = MasterPress::$parent; MasterPress::$model->infer_position(); } }
public function grid() { MPC::incl("post-types"); MPV::incl("fields"); MPV::incl("post-types"); $info = MasterPress::$view; $role_name = MasterPress::$parent; ?> <div class="title-info-panel"> <div class="title-info-panel-lt"> <h3><i class="user-role"></i><span class="label"><?php _e("User Role:", MASTERPRESS_DOMAIN) ?></span><span class="value"> <?php echo $role_name ?></span></h3> </div> </div> <?php MPV::messages(); ?> <div class="grid-set"> <?php $field_sets = MPM_RoleFieldSet::find_by_role( $role_name, "name" ); ?> <?php MPV::field_set_icon_styles($field_sets); ?> <?php $has_actions = MasterPress::current_user_can("edit_user_role_field_sets,delete_user_role_field_sets,edit_user_role_fields,delete_user_role_fields"); $can_edit = MasterPress::current_user_can("edit_user_role_field_sets"); $can_delete = MasterPress::current_user_can("delete_user_role_field_sets"); $can_create = MasterPress::current_user_can("create_user_role_field_sets"); $can_edit_fields = MasterPress::current_user_can("edit_user_role_fields"); $can_delete_fields = MasterPress::current_user_can("delete_user_role_fields"); $can_create_fields = MasterPress::current_user_can("create_user_role_fields"); $less = ($can_create_fields) ? 1 : 0; $colspan = ( $has_actions ? 4 : 3 ) - $less; foreach ($field_sets as $field_set) { if (MPC::is_deleting($field_set->id, "delete-field-set")) { $this->confirm_delete($field_set); } else { foreach ($field_set->fields() as $field) { if (MPC::is_deleting($field->id, "delete-field")) { $this->confirm_delete_field($field); } } } } ?> <?php $fg_count = 0; ?> <?php if (count($field_sets)) : ?> <table cellspacing="0" class="grid grid-field-sets"> <thead> <tr> <th class="first type"><i class="types"></i><span><?php _e("Type", MASTERPRESS_DOMAIN) ?></span></th> <th class="label"><i class="label-string"></i><span><?php _e("Label", MASTERPRESS_DOMAIN) ?></span></th> <th class="front-end-name <?php echo $has_actions ? "" : "last" ?>"><i class="script-php"></i><span><?php _e("Front End Name", MASTERPRESS_DOMAIN) ?></span></th> <?php if ($has_actions) : ?> <th class="actions last"><i class="buttons"></i><span><?php _e("Actions", MASTERPRESS_DOMAIN) ?></span></th> <?php endif; ?> </tr> </thead> <tbody> <?php foreach ($field_sets as $field_set) : $fg_count++; ?> <?php $display = $field_set->display_label(); $display_td = $display; if ($field_set->icon != "") { $display_td = WOOF_HTML::tag("span", array("class" => "with-icon field-set-".$field_set->id), $display); } $deleting_class = MPC::is_deleting($field_set->id, "delete-field-set") ? 'deleting' : ''; $editable_class = $can_edit ? " editable " : ""; $meta = $can_edit ? "{ href: '".MasterPress::admin_url("roles", "edit-field-set", array("id" => $field_set->id, "parent" => $role_name) )."' }" : ""; ?> <?php $disabled = $field_set->disabled ? "disabled" : ""; $title = $field_set->disabled ? ' title="'.__("this field set is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?> <?php if (!$field_set->in_current_site()) { $disabled = "disabled"; $title = ' title="'.__("this field set is not currently available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" '; } ?> <tr <?php echo $title ?> class="<?php echo $disabled ?> <?php echo $editable_class.$deleting_class ?> <?php echo MPV::updated_class("edit-field-set,create-field-set", $field_set->id) ?> <?php echo $meta ?>"> <?php if ($field_set->allow_multiple) : ?> <th class="first type icon"><i class="metabox-add-remove-large" title="<?php _e("Field Set (Multiple Items)", MASTERPRESS_DOMAIN) ?>"></i></th> <?php else : ?> <th class="first type icon"><i class="metabox-large" title="<?php _e("Field Set", MASTERPRESS_DOMAIN) ?>"></i></th> <?php endif; ?> <th class="label"><strong><?php echo $display_td ?></strong></th> <th class="front-end-name <?php echo $has_actions ? "" : "last" ?>"><span class="tt"><?php echo $field_set->display_name() ?></span></th> <?php if ($has_actions) : ?> <th class="actions last"> <div> <?php if (MPC::is_deleting($field_set->id, "delete-field-set")) : ?> <span class="confirm-action"> </span> <?php else: ?> <?php if ($can_edit) : ?> <?php echo MPV::action_button("roles", "edit-field-set", self::__edit(), array("id" => $field_set->id, "parent" => $role_name), array("class" => "button button-edit") ); ?> <?php endif; ?> <?php if ($can_delete) : ?> <?php echo MPV::action_button("roles", "delete-field-set", self::__delete(), array("id" => $field_set->id, "parent" => $role_name), array("class" => "button button-delete") ); ?> <?php endif; ?> <?php endif; ?> </div> </th> <?php endif; // has_actions ?> </tr> <?php $count = 0; $fields = $field_set->fields(); ?> <?php foreach ($fields as $field) : $count++; $first = $count == 1 ? 'first' : ''; $disabled = $field_set->disabled || $field->disabled ? "disabled" : ""; $title = $field_set->disabled ? ' title="'.__("this field is disabled", MASTERPRESS_DOMAIN).'" ' : ""; ?> <?php if (!$field_set->in_current_site() || !$field->in_current_site()) { $disabled = "disabled"; $title = ' title="'.__("this field is not currenty available in this site (multi-site setting)", MASTERPRESS_DOMAIN).'" '; } ?> <?php $deleting_class = MPC::is_deleting($field_set->id, "delete-field-set") || MPC::is_deleting($field->id, "delete-field") ? 'deleting' : ''; $editable_class = $can_edit_fields ? " editable " : ""; $meta = $can_edit ? "{ href: '".MasterPress::admin_url("roles", "edit-field", array("id" => $field->id, "gparent" => $_GET["parent"], "parent" => $field_set->id) )."' }" : ""; ?> <?php if ($type_class = MPFT::type_class($field->type)) : ?> <tr <?php echo $title ?> class="sub <?php echo $editable_class.$deleting_class ?> <?php echo $disabled ?> <?php echo $first ?> <?php echo $count % 2 == 0 ? "even" : "" ?> <?php echo MPV::updated_class("edit-field,create-field", $field->id) ?> <?php echo $meta ?>"> <td class="type icon first" title="<?php echo call_user_func( array($type_class, "__s") ) ?>"><span class="mp-icon mp-icon-field-type-<?php echo $field->type ?>"></span></td> <td class="label"><strong><?php echo $field->display_label() ?></strong></td> <td class="front-end-name <?php echo $has_actions ? "" : "last" ?>"><span class="tt"><span class="arrow">-> </span><?php echo $field->display_name() ?></span></td> <?php if ($has_actions) : ?> <td class="actions last"> <?php if (MPC::is_deleting($field->id, "delete-field")) : ?> <span class="confirm-action"> </span> <?php else: ?> <div> <?php if ($can_edit_fields) : ?> <?php echo MPV::action_button("roles", "edit-field", self::__edit(), array("id" => $field->id, "gparent" => $_GET["parent"], "parent" => $field_set->id), array("class" => "button button-edit") ); ?> <?php endif; ?> <?php if ($can_delete_fields) : ?> <?php echo MPV::action_button("roles", "delete-field", self::__delete(), array("id" => $field->id, "gparent" => $_GET["parent"], "parent" => $role_name), array("class" => "button button-delete") ); ?> <?php endif; ?> </div> <?php endif; ?> </td> <?php endif; // has_actions ?> </tr> <?php endif; ?> <?php endforeach; ?> <tr class="summary <?php echo $can_create_fields ? "editable" : "" ?>"> <?php if (count($fields)) : ?> <td colspan="<?php echo $colspan ?>" class="first <?php echo $can_create_fields ? "" : "last" ?>"><?php printf( __( "%s contains %s", MASTERPRESS_DOMAIN ), $display, MPU::__items( $field_set->field_count(), __("%d custom field", MASTERPRESS_DOMAIN), __("%d custom fields", MASTERPRESS_DOMAIN) ) ) ?></td> <?php else: ?> <td colspan="<?php echo $colspan ?>" class="hl first last"><span><?php printf( __( "<strong>%s</strong> is not yet active as it contains <em>no custom fields</em>. Click here to create one", MASTERPRESS_DOMAIN ), $field_set->display_label() ); ?></span></td> <?php endif; ?> <?php if ($can_create_fields) : ?> <td class="last actions <?php echo count($fields) ? "" : "hl" ?>"> <?php echo MPV::action_button("roles", "create-field", self::__create(MPV_Fields::__s()), array("gparent" => $_GET["parent"], "parent" => $field_set->id), array("class" => "button create-field") ); ?> </td> <?php endif; // can_create_fields ?> </tr> <tr class="gap <?php if ($fg_count == count($field_sets)) { echo "gap-last"; } ?>"> <td colspan="4"> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php if ($can_create) : ?> <div class="grid-foot-controls"> <?php echo MPV::action_button("roles", "create-field-set", MPV::__create( MPV_RoleFieldSets::__s() ), array( "parent" => $role_name ) ); ?> </div> <?php endif; ?> <?php else: ?> <?php if ($can_create) : ?> <a href="<?php echo MasterPress::admin_url("roles", "create-field-set", array("parent" => MasterPress::$parent ) ) ?>" class="no-items-create"> <i class="plus-circle"></i> <span><?php printf( __( "The '<em>%s</em>' role currently has <em>no field sets</em>. Click here to create one.", MASTERPRESS_DOMAIN ), $role_name ) ?></span> </a> <?php endif; ?> <?php endif; ?> </div> <?php } // end grid()
public static function options_form( $options ) { $defaults = array(); if (MPC::is_create()) { $defaults = array(); } $options = wp_parse_args( $options, $defaults ); $p = self::type_prefix(__CLASS__); // setup variables to insert into the heredoc string // (this is required where we cannot call functions within heredoc strings) $maxlength_label = __("Maximum Length:", MASTERPRESS_DOMAIN); $maxlength_note = __("(characters)", MASTERPRESS_DOMAIN); $maxlength = self::option_value($options, "maxlength"); $status_checked_attr = WOOF_HTML::checked_attr(self::option_value($options, "status") == "yes"); $status_label = __("show a count of remaining characters", MASTERPRESS_DOMAIN); $default_value_label = __("Default Value:", MASTERPRESS_DOMAIN); $default_value_note = __("Use the preview of your control above to set a default value", MASTERPRESS_DOMAIN); $default_value = self::option_value($options, "default_value"); $maxwidth = MPFT::options_maxwidth( $p, $options ); $font = MPFT::options_font( $p, $options ); $html = <<<HTML <div class="f"> <label for="{$p}maxlength">{$maxlength_label}</label> <div id="fw-{$p}maxlength" class="fw"> <input id="{$p}maxlength" name="type_options[maxlength]" type="text" value="{$maxlength}" class="text" /><span class="note">{$maxlength_note}</span> <div id="{$p}status-wrap"> <input id="{$p}status" type="checkbox" name="type_options[status]" {$status_checked_attr} value="yes" class="checkbox" /> <label for="{$p}status" class="checkbox">{$status_label}</label> </div> </div> </div> <!-- /.f --> {$maxwidth} {$font} <div class="f"> <label for="{$p}default_value">{$default_value_label}</label> <div id="fw-{$p}default-value" class="fw"> <input id="{$p}default-value" name="type_options[default_value]" type="text" value="{$default_value}" class="text" /> <p class="note">{$default_value_note}</p> </div> </div> <!-- /.f --> HTML; return $html; }
static function combine_type_scripts() { $files = array(); $type_keys = MPFT::type_keys(); // files to merge foreach (MPFT::type_keys() as $type) { $base = WOOF::root_relative_url( MPU::type_file_url($type, "") ); $file = MPU::type_file_path($type, "mpft-$type.js"); if (file_exists($file)) { $files[] = array("base" => $base, "file" => $file); } } $image_base = WOOF::root_relative_url( MASTERPRESS_IMAGES_URL ); // we'll be able to kick this off with an AJAX action in the MasterPress overview // the dev guide for field types must point the "REBUILD" process out to developers! // we can also run this on install and upgrade, so that if field types change, the files would be rebuilt // get code from archive folder if it exists, otherwise grab latest files, merge and save in archive folder if (file_exists(MASTERPRESS_CONTENT_MPFT_CACHE_DIR) && is_writable ( MASTERPRESS_CONTENT_MPFT_CACHE_DIR ) ) { // get and merge code $content = ''; foreach ($files as $file) { $content .= file_get_contents($file["file"]); } MPU::incl_lib("jsminplus.php"); $content = JSMinPlus::minify($content); $handle = fopen(MASTERPRESS_CONTENT_MPFT_CACHE_DIR."mpft-all.js", 'w'); if ($handle) { if (flock($handle, LOCK_EX)) { fwrite($handle, $content); flock($handle, LOCK_UN); } fclose($handle); } } }