/**
  * Get an instance of this class.
  *
  * @return GFPolls
  */
 public static function get_instance()
 {
     if (self::$_instance == null) {
         self::$_instance = new GFPolls();
     }
     return self::$_instance;
 }
 function widget($args, $instance)
 {
     $gf_polls = GFPolls::get_instance();
     wp_enqueue_script('gpoll_js', plugins_url('js/gpoll.js', __FILE__), array('jquery'), $gf_polls->_version);
     $gf_polls->localize_scripts();
     wp_enqueue_style('gpoll_css', plugins_url('css/gpoll.css', __FILE__), null, $gf_polls->_version);
     extract($args);
     echo $before_widget;
     $title = apply_filters('widget_title', $instance['title']);
     $form_id = $instance['form_id'];
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     $mode = rgar($instance, "mode");
     $override_form_settings = rgar($instance, 'override_form_settings');
     if ("" === $override_form_settings) {
         $override_form_settings = true;
     }
     if ($override_form_settings) {
         $style = rgar($instance, "style");
         $display_results = rgar($instance, "display_results");
         $display_results_string = $display_results == "1" ? "true" : "false";
         $show_results_link = rgar($instance, "show_results_link");
         $show_results_link_string = $show_results_link == "1" ? "true" : "false";
         $show_percentages = rgar($instance, "show_percentages");
         $show_percentages_string = $show_percentages == "1" ? "true" : "false";
         $show_counts = rgar($instance, "show_counts");
         $show_counts_string = $show_counts == "1" ? "true" : "false";
         $block_repeat_voters = rgar($instance, "block_repeat_voters");
         $cookie = $block_repeat_voters == "1" ? rgar($instance, "cookie") : "";
         $displayconfirmation = rgar($instance, "displayconfirmation");
         $displayconfirmation = $displayconfirmation == "1" ? "true" : "false";
     } else {
         $form = GFFormsModel::get_form_meta($form_id);
         $style = $gf_polls->get_form_setting($form, "style");
         $display_results = $gf_polls->get_form_setting($form, "displayResults");
         $display_results_string = $display_results ? "true" : "false";
         $show_results_link = $gf_polls->get_form_setting($form, "showResultsLink");
         $show_results_link_string = $show_results_link ? "true" : "false";
         $show_percentages = $gf_polls->get_form_setting($form, "showPercentages");
         $show_percentages_string = $show_percentages ? "true" : "false";
         $show_counts = $gf_polls->get_form_setting($form, "showCounts");
         $show_counts_string = $show_counts ? "true" : "false";
         $block_repeat_voters = $gf_polls->get_form_setting($form, "blockRepeatVoters");
         $cookie = $block_repeat_voters ? $gf_polls->get_form_setting($form, "cookie") : "";
         $displayconfirmation = "true";
     }
     $tabindex = rgar($instance, "tabindex");
     $showtitle = rgar($instance, "showtitle");
     $showtitle = $showtitle == "1" ? "true" : "false";
     $showdescription = rgar($instance, "showdescription");
     $showdescription = $showdescription == "1" ? "true" : "false";
     $ajax = rgar($instance, "ajax");
     $ajax = $ajax == "1" ? "true" : "false";
     $disable_scripts = rgar($instance, "disable_scripts");
     $disable_scripts = $disable_scripts == "1" ? "true" : "false";
     $shortcode = "[gravityforms action=\"polls\" field=\"0\" id=\"{$form_id}\" style=\"{$style}\" mode=\"{$mode}\" display_results=\"{$display_results_string}\" show_results_link=\"{$show_results_link_string}\" cookie=\"{$cookie}\" ajax=\"{$ajax}\" disable_scripts=\"{$disable_scripts}\" tabindex=\"{$tabindex}\" title=\"{$showtitle}\" description=\"{$showdescription}\" confirmation=\"{$displayconfirmation}\" percentages=\"{$show_percentages_string}\" counts=\"{$show_counts_string}\"]";
     echo do_shortcode($shortcode);
     echo $after_widget;
 }
 /**
  * Load the scripts and styles needed for the display of the poll widget
  *
  * @since 1.8
  */
 private function enqueue_scripts_and_styles()
 {
     $GFPolls = GFPolls::get_instance();
     wp_enqueue_script('gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array('jquery'), $GFPolls->_version);
     $GFPolls->localize_scripts();
     wp_enqueue_style('gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version);
 }
function gf_polls()
{
    return GFPolls::get_instance();
}