Completed
Push — master ( e75b66...257029 )
by Andrew
06:07 queued 03:34
created
app/classes/classy.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public static function get_instance() {
34 34
 
35
-		if ( null === self::$single_instance ) {
35
+		if (null === self::$single_instance) {
36 36
 
37 37
 			self::$single_instance = new self();
38 38
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
 		$this->init_config();
60 60
 
61
-		add_filter( 'theme_page_templates', array( $this, 'filter_templates' ) );
61
+		add_filter('theme_page_templates', array($this, 'filter_templates'));
62 62
 	}
63 63
 
64 64
 	/**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * Load template functions.
73 73
 	 */
74 74
 	private function load_template_function() {
75
-		require_once( CLASSY_THEME_PATH . 'app/functions/template-functions.php' );
75
+		require_once(CLASSY_THEME_PATH.'app/functions/template-functions.php');
76 76
 	}
77 77
 
78 78
 	/**
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 
86 86
 		$theme = wp_get_theme();
87 87
 
88
-		define( 'CLASSY_THEME', $theme->template );
89
-		define( 'CLASSY_THEME_NAME', $theme->get( 'Name' ) );
90
-		define( 'CLASSY_THEME_PATH', get_template_directory() . '/' );
91
-		define( 'CLASSY_THEME_DIR', get_template_directory_uri() . '/' );
92
-		define( 'CLASSY_THEME_VERSION', $theme->get( 'Version' ) );
93
-		define( 'CLASSY_THEME_FRAMEWORK_PATH', CLASSY_THEME_PATH . 'app/' );
94
-		define( 'CLASSY_THEME_FRAMEWORK_DIR', CLASSY_THEME_DIR . 'app/' );
88
+		define('CLASSY_THEME', $theme->template);
89
+		define('CLASSY_THEME_NAME', $theme->get('Name'));
90
+		define('CLASSY_THEME_PATH', get_template_directory().'/');
91
+		define('CLASSY_THEME_DIR', get_template_directory_uri().'/');
92
+		define('CLASSY_THEME_VERSION', $theme->get('Version'));
93
+		define('CLASSY_THEME_FRAMEWORK_PATH', CLASSY_THEME_PATH.'app/');
94
+		define('CLASSY_THEME_FRAMEWORK_DIR', CLASSY_THEME_DIR.'app/');
95 95
 
96 96
 	}
97 97
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return array
111 111
 	 */
112
-	public function filter_templates( $page_templates = array() ) {
112
+	public function filter_templates($page_templates = array()) {
113 113
 
114 114
 		$custom_templates = View::get_page_templates_list();
115 115
 
116
-		return array_merge( $page_templates, $custom_templates );
116
+		return array_merge($page_templates, $custom_templates);
117 117
 
118 118
 	}
119 119
 
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @return mixed|bool Return false if variable not found.
126 126
 	 */
127
-	public static function get_config_var( $name ) {
127
+	public static function get_config_var($name) {
128 128
 
129 129
 		$vars = Config::get_vars();
130 130
 
131
-		return ( isset( $vars[ $name ] ) ) ? $vars[ $name ] : false;
131
+		return (isset($vars[$name])) ? $vars[$name] : false;
132 132
 
133 133
 	}
134 134
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public static function textdomain() {
141 141
 
142
-		$textdomain = Classy::get_config_var( 'textdomain' );
142
+		$textdomain = Classy::get_config_var('textdomain');
143 143
 
144 144
 		return $textdomain ? $textdomain : CLASSY_THEME;
145 145
 
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	 * @param  array|null  $data Additional params.
155 155
 	 * @return void
156 156
 	 */
157
-	public static function render( $view = null, $data = null ) {
157
+	public static function render($view = null, $data = null) {
158 158
 
159
-		$views = CLASSY_THEME_PATH . View::$folder;
160
-		$cache = WP_CONTENT_DIR . '/viewcache';
159
+		$views = CLASSY_THEME_PATH.View::$folder;
160
+		$cache = WP_CONTENT_DIR.'/viewcache';
161 161
 		$common_scope = Scope::get_common_scope();
162 162
 
163
-		if ( null !== $view && is_string( $view ) ) {
163
+		if (null !== $view && is_string($view)) {
164 164
 
165
-			if ( $data && is_array( $data ) ) {
165
+			if ($data && is_array($data)) {
166 166
 
167
-				$scope = array_merge( $common_scope, $data );
167
+				$scope = array_merge($common_scope, $data);
168 168
 
169 169
 			} else {
170 170
 
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 
180 180
 		}
181 181
 
182
-		$renderer = new BladeRenderer( $views, array( 'cache_path' => $cache ) );
182
+		$renderer = new BladeRenderer($views, array('cache_path' => $cache));
183 183
 
184
-		$html = $renderer->render( $view, $scope );
184
+		$html = $renderer->render($view, $scope);
185 185
 
186
-		echo self::maybe_minify( $html );
186
+		echo self::maybe_minify($html);
187 187
 
188 188
 	}
189 189
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 	 * @param  string $html HTML string.
194 194
 	 * @return string
195 195
 	 */
196
-	private static function maybe_minify( $html ) {
196
+	private static function maybe_minify($html) {
197 197
 
198
-		$minify_html = self::get_config_var( 'minify_html' );
198
+		$minify_html = self::get_config_var('minify_html');
199 199
 
200
-		if ( true === $minify_html ) {
200
+		if (true === $minify_html) {
201 201
 
202
-			$html = self::minify_html( $html );
202
+			$html = self::minify_html($html);
203 203
 
204 204
 		}
205 205
 
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
 	 * @param  string $html HTML string.
214 214
 	 * @return string
215 215
 	 */
216
-	private static function minify_html( $html ) {
216
+	private static function minify_html($html) {
217 217
 
218 218
 		$search = array(
219 219
 			"/\n/s",
220
-			'/\>[^\S ]+/s',  // Strip whitespaces after tags, except space.
221
-			'/[^\S ]+\</s',  // Strip whitespaces before tags, except space.
222
-			'/(\s)+/s',       // Shorten multiple whitespace sequences.
220
+			'/\>[^\S ]+/s', // Strip whitespaces after tags, except space.
221
+			'/[^\S ]+\</s', // Strip whitespaces before tags, except space.
222
+			'/(\s)+/s', // Shorten multiple whitespace sequences.
223 223
 			'/<!--(.|\s)*?-->/',
224 224
 		);
225 225
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 			'',
232 232
 		);
233 233
 
234
-		return preg_replace( $search, $replace, $html );
234
+		return preg_replace($search, $replace, $html);
235 235
 
236 236
 	}
237 237
 
@@ -256,27 +256,27 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return array
258 258
 	 */
259
-	public static function get_posts( $args = false, $return = '\Classy\Models\Post' ) {
259
+	public static function get_posts($args = false, $return = '\Classy\Models\Post') {
260 260
 
261 261
 		$_return = array();
262 262
 
263
-		$query = Query_Helper::find_query( $args );
263
+		$query = Query_Helper::find_query($args);
264 264
 
265
-		if ( isset( $query->posts ) ) {
265
+		if (isset($query->posts)) {
266 266
 
267
-			foreach ( $query->posts as $post ) {
267
+			foreach ($query->posts as $post) {
268 268
 
269
-				if ( 'id' === $return ) {
269
+				if ('id' === $return) {
270 270
 
271 271
 					$_return[] = $post->id;
272 272
 
273
-				} elseif ( 'object' === $return ) {
273
+				} elseif ('object' === $return) {
274 274
 
275 275
 					$_return[] = $post;
276 276
 
277
-				} elseif ( class_exists( $return ) ) {
277
+				} elseif (class_exists($return)) {
278 278
 
279
-					$_return[] = new $return( $post );
279
+					$_return[] = new $return($post);
280 280
 
281 281
 				}
282 282
 			}
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @return mixed
296 296
 	 */
297
-	public static function get_post( $args = false, $return_type = '\Classy\Models\Post' ) {
297
+	public static function get_post($args = false, $return_type = '\Classy\Models\Post') {
298 298
 
299
-		$posts = self::get_posts( $args, $return_type );
299
+		$posts = self::get_posts($args, $return_type);
300 300
 
301
-		if ( $post = reset( $posts ) ) {
301
+		if ($post = reset($posts)) {
302 302
 			return $post;
303 303
 		}
304 304
 
@@ -311,62 +311,62 @@  discard block
 block discarded – undo
311 311
 	 *
312 312
 	 * @return array mixed
313 313
 	 */
314
-	public static function get_pagination( $prefs = array() ) {
314
+	public static function get_pagination($prefs = array()) {
315 315
 
316 316
 		global $wp_query;
317 317
 		global $paged;
318 318
 		global $wp_rewrite;
319 319
 
320 320
 		$args = array();
321
-		$args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] );
321
+		$args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']);
322 322
 
323
-		if ( $wp_rewrite->using_permalinks() ) {
323
+		if ($wp_rewrite->using_permalinks()) {
324 324
 
325
-			$url = explode( '?', get_pagenum_link( 0 ) );
325
+			$url = explode('?', get_pagenum_link(0));
326 326
 
327
-			if ( isset( $url[1] ) ) {
328
-				parse_str( $url[1], $query );
327
+			if (isset($url[1])) {
328
+				parse_str($url[1], $query);
329 329
 				$args['add_args'] = $query;
330 330
 			}
331 331
 
332 332
 			$args['format'] = 'page/%#%';
333
-			$args['base'] = trailingslashit( $url[0] ).'%_%';
333
+			$args['base'] = trailingslashit($url[0]).'%_%';
334 334
 
335 335
 		} else {
336 336
 			$big = 999999999;
337
-			$args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) );
337
+			$args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big)));
338 338
 		}
339 339
 
340 340
 		$args['type'] = 'array';
341
-		$args['current'] = max( 1, get_query_var( 'paged' ) );
342
-		$args['mid_size'] = max( 9 - $args['current'], 3 );
341
+		$args['current'] = max(1, get_query_var('paged'));
342
+		$args['mid_size'] = max(9 - $args['current'], 3);
343 343
 		$args['prev_next'] = false;
344 344
 
345
-		if ( is_int( $prefs ) ) {
345
+		if (is_int($prefs)) {
346 346
 			$args['mid_size'] = $prefs - 2;
347 347
 		} else {
348
-			$args = array_merge( $args, $prefs );
348
+			$args = array_merge($args, $prefs);
349 349
 		}
350 350
 
351 351
 		$data = array();
352
-		$data['pages'] = Helper::paginate_links( $args );
353
-		$next = get_next_posts_page_link( $args['total'] );
352
+		$data['pages'] = Helper::paginate_links($args);
353
+		$next = get_next_posts_page_link($args['total']);
354 354
 
355
-		if ( $next ) {
356
-			$data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' );
355
+		if ($next) {
356
+			$data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next');
357 357
 		}
358 358
 
359
-		$prev = previous_posts( false );
359
+		$prev = previous_posts(false);
360 360
 
361
-		if ( $prev ) {
362
-			$data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' );
361
+		if ($prev) {
362
+			$data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev');
363 363
 		}
364 364
 
365
-		if ( $paged < 2 ) {
365
+		if ($paged < 2) {
366 366
 			$data['prev'] = null;
367 367
 		}
368 368
 
369
-		return Helper::array_to_object( $data );
369
+		return Helper::array_to_object($data);
370 370
 
371 371
 	}
372 372
 }
Please login to merge, or discard this patch.