Completed
Push — master ( 253e75...b9a936 )
by Stephanie
05:12
created

FrmShowForm::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
class FrmShowForm extends WP_Widget {
4
5
	public function __construct() {
6
		$widget_ops = array( 'description' => __( 'Display a Formidable Form', 'formidable' ) );
7
		parent::__construct('frm_show_form', __( 'Formidable Form', 'formidable' ), $widget_ops);
8
	}
9
10
	public function widget( $args, $instance ) {
11
        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
12
13
		echo $args['before_widget'];
0 ignored issues
show
introduced by
Expected next thing to be a escaping function, not '$args'
Loading history...
14
15
		echo '<div class="frm_form_widget">';
16
		if ( $title ) {
17
			echo $args['before_title'] . stripslashes($title) . $args['after_title'];
0 ignored issues
show
introduced by
Expected next thing to be a escaping function, not '$args'
Loading history...
introduced by
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'stripslashes'
Loading history...
18
		}
19
20
		$form_atts = array(
21
			'id' => $instance['form'],
22
			'title' => false,
23
			'description' => isset( $instance['description'] ) ? $instance['description'] : false,
24
		);
25
26
		echo FrmFormsController::get_form_shortcode( $form_atts );
0 ignored issues
show
introduced by
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'FrmFormsController'
Loading history...
27
28
		echo '</div>';
29
		echo $args['after_widget'];
0 ignored issues
show
introduced by
Expected next thing to be a escaping function, not '$args'
Loading history...
30
	}
31
32
	public function update( $new_instance, $old_instance ) {
33
		return $new_instance;
34
	}
35
36
	public function form( $instance ) {
37
	    //Defaults
38
		$instance = wp_parse_args( (array) $instance, array(
39
		    'title' => false, 'form' => false, 'description' => false,
40
		) );
41
?>
42
	<p><label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php _e( 'Title', 'formidable' ) ?>:</label><br/>
43
	<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id('title') ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" value="<?php echo esc_attr( stripslashes($instance['title']) ); ?>" /></p>
44
45
	<p><label for="<?php echo esc_attr( $this->get_field_id('form') ); ?>"><?php _e( 'Form', 'formidable' ) ?>:</label><br/>
46
<?php
47
	    FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], array(
48
	        'blank' => false, 'field_id' => $this->get_field_id('form'),
49
            'class' => 'widefat',
50
	    ) );
51
?>
52
	</p>
53
54
	<p><label for="<?php echo esc_attr( $this->get_field_id('description') ); ?>"><input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo esc_attr( $this->get_field_id('description') ); ?>" name="<?php echo esc_attr( $this->get_field_name('description') ); ?>" value="1" />
55
	<?php _e( 'Show Description', 'formidable' ) ?></label></p>
56
<?php
57
	}
58
}
59