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();
 }
示例#2
0
 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);
 }
示例#3
0
 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);
 }
 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);
 }
 /**
  * @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;
 }
示例#8
0
 protected function radio($key, $label, $attributes)
 {
     $radio = WP_Form_Element::create('radio')->set_name($attributes['name'])->set_label($label)->set_value($key)->set_attribute('id', $attributes['name'] . '-' . $key);
     if (isset($attributes['type'])) {
         unset($attributes['type']);
     }
     if (isset($attributes['name'])) {
         unset($attributes['name']);
     }
     if (isset($attributes['value'])) {
         unset($attributes['value']);
     }
     foreach ($attributes as $att => $value) {
         $radio->set_attribute($att, $value);
     }
     do_action('wp_form_radio_group_member', $radio);
     return $radio->render();
 }
 protected function checkbox($key, $label, $attributes)
 {
     $checkbox = WP_Form_Element::create('checkbox')->set_name($attributes['name'] . '[]')->set_label($label)->set_value($key)->set_attribute('id', $attributes['name'] . '-' . $key);
     if (isset($attributes['type'])) {
         unset($attributes['type']);
     }
     if (isset($attributes['name'])) {
         unset($attributes['name']);
     }
     if (isset($attributes['value'])) {
         unset($attributes['value']);
     }
     foreach ($attributes as $att => $value) {
         $checkbox->set_attribute($att, $value);
     }
     do_action('wp_form_checkbox_group_member', $checkbox);
     return $checkbox->render();
 }
 /**
  * Get an array of all child components, sorted by priority.
  *
  * @return WP_Form_Component[]
  */
 public function get_children()
 {
     $elements = WP_Form_Element::sort_elements($this->elements);
     return $elements;
 }
示例#11
0
 public function setup_nonce_fields()
 {
     $nonce = wp_create_nonce($this->id);
     $this->add_element(WP_Form_Element::create('hidden')->set_name('wp_form_id')->set_value($this->id)->set_priority(-10));
     $this->add_element(WP_Form_Element::create('hidden')->set_name('wp_form_nonce')->set_value($nonce)->set_priority(-10));
 }
示例#12
0
<?php

/**
 * Used by PhpStorm to map factory methods to classes for code completion, source code analysis, etc.
 *
 * The code is not ever actually executed and it only needed during development when coding with PhpStorm.
 *
 * @see http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata
 * @see http://blog.jetbrains.com/webide/2013/04/phpstorm-6-0-1-eap-build-129-177/
 */
namespace PHPSTORM_META;

/** @noinspection PhpUnusedLocalVariableInspection */
// just to have a green code below
/** @noinspection PhpIllegalArrayKeyTypeInspection */
$STATIC_METHOD_TYPES = [\WP_Form_Element::create('') => ['button' instanceof \WP_Form_Element_Button, 'checkbox' instanceof \WP_Form_Element_Checkbox, 'checkboxes' instanceof \WP_Form_Element_Checkboxes, 'fieldset' instanceof \WP_Form_Element_Fieldset, 'file' instanceof \WP_Form_Element_File, 'hidden' instanceof \WP_Form_Element_Hidden, 'password' instanceof \WP_Form_Element_Password, 'radio' instanceof \WP_Form_Element_Radio, 'radios' instanceof \WP_Form_Element_Radios, 'reset' instanceof \WP_Form_Element_Reset, 'select' instanceof \WP_Form_Element_Select, 'submit' instanceof \WP_Form_Element_Submit, 'text' instanceof \WP_Form_Element_Text, 'textarea' instanceof \WP_Form_Element_Textarea]];