| 1 |
<?php |
| 2 |
|
| 3 |
class FrmShowForm extends WP_Widget { |
| 4 |
|
| 5 |
function __construct() { |
| 6 |
$widget_ops = array( 'description' => __( "Display a Formidable Form", 'formidable') ); |
| 7 |
$this->WP_Widget('frm_show_form', __('Formidable Form', 'formidable'), $widget_ops); |
| 8 |
} |
| 9 |
|
| 10 |
function widget( $args, $instance ) { |
| 11 |
extract($args); |
| 12 |
|
| 13 |
$frm_form = new FrmForm(); |
| 14 |
$form_name = $frm_form->getName( $instance['form'] ); |
| 15 |
$title = apply_filters('widget_title', empty($instance['title']) ? $form_name : $instance['title']); |
| 16 |
$instance['description'] = isset($instance['description']) ? $instance['description'] : false; |
| 17 |
|
| 18 |
echo $before_widget; |
| 19 |
$select_class = (isset($instance['select_width']) and $instance['select_width']) ? ' frm_set_select' : ''; |
| 20 |
echo '<div class="frm_form_widget'.$select_class.'">'; |
| 21 |
if ( $title ) |
| 22 |
echo $before_title . stripslashes($title) . $after_title; |
| 23 |
|
| 24 |
if(isset($instance['size']) and is_numeric($instance['size'])){ |
| 25 |
global $frm_vars; |
| 26 |
$frm_vars['sidebar_width'] = $instance['size']; |
| 27 |
} |
| 28 |
|
| 29 |
echo FrmFormsController::show_form($instance['form'], '', false, $instance['description']); |
| 30 |
$frm_vars['sidebar_width'] = ''; |
| 31 |
echo '</div>'; |
| 32 |
echo $after_widget; |
| 33 |
} |
| 34 |
|
| 35 |
function update( $new_instance, $old_instance ) { |
| 36 |
return $new_instance; |
| 37 |
} |
| 38 |
|
| 39 |
function form( $instance ) { |
| 40 |
//Defaults |
| 41 |
$instance = wp_parse_args( (array) $instance, array('title' => false, 'form' => false, 'description' => false, 'size' => 20, 'select_width' => false) ); |
| 42 |
?> |
| 43 |
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'formidable') ?>:</label> |
| 44 |
<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr( stripslashes($instance['title']) ); ?>" /></p> |
| 45 |
|
| 46 |
<p><label for="<?php echo $this->get_field_id('form'); ?>"><?php _e('Form', 'formidable') ?>:</label> |
| 47 |
<?php FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], false, $this->get_field_id('form') )?> |
| 48 |
</p> |
| 49 |
|
| 50 |
<p><label for="<?php echo $this->get_field_id('description'); ?>"><input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" value="1" /> |
| 51 |
<?php _e('Show Description', 'formidable') ?></label></p> |
| 52 |
|
| 53 |
<p><label for="<?php echo $this->get_field_id('select_width'); ?>"><input class="checkbox" type="checkbox" <?php checked($instance['select_width'], true) ?> id="<?php echo $this->get_field_id('select_width'); ?>" name="<?php echo $this->get_field_name('select_width'); ?>" value="1" /> |
| 54 |
<?php _e('Fit Select Boxes into SideBar', 'formidable') ?></label></p> |
| 55 |
|
| 56 |
<p><label class="checkbox" for="<?php echo $this->get_field_id('size'); ?>"><?php _e('Field Size', 'formidable') ?>:</label> |
| 57 |
|
| 58 |
<input type="text" size="3" id="<?php echo $this->get_field_id('size'); ?>" name="<?php echo $this->get_field_name('size'); ?>" value="<?php echo esc_attr( $instance['size'] ); ?>" /> <span class="howto" style="display:inline;"><?php _e('characters wide', 'formidable') ?></span></p> |
| 59 |
<p class="description"><?php _e('If your text fields are too big for your sidebar insert a size here.', 'formidable') ?></p> |
| 60 |
<?php |
| 61 |
} |
| 62 |
} |
| 63 |
|