Passed
Push — master ( 029a1e...f62b8c )
by Warwick
04:47
created
classes/frontend/class-gallery.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public static function get_instance() {
81 81
 		// If the single instance hasn't been set, set it now.
82
-		if ( null === self::$instance ) {
82
+		if (null === self::$instance) {
83 83
 			self::$instance = new self();
84 84
 		}
85 85
 		return self::$instance;
@@ -92,24 +92,24 @@  discard block
 block discarded – undo
92 92
 	 * @param  string $post_type
93 93
 	 * @return boolean
94 94
 	 */
95
-	public function has_gallery( $item_id = '', $post_type = '' ) {
95
+	public function has_gallery($item_id = '', $post_type = '') {
96 96
 		$this->gallery     = array();
97 97
 		$this->has_gallery = false;
98
-		if ( '' === $item_id ) {
98
+		if ('' === $item_id) {
99 99
 			$this->item_id = get_the_ID();
100 100
 		} else {
101 101
 			$this->item_id = $item_id;
102 102
 		}
103 103
 
104
-		if ( '' === $post_type ) {
105
-			$this->post_type = get_post_type( $this->item_id );
104
+		if ('' === $post_type) {
105
+			$this->post_type = get_post_type($this->item_id);
106 106
 		}
107
-		$gallery = get_post_meta( $this->item_id, $this->post_type . '_gallery', true );
108
-		if ( ! empty( $gallery ) ) {
107
+		$gallery = get_post_meta($this->item_id, $this->post_type . '_gallery', true);
108
+		if ( ! empty($gallery)) {
109 109
 			$this->gallery     = $gallery;
110 110
 			$this->has_gallery = true;
111
-			wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/src/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true );
112
-			wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-slider.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true );
111
+			wp_enqueue_script('slick', LSX_HEALTH_PLAN_URL . 'assets/js/src/slick.min.js', array('jquery'), LSX_HEALTH_PLAN_VER, true);
112
+			wp_enqueue_script('lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-slider.js', array('slick'), LSX_HEALTH_PLAN_VER, true);
113 113
 		}
114 114
 		return $this->has_gallery;
115 115
 	}
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 	 * @param  string $post_type
122 122
 	 * @return array
123 123
 	 */
124
-	public function get_defaults( $item_id = '', $post_type = '' ) {
125
-		if ( '' === $item_id ) {
124
+	public function get_defaults($item_id = '', $post_type = '') {
125
+		if ('' === $item_id) {
126 126
 			$item_id = $this->item_id;
127 127
 		}
128
-		if ( '' === $post_type ) {
128
+		if ('' === $post_type) {
129 129
 			$post_type = $this->post_type;
130 130
 		}
131 131
 		$this->defaults = array(
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 			'interval'  => false,
135 135
 			'css_class' => false,
136 136
 		);
137
-		foreach ( $this->defaults as $key => $default ) {
138
-			$override = get_post_meta( $item_id, $this->post_type . '_gallery_' . $key, true );
139
-			if ( '' !== $override && false !== $override && ! empty( $override ) ) {
140
-				$this->defaults[ $key ] = $override;
137
+		foreach ($this->defaults as $key => $default) {
138
+			$override = get_post_meta($item_id, $this->post_type . '_gallery_' . $key, true);
139
+			if ('' !== $override && false !== $override && ! empty($override)) {
140
+				$this->defaults[$key] = $override;
141 141
 			}
142 142
 		}
143 143
 		return $this->defaults;
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
 	 * @param string $post_type
151 151
 	 * @return void
152 152
 	 */
153
-	public function get_gallery( $item_id = '', $post_type = '', $args = array() ) {
153
+	public function get_gallery($item_id = '', $post_type = '', $args = array()) {
154 154
 		$return     = '';
155 155
 		$this->html = array();
156
-		$this->args = wp_parse_args( $args, $this->get_defaults( $item_id, $post_type ) );
157
-		if ( ! empty( $this->gallery ) ) {
156
+		$this->args = wp_parse_args($args, $this->get_defaults($item_id, $post_type));
157
+		if ( ! empty($this->gallery)) {
158 158
 			$this->args['count'] = 1;
159
-			if ( '' !== $post_type ) {
159
+			if ('' !== $post_type) {
160 160
 				$this->args['post_type'] = $post_type;
161 161
 			} else {
162 162
 				$this->args['post_type'] = $this->post_type;
@@ -165,20 +165,20 @@  discard block
 block discarded – undo
165 165
 			// output the opening boostrap row divs.
166 166
 			$this->before_loop();
167 167
 
168
-			foreach ( $this->gallery as $key => $gallery ) {
168
+			foreach ($this->gallery as $key => $gallery) {
169 169
 
170 170
 				$this->loop_start();
171 171
 
172
-				if ( isset( $gallery['exercise_gallery_image_id'] ) && ! empty( $gallery['exercise_gallery_image_id'] ) ) {
173
-					$this->html[] = '<img alt="' . get_the_title( $gallery['exercise_gallery_image_id'] ) . '" src="' . $gallery['exercise_gallery_image'] . '" />';
174
-				} elseif ( isset( $gallery['exercise_gallery_external'] ) && ! empty( $gallery['exercise_gallery_external'] ) ) {
172
+				if (isset($gallery['exercise_gallery_image_id']) && ! empty($gallery['exercise_gallery_image_id'])) {
173
+					$this->html[] = '<img alt="' . get_the_title($gallery['exercise_gallery_image_id']) . '" src="' . $gallery['exercise_gallery_image'] . '" />';
174
+				} elseif (isset($gallery['exercise_gallery_external']) && ! empty($gallery['exercise_gallery_external'])) {
175 175
 					$this->html[] = $gallery['exercise_gallery_external']; // WPCS: XSS OK.
176
-				} elseif ( isset( $gallery['exercise_gallery_embed'] ) && ! empty( $gallery['exercise_gallery_embed'] ) ) {
176
+				} elseif (isset($gallery['exercise_gallery_embed']) && ! empty($gallery['exercise_gallery_embed'])) {
177 177
 					$embed_args = array(
178 178
 						'width' => '530',
179 179
 					);
180
-					$embed        = wp_oembed_get( $gallery['exercise_gallery_embed'], $embed_args );
181
-					$this->html[] = str_replace( 'width="530"', 'width="100%"', $embed ); // WPCS: XSS OK.
180
+					$embed        = wp_oembed_get($gallery['exercise_gallery_embed'], $embed_args);
181
+					$this->html[] = str_replace('width="530"', 'width="100%"', $embed); // WPCS: XSS OK.
182 182
 				}
183 183
 
184 184
 				$this->loop_end();
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 		}
192 192
 
193 193
 		// Join the html output if its not empty.
194
-		if ( ! empty( $this->html ) ) {
195
-			$return = implode( '', $this->html );
194
+		if ( ! empty($this->html)) {
195
+			$return = implode('', $this->html);
196 196
 		}
197 197
 		return $return;
198 198
 	}
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	 * Runs just after the if and before the while statement in $this->output()
214 214
 	 */
215 215
 	public function before_loop() {
216
-		if ( 'slider' === $this->args['layout'] ) {
217
-			$this->carousel_id = wp_rand( 20, 20000 );
216
+		if ('slider' === $this->args['layout']) {
217
+			$this->carousel_id = wp_rand(20, 20000);
218 218
 			$this->html[]      = "<div class='lsx-hp-widget-items slick-slider slick-dotted slick-has-arrows {$this->args['css_class']} ' data-interval='{$this->args['interval']}' data-slick='{ \"slidesToShow\": {$this->args['columns']}, \"slidesToScroll\": {$this->args['columns']} }'>";
219 219
 		} else {
220 220
 			$this->html[] = "<div class='lsx-hp-widget-items widget-item-grid-layout'>";
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 	 */
227 227
 	public function loop_start() {
228 228
 		// Get the call for the active slide.
229
-		if ( 'slider' === $this->args['layout'] ) {
229
+		if ('slider' === $this->args['layout']) {
230 230
 			$this->html[] = "<div class='lsx-hp-widget-item-wrap lsx-{$this->args['post_type']}'>";
231 231
 		} else {
232
-			if ( 1 === $this->args['count'] ) {
232
+			if (1 === $this->args['count']) {
233 233
 				$this->html[] = "<div class='row'>";
234 234
 			}
235 235
 			$this->html[] = '<div class="' . $this->column_class() . '">';
@@ -240,16 +240,16 @@  discard block
 block discarded – undo
240 240
 	 * Runs at the very end of the loop before it runs again.
241 241
 	 */
242 242
 	public function loop_end() {
243
-		if ( 'slider' !== $this->args['layout'] ) {
243
+		if ('slider' !== $this->args['layout']) {
244 244
 			$this->html[] = '</div>';
245 245
 		}
246 246
 		// Close the current slide panel.
247
-		if ( 'slider' === $this->args['layout'] ) {
247
+		if ('slider' === $this->args['layout']) {
248 248
 			$this->html[] = '</div>';
249
-		} elseif ( 0 === $this->args['count'] % $this->args['columns'] || count( $this->gallery ) === $this->args['count'] ) {
249
+		} elseif (0 === $this->args['count'] % $this->args['columns'] || count($this->gallery) === $this->args['count']) {
250 250
 			$this->html[] = '</div>';
251 251
 
252
-			if ( $this->args['count'] < count( $this->gallery ) ) {
252
+			if ($this->args['count'] < count($this->gallery)) {
253 253
 				$this->html[] = "<div class='row'>";
254 254
 			}
255 255
 		}
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	public function after_loop() {
262 262
 		// Slider output Closing.
263
-		if ( 'slider' === $this->args['layout'] ) {
263
+		if ('slider' === $this->args['layout']) {
264 264
 			$this->html[] = '</div>';
265 265
 		} else {
266 266
 			$this->html[] = '</div>';
Please login to merge, or discard this patch.