'', 'def' => '', 'widget' => 'text', 'type' => 'text', 'desc' => '', 'items' => array(), ); return wp_parse_args($args, $defaults); } function enqueue_resources() { wp_enqueue_script( "phosphor-form-script" ); wp_enqueue_style( "phosphor-form-styles" ); } function render_with_label($args) { $this->enqueue_resources(); $args = $this->parse_args($args); ?> print_field($args); } /** * Takes an array of attributes and outputs a settings field by using the appropriate callback. * * @var array $args Field arguments such as field type, current value etc. **/ public function render($args){ $this->enqueue_resources(); $args = $this->parse_args($args); $this->print_field($args); } public function print_field($args) { call_user_func( array($this, $args['widget'] . '_widget_callback'), $args['field_name'], $args['current'], $args ); if( $args['desc'] ): ?>

$subitem) { $input[$subitem_key] = (bool)$subitem; } break; case 'html': $input = balanceTags($input); break; default: $input = wp_strip_all_tags($input); break; } return $input; } public function make_field_name($base, $indices) { $field_name = $base; foreach ($indices as $index) { $field_name .= '['. $index . ']'; } return $field_name; } public function get_current_val($values, $indices) { $val = $values; foreach ($indices as $index) { if( isset($val[ $index ]) ){ $val = $val[ $index ]; } else { $val = ''; } } return $val; } function nested_widget_callback($field_name, $current, $args) { foreach($args['items'] as $item_id => $item): $item_args = array_merge( array( 'current' => isset( $args['current'][$item_id] ) ? $args['current'][$item_id] : '', 'field_name' => $args['field_name'] . '['. $item_id .']' ), $item ); $this->render($item_args); endforeach; } function text_widget_callback($field_name, $current, $args) { ?>
/>
$checkboxitem ): $item_field_name = $field_name."[$key]"; $item_current = isset($current[$key]) ? $current[$key] : ''; ?> />
'', 'min' => '', 'max' => '' ) ); ?>