Esempio n. 1
0
 /**
  * Generate the corresponding HTML for a field.
  *
  * @param array $args
  *
  * @return string
  */
 protected function _render($args)
 {
     $args = wp_parse_args($args, array('value' => '', 'desc_pos' => 'after', 'extra' => array('class' => 'regular-text')));
     if (!isset($args['extra']['id']) && !is_array($args['name']) && false === strpos($args['name'], '[')) {
         $args['extra']['id'] = $args['name'];
     }
     return FormField::_input_gen($args);
 }
 /**
  * Generate the corresponding HTML for a field.
  *
  * @param array $args
  *
  * @return string
  */
 protected function _render($args)
 {
     $args = wp_parse_args($args, array('value' => true, 'desc' => null, 'checked' => false, 'extra' => array()));
     $args['extra']['checked'] = $args['checked'];
     if (is_null($args['desc']) && !is_bool($args['value'])) {
         $args['desc'] = str_replace('[]', '', $args['value']);
     }
     return FormField::_input_gen($args);
 }
 /**
  * The actual rendering.
  *
  * @param array $args
  */
 protected function _render($args)
 {
     $args = wp_parse_args($args, array('value' => '', 'desc_pos' => 'after', 'extra' => array('class' => 'regular-text')));
     $values = maybe_unserialize($args['value']);
     $opts = '';
     foreach ($values as $index => $group) {
         $group_id = 'group_' . $index;
         $opts .= '<div id="' . $group_id . '">';
         if (is_array($group)) {
             foreach ($group as $key => $value) {
                 $single_input = FormField::_input_gen(array('name' => $args['name'] . '[' . $index . '][' . $key . ']', 'type' => 'text', 'value' => $value, 'desc' => $key, 'desc_pos' => 'before'));
                 $opts .= '<br>' . str_replace(FormBuilder::TOKEN, $single_input, $args['wrap_each']);
             }
             $opts .= '<button class="btnRemoveRule" data-id="' . $group_id . '">Remove</button></div>';
         }
     }
     $opts .= '<button class="btnAddRule" data-count="' . count($values) . '">Add</button>';
     return FormField::add_desc($opts, $args['desc'], $args['desc_pos']);
 }