Esempio n. 1
0
 public function __construct()
 {
     parent::__construct();
     $this->_nicename = __('Terms List', 'ninja-forms');
     add_filter('ninja_forms_localize_field_' . $this->_type, array($this, 'add_term_options'));
     add_filter('ninja_forms_localize_field_' . $this->_type . '_preview', array($this, 'add_term_options'));
     $term_settings = array();
     $taxonomies = get_taxonomies(array('public' => true), 'objects');
     foreach ($taxonomies as $name => $taxonomy) {
         if (in_array($name, $this->_excluded_taxonomies)) {
             continue;
         }
         $this->_settings['taxonomy']['options'][] = array('label' => $taxonomy->labels->name, 'value' => $name);
         $terms = get_terms($name, array('hide_empty' => false));
         if (!$terms) {
             $term_settings[] = array('name' => $name . '_no_terms', 'type' => 'html', 'width' => 'full', 'value' => sprintf(__('No available terms for this taxonomy. %sAdd a term%s', 'ninja-forms'), '<a href="' . admin_url("edit-tags.php?taxonomy={$name}") . '">', '</a>'), 'deps' => array('taxonomy' => $name));
         }
         foreach ($terms as $term) {
             if (1 == $term->term_id) {
                 continue;
             }
             $term_settings[] = array('name' => 'taxonomy_term_' . $term->term_id, 'type' => 'toggle', 'label' => $term->name . ' (' . $term->count . ')', 'width' => 'one-third', 'deps' => array('taxonomy' => $name));
         }
     }
     $this->_settings['taxonomy_terms'] = array('name' => 'taxonomy_terms', 'type' => 'fieldset', 'label' => __('Available Terms'), 'width' => 'full', 'group' => 'primary', 'settings' => $term_settings);
     $this->_settings['options']['group'] = '';
 }
Esempio n. 2
0
 public function __construct()
 {
     parent::__construct();
     $this->_nicename = __('Terms List', 'ninja-forms');
     add_action('admin_init', array($this, 'init_settings'));
     add_filter('ninja_forms_display_field', array($this, 'active_taxonomy_field_check'));
     add_filter('ninja_forms_localize_field_' . $this->_type, array($this, 'add_term_options'));
     add_filter('ninja_forms_localize_field_' . $this->_type . '_preview', array($this, 'add_term_options'));
     $this->_settings['options']['group'] = '';
 }
Esempio n. 3
0
 public function __construct()
 {
     parent::__construct();
     $this->_nicename = __('Terms List', 'ninja-forms');
     add_filter('ninja_forms_localize_field_' . $this->_type, array($this, 'add_term_options'));
     add_filter('ninja_forms_localize_field_' . $this->_type . '_preview', array($this, 'add_term_options'));
     $term_settings = array();
     $taxonomies = get_taxonomies('', 'objects');
     foreach ($taxonomies as $name => $taxonomy) {
         $this->_settings['taxonomy']['options'][] = array('label' => $taxonomy->labels->name, 'value' => $name);
         $terms = get_terms($name);
         foreach ($terms as $term) {
             $term_settings[] = array('name' => 'taxonomy_term_' . $term->term_id, 'type' => 'toggle', 'label' => $term->name, 'width' => 'one-third', 'deps' => array('taxonomy' => $name));
         }
     }
     $this->_settings['taxonomy_terms'] = array('name' => 'taxonomy_terms', 'type' => 'fieldset', 'label' => __('Available Terms'), 'width' => 'full', 'group' => 'primary', 'settings' => $term_settings);
     $this->_settings['options']['group'] = '';
 }