示例#1
0
 /**
  * Displays the widget form
  */
 function form($instance)
 {
     if (!$this->shortcode) {
         return '';
     }
     // Set up some default widget settings.
     $defaults = array();
     foreach ($this->shortcode->get_attributes() as $attribute) {
         $defaults[$attribute->get_id()] = $attribute->get_default();
     }
     $defaults['widget_title'] = $this->shortcode->get_label();
     $instance = wp_parse_args((array) $instance, $defaults);
     echo '<ul class="g1-form-controls">';
     $form_control = G1_Form_Control_Factory::create($this->get_field_id('widget_title'), array('label' => __('Widget title', 'g1_theme'), 'name' => $this->get_field_name('widget_title'), 'value' => $instance['widget_title']));
     $form_control->render();
     foreach ($this->shortcode->get_attributes() as $attribute_id => $attribute) {
         // Skip id and class attributes
         if (in_array($attribute_id, array('id', 'class'))) {
             continue;
         }
         $attribute = clone $attribute;
         $form_control = G1_Form_Control_Factory::create_form_control_from_attribute($attribute);
         $form_control->set_id($this->get_field_id($attribute->get_id()));
         $form_control->set_name($this->get_field_name($attribute->get_id()));
         $form_control->set_value($instance[$attribute->get_id()]);
         $form_control->render();
     }
     if ($this->shortcode->has_content()) {
         $attribute = $this->shortcode->get_content();
         $value = !empty($instance[$attribute->get_id()]) ? $instance[$attribute->get_id()] : '';
         $form_control = G1_Form_Control_Factory::create_form_control_from_attribute($attribute);
         $form_control->set_id($this->get_field_id($attribute->get_id()));
         $form_control->set_name($this->get_field_name($attribute->get_id()));
         $form_control->set_value($value);
         $form_control->render();
     }
     echo '</ul>';
 }
示例#2
0
 protected function captureLayout()
 {
     $id = $this->get_prefix() . '[layout]';
     $args = array('label' => __('Layout', 'g1_theme'), 'hint' => __('Position of the description', 'g1_theme'), 'name' => $this->get_prefix() . '[layout]', 'choices' => array('bubble-top-left' => 'top-left', 'bubble-top-center' => 'top-center', 'bubble-top-right' => 'top-right', 'bubble-bottom-left' => 'bottom-left', 'bubble-bottom-center' => 'bottom-center', 'bubble-bottom-right' => 'bottom-right'));
     $obj = G1_Form_Control_Factory::create($id, $args, G1_Form_Control_Factory::TYPE_CHOICE);
     $obj->set_value($this->slide->get_layout());
     return $obj->capture();
 }
示例#3
0
 /**
  * Captures the HTML code of the content
  *
  * @return          string
  */
 public function capture_content()
 {
     $content = $this->get_shortcode()->get_content();
     $out = '';
     if ($content) {
         $control = G1_Form_Control_Factory::create_form_control_from_attribute($content);
         $out .= '<div class="g1-shortcode-content">' . $control->capture() . '</div>';
     }
     return $out;
 }