Beispiel #1
0
 /**
  * @param $item WPCF_Field_Group_Term
  *
  * @return string
  */
 function column_taxonomies($item)
 {
     $taxonomies = $item->get_associated_taxonomies();
     if (empty($taxonomies)) {
         $output = __('Any', 'wpcf');
     } else {
         $taxonomy_labels = array();
         foreach ($taxonomies as $taxonomy_slug) {
             $taxonomy_labels[] = WPCF_Utils::taxonomy_slug_to_label($taxonomy_slug);
         }
         $output = implode(', ', $taxonomy_labels);
     }
     return $output;
 }
Beispiel #2
0
 /**
  * Update the "form" data for the filter dialog.
  *
  * @param string $filter Filter name. Only 'taxonomies-for-meta' is supported here.
  * @param array $form Form data that will be modified.
  */
 protected function form_add_filter_dialog($filter, &$form)
 {
     switch ($filter) {
         case 'taxonomies-for-termmeta':
             include_once WPCF_INC_ABSPATH . '/fields.php';
             // Oh dear god, why?
             $taxonomy_slugs = $this->get_relevant_taxonomy_slugs();
             ksort($taxonomy_slugs);
             $field_group = $this->get_field_group();
             // Can be null when creating new field group
             $currently_supported_taxonomy_slugs = null == $field_group ? array() : $field_group->get_associated_taxonomies();
             // Setup the form
             $form += $this->add_description(__('Select ' . 'specific Taxonomies that you want to use with this Field Group:', 'wpcf'));
             $form['ul-begin'] = array('#type' => 'markup', '#markup' => '<ul>');
             // Add a checkbox for each taxonomy
             foreach ($taxonomy_slugs as $taxonomy_slug) {
                 $label = WPCF_Utils::taxonomy_slug_to_label($taxonomy_slug);
                 $form[$taxonomy_slug] = array('#name' => esc_attr($taxonomy_slug), '#type' => 'checkbox', '#value' => 1, '#default_value' => $this->ajax_filter_default_value($taxonomy_slug, $currently_supported_taxonomy_slugs, 'taxonomies-for-termmeta'), '#inline' => true, '#before' => '<li>', '#after' => '</li>', '#title' => $label, '#attributes' => array('data-wpcf-value' => esc_attr($taxonomy_slug), 'data-wpcf-prefix' => 'taxonomy-'));
             }
             $form['ul-end'] = array('#type' => 'markup', '#markup' => '</ul><br class="clear" />');
             break;
     }
 }