24 $this->widget_id =
'poll';
25 $this->widget_description = __(
'Displays the results of Poll Fields that exist in the form.',
'gk-gravityview' );
26 $this->widget_subtitle = sprintf( _x(
'Note: this will display poll results for %sall form entries%s, not only the entries displayed in the View.',
'The string placeholders are for emphasis HTML',
'gk-gravityview' ),
'<em>',
'</em>' );
28 $default_values = array(
34 'percentages' => array(
35 'label' => __(
'Display Percentages',
'gk-gravityview'),
38 'tooltip' => __(
'Display results percentages as part of results? Supported values are: true, false. Defaults to "true".',
'gk-gravityview' ),
41 'label' => __(
'Display Counts',
'gk-gravityview'),
44 'tooltip' => __(
'Display number of times each choice has been selected when displaying results? Supported values are: true, false. Defaults to "true".',
'gk-gravityview' ),
48 'label' => __(
'Style',
'gk-gravityview'),
49 'tooltip' => __(
'The Polls Add-On currently supports 4 built in styles: red, green, orange, blue. Defaults to "green".',
'gk-gravityview' ),
52 'green' => __(
'Green',
'gk-gravityview'),
53 'blue' => __(
'Blue',
'gk-gravityview'),
54 'red' => __(
'Red',
'gk-gravityview'),
55 'orange' => __(
'Orange',
'gk-gravityview'),
62 add_filter(
'gravityview_template_paths', array( $this,
'add_template_path' ) );
65 parent::__construct( __(
'Poll Results',
'gk-gravityview' ) , null, $default_values,
$settings );
78 $file_paths[ $index ] = plugin_dir_path( __FILE__ ) .
'templates/';
90 $GFPolls = GFPolls::get_instance();
92 wp_enqueue_script(
'gpoll_js', $GFPolls->get_base_url() .
'/js/gpoll.js', array(
'jquery'), $GFPolls->_version);
94 $GFPolls->localize_scripts();
96 wp_enqueue_style(
'gpoll_css', $GFPolls->get_base_url() .
'/css/gpoll.css', null, $GFPolls->_version);
106 if( ! class_exists(
'GFPolls') ) {
108 gravityview()->log->error(
'Poll Widget not displayed; the Poll Addon is not loaded' );
115 $poll_fields = array( $view->form->form[
'id'] => GFCommon::get_fields_by_type( $view->form, array(
'poll' ) ) );
117 foreach ( $view->joins as $join ) {
118 $poll_fields[ $join->join_on->form[
'id'] ] = GFCommon::get_fields_by_type( $join->join_on->form, array(
'poll' ) );
121 $poll_fields = array_filter( $poll_fields );
123 if ( empty ( $poll_fields ) ) {
124 gravityview()->log->error(
'Poll Widget not displayed; there are no poll fields for the form' );
128 $this->poll_fields = $poll_fields;
130 return parent::pre_render_frontend();
142 $default_settings = array(
145 'percentages' =>
true,
149 $settings = wp_parse_args( $widget_settings, $default_settings );
175 if( !class_exists(
'GFFormDisplay' ) ) {
176 include_once( GFCommon::get_base_path() .
'/form_display.php' );
183 $percentages = empty(
$settings[
'percentages'] ) ?
'false' :
'true';
185 $counts = empty(
$settings[
'counts'] ) ?
'false' :
'true';
188 $merge_tag = sprintf(
'{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}',
$settings[
'field'],
$settings[
'style'], $percentages, $counts );
190 $merge_tag = sprintf(
'{all_poll_results: style="%s" percentages="%s" counts="%s"}',
$settings[
'style'], $percentages, $counts );
static getInstance( $passed_post=NULL)
$gravityview_view
array $entry array $form array $field_settings
if(empty( $field_settings['content'])) $content
gravityview()
The main GravityView wrapper function.