public function form($instance) { foreach (self::$widget_settings as $setting) { ${$setting} = isset($instance[$setting]) ? $instance[$setting] : ''; } $buttons = \PodloveSubscribeButton\Model\Button::all(); if (is_multisite()) { $network_buttons = \PodloveSubscribeButton\Model\NetworkButton::all(); } $buttons_as_options = function ($buttons) { foreach ($buttons as $subscribebutton) { echo "<option value='" . $subscribebutton->name . "' " . ($subscribebutton->name == $button ? 'selected=\\"selected\\"' : '') . " >" . $subscribebutton->title . " (" . $subscribebutton->name . ")</option>"; } }; ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title', 'podlove'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $title; ?> " /> <label for="<?php echo $this->get_field_id('color'); ?> "><?php _e('Color', 'podlove'); ?> </label> <input class="podlove_subscribe_button_color" id="<?php echo $this->get_field_id('color'); ?> " name="<?php echo $this->get_field_name('color'); ?> " value="<?php echo $color; ?> " /> <style type="text/css"> .sp-replacer { display: flex; } .sp-preview { flex-grow: 10; } </style> <label for="<?php echo $this->get_field_id('button'); ?> "><?php _e('Button', 'podlove'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('button'); ?> " name="<?php echo $this->get_field_name('button'); ?> "> <?php if (isset($network_buttons) && count($network_buttons) > 0) { ?> <optgroup label="<?php _e('Local', 'podlove'); ?> "> <?php $buttons_as_options($buttons); ?> </optgroup> <optgroup label="<?php _e('Network', 'podlove'); ?> "> <?php $buttons_as_options($network_buttons); ?> </optgroup> <?php } else { $buttons_as_options($buttons); } ?> </select> <?php $customize_options = array('size' => array('name' => 'Size', 'options' => \PodloveSubscribeButton\Model\Button::$size), 'style' => array('name' => 'Style', 'options' => \PodloveSubscribeButton\Model\Button::$style), 'format' => array('name' => 'Format', 'options' => \PodloveSubscribeButton\Model\Button::$format), 'autowidth' => array('name' => 'Autowidth', 'options' => \PodloveSubscribeButton\Model\Button::$width)); foreach ($customize_options as $slug => $properties) { ?> <label for="<?php echo $this->get_field_id($slug); ?> "><?php _e($properties['name'], 'podlove'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id($slug); ?> " name="<?php echo $this->get_field_name($slug); ?> "> <option value="default" <?php echo ${$slug} == 'default' ? 'selected="selected"' : ''; ?> ><?php _e('Default ' . $properties['name'], 'podlove'); ?> </option> <optgroup> <?php foreach ($properties['options'] as $property => $name) { ?> <option value="<?php echo $property; ?> " <?php echo ${$slug} == $property ? 'selected="selected"' : ''; ?> ><?php _e($name, 'podlove'); ?> </option> <?php } ?> </optgroup> </select> <?php } ?> <label for="<?php echo $this->get_field_id('infotext'); ?> "><?php _e('Description', 'podlove'); ?> </label> <textarea class="widefat" rows="10" id="<?php echo $this->get_field_id('infotext'); ?> " name="<?php echo $this->get_field_name('infotext'); ?> "><?php echo $infotext; ?> </textarea> </p> <?php }