Completed
Push — develop ( ec61b1...89c7bd )
by Zack
20:07
created
includes/widgets/poll/class-gravityview-widget-poll.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	function __construct() {
23 23
 
24 24
 		$this->widget_id = 'poll';
25
-		$this->widget_description = __('Displays the results of Poll Fields that exist in the form.', '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', 'gravityview' ), '<em>', '</em>' );
25
+		$this->widget_description = __( 'Displays the results of Poll Fields that exist in the form.', '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', 'gravityview' ), '<em>', '</em>' );
27 27
 
28 28
 		$default_values = array(
29 29
 			'header' => 1,
@@ -32,27 +32,27 @@  discard block
 block discarded – undo
32 32
 
33 33
 		$settings = array(
34 34
 			'percentages' => array(
35
-				'label' => __('Display Percentages', 'gravityview'),
35
+				'label' => __( 'Display Percentages', 'gravityview' ),
36 36
 				'type' => 'checkbox',
37 37
 				'value' => true,
38 38
 				'tooltip' => __( 'Display results percentages as part of results? Supported values are: true, false. Defaults to "true".', 'gravityview' ),
39 39
 			),
40 40
 			'counts' => array(
41
-				'label' => __('Display Counts', 'gravityview'),
41
+				'label' => __( 'Display Counts', 'gravityview' ),
42 42
 				'type' => 'checkbox',
43 43
 				'value' => true,
44 44
 				'tooltip' => __( 'Display number of times each choice has been selected when displaying results? Supported values are: true, false. Defaults to "true".', 'gravityview' ),
45 45
 			),
46 46
 			'style' => array(
47 47
 				'type' => 'select',
48
-				'label' => __('Style', 'gravityview'),
48
+				'label' => __( 'Style', 'gravityview' ),
49 49
 				'tooltip' => __( 'The Polls Add-On currently supports 4 built in styles: red, green, orange, blue. Defaults to "green".', 'gravityview' ),
50 50
 				'value' => 'green',
51 51
 				'choices' => array(
52
-					'green' => __('Green', 'gravityview'),
53
-					'blue' => __('Blue', 'gravityview'),
54
-					'red' => __('Red', 'gravityview'),
55
-					'orange' => __('Orange', 'gravityview'),
52
+					'green' => __( 'Green', 'gravityview' ),
53
+					'blue' => __( 'Blue', 'gravityview' ),
54
+					'red' => __( 'Red', 'gravityview' ),
55
+					'orange' => __( 'Orange', 'gravityview' ),
56 56
 				),
57 57
 			),
58 58
 		);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 			add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
63 63
 		}
64 64
 
65
-		parent::__construct( __( 'Poll Results', 'gravityview' ) , null, $default_values, $settings );
65
+		parent::__construct( __( 'Poll Results', 'gravityview' ), null, $default_values, $settings );
66 66
 	}
67 67
 
68 68
 	/**
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 
90 90
 		$GFPolls = GFPolls::get_instance();
91 91
 
92
-		wp_enqueue_script('gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array('jquery'), $GFPolls->_version);
92
+		wp_enqueue_script( 'gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array( 'jquery' ), $GFPolls->_version );
93 93
 
94 94
 		$GFPolls->localize_scripts();
95 95
 
96
-		wp_enqueue_style('gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version);
96
+		wp_enqueue_style( 'gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version );
97 97
 	}
98 98
 
99 99
 	/**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	public function pre_render_frontend() {
105 105
 
106
-		if( ! class_exists('GFPolls') ) {
106
+		if ( ! class_exists( 'GFPolls' ) ) {
107 107
 
108 108
 			gravityview()->log->error( 'Poll Widget not displayed; the Poll Addon is not loaded' );
109 109
 
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$view = gravityview()->views->get();
114 114
 
115
-		$poll_fields = array( $view->form->form['id'] => GFCommon::get_fields_by_type( $view->form, array( 'poll' ) ) );
115
+		$poll_fields = array( $view->form->form[ 'id' ] => GFCommon::get_fields_by_type( $view->form, array( 'poll' ) ) );
116 116
 
117 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' ) );
118
+			$poll_fields[ $join->join_on->form[ 'id' ] ] = GFCommon::get_fields_by_type( $join->join_on->form, array( 'poll' ) );
119 119
 		}
120 120
 
121 121
 		$poll_fields = array_filter( $poll_fields );
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public function render_frontend( $widget_args, $content = '', $context = '' ) {
169 169
 
170
-		if( ! $this->pre_render_frontend() ) {
170
+		if ( ! $this->pre_render_frontend() ) {
171 171
 			return;
172 172
 		}
173 173
 
174 174
 		// Make sure the class is loaded in DataTables
175
-		if( !class_exists( 'GFFormDisplay' ) ) {
175
+		if ( ! class_exists( 'GFFormDisplay' ) ) {
176 176
 			include_once( GFCommon::get_base_path() . '/form_display.php' );
177 177
 		}
178 178
 
@@ -180,14 +180,14 @@  discard block
 block discarded – undo
180 180
 
181 181
 		$settings = $this->get_frontend_settings( $widget_args );
182 182
 
183
-		$percentages = empty( $settings['percentages'] ) ? 'false' : 'true';
183
+		$percentages = empty( $settings[ 'percentages' ] ) ? 'false' : 'true';
184 184
 
185
-		$counts = empty( $settings['counts'] ) ? 'false' : 'true';
185
+		$counts = empty( $settings[ 'counts' ] ) ? 'false' : 'true';
186 186
 
187
-		if( !empty( $settings['field'] ) ) {
188
-			$merge_tag = sprintf( '{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings['field'], $settings['style'], $percentages, $counts );
187
+		if ( ! empty( $settings[ 'field' ] ) ) {
188
+			$merge_tag = sprintf( '{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings[ 'field' ], $settings[ 'style' ], $percentages, $counts );
189 189
 		} else {
190
-			$merge_tag = sprintf( '{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings['style'], $percentages, $counts );
190
+			$merge_tag = sprintf( '{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings[ 'style' ], $percentages, $counts );
191 191
 		}
192 192
 
193 193
 		$gravityview_view = GravityView_View::getInstance();
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		$gravityview_view->poll_settings = $settings;
198 198
 		$gravityview_view->poll_fields = $this->poll_fields;
199 199
 
200
-		$gravityview_view->render('widget', 'poll', false );
200
+		$gravityview_view->render( 'widget', 'poll', false );
201 201
 
202 202
 		unset( $gravityview_view->poll_merge_tag, $gravityview_view->poll_settings, $gravityview_view->poll_form, $gravityview_view->poll_fields );
203 203
 	}
Please login to merge, or discard this patch.