Example #1
0
 private function render_options()
 {
     $shortcode = $this->get_shortcode_options($this->options);
     if ($shortcode !== null) {
         echo '<div id="accordion" class="accordion">';
         foreach ($shortcode['sections'] as $section) {
             echo '<h3><a href="#">' . $section['title'] . '</a></h3>';
             echo '<div>';
             foreach ($section['fields'] as $field) {
                 $attr = array();
                 $attr = isset($field['attr']) ? $field['attr'] : null;
                 // prefix name with shortcode so shortcode generator can work
                 $attr['name'] = $this->shortcode . '_' . $field['id'];
                 if (isset($field['desc'])) {
                     $attr['desc'] = $field['desc'];
                 }
                 if (isset($field['id'])) {
                     $attr['id'] = $field['id'];
                 }
                 $value = '';
                 if (isset($field['default'])) {
                     // set value to default
                     $value = $field['default'];
                     // also set data-default for shortcode generator ;)
                     $attr['data-default'] = $field['default'];
                 }
                 $option = OxyOptions::create_option($field, $value, $attr);
                 if ($option !== false) {
                     echo '<div class="option">';
                     echo '<label for="' . $field['id'] . '">' . $field['name'] . '</label>';
                     $option->render();
                     echo '</div>';
                 }
                 if (isset($field['desc'])) {
                     echo '<p>' . $field['desc'] . '</p>';
                 }
             }
             echo '</div>';
         }
         echo '</div>';
     }
 }
Example #2
0
 /**
  * Creates a single option
  *
  * @return void
  * @since 1.0
  **/
 function render_option($field)
 {
     $value = isset($this->_options[$field['id']]) ? $this->_options[$field['id']] : null;
     $attr = array('name' => THEME_SHORT . '-options[' . $field['id'] . ']');
     // create new field
     $form_field = OxyOptions::create_option($field, $value, $attr);
     if ($form_field !== false) {
         $form_field->render();
         if (isset($field['desc'])) {
             echo '<span class="description">' . $field['desc'] . '</span>';
         }
     }
 }