/**
     * @param array $settings
     * @param WP_Widget $widget
     */
    public function widget_form($settings, WP_Widget $widget)
    {
        $forms = mc4wp_get_forms();
        ?>
		<p>
			<label for="<?php 
        echo $widget->get_field_id('form_id');
        ?>
"><?php 
        _e('Form:', 'mailchimp-for-wp');
        ?>
</label>
			<select class="widefat" name="<?php 
        echo $widget->get_field_name('form_id');
        ?>
" id="<?php 
        echo $widget->get_field_id('form_id');
        ?>
">
				<option value="0" disabled <?php 
        selected($settings['form_id'], 0);
        ?>
><?php 
        _e('Select the form to show', 'mailchimp-for-wp');
        ?>
</option>
				<?php 
        foreach ($forms as $f) {
            ?>
					<option value="<?php 
            echo esc_attr($f->ID);
            ?>
" <?php 
            selected($settings['form_id'], $f->ID);
            ?>
><?php 
            echo esc_html($f->name);
            ?>
</option>
				<?php 
        }
        ?>
			</select>
		</p>

		<?php 
        if (empty($forms)) {
            ?>
			<p class="help"><?php 
            printf(__('You don\'t have any sign-up forms. <a href="%s">Would you like to create one now?</a>', 'mailchimp-for-wp'), mc4wp_get_add_form_url());
            ?>
</p>
		<?php 
        }
    }
 public function form($instance)
 {
     $this->view->form($instance, parent::get_field_id('title'), parent::get_field_name('title'), parent::get_field_id('form_id'), parent::get_field_name('form_id'));
 }
Пример #3
0
 /**
  * @see WP_Widget::get_field_name()
  */
 function test_wp_widget_get_field_name()
 {
     $widget = new WP_Widget('foo', 'Foo');
     $widget->_set(2);
     $this->assertEquals('widget-foo[2][title]', $widget->get_field_name('title'));
 }
Пример #4
0
 public function form($instance)
 {
     $this->view->form($instance, parent::get_field_id('title'), parent::get_field_name('title'), parent::get_field_id('type'), parent::get_field_name('type'), parent::get_field_id('show_name'), parent::get_field_name('show_name'), parent::get_field_id('open_option'), parent::get_field_name('open_option'), parent::get_field_id('count'), parent::get_field_name('count'), parent::get_field_id('width'), parent::get_field_name('width'), parent::get_field_id('height'), parent::get_field_name('height'), parent::get_field_id('background_transparent'), parent::get_field_name('background_transparent'), parent::get_field_id('background_color'), parent::get_field_name('background_color'), parent::get_field_id('text_color'), parent::get_field_name('text_color'), parent::get_field_id('theme_id'), parent::get_field_name('theme_id'));
 }
Пример #5
0
/**
 * Output textarea field
 *
 * @since SG Window 1.0.0
 *
 * @param WP_Widget $object widget object.
 * @param string $name widget option name.
 * @param array $instance Array of widget options.
 * @param string $title Title
*/
function sgwindow_echo_input_textarea($object, $name, $instance, $title, $rows = 10, $cols = 30)
{
    ?>
	<p>
		<label for="<?php 
    echo esc_attr($object->get_field_id($name));
    ?>
"><?php 
    echo esc_html($title);
    ?>
</label>
		<br>
		<textarea name="<?php 
    echo esc_attr($object->get_field_name($name));
    ?>
" rows="<?php 
    echo $rows;
    ?>
" id="<?php 
    echo esc_attr($object->get_field_id($name));
    ?>
"><?php 
    echo esc_textarea($instance[$name]);
    ?>
</textarea>		
	</p>
	<?php 
}
 public function form($instance)
 {
     $this->view->form($instance, parent::get_field_id('title'), parent::get_field_name('title'), parent::get_field_id('gallery_id'), parent::get_field_name('gallery_id'), parent::get_field_id('width'), parent::get_field_name('width'), parent::get_field_id('height'), parent::get_field_name('height'), parent::get_field_id('effect'), parent::get_field_name('effect'), parent::get_field_id('interval'), parent::get_field_name('interval'), parent::get_field_id('shuffle'), parent::get_field_name('shuffle'), parent::get_field_id('theme_id'), parent::get_field_name('theme_id'));
 }
 function get_field_name($varname)
 {
     // replace all x[y] by x][y
     $varname = str_replace(']', '', $varname);
     $varname = str_replace('[', '][', $varname);
     return parent::get_field_name($varname);
 }
Пример #8
0
 public function form($instance)
 {
     $this->view->form($instance, parent::get_field_id('title'), parent::get_field_name('title'), parent::get_field_id('type'), parent::get_field_name('type'), parent::get_field_id('show'), parent::get_field_name('show'), parent::get_field_id('gallery_id'), parent::get_field_name('gallery_id'), parent::get_field_id('album_id'), parent::get_field_name('album_id'), parent::get_field_id('count'), parent::get_field_name('count'), parent::get_field_id('width'), parent::get_field_name('width'), parent::get_field_id('height'), parent::get_field_name('height'), parent::get_field_id('theme_id'), parent::get_field_name('theme_id'));
 }
    /**
     * Display legacy fields in the widget edit form.
     *
     * @since 4.0.0
     *
     * @param array     $instance The widget instance settings.
     * @param WP_Widget $widget   Widget instance.
     */
    public function display_fields($instance, $widget)
    {
        if (is_simple_image_widget_legacy() || !empty($instance['image'])) {
            ?>
			<div class="simple-image-widget-legacy-fields">
				<?php 
            if (!is_simple_image_widget_legacy()) {
                ?>
					<p>
						<em><?php 
                _e('These fields are here to maintain your data from an earlier version.', 'simple-image-widget');
                ?>
</em>
					</p>
					<p>
						<em><?php 
                _e('Select an image, then clear these values, and they will disappear when you save the widget.', 'simple-image-widget');
                ?>
</em>
					</p>
				<?php 
            }
            ?>

				<p>
					<label for="<?php 
            echo esc_attr($widget->get_field_id('image'));
            ?>
"><?php 
            _e('Image URL:', 'simple-image-widget');
            ?>
</label>
					<input type="text" name="<?php 
            echo esc_attr($widget->get_field_name('image'));
            ?>
" id="<?php 
            echo esc_attr($widget->get_field_id('image'));
            ?>
" value="<?php 
            echo esc_url($instance['image']);
            ?>
" class="widefat">
				</p>
				<p>
					<label for="<?php 
            echo esc_attr($widget->get_field_id('alt'));
            ?>
"><?php 
            _e('Alternate Text:', 'simple-image-widget');
            ?>
</label>
					<input type="text" name="<?php 
            echo esc_attr($widget->get_field_name('alt'));
            ?>
" id="<?php 
            echo esc_attr($widget->get_field_id('alt'));
            ?>
" value="<?php 
            echo esc_attr($instance['alt']);
            ?>
" class="widefat">
				</p>
			</div>
			<?php 
        }
    }
    /**
     * Add a color setting to all widgets
     *
     * @param \WP_Widget $widget
     * @param null       $return
     * @param array      $instance
     */
    public function in_widget_form(&$widget, &$return, $instance)
    {
        $border_color = isset($instance['border-color']) ? $instance['border-color'] : self::COLOR_DEFAULT;
        ?>
			<p>
				<label for="<?php 
        echo $widget->get_field_id('border-color');
        ?>
">
					<?php 
        _e('Border color (Used in the footer)', 'yoastcom');
        ?>
				</label>
				<select id="<?php 
        echo $widget->get_field_id('border-color');
        ?>
" name="<?php 
        echo $widget->get_field_name('border-color');
        ?>
" class="widefat">
					<option value="<?php 
        echo esc_attr(self::COLOR_PURPLE);
        ?>
"<?php 
        selected(self::COLOR_PURPLE, $border_color);
        ?>
>
						<?php 
        _e('Purple', 'yoastcom');
        ?>
					</option>
					<option value="<?php 
        echo esc_attr(self::COLOR_BLUE);
        ?>
"<?php 
        selected(self::COLOR_BLUE, $border_color);
        ?>
>
						<?php 
        _e('Blue', 'yoastcom');
        ?>
					</option>
					<option value="<?php 
        echo esc_attr(self::COLOR_GREEN);
        ?>
"<?php 
        selected(self::COLOR_GREEN, $border_color);
        ?>
>
						<?php 
        _e('Green', 'yoastcom');
        ?>
					</option>
					<option value="<?php 
        echo esc_attr(self::COLOR_PINK);
        ?>
"<?php 
        selected(self::COLOR_PINK, $border_color);
        ?>
>
						<?php 
        _e('Pink', 'yoastcom');
        ?>
					</option>
					<option value="<?php 
        echo esc_attr(self::COLOR_ORANGE);
        ?>
"<?php 
        selected(self::COLOR_ORANGE, $border_color);
        ?>
>
						<?php 
        _e('Orange', 'yoastcom');
        ?>
					</option>
				</select>
			</p>
		<?php 
        $return = null;
    }
Пример #11
0
 /**
  * @see WP_Widget::get_field_name()
  * @dataProvider data_wp_widget_get_field_name
  *
  */
 function test_wp_widget_get_field_name($expected, $value_to_test)
 {
     $widget = new WP_Widget('foo', 'Foo');
     $widget->_set(2);
     $this->assertEquals($expected, $widget->get_field_name($value_to_test));
 }
Пример #12
0
    function form($instance)
    {
        $instance = wp_parse_args((array) $instance, $this->map_param_default_array);
        //print_r($instance);
        if (!empty($this->map_array['params'])) {
            foreach ($this->map_array['params'] as $param) {
                switch ($param['type']) {
                    case 'textarea_html':
                        //print_r($param);
                        ?>
                        <p>
                            <label for="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>

                            <textarea  class="widefat" name="<?php 
                        echo $this->WP_Widget_this->get_field_name($param['param_name']);
                        ?>
" id="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
" cols="30" rows="10"><?php 
                        echo esc_textarea($instance[$param['param_name']]);
                        ?>
</textarea>


                            <div class="td-wpa-info">
                                <?php 
                        echo $param['description'];
                        ?>
                            </div>

                        </p>
                        <?php 
                        break;
                    case 'textfield':
                        // we have to change custom_title to custom-title to have "-title" at the end. That's what
                        // WordPress uses to put the title of the widget on post @see widgets.js
                        // suggested at: http://forum.tagdiv.com/topic/please-add-block-title-to-backend-widget-title/#post-58087
                        if ($param['param_name'] == 'custom_title') {
                            $field_id = $this->WP_Widget_this->get_field_id('custom-title');
                        } else {
                            $field_id = $this->WP_Widget_this->get_field_id($param['param_name']);
                        }
                        ?>
                        <p>
                            <label for="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>
                            <input class="widefat" id="<?php 
                        echo $field_id;
                        ?>
"
                                   name="<?php 
                        echo $this->WP_Widget_this->get_field_name($param['param_name']);
                        ?>
" type="text"
                                   value="<?php 
                        echo $instance[$param['param_name']];
                        ?>
" />

                            <div class="td-wpa-info">
                                <?php 
                        echo $param['description'];
                        ?>
                            </div>

                        </p>
                        <?php 
                        break;
                    case 'dropdown':
                        ?>
                        <p>
                            <label for="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>
                            <select name="<?php 
                        echo $this->WP_Widget_this->get_field_name($param['param_name']);
                        ?>
" id="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
" class="widefat">
                                <?php 
                        foreach ($param['value'] as $param_name => $param_value) {
                            ?>
                                    <option value="<?php 
                            echo $param_value;
                            ?>
"<?php 
                            selected($instance[$param['param_name']], $param_value);
                            ?>
><?php 
                            echo $param_name;
                            ?>
</option>
                                <?php 
                        }
                        ?>
                            </select>

                            <div class="td-wpa-info">
                                <?php 
                        echo $param['description'];
                        ?>
                            </div>
                        </p>
                        <?php 
                        break;
                    case 'colorpicker':
                        $empty_color_fix = '#';
                        if (!empty($instance[$param['param_name']])) {
                            $empty_color_fix = $instance[$param['param_name']];
                        }
                        $widget_color_picker_id = td_global::td_generate_unique_id();
                        ?>
                        <p>
                            <label for="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"><?php 
                        echo $param['heading'];
                        ?>
</label>
                            <input data-td-w-color="<?php 
                        echo $widget_color_picker_id;
                        ?>
" class="widefat td-color-picker-field" id="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"
                                   name="<?php 
                        echo $this->WP_Widget_this->get_field_name($param['param_name']);
                        ?>
" type="text"
                                   value="<?php 
                        echo $empty_color_fix;
                        ?>
" />
                            <div id="<?php 
                        echo $widget_color_picker_id;
                        ?>
" class="td-color-picker-widget" rel="<?php 
                        echo $this->WP_Widget_this->get_field_id($param['param_name']);
                        ?>
"></div>
                        </p>

                        <div class="td-wpa-info">
                            <?php 
                        echo $param['description'];
                        ?>
                        </div>

                        <script>
                            td_widget_attach_color_picker();
                        </script>


                        <?php 
                        break;
                }
            }
        }
    }
 public function form($instance)
 {
     $this->view->form($instance, parent::get_field_id('title'), parent::get_field_name('title'), parent::get_field_id('feed_id'), parent::get_field_name('feed_id'), parent::get_field_id('img_number'), parent::get_field_name('img_number'), parent::get_field_id('show_likes_comments'), parent::get_field_name('show_likes_comments'), parent::get_field_id('number_of_columns'), parent::get_field_name('number_of_columns'));
 }
 /**
  * form function must be expanded by the plugin to display plugin widget info to screen
  *
  * @ignore - WP_Widget::form must be public
  *
  * @since 1.0
  *
  * @param array $instance Required - Data to be displayed on the form
  *
  * @return none
  */
 public function form($instance)
 {
     $widget_fields = get_option($this->options->get_value('widget-fields-option-name'));
     $defaults = new TSP_Easy_Dev_Data($widget_fields);
     if (!empty($instance)) {
         $defaults->set_values($instance);
     } else {
         $defaults->decode_values();
     }
     //endelse
     $fields = $defaults->get_values(true);
     foreach ($fields as $key => $value) {
         // since there are multiple widgets on a page it is important
         // to make sure the id and name are unique to this particular
         // instance of the plugin so add a unique id and name
         // by using the get_field_id and get_field_name from the parent
         // Widget class
         $fields[$key]['id'] = parent::get_field_id($key);
         $fields[$key]['name'] = parent::get_field_name($key);
     }
     //end foreach
     $this->display_form($fields);
 }