示例#1
0
 /**
  * Render an individual option.
  *
  * Should be of the form:
  * <code>
  * array(
  *	 'atts'			=> $atts,
  *	 'value'		=> $value,
  *	 'label'		=> $label,
  *	 'disabled'		=> $boolean,
  *	 'checked'		=> $boolean,
  * )
  * </code>
  *
  * @return string
  * @since 1.0
  */
 public function render_option(array $option, Element $e)
 {
     // The default option arguments.
     $option = array_merge(array('disabled' => false, 'checked' => false, 'value' => NULL, 'atts' => NULL, 'label' => ''), $option);
     /** CheckBox Input ****************************************************/
     // Set the 'checked' attribute.
     if (empty($option['selected']) && !empty($option['value'])) {
         if (in_array($option['value'], (array) $e->get_value())) {
             $option['selected'] = true;
         }
     }
     // Get the Attributes object.
     $option['atts'] = \Nmwdhj\create_atts_obj($option['atts'])->set_atts(array('selected' => (bool) $option['selected'], 'disabled' => (bool) $option['disabled'], 'value' => $option['value']))->set_atts($e->get_atts(), false);
     // Fix the 'name' attribute.
     if ($option['atts']->has_attr('name')) {
         $name = $option['atts']->get_attr('name');
         if (substr($name, -2) !== '[]') {
             $option['atts']->set_attr('name', $name . '[]');
         }
     }
     // The checkbox input output.
     $content = '<input' . strval($option['atts']) . ' />';
     /** CheckBox Label ****************************************************/
     if (!empty($option['label'])) {
         $label_atts = \Nmwdhj\create_atts_obj($e->get_option('label_atts'));
         if (!$label_atts->has_attr('for') && $option['atts']->has_attr('id')) {
             $label_atts->set_attr('for', $option['atts']->get_attr('id'));
         }
         $content = $this->render_label(array('position' => $e->get_option('label_position'), 'label' => $option['label'], 'atts' => $label_atts), $content);
     }
     return $content;
 }
示例#2
0
 /**
  * Render the Element View
  *
  * @return string
  * @since 1.3
  */
 public function render_element(Element $e)
 {
     $content = '<fieldset' . $e->get_atts('string') . '>';
     foreach ($e->get_elements() as $element) {
         $content .= $element->get_output();
     }
     $content .= '</fieldset>';
     return $content;
 }
示例#3
0
 /**
  * Render the Element View.
  *
  * @return string
  * @since 1.3
  */
 public function render_element(Element $e)
 {
     ob_start();
     // Merge the editor settings with the defaults.
     $settings = array_merge(array('textarea_name' => $e->get_name()), (array) $e->get_option('settings'));
     wp_editor($e->get_value(), $e->get_ID(), $settings);
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
示例#4
0
 /**
  * Render the Element View.
  *
  * @return string
  * @since 1.3
  */
 public function render_element(Element $e)
 {
     $atts = clone $e->get_atts_obj();
     if ($atts->has_attr(array('multiple', 'name'))) {
         $name = $atts->get_attr('name');
         if (substr($name, -2) !== '[]') {
             $atts->set_attr('name', $name . '[]');
         }
     }
     $content = '<select' . strval($atts) . '>';
     $content .= $this->render_options($e->get_value_options(), $e->get_value());
     $content .= '</select>';
     return $content;
 }
示例#5
0
 /**
  * Configure the element
  *
  * @return Fieldset
  * @since 1.3
  */
 public function configure($args)
 {
     if (is_array($args) && isset($args['elements'])) {
         if (is_array($args['elements'])) {
             foreach ($args['elements'] as $key => $element) {
                 $this->add($element, array('key' => $key));
             }
         }
     }
     parent::configure($args);
 }
示例#6
0
 /**
  * Render the Element View.
  *
  * @return string
  * @since 1.3
  */
 public function render_element(Element $e)
 {
     if ($e->is_checked()) {
         $e->set_attr('checked', 'checked');
     }
     if (!$e->has_attr('value')) {
         $e->set_attr('value', $e->get_checked_value());
     }
     return parent::render_element($e);
 }
示例#7
0
 /**
  * Render the Element View.
  *
  * @return string
  * @since 1.3
  */
 public function render_element(Element $e)
 {
     return $this->render_tag('textarea', $e->get_atts_obj(), esc_textarea($e->get_value()));
 }
示例#8
0
 /**
  * Render the Element View.
  *
  * @return string
  * @since 1.3
  */
 public function render_element(Element $e)
 {
     return $this->render_tag('button', $e->get_atts_obj(), $e->get_content());
 }
示例#9
0
 /**
  * Render the Element View.
  *
  * @return string
  * @since 1.3
  */
 public function render_element(Element $e)
 {
     return '<input' . $e->get_atts('string') . ' />';
 }