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);
 }
Example #3
0
function gf_polls()
{
    return GFPolls::get_instance();
}
Example #4
0
                }
                if ($field_values != '') {
                    $field_values .= '&';
                }
                $field_values .= "gpoll_enabled=1&gpoll_field={$field_id}&gpoll_style={$style}&gpoll_display_results={$display_results}&gpoll_show_results_link={$show_results_link}&gpoll_cookie={$cookie}&gpoll_confirmation={$confirmation}&gpoll_percentages={$percentages}&gpoll_counts={$counts}&gpoll_checksum={$checksum}";
                parse_str($field_values, $field_value_array);
                $field_value_array = stripslashes_deep($field_value_array);
                $output = RGForms::get_form($form_id, $title, $description, false, $field_value_array, $ajax, $tabindex);
            }
            if (false === $return) {
                echo $output;
            } else {
                return $output;
            }
        }
        private function generate_checksum($display_results, $show_results_link, $cookie, $confirmation, $percentages, $counts, $style)
        {
            $checksum_vars = array($display_results, $show_results_link, $cookie, $confirmation, $percentages, $counts, $style);
            return wp_hash(crc32(base64_encode(serialize($checksum_vars))));
        }
        public function poll_total_shortcode($atts, $content = null)
        {
            extract(shortcode_atts(array('id' => '1'), $atts));
            $totals = RGFormsModel::get_form_counts($id);
            $total = $totals['total'];
            return $total;
        }
    }
    //end class GFPolls
    GFPolls::get_instance();
}