protected function textarea(WP_Form_Element $element) { $attributes = $element->get_all_attributes(); $content = ''; if (isset($attributes['value'])) { $content = $attributes['value']; unset($attributes['value']); } $settings = $this->settings; if (empty($settings['textarea_name']) && !empty($attributes['name'])) { $settings['textarea_name'] = $attributes['name']; } if (empty($settings['textarea_rows']) && !empty($attributes['rows'])) { $settings['textarea_rows'] = $attributes['rows']; } $classes = $element->get_classes(); if (empty($settings['editor_class']) && !empty($classes)) { $settings['editor_class'] = implode(' ', $classes); } $id = $element->get_id(); if (empty($id) && !empty($attributes['name'])) { $id = $attributes['name']; } ob_start(); wp_editor($content, $id, $settings); return ob_get_clean(); }
protected function input(WP_Form_Element $element) { $attributes = $element->get_all_attributes(); $attributes = WP_Form_View::prepare_attributes($attributes); $template = '<input %s />'; return sprintf($template, $attributes); }
protected function button(WP_Form_Element $element) { $attributes = $element->get_all_attributes(); $label = $element->get_label(); $attributes = WP_Form_View::prepare_attributes($attributes); $template = '<button %s>%s</button>'; return sprintf($template, $attributes, $label); }
protected function markup(WP_Form_Element $element) { $content = $element->get_content(); $attributes = $element->get_all_attributes(); unset($attributes['value'], $attributes['type']); $attributes = WP_Form_View::prepare_attributes($attributes); $template = '<div %s>%s</div>'; return sprintf($template, $attributes, $content); }
/** * @return array */ public function get_all_attributes() { $attributes = parent::get_all_attributes(); // don't explicitly set an empty value, let the browser use its default if (empty($attributes['value']) && isset($attributes['value'])) { unset($attributes['value']); } return $attributes; }
/** * @return array */ public function get_all_attributes() { $attributes = parent::get_all_attributes(); if (!isset($attributes['rows'])) { $attributes['rows'] = 5; } if (!isset($attributes['cols'])) { $attributes['cols'] = 40; } return $attributes; }
protected function textarea(WP_Form_Element $element) { $attributes = $element->get_all_attributes(); $value = ''; if (isset($attributes['value'])) { $value = esc_textarea($attributes['value']); unset($attributes['value']); } $attributes = WP_Form_View::prepare_attributes($attributes); $template = '<textarea %s>%s</textarea>'; return sprintf($template, $attributes, $value); }