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(); }
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(); }
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)); }
<?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]];