/**
 * Registers translation data.
 * 
 * @param type $post_type
 * @param type $data 
 */
function wpcf_custom_taxonimies_register_translation($taxonomy, $data)
{
    if (!function_exists('icl_register_string')) {
        return $data;
    }
    $default = wpcf_custom_taxonomies_default();
    if (isset($data['description'])) {
        wpcf_translate_register_string('Types-TAX', $taxonomy . ' description', $data['description']);
    }
    foreach ($data['labels'] as $label => $string) {
        if ($label == 'name' || $label == 'singular_name') {
            wpcf_translate_register_string('Types-TAX', $taxonomy . ' ' . $label, $string);
            continue;
        }
        if (!isset($default['labels'][$label]) || $string !== $default['labels'][$label]) {
            wpcf_translate_register_string('Types-TAX', $taxonomy . ' ' . $label, $string);
        }
    }
}
Example #2
0
/**
 * Gets taxonomies data.
 * 
 * @param type $cfui_tax
 * @return type 
 */
function wpcf_admin_migrate_get_cfui_tax_data($cfui_tax)
{
    $cfui_tax_migrated = array();
    $supports = array();
    if (!empty($cfui_tax[1])) {
        foreach ($cfui_tax[1] as $temp_key => $support) {
            $supports[$support] = 1;
        }
    }
    $wpcf_taxonomies_defaults = wpcf_custom_taxonomies_default();
    $slug = $id = sanitize_title($cfui_tax['name']);
    // Set labels
    $labels = isset($cfui_tax[0]) ? $cfui_tax[0] : array();
    $labels['name'] = !empty($cfui_tax['label']) ? $cfui_tax['label'] : $slug;
    $labels['singular_name'] = !empty($cfui_tax['singular_label']) ? $cfui_tax['singular_label'] : $slug;
    foreach ($wpcf_taxonomies_defaults['labels'] as $label_id => $label_text) {
        if (empty($labels[$label_id])) {
            $labels[$label_id] = $label_text;
        }
    }
    foreach ($labels as $label_id => $label_text) {
        if (!isset($wpcf_taxonomies_defaults['labels'][$label_id])) {
            unset($labels[$label_id]);
        }
    }
    // Force menu_name label
    if (empty($labels['menu_name'])) {
        $labels['menu_name'] = $labels['name'];
    }
    // Set rewrite
    $rewrite = empty($cfui_tax['rewrite']) ? 0 : array();
    if (is_array($rewrite)) {
        $rewrite = array('enabled' => 1, 'slug' => !empty($cfui_tax['rewrite_slug']) ? $cfui_tax['rewrite_slug'] : '', 'with_front' => 1, 'hierarchical' => (bool) $cfui_tax['hierarchical']);
    }
    $cfui_tax_migrated[$slug] = array('labels' => $labels, 'supports' => $supports, 'slug' => $slug, 'wpcf-tax' => $slug, 'rewrite' => $rewrite, 'slug' => $slug, 'id' => $id, 'public' => 'public', 'query_var_enabled' => (bool) $cfui_tax['query_var'], 'query_var' => '', 'hierarchical' => (bool) $cfui_tax['hierarchical'] ? 'hierarchical' : 'flat');
    unset($cfui_tax[0], $cfui_tax[1], $cfui_tax['rewrite'], $cfui_tax['name'], $cfui_tax['label'], $cfui_tax['singular_label'], $cfui_tax['rewrite_slug'], $cfui_tax['capabilities'], $cfui_tax['hierarchical']);
    $cfui_tax_migrated[$slug] = array_merge($wpcf_taxonomies_defaults, array_merge($cfui_tax, $cfui_tax_migrated[$slug]));
    return $cfui_tax_migrated[$slug];
}
 /**
  * Summary.
  *
  * Description.
  *
  * @since x.x.x
  * @access (for functions: only use if private)
  *
  * @see Function/method/class relied on
  * @link URL
  * @global type $varname Description.
  * @global type $varname Description.
  *
  * @param type $var Description.
  * @param type $var Optional. Description.
  * @return type Description.
  */
 public function form()
 {
     $this->save();
     global $wpcf;
     $id = false;
     $update = false;
     $taxonomies = array();
     if (isset($_GET[$this->get_id])) {
         $id = sanitize_text_field($_GET[$this->get_id]);
     } elseif (isset($_POST[$this->get_id])) {
         $id = sanitize_text_field($_POST[$this->get_id]);
     }
     if ($id) {
         $taxonomies = $this->taxonomies->get();
         if (isset($taxonomies[$id])) {
             $this->ct = $taxonomies[$id];
             $update = true;
         } else {
             wpcf_admin_message(__('Wrong Taxonomy specified.', 'wpcf'), 'error');
             return false;
         }
     } else {
         $this->ct = wpcf_custom_taxonomies_default();
     }
     $current_user_can_edit = WPCF_Roles::user_can_edit('custom-taxonomy', $this->ct);
     /**
      * sanitize _builtin
      */
     if (!isset($this->ct['_builtin'])) {
         $this->ct['_builtin'] = false;
     }
     $form = $this->prepare_screen();
     if ($current_user_can_edit && $update) {
         $form['id'] = array('#type' => 'hidden', '#value' => $id, '#name' => 'ct[wpcf-tax]');
     }
     /**
      * post icon field
      */
     $menu_icon = isset($this->ct['icon']) && !empty($this->ct['icon']) ? $this->ct['icon'] : 'admin-post';
     $form['icon'] = array('#type' => 'hidden', '#name' => 'ct[icon]', '#value' => $menu_icon, '#id' => 'wpcf-types-icon');
     $form['form-open'] = array('#type' => 'markup', '#markup' => sprintf('<div id="post-body-content" class="%s">', $current_user_can_edit ? '' : 'wpcf-types-read-only'), '_builtin' => true);
     $form['table-1-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat js-wpcf-slugize-container"><thead><tr><th colspan="2">' . __('Taxonomy name and description', 'wpcf') . '</th></tr></thead><tbody>');
     $table_row = '<tr><td><LABEL></td><td><ERROR><BEFORE><ELEMENT><AFTER></td></tr>';
     $form['name'] = array('#type' => 'textfield', '#name' => 'ct[labels][name]', '#title' => __('Taxonomy name plural', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in plural!', 'wpcf') . '.', '#value' => isset($this->ct['labels']['name']) ? wp_kses_post($this->ct['labels']['name']) : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true, '#attributes' => array('placeholder' => __('Enter Taxonomy name plural', 'wpcf'), 'class' => 'widefat'));
     $form['name-singular'] = array('#type' => 'textfield', '#name' => 'ct[labels][singular_name]', '#title' => __('Taxonomy name singular', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . '.', '#value' => isset($this->ct['labels']['singular_name']) ? wp_kses_post($this->ct['labels']['singular_name']) : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true, '#attributes' => array('placeholder' => __('Enter Taxonomy name singular', 'wpcf'), 'class' => 'widefat js-wpcf-slugize-source'));
     /*
      *
      * IF isset $_POST['slug'] it means form is not submitted
      */
     $attributes = array();
     if (!empty($_POST['ct']['slug'])) {
         $reserved = wpcf_is_reserved_name(sanitize_text_field($_POST['ct']['slug']), 'taxonomy');
         if (is_wp_error($reserved)) {
             $attributes = array('class' => 'wpcf-form-error', 'onclick' => 'jQuery(this).removeClass(\'wpcf-form-error\');');
         }
     }
     $form['slug'] = array('#type' => 'textfield', '#name' => 'ct[slug]', '#title' => __('Slug', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . __('Machine readable name.', 'wpcf') . '<br />' . __('If not provided - will be created from singular name.', 'wpcf') . '<br />', '#value' => isset($this->ct['slug']) ? $this->ct['slug'] : '', '#pattern' => $table_row, '#inline' => true, '#validate' => array('required' => array('value' => true), 'nospecialchars' => array('value' => true), 'maxlength' => array('value' => 30)), '#attributes' => $attributes + array('maxlength' => '30', 'placeholder' => __('Enter Taxonomy slug', 'wpcf'), 'class' => 'widefat js-wpcf-slugize'));
     $form['description'] = array('#type' => 'textarea', '#name' => 'ct[description]', '#title' => __('Description', 'wpcf'), '#value' => isset($this->ct['description']) ? $this->ct['description'] : '', '#attributes' => array('rows' => 4, 'cols' => 60, 'placeholder' => __('Enter Taxonomy description', 'wpcf'), 'class' => 'hidden js-wpcf-description'), '#pattern' => $table_row, '#inline' => true, '#after' => $this->ct['_builtin'] ? __('This is built-in WordPress Taxonomy.', 'wpcf') : sprintf('<a class="js-wpcf-toggle-description hidden" href="#">%s</a>', __('Add description', 'wpcf')));
     $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
     $form['box-1-close'] = array('#type' => 'markup', '#markup' => '</div>', '_builtin' => true);
     if ($this->ct['_builtin']) {
         $form['name']['#attributes']['disabled'] = 'disabled';
         $form['name-singular']['#attributes']['disabled'] = 'disabled';
         $form['slug']['#attributes']['disabled'] = 'disabled';
         $form['description']['#attributes']['disabled'] = 'disabled';
     }
     /**
      * return form if current_user_can edit
      */
     if ($current_user_can_edit) {
         return $form;
     }
     return wpcf_admin_common_only_show($form);
 }
Example #4
0
/**
 * Translates data.
 *
 * @param type $taxonomy
 * @param type $data
 */
function wpcf_wpml_taxonomy_translate($data, $taxonomy)
{
    if (!function_exists('icl_t')) {
        return $data;
    }
    $default = wpcf_custom_taxonomies_default();
    if (!empty($data['description'])) {
        $data['description'] = wpcf_translate($taxonomy . ' description', $data['description'], 'Types-TAX');
    }
    foreach ($data['labels'] as $label => $string) {
        if ($label == 'name' || $label == 'singular_name') {
            $data['labels'][$label] = wpcf_translate($taxonomy . ' ' . $label, $string, 'Types-TAX');
            continue;
        }
        if (!isset($default['labels'][$label]) || $string !== $default['labels'][$label]) {
            $data['labels'][$label] = wpcf_translate($taxonomy . ' ' . $label, $string, 'Types-TAX');
        } else {
            $data['labels'][$label] = wpcf_translate($label, $string, 'Types-TAX');
        }
    }
    return $data;
}
/**
 * Add/edit form structure
 */
function wpcf_admin_custom_taxonomies_form()
{
    global $wpcf;
    include_once dirname(__FILE__) . '/common-functions.php';
    $ct = array();
    $id = false;
    $update = false;
    if (isset($_GET['wpcf-tax'])) {
        $id = $_GET['wpcf-tax'];
    } else {
        if (isset($_POST['wpcf-tax'])) {
            $id = $_POST['wpcf-tax'];
        }
    }
    if ($id) {
        $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
        if (isset($custom_taxonomies[$id])) {
            $ct = $custom_taxonomies[$id];
            $update = true;
            // Set rewrite if needed
            if (isset($_GET['wpcf-rewrite'])) {
                flush_rewrite_rules();
            }
        } else {
            wpcf_admin_message(__('Wrong custom taxonomy specified', 'wpcf'), 'error');
            return false;
        }
    } else {
        $ct = wpcf_custom_taxonomies_default();
    }
    $form = array();
    /**
     * postbox-controll
     */
    $markup = wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false, false);
    $markup .= wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false, false);
    $form['postbox-controll'] = array('#type' => 'markup', '#markup' => $markup);
    /**
     * form setup
     */
    $form['#form']['callback'] = 'wpcf_admin_custom_taxonomies_form_submit';
    $form['#form']['redirection'] = false;
    if ($update) {
        $form['id'] = array('#type' => 'hidden', '#value' => $id, '#name' => 'ct[wpcf-tax]');
    }
    /**
     * WP control for meta boxes
     */
    include_once ABSPATH . '/wp-admin/includes/meta-boxes.php';
    wp_enqueue_script('post');
    $form['form-open'] = array('#type' => 'markup', '#markup' => '<div id="poststuff">');
    $form['form-metabox-holder-columns-2-open'] = array('#type' => 'markup', '#markup' => '<div id="post-body" class="metabox-holder columns-2">');
    $form['post-body-content-open'] = array('#type' => 'markup', '#markup' => '<div id="post-body-content">');
    $form['table-1-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="2">' . __('Name and description', 'wpcf') . '</th></tr></thead><tbody>');
    $table_row = '<tr><td><LABEL></td><td><ERROR><ELEMENT></td></tr>';
    $form['name'] = array('#type' => 'textfield', '#name' => 'ct[labels][name]', '#title' => __('Custom taxonomy name plural', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in plural!', 'wpcf') . '.', '#value' => isset($ct['labels']['name']) ? $ct['labels']['name'] : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true);
    $form['name-singular'] = array('#type' => 'textfield', '#name' => 'ct[labels][singular_name]', '#title' => __('Custom taxonomy name singular', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . '.', '#value' => isset($ct['labels']['singular_name']) ? $ct['labels']['singular_name'] : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true);
    /*
     * 
     * IF isset $_POST['slug'] it means form is not submitted
     */
    $attributes = array();
    if (!empty($_POST['ct']['slug'])) {
        $reserved = wpcf_is_reserved_name($_POST['ct']['slug'], 'taxonomy');
        if (is_wp_error($reserved)) {
            $attributes = array('class' => 'wpcf-form-error', 'onclick' => 'jQuery(this).removeClass(\'wpcf-form-error\');');
        }
    }
    $form['slug'] = array('#type' => 'textfield', '#name' => 'ct[slug]', '#title' => __('Slug', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . __('Machine readable name.', 'wpcf') . '<br />' . __('If not provided - will be created from singular name.', 'wpcf') . '<br />', '#value' => isset($ct['slug']) ? $ct['slug'] : '', '#pattern' => $table_row, '#inline' => true, '#validate' => array('required' => array('value' => true), 'nospecialchars' => array('value' => true), 'maxlength' => array('value' => 30)), '#attributes' => $attributes + array('maxlength' => '30'));
    $form['description'] = array('#type' => 'textarea', '#name' => 'ct[description]', '#title' => __('Description', 'wpcf'), '#value' => isset($ct['description']) ? $ct['description'] : '', '#attributes' => array('rows' => 4, 'cols' => 60), '#pattern' => $table_row, '#inline' => true);
    $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
    $form['post-body-content-close'] = array('#type' => 'markup', '#markup' => '</div>');
    /**
     * get box order
     */
    $meta_box_order_defaults = array('side' => 'submitdiv,wpcf_visibility,post_types', 'normal' => 'labels,options');
    $screen = get_current_screen();
    if (false == ($meta_box_order = get_user_option('meta-box-order_' . $screen->id))) {
        $meta_box_order = $meta_box_order_defaults;
    } else {
        if (isset($meta_box_order[0]) && !isset($meta_box_order['normal'])) {
            $meta_box_order['normal'] = $meta_box_order[0];
        }
    }
    $meta_boxes = array('submitdiv' => false, 'wpcf_visibility' => $ct, 'post_types' => $ct, 'labels' => $ct, 'options' => $ct);
    /**
     * postbox-container-1
     */
    $form['postbox-container-1-open'] = array('#type' => 'markup', '#markup' => '<div id="postbox-container-1" class="postbox-container"><div class="meta-box-sortables ui-sortable" id="side-sortables">');
    foreach (explode(',', $meta_box_order['side']) as $key) {
        $function = sprintf('wpcf_admin_metabox_%s', $key);
        if (is_callable($function)) {
            $form += $function($meta_boxes[$key], 'side');
            unset($meta_boxes[$key]);
        }
    }
    /* close side container */
    $form['postbox-container-1-close'] = array('#type' => 'markup', '#markup' => '</div></div>');
    /**
     * normal container
     */
    $form['postbox-container-2-open'] = array('#type' => 'markup', '#markup' => '<div id="postbox-container-2" class="postbox-container"><div class="meta-box-sortables ui-sortable" id="normal-sortables">');
    foreach (explode(',', $meta_box_order['normal']) as $key) {
        $function = sprintf('wpcf_admin_metabox_%s', $key);
        if (is_callable($function)) {
            $form += $function($meta_boxes[$key]);
            unset($meta_boxes[$key]);
        }
    }
    /**
     * grab missing meta-boxes
     */
    foreach (array_keys($meta_boxes) as $key) {
        $function = sprintf('wpcf_admin_metabox_%s', $key);
        if (is_callable($function)) {
            $form += $function($meta_boxes[$key]);
        }
    }
    /**
     * filter wpcf_post_type_form
     */
    $form = $form + apply_filters('wpcf_post_type_form', array(), $ct);
    /**
     * container-2 close
     */
    $form['postbox-container-2-close'] = array('#type' => 'markup', '#markup' => '</div></div>');
    $form['form-close'] = array('#type' => 'markup', '#markup' => '</div></div>');
    return $form;
}
/**
 * Add/edit form structure
 */
function wpcf_admin_custom_taxonomies_form()
{
    global $wpcf;
    $ct = array();
    $id = false;
    $update = false;
    if (isset($_GET['wpcf-tax'])) {
        $id = $_GET['wpcf-tax'];
    } else {
        if (isset($_POST['wpcf-tax'])) {
            $id = $_POST['wpcf-tax'];
        }
    }
    if ($id) {
        $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
        if (isset($custom_taxonomies[$id])) {
            $ct = $custom_taxonomies[$id];
            $update = true;
            // Set rewrite if needed
            if (isset($_GET['wpcf-rewrite'])) {
                flush_rewrite_rules();
            }
        } else {
            wpcf_admin_message(__('Wrong custom taxonomy specified', 'wpcf'), 'error');
            return false;
        }
    } else {
        $ct = wpcf_custom_taxonomies_default();
    }
    $form = array();
    $form['#form']['callback'] = 'wpcf_admin_custom_taxonomies_form_submit';
    $form['#form']['redirection'] = false;
    if ($update) {
        $form['id'] = array('#type' => 'hidden', '#value' => $id, '#name' => 'ct[wpcf-tax]');
    }
    $form['table-1-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="2">' . __('Name and description', 'wpcf') . '</th></tr></thead><tbody>');
    $table_row = '<tr><td><LABEL></td><td><ERROR><ELEMENT></td></tr>';
    $form['name'] = array('#type' => 'textfield', '#name' => 'ct[labels][name]', '#title' => __('Custom taxonomy name plural', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in plural!', 'wpcf') . '.', '#value' => isset($ct['labels']['name']) ? $ct['labels']['name'] : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true);
    $form['name-singular'] = array('#type' => 'textfield', '#name' => 'ct[labels][singular_name]', '#title' => __('Custom taxonomy name singular', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . '.', '#value' => isset($ct['labels']['singular_name']) ? $ct['labels']['singular_name'] : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true);
    /*
     * 
     * IF isset $_POST['slug'] it means form is not submitted
     */
    $attributes = array();
    if (!empty($_POST['ct']['slug'])) {
        $reserved = wpcf_is_reserved_name($_POST['ct']['slug'], 'taxonomy');
        if (is_wp_error($reserved)) {
            $attributes = array('class' => 'wpcf-form-error', 'onclick' => 'jQuery(this).removeClass(\'wpcf-form-error\');');
        }
    }
    $form['slug'] = array('#type' => 'textfield', '#name' => 'ct[slug]', '#title' => __('Slug', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . __('Machine readable name.', 'wpcf') . '<br />' . __('If not provided - will be created from singular name.', 'wpcf') . '<br />', '#value' => isset($ct['slug']) ? $ct['slug'] : '', '#pattern' => $table_row, '#inline' => true, '#validate' => array('required' => array('value' => true), 'nospecialchars' => array('value' => true), 'maxlength' => array('value' => 30)), '#attributes' => $attributes + array('maxlength' => '30'));
    $form['description'] = array('#type' => 'textarea', '#name' => 'ct[description]', '#title' => __('Description', 'wpcf'), '#value' => isset($ct['description']) ? $ct['description'] : '', '#attributes' => array('rows' => 4, 'cols' => 60), '#pattern' => $table_row, '#inline' => true);
    $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
    $form['table-2-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-visibility-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __('Visibility', 'wpcf') . '</th></tr></thead><tbody><tr><td>');
    $form['public'] = array('#type' => 'radios', '#name' => 'ct[public]', '#options' => array(__('Make this taxonomy public (will appear in the WordPress Admin menu)', 'wpcf') => 'public', __('Hidden - users cannot directly edit data in this taxonomy', 'wpcf') => 'hidden'), '#default_value' => isset($ct['public']) && strval($ct['public']) == 'hidden' ? 'hidden' : 'public', '#inline' => true);
    $form['table-2-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table>');
    $post_types = get_post_types('', 'objects');
    $options = array();
    foreach ($post_types as $post_type_slug => $post_type) {
        if (in_array($post_type_slug, $wpcf->excluded_post_types) || !$post_type->show_ui) {
            continue;
        }
        $options[$post_type_slug]['#name'] = 'ct[supports][' . $post_type_slug . ']';
        $options[$post_type_slug]['#title'] = $post_type->labels->singular_name;
        $options[$post_type_slug]['#default_value'] = !empty($ct['supports'][$post_type_slug]);
        $options[$post_type_slug]['#inline'] = true;
        $options[$post_type_slug]['#after'] = '&nbsp;&nbsp;';
        if (is_rtl()) {
            $options[$post_type_slug]['#before'] = '<div style="float:right;margin-left:10px;">';
            $options[$post_type_slug]['#after'] .= '</div>';
        }
    }
    $form['table-3-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-taxonomies-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __('Select Post Types', 'wpcf') . '</th></tr></thead><tbody><tr><td>');
    $form['types'] = array('#type' => 'checkboxes', '#options' => $options, '#description' => __('Registered post types that will be used with this taxonomy.', 'wpcf'), '#name' => 'ct[supports]', '#inline' => true);
    $form['table-3-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table>');
    $form['table-4-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-labels-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="3">' . __('Labels', 'wpcf') . '</th></tr></thead><tbody>');
    $labels = array('search_items' => array('title' => __('Search %s', 'wpcf'), 'description' => __("The search items text. Default is __( 'Search Tags' ) or __( 'Search Categories' ).", 'wpcf')), 'popular_items' => array('title' => __('Popular %s', 'wpcf'), 'description' => __("The popular items text. Default is __( 'Popular Tags' ) or null.", 'wpcf')), 'all_items' => array('title' => __('All %s', 'wpcf'), 'description' => __("The all items text. Default is __( 'All Tags' ) or __( 'All Categories' ).", 'wpcf')), 'parent_item' => array('title' => __('Parent %s', 'wpcf'), 'description' => __("The parent item text. This string is not used on non-hierarchical taxonomies such as post tags. Default is null or __( 'Parent Category' ).", 'wpcf')), 'parent_item_colon' => array('title' => __('Parent %s:', 'wpcf'), 'description' => __("The same as parent_item, but with colon : in the end null, __( 'Parent Category:' ).", 'wpcf')), 'edit_item' => array('title' => __('Edit %s', 'wpcf'), 'description' => __("The edit item text. Default is __( 'Edit Tag' ) or __( 'Edit Category' ).", 'wpcf')), 'update_item' => array('title' => __('Update %s', 'wpcf'), 'description' => __("The update item text. Default is __( 'Update Tag' ) or __( 'Update Category' ).", 'wpcf')), 'add_new_item' => array('title' => __('Add New %s', 'wpcf'), 'description' => __("The add new item text. Default is __( 'Add New Tag' ) or __( 'Add New Category' ).", 'wpcf')), 'new_item_name' => array('title' => __('New %s Name', 'wpcf'), 'description' => __("The new item name text. Default is __( 'New Tag Name' ) or __( 'New Category Name' ).", 'wpcf')), 'separate_items_with_commas' => array('title' => __('Separate %s with commas', 'wpcf'), 'description' => __("The separate item with commas text used in the taxonomy meta box. This string isn't used on hierarchical taxonomies. Default is __( 'Separate tags with commas' ), or null.", 'wpcf')), 'add_or_remove_items' => array('title' => __('Add or remove %s', 'wpcf'), 'description' => __("the add or remove items text used in the meta box when JavaScript is disabled. This string isn't used on hierarchical taxonomies. Default is __( 'Add or remove tags' ) or null.", 'wpcf')), 'choose_from_most_used' => array('title' => __('Choose from the most used %s', 'wpcf'), 'description' => __("The choose from most used text used in the taxonomy meta box. This string isn't used on hierarchical taxonomies. Default is __( 'Choose from the most used tags' ) or null.", 'wpcf')), 'menu_name' => array('title' => __('Menu Name', 'wpcf'), 'description' => __("The menu name text. This string is the name to give menu items. Defaults to value of name.", 'wpcf')));
    foreach ($labels as $name => $data) {
        $form['labels-' . $name] = array('#type' => 'textfield', '#name' => 'ct[labels][' . $name . ']', '#title' => ucwords(str_replace('_', ' ', $name)), '#description' => $data['description'], '#value' => isset($ct['labels'][$name]) ? $ct['labels'][$name] : '', '#inline' => true, '#pattern' => '<tr><td><LABEL></td><td><ELEMENT></td><td><DESCRIPTION></td>');
    }
    $form['table-4-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
    $form['table-6-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-supports-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __('Options', 'wpcf') . '</th></tr></thead><tbody><tr><td>');
    $form['make-hierarchical'] = array('#type' => 'radios', '#name' => 'ct[hierarchical]', '#default_value' => empty($ct['hierarchical']) || $ct['hierarchical'] == 'flat' ? 'flat' : 'hierarchical', '#inline' => true, '#options' => array(__('Hierarchical - like post categories, with parent / children relationship and checkboxes to select taxonomy', 'wpcf') => 'hierarchical', __('Flat - like post tags, with a text input to enter terms', 'wpcf') => 'flat'), '#after' => '<br /><br />');
    $form['rewrite-enabled'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Rewrite', 'wpcf'), '#name' => 'ct[rewrite][enabled]', '#description' => __('Rewrite permalinks with this format. Default will use $taxonomy as query var.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['enabled']), '#inline' => true);
    $hidden = empty($ct['rewrite']['enabled']) ? ' class="hidden"' : '';
    $form['rewrite-slug'] = array('#type' => 'textfield', '#name' => 'ct[rewrite][slug]', '#title' => __('Prepend posts with this slug', 'wpcf'), '#description' => __('Optional', 'wpcf') . '. ' . __("Prepend posts with this slug - defaults to taxonomy's name.", 'wpcf'), '#value' => isset($ct['rewrite']['slug']) ? $ct['rewrite']['slug'] : '', '#inline' => true, '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>', '#after' => '</div>', '#validate' => array('rewriteslug' => array('value' => 'true')));
    $form['rewrite-with_front'] = array('#type' => 'checkbox', '#force_boolean' => true, '#title' => __('Allow permalinks to be prepended with front base', 'wpcf'), '#name' => 'ct[rewrite][with_front]', '#description' => __('Defaults to true.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['with_front']), '#inline' => true);
    $form['rewrite-hierarchical'] = array('#type' => 'checkbox', '#name' => 'ct[rewrite][hierarchical]', '#title' => __('Hierarchical URLs', 'wpcf'), '#description' => sprintf(__('True or false allow hierarchical urls (implemented in %sVersion 3.1%s).', 'wpcf'), '<a href="http://codex.wordpress.org/Version_3.1" title="Version 3.1" target="_blank">', '</a>'), '#default_value' => !empty($ct['rewrite']['hierarchical']), '#inline' => true);
    $form['vars'] = array('#type' => 'checkboxes', '#name' => 'ct[advanced]', '#inline' => true, '#options' => array('show_ui' => array('#name' => 'ct[show_ui]', '#default_value' => !empty($ct['show_ui']), '#title' => __('show_ui', 'wpcf'), '#description' => __('Whether to generate a default UI for managing this taxonomy.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of public argument.', 'wpcf'), '#inline' => true), 'show_in_nav_menus' => array('#name' => 'ct[show_in_nav_menus]', '#default_value' => !empty($ct['show_in_nav_menus']), '#title' => __('show_in_nav_menus', 'wpcf'), '#description' => __('True makes this taxonomy available for selection in navigation menus.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of public argument.', 'wpcf'), '#inline' => true), 'show_tagcloud' => array('#name' => 'ct[show_tagcloud]', '#default_value' => !empty($ct['show_tagcloud']), '#title' => __('show_tagcloud', 'wpcf'), '#description' => __('Whether to allow the Tag Cloud widget to use this taxonomy.', 'wpcf') . '<br />' . __('Default: if not set, defaults to value of show_ui argument.', 'wpcf'), '#inline' => true)));
    if (wpcf_compare_wp_version('3.5', '>=')) {
        $form['vars']['#options']['show_admin_column'] = array('#name' => 'ct[show_admin_column]', '#default_value' => !empty($ct['show_admin_column']), '#title' => __('show_admin_column', 'wpcf'), '#description' => __('Whether to allow automatic creation of taxonomy columns on associated post-types.', 'wpcf') . '<br />' . __('Default: false.', 'wpcf'), '#inline' => true);
    }
    $query_var = isset($ct['query_var']) ? $ct['query_var'] : '';
    $hidden = !empty($ct['query_var_enabled']) ? '' : ' class="hidden"';
    $form['query_var'] = array('#type' => 'checkbox', '#name' => 'ct[query_var_enabled]', '#title' => 'query_var', '#description' => __('False to prevent queries, or string to customize query var. Default will use $taxonomy as query var.', 'wpcf') . '<br />' . __('Default: $taxonomy.', 'wpcf'), '#default_value' => !empty($ct['query_var_enabled']), '#after' => '<div id="wpcf-types-form-queryvar-toggle"' . $hidden . '><input type="text" name="ct[query_var]" value="' . $query_var . '" class="wpcf-form-textfield form-textfield textfield" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __('Optional', 'wpcf') . '. ' . __('String to customize query var', 'wpcf') . '</div></div>', '#inline' => true);
    $form['update_count_callback'] = array('#type' => 'textfield', '#name' => 'ct[update_count_callback]', '#title' => 'update_count_callback', 'wpcf', '#description' => __('Function name that will be called to update the count of an associated $object_type, such as post, is updated.', 'wpcf') . '<br />' . __('Default: None.', 'wpcf'), '#value' => !empty($ct['update_count_callback']) ? $ct['update_count_callback'] : '', '#inline' => true);
    $form['table-6-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table>');
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Save Taxonomy', 'wpcf'), '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'));
    return $form;
}