|
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 FrmAppHelper::kses( $args['before_widget'], 'all' ); // WPCS: XSS ok. |
|
14
|
|
|
|
|
15
|
|
|
echo '<div class="frm_form_widget">'; |
|
16
|
|
|
if ( $title ) { |
|
17
|
|
|
echo FrmAppHelper::kses( $args['before_title'] . stripslashes( $title ) . $args['after_title'], 'all' ); // WPCS: XSS ok. |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
$form_atts = array( |
|
21
|
|
|
'id' => isset( $instance['form'] ) ? $instance['form'] : 0, |
|
22
|
|
|
'title' => false, |
|
23
|
|
|
'description' => isset( $instance['description'] ) ? $instance['description'] : false, |
|
24
|
|
|
); |
|
25
|
|
|
|
|
26
|
|
|
echo FrmFormsController::get_form_shortcode( $form_atts ); // WPCS: XSS ok. |
|
27
|
|
|
|
|
28
|
|
|
echo '</div>'; |
|
29
|
|
|
echo FrmAppHelper::kses( $args['after_widget'], 'all' ); // WPCS: XSS ok. |
|
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, |
|
40
|
|
|
'form' => false, |
|
41
|
|
|
'description' => false, |
|
42
|
|
|
) ); |
|
43
|
|
|
?> |
|
44
|
|
|
<p> |
|
45
|
|
|
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"> |
|
46
|
|
|
<?php esc_html_e( 'Title', 'formidable' ); ?>: |
|
47
|
|
|
</label> |
|
48
|
|
|
<br/> |
|
49
|
|
|
<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'] ) ); ?>" /> |
|
50
|
|
|
</p> |
|
51
|
|
|
|
|
52
|
|
|
<p> |
|
53
|
|
|
<label for="<?php echo esc_attr( $this->get_field_id( 'form' ) ); ?>"><?php esc_html_e( 'Form', 'formidable' ); ?>:</label><br/> |
|
54
|
|
|
<?php |
|
55
|
|
|
FrmFormsHelper::forms_dropdown( $this->get_field_name( 'form' ), $instance['form'], array( |
|
56
|
|
|
'blank' => false, |
|
57
|
|
|
'field_id' => $this->get_field_id( 'form' ), |
|
58
|
|
|
'class' => 'widefat', |
|
59
|
|
|
) ); |
|
60
|
|
|
?> |
|
61
|
|
|
</p> |
|
62
|
|
|
|
|
63
|
|
|
<p> |
|
64
|
|
|
<label for="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>"> |
|
65
|
|
|
<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" /> |
|
66
|
|
|
<?php esc_html_e( 'Show Description', 'formidable' ); ?> |
|
67
|
|
|
</label> |
|
68
|
|
|
</p> |
|
69
|
|
|
<?php |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|