@@ -2,5 +2,5 @@ |
||
| 2 | 2 | /** |
| 3 | 3 | * Init our WordPress Theme. |
| 4 | 4 | */ |
| 5 | -require_once( __DIR__ . '/vendor/autoload.php' ); |
|
| 5 | +require_once(__DIR__.'/vendor/autoload.php'); |
|
| 6 | 6 | \Classy\Classy::get_instance(); |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | global $post; |
| 4 | 4 | |
| 5 | -$classypost = new \Classy\Models\Post( $post ); |
|
| 5 | +$classypost = new \Classy\Models\Post($post); |
|
| 6 | 6 | |
| 7 | -Classy\Classy::render( 'layout.comments', array( 'post' => $classypost ) ); |
|
| 7 | +Classy\Classy::render('layout.comments', array('post' => $classypost)); |
|
@@ -3,4 +3,4 @@ |
||
| 3 | 3 | * Theme header. |
| 4 | 4 | */ |
| 5 | 5 | $framework = get_theme_framework(); |
| 6 | -$framework::render( 'layout.header' ); |
|
| 6 | +$framework::render('layout.header'); |
|
@@ -3,4 +3,4 @@ |
||
| 3 | 3 | * Theme footer. |
| 4 | 4 | */ |
| 5 | 5 | $framework = get_theme_framework(); |
| 6 | -$framework::render( 'layout.footer' ); |
|
| 6 | +$framework::render('layout.footer'); |
|
@@ -259,7 +259,7 @@ |
||
| 259 | 259 | * |
| 260 | 260 | * @param array $prefs Args for paginate_links. |
| 261 | 261 | * |
| 262 | - * @return array mixed |
|
| 262 | + * @return \stdClass mixed |
|
| 263 | 263 | */ |
| 264 | 264 | public static function get_pagination( $prefs = array() ) { |
| 265 | 265 | |
@@ -229,12 +229,14 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | $scope = array_merge( $common_scope, $data ); |
| 231 | 231 | |
| 232 | - } else { |
|
| 232 | + } |
|
| 233 | + else { |
|
| 233 | 234 | |
| 234 | 235 | $scope = $common_scope; |
| 235 | 236 | |
| 236 | 237 | } |
| 237 | - } else { |
|
| 238 | + } |
|
| 239 | + else { |
|
| 238 | 240 | |
| 239 | 241 | $view = ClassyView::get_view(); |
| 240 | 242 | |
@@ -283,11 +285,13 @@ discard block |
||
| 283 | 285 | |
| 284 | 286 | $_return[] = $post->id; |
| 285 | 287 | |
| 286 | - } elseif ( 'object' === $return ) { |
|
| 288 | + } |
|
| 289 | + elseif ( 'object' === $return ) { |
|
| 287 | 290 | |
| 288 | 291 | $_return[] = $post; |
| 289 | 292 | |
| 290 | - } elseif ( class_exists( $return ) ) { |
|
| 293 | + } |
|
| 294 | + elseif ( class_exists( $return ) ) { |
|
| 291 | 295 | |
| 292 | 296 | $_return[] = new $return( $post ); |
| 293 | 297 | |
@@ -341,7 +345,8 @@ discard block |
||
| 341 | 345 | $args['format'] = 'page/%#%'; |
| 342 | 346 | $args['base'] = trailingslashit( $url[0] ).'%_%'; |
| 343 | 347 | |
| 344 | - } else { |
|
| 348 | + } |
|
| 349 | + else { |
|
| 345 | 350 | $big = 999999999; |
| 346 | 351 | $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
| 347 | 352 | } |
@@ -353,7 +358,8 @@ discard block |
||
| 353 | 358 | |
| 354 | 359 | if ( is_int( $prefs ) ) { |
| 355 | 360 | $args['mid_size'] = $prefs - 2; |
| 356 | - } else { |
|
| 361 | + } |
|
| 362 | + else { |
|
| 357 | 363 | $args = array_merge( $args, $prefs ); |
| 358 | 364 | } |
| 359 | 365 | |
@@ -32,7 +32,7 @@ discard block |
||
| 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 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $this->load_custom_includes(); |
| 62 | 62 | |
| 63 | - add_filter( 'theme_page_templates', array( $this, 'filter_templates' ) ); |
|
| 63 | + add_filter('theme_page_templates', array($this, 'filter_templates')); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -74,20 +74,20 @@ discard block |
||
| 74 | 74 | * Load template functions. |
| 75 | 75 | */ |
| 76 | 76 | private function load_template_function() { |
| 77 | - require_once( CLASSY_THEME_FRAMEWORK_PATH . 'core/functions/template-functions.php' ); |
|
| 77 | + require_once(CLASSY_THEME_FRAMEWORK_PATH.'core/functions/template-functions.php'); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Loads custom files specified in custom/config.php. |
| 82 | 82 | */ |
| 83 | 83 | private function load_custom_includes() { |
| 84 | - $include = self::get_config_var( 'include' ); |
|
| 84 | + $include = self::get_config_var('include'); |
|
| 85 | 85 | |
| 86 | - if ( is_array( $include ) ) { |
|
| 87 | - foreach ( $include as $file ) { |
|
| 88 | - $files = (array) glob( CLASSY_THEME_FRAMEWORK_PATH . 'custom/' . $file ); |
|
| 89 | - foreach ( $files as $filename ) { |
|
| 90 | - if ( is_readable( $filename ) ) { |
|
| 86 | + if (is_array($include)) { |
|
| 87 | + foreach ($include as $file) { |
|
| 88 | + $files = (array) glob(CLASSY_THEME_FRAMEWORK_PATH.'custom/'.$file); |
|
| 89 | + foreach ($files as $filename) { |
|
| 90 | + if (is_readable($filename)) { |
|
| 91 | 91 | require_once $filename; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $theme = wp_get_theme(); |
| 107 | 107 | |
| 108 | - define( 'CLASSY_THEME', $theme->template ); |
|
| 109 | - define( 'CLASSY_THEME_NAME', $theme->get( 'Name' ) ); |
|
| 110 | - define( 'CLASSY_THEME_PATH', get_template_directory() . '/' ); |
|
| 111 | - define( 'CLASSY_THEME_DIR', get_template_directory_uri() . '/' ); |
|
| 112 | - define( 'CLASSY_THEME_VERSION', $theme->get( 'Version' ) ); |
|
| 113 | - define( 'CLASSY_THEME_FRAMEWORK_PATH', CLASSY_THEME_PATH . 'app/' ); |
|
| 114 | - define( 'CLASSY_THEME_FRAMEWORK_DIR', CLASSY_THEME_DIR . 'app/' ); |
|
| 108 | + define('CLASSY_THEME', $theme->template); |
|
| 109 | + define('CLASSY_THEME_NAME', $theme->get('Name')); |
|
| 110 | + define('CLASSY_THEME_PATH', get_template_directory().'/'); |
|
| 111 | + define('CLASSY_THEME_DIR', get_template_directory_uri().'/'); |
|
| 112 | + define('CLASSY_THEME_VERSION', $theme->get('Version')); |
|
| 113 | + define('CLASSY_THEME_FRAMEWORK_PATH', CLASSY_THEME_PATH.'app/'); |
|
| 114 | + define('CLASSY_THEME_FRAMEWORK_DIR', CLASSY_THEME_DIR.'app/'); |
|
| 115 | 115 | |
| 116 | 116 | } |
| 117 | 117 | |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return array |
| 131 | 131 | */ |
| 132 | - public function filter_templates( $page_templates = array() ) { |
|
| 132 | + public function filter_templates($page_templates = array()) { |
|
| 133 | 133 | |
| 134 | 134 | $custom_templates = View::get_page_templates_list(); |
| 135 | 135 | |
| 136 | - return array_merge( $page_templates, $custom_templates ); |
|
| 136 | + return array_merge($page_templates, $custom_templates); |
|
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @return mixed|bool Return false if variable not found. |
| 146 | 146 | */ |
| 147 | - public static function get_config_var( $name ) { |
|
| 147 | + public static function get_config_var($name) { |
|
| 148 | 148 | |
| 149 | 149 | $vars = Config::get_vars(); |
| 150 | 150 | |
| 151 | - return ( isset( $vars[ $name ] ) ) ? $vars[ $name ] : false; |
|
| 151 | + return (isset($vars[$name])) ? $vars[$name] : false; |
|
| 152 | 152 | |
| 153 | 153 | } |
| 154 | 154 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public static function textdomain() { |
| 161 | 161 | |
| 162 | - $textdomain = Classy::get_config_var( 'textdomain' ); |
|
| 162 | + $textdomain = Classy::get_config_var('textdomain'); |
|
| 163 | 163 | |
| 164 | 164 | return $textdomain ? $textdomain : CLASSY_THEME; |
| 165 | 165 | |
@@ -174,17 +174,17 @@ discard block |
||
| 174 | 174 | * @param array|null $data Additional params. |
| 175 | 175 | * @return void |
| 176 | 176 | */ |
| 177 | - public static function render( $view = null, $data = null ) { |
|
| 177 | + public static function render($view = null, $data = null) { |
|
| 178 | 178 | |
| 179 | - $views = CLASSY_THEME_PATH . View::$folder; |
|
| 180 | - $cache = WP_CONTENT_DIR . '/viewcache'; |
|
| 179 | + $views = CLASSY_THEME_PATH.View::$folder; |
|
| 180 | + $cache = WP_CONTENT_DIR.'/viewcache'; |
|
| 181 | 181 | $common_scope = Scope::get_common_scope(); |
| 182 | 182 | |
| 183 | - if ( null !== $view && is_string( $view ) ) { |
|
| 183 | + if (null !== $view && is_string($view)) { |
|
| 184 | 184 | |
| 185 | - if ( $data && is_array( $data ) ) { |
|
| 185 | + if ($data && is_array($data)) { |
|
| 186 | 186 | |
| 187 | - $scope = array_merge( $common_scope, $data ); |
|
| 187 | + $scope = array_merge($common_scope, $data); |
|
| 188 | 188 | |
| 189 | 189 | } else { |
| 190 | 190 | |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - $renderer = new BladeRenderer( $views, array( 'cache_path' => $cache ) ); |
|
| 202 | + $renderer = new BladeRenderer($views, array('cache_path' => $cache)); |
|
| 203 | 203 | |
| 204 | - $html = $renderer->render( $view, $scope ); |
|
| 204 | + $html = $renderer->render($view, $scope); |
|
| 205 | 205 | |
| 206 | - echo self::maybe_minify( $html ); |
|
| 206 | + echo self::maybe_minify($html); |
|
| 207 | 207 | |
| 208 | 208 | } |
| 209 | 209 | |
@@ -213,13 +213,13 @@ discard block |
||
| 213 | 213 | * @param string $html HTML string. |
| 214 | 214 | * @return string |
| 215 | 215 | */ |
| 216 | - private static function maybe_minify( $html ) { |
|
| 216 | + private static function maybe_minify($html) { |
|
| 217 | 217 | |
| 218 | - $minify_html = self::get_config_var( 'minify_html' ); |
|
| 218 | + $minify_html = self::get_config_var('minify_html'); |
|
| 219 | 219 | |
| 220 | - if ( true === $minify_html ) { |
|
| 220 | + if (true === $minify_html) { |
|
| 221 | 221 | |
| 222 | - $html = self::minify_html( $html ); |
|
| 222 | + $html = self::minify_html($html); |
|
| 223 | 223 | |
| 224 | 224 | } |
| 225 | 225 | |
@@ -233,13 +233,13 @@ discard block |
||
| 233 | 233 | * @param string $html HTML string. |
| 234 | 234 | * @return string |
| 235 | 235 | */ |
| 236 | - private static function minify_html( $html ) { |
|
| 236 | + private static function minify_html($html) { |
|
| 237 | 237 | |
| 238 | 238 | $search = array( |
| 239 | 239 | "/\n/s", |
| 240 | - '/\>[^\S ]+/s', // Strip whitespaces after tags, except space. |
|
| 241 | - '/[^\S ]+\</s', // Strip whitespaces before tags, except space. |
|
| 242 | - '/(\s)+/s', // Shorten multiple whitespace sequences. |
|
| 240 | + '/\>[^\S ]+/s', // Strip whitespaces after tags, except space. |
|
| 241 | + '/[^\S ]+\</s', // Strip whitespaces before tags, except space. |
|
| 242 | + '/(\s)+/s', // Shorten multiple whitespace sequences. |
|
| 243 | 243 | '/<!--(.|\s)*?-->/', |
| 244 | 244 | ); |
| 245 | 245 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | '', |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - return preg_replace( $search, $replace, $html ); |
|
| 254 | + return preg_replace($search, $replace, $html); |
|
| 255 | 255 | |
| 256 | 256 | } |
| 257 | 257 | |
@@ -276,27 +276,27 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return array |
| 278 | 278 | */ |
| 279 | - public static function get_posts( $args = false, $return = '\Classy\Models\Post' ) { |
|
| 279 | + public static function get_posts($args = false, $return = '\Classy\Models\Post') { |
|
| 280 | 280 | |
| 281 | 281 | $_return = array(); |
| 282 | 282 | |
| 283 | - $query = Query_Helper::find_query( $args ); |
|
| 283 | + $query = Query_Helper::find_query($args); |
|
| 284 | 284 | |
| 285 | - if ( isset( $query->posts ) ) { |
|
| 285 | + if (isset($query->posts)) { |
|
| 286 | 286 | |
| 287 | - foreach ( $query->posts as $post ) { |
|
| 287 | + foreach ($query->posts as $post) { |
|
| 288 | 288 | |
| 289 | - if ( 'id' === $return ) { |
|
| 289 | + if ('id' === $return) { |
|
| 290 | 290 | |
| 291 | 291 | $_return[] = $post->id; |
| 292 | 292 | |
| 293 | - } elseif ( 'object' === $return ) { |
|
| 293 | + } elseif ('object' === $return) { |
|
| 294 | 294 | |
| 295 | 295 | $_return[] = $post; |
| 296 | 296 | |
| 297 | - } elseif ( class_exists( $return ) ) { |
|
| 297 | + } elseif (class_exists($return)) { |
|
| 298 | 298 | |
| 299 | - $_return[] = new $return( $post ); |
|
| 299 | + $_return[] = new $return($post); |
|
| 300 | 300 | |
| 301 | 301 | } |
| 302 | 302 | } |
@@ -314,11 +314,11 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @return mixed |
| 316 | 316 | */ |
| 317 | - public static function get_post( $args = false, $return_type = '\Classy\Models\Post' ) { |
|
| 317 | + public static function get_post($args = false, $return_type = '\Classy\Models\Post') { |
|
| 318 | 318 | |
| 319 | - $posts = self::get_posts( $args, $return_type ); |
|
| 319 | + $posts = self::get_posts($args, $return_type); |
|
| 320 | 320 | |
| 321 | - if ( $post = reset( $posts ) ) { |
|
| 321 | + if ($post = reset($posts)) { |
|
| 322 | 322 | return $post; |
| 323 | 323 | } |
| 324 | 324 | |
@@ -331,62 +331,62 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return array mixed |
| 333 | 333 | */ |
| 334 | - public static function get_pagination( $prefs = array() ) { |
|
| 334 | + public static function get_pagination($prefs = array()) { |
|
| 335 | 335 | |
| 336 | 336 | global $wp_query; |
| 337 | 337 | global $paged; |
| 338 | 338 | global $wp_rewrite; |
| 339 | 339 | |
| 340 | 340 | $args = array(); |
| 341 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
| 341 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
| 342 | 342 | |
| 343 | - if ( $wp_rewrite->using_permalinks() ) { |
|
| 343 | + if ($wp_rewrite->using_permalinks()) { |
|
| 344 | 344 | |
| 345 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
| 345 | + $url = explode('?', get_pagenum_link(0)); |
|
| 346 | 346 | |
| 347 | - if ( isset( $url[1] ) ) { |
|
| 348 | - parse_str( $url[1], $query ); |
|
| 347 | + if (isset($url[1])) { |
|
| 348 | + parse_str($url[1], $query); |
|
| 349 | 349 | $args['add_args'] = $query; |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | $args['format'] = 'page/%#%'; |
| 353 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
| 353 | + $args['base'] = trailingslashit($url[0]).'%_%'; |
|
| 354 | 354 | |
| 355 | 355 | } else { |
| 356 | 356 | $big = 999999999; |
| 357 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
| 357 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | $args['type'] = 'array'; |
| 361 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
| 362 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
| 361 | + $args['current'] = max(1, get_query_var('paged')); |
|
| 362 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
| 363 | 363 | $args['prev_next'] = false; |
| 364 | 364 | |
| 365 | - if ( is_int( $prefs ) ) { |
|
| 365 | + if (is_int($prefs)) { |
|
| 366 | 366 | $args['mid_size'] = $prefs - 2; |
| 367 | 367 | } else { |
| 368 | - $args = array_merge( $args, $prefs ); |
|
| 368 | + $args = array_merge($args, $prefs); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | $data = array(); |
| 372 | - $data['pages'] = Helper::paginate_links( $args ); |
|
| 373 | - $next = get_next_posts_page_link( $args['total'] ); |
|
| 372 | + $data['pages'] = Helper::paginate_links($args); |
|
| 373 | + $next = get_next_posts_page_link($args['total']); |
|
| 374 | 374 | |
| 375 | - if ( $next ) { |
|
| 376 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
| 375 | + if ($next) { |
|
| 376 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - $prev = previous_posts( false ); |
|
| 379 | + $prev = previous_posts(false); |
|
| 380 | 380 | |
| 381 | - if ( $prev ) { |
|
| 382 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
| 381 | + if ($prev) { |
|
| 382 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if ( $paged < 2 ) { |
|
| 385 | + if ($paged < 2) { |
|
| 386 | 386 | $data['prev'] = null; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - return Helper::array_to_object( $data ); |
|
| 389 | + return Helper::array_to_object($data); |
|
| 390 | 390 | |
| 391 | 391 | } |
| 392 | 392 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param string $type View|scope. |
| 122 | 122 | * @param string $page Request type like: home, single etc. |
| 123 | 123 | * |
| 124 | - * @return array|bool |
|
| 124 | + * @return string|false |
|
| 125 | 125 | */ |
| 126 | 126 | public static function get_available_file( $type = 'view', $page ) { |
| 127 | 127 | $views = self::get_request_hierarchy_list( $page ); |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | /** |
| 307 | 307 | * Returns classy template name or boolean if this is not classy template. |
| 308 | 308 | * |
| 309 | - * @return mixed |
|
| 309 | + * @return string|false |
|
| 310 | 310 | */ |
| 311 | 311 | public static function get_classy_template() { |
| 312 | 312 | preg_match( '/classy\-(.*)/', get_page_template_slug(), $matches ); |
@@ -26,39 +26,39 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | protected static function check_request() { |
| 28 | 28 | |
| 29 | - if ( is_404() ) : return '404'; |
|
| 29 | + if (is_404()) : return '404'; |
|
| 30 | 30 | |
| 31 | - elseif ( is_search() ) : return 'search'; |
|
| 31 | + elseif (is_search()) : return 'search'; |
|
| 32 | 32 | |
| 33 | - elseif ( is_front_page() ) : return 'front-page'; |
|
| 33 | + elseif (is_front_page()) : return 'front-page'; |
|
| 34 | 34 | |
| 35 | - elseif ( is_home() ) : return 'home'; |
|
| 35 | + elseif (is_home()) : return 'home'; |
|
| 36 | 36 | |
| 37 | - elseif ( is_post_type_archive() ) : return 'post_type_archive'; |
|
| 37 | + elseif (is_post_type_archive()) : return 'post_type_archive'; |
|
| 38 | 38 | |
| 39 | - elseif ( is_tax() ) : return 'taxonomy'; |
|
| 39 | + elseif (is_tax()) : return 'taxonomy'; |
|
| 40 | 40 | |
| 41 | - elseif ( is_attachment() ) : return 'attachment'; |
|
| 41 | + elseif (is_attachment()) : return 'attachment'; |
|
| 42 | 42 | |
| 43 | - elseif ( is_single() ) : return 'single'; |
|
| 43 | + elseif (is_single()) : return 'single'; |
|
| 44 | 44 | |
| 45 | - elseif ( self::is_classy_template() ) : return 'classy-template'; |
|
| 45 | + elseif (self::is_classy_template()) : return 'classy-template'; |
|
| 46 | 46 | |
| 47 | - elseif ( is_page() ) : return 'page'; |
|
| 47 | + elseif (is_page()) : return 'page'; |
|
| 48 | 48 | |
| 49 | - elseif ( is_singular() ) : return 'singular'; |
|
| 49 | + elseif (is_singular()) : return 'singular'; |
|
| 50 | 50 | |
| 51 | - elseif ( is_category() ) : return 'category'; |
|
| 51 | + elseif (is_category()) : return 'category'; |
|
| 52 | 52 | |
| 53 | - elseif ( is_tag() ) : return 'tag'; |
|
| 53 | + elseif (is_tag()) : return 'tag'; |
|
| 54 | 54 | |
| 55 | - elseif ( is_author() ) : return 'author'; |
|
| 55 | + elseif (is_author()) : return 'author'; |
|
| 56 | 56 | |
| 57 | - elseif ( is_date() ) : return 'date'; |
|
| 57 | + elseif (is_date()) : return 'date'; |
|
| 58 | 58 | |
| 59 | - elseif ( is_archive() ) : return 'archive'; |
|
| 59 | + elseif (is_archive()) : return 'archive'; |
|
| 60 | 60 | |
| 61 | - elseif ( is_paged() ) : return 'paged'; |
|
| 61 | + elseif (is_paged()) : return 'paged'; |
|
| 62 | 62 | |
| 63 | 63 | else : |
| 64 | 64 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @return string |
| 74 | 74 | */ |
| 75 | 75 | public static function get_current_request() { |
| 76 | - if ( is_null( self::$current_request ) ) { |
|
| 76 | + if (is_null(self::$current_request)) { |
|
| 77 | 77 | self::$current_request = self::check_request(); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return string Full file path. |
| 91 | 91 | */ |
| 92 | - public static function get_file_path( $type = 'view', $view ) { |
|
| 93 | - $view = str_replace( '.', '/', $view ); |
|
| 92 | + public static function get_file_path($type = 'view', $view) { |
|
| 93 | + $view = str_replace('.', '/', $view); |
|
| 94 | 94 | |
| 95 | - if ( 'view' === $type ) { |
|
| 96 | - return CLASSY_THEME_PATH . View::$folder . '/' . $view . '.blade.php'; |
|
| 97 | - } elseif ( 'scope' === $type ) { |
|
| 98 | - return CLASSY_THEME_PATH . Scope::$folder . '/' . $view . '.php'; |
|
| 95 | + if ('view' === $type) { |
|
| 96 | + return CLASSY_THEME_PATH.View::$folder.'/'.$view.'.blade.php'; |
|
| 97 | + } elseif ('scope' === $type) { |
|
| 98 | + return CLASSY_THEME_PATH.Scope::$folder.'/'.$view.'.php'; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | return ''; |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return boolean true|false |
| 111 | 111 | */ |
| 112 | - public static function file_exists( $type = 'view', $file ) { |
|
| 112 | + public static function file_exists($type = 'view', $file) { |
|
| 113 | 113 | return file_exists( |
| 114 | - self::get_file_path( $type, str_replace( '.', '/', $file ) ) |
|
| 114 | + self::get_file_path($type, str_replace('.', '/', $file)) |
|
| 115 | 115 | ); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return array|bool |
| 125 | 125 | */ |
| 126 | - public static function get_available_file( $type = 'view', $page ) { |
|
| 127 | - $views = self::get_request_hierarchy_list( $page ); |
|
| 126 | + public static function get_available_file($type = 'view', $page) { |
|
| 127 | + $views = self::get_request_hierarchy_list($page); |
|
| 128 | 128 | |
| 129 | - foreach ( $views as $view ) { |
|
| 130 | - if ( self::file_exists( $type, $view ) ) { |
|
| 129 | + foreach ($views as $view) { |
|
| 130 | + if (self::file_exists($type, $view)) { |
|
| 131 | 131 | return $view; |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -142,26 +142,26 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @return array |
| 144 | 144 | */ |
| 145 | - private static function get_request_hierarchy_list( $type ) { |
|
| 145 | + private static function get_request_hierarchy_list($type) { |
|
| 146 | 146 | $views = array(); |
| 147 | 147 | |
| 148 | - if ( 'home' === $type ) : |
|
| 148 | + if ('home' === $type) : |
|
| 149 | 149 | $views[] = 'home'; |
| 150 | - elseif ( 'single' === $type ) : |
|
| 150 | + elseif ('single' === $type) : |
|
| 151 | 151 | |
| 152 | - $views[] = get_post_type() . '.single'; |
|
| 152 | + $views[] = get_post_type().'.single'; |
|
| 153 | 153 | $views[] = 'single'; |
| 154 | 154 | |
| 155 | - elseif ( 'post_type_archive' === $type ) : |
|
| 155 | + elseif ('post_type_archive' === $type) : |
|
| 156 | 156 | |
| 157 | - $views[] = get_post_type() . '.archive'; |
|
| 157 | + $views[] = get_post_type().'.archive'; |
|
| 158 | 158 | $views[] = 'archive'; |
| 159 | 159 | |
| 160 | - elseif ( 'taxonomy' === $type ) : |
|
| 160 | + elseif ('taxonomy' === $type) : |
|
| 161 | 161 | |
| 162 | 162 | $term = get_queried_object(); |
| 163 | 163 | |
| 164 | - if ( ! empty( $term->slug ) ) { |
|
| 164 | + if (!empty($term->slug)) { |
|
| 165 | 165 | $taxonomy = $term->taxonomy; |
| 166 | 166 | |
| 167 | 167 | $views[] = "taxonomy.$taxonomy-{$term->slug}"; |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | $views[] = 'taxonomy.taxonomy'; |
| 172 | 172 | $views[] = 'taxonomy'; |
| 173 | 173 | |
| 174 | - elseif ( 'category' === $type ) : |
|
| 174 | + elseif ('category' === $type) : |
|
| 175 | 175 | |
| 176 | 176 | $category = get_queried_object(); |
| 177 | 177 | |
| 178 | - if ( ! empty( $category->slug ) ) { |
|
| 178 | + if (!empty($category->slug)) { |
|
| 179 | 179 | $views[] = "category.{$category->slug}"; |
| 180 | 180 | $views[] = "category.{$category->term_id}"; |
| 181 | 181 | } |
@@ -183,18 +183,18 @@ discard block |
||
| 183 | 183 | $views[] = 'category.category'; |
| 184 | 184 | $views[] = 'category'; |
| 185 | 185 | |
| 186 | - elseif ( 'attachment' === $type ) : |
|
| 186 | + elseif ('attachment' === $type) : |
|
| 187 | 187 | |
| 188 | 188 | $attachment = get_queried_object(); |
| 189 | 189 | |
| 190 | - if ( $attachment ) { |
|
| 191 | - if ( false !== strpos( $attachment->post_mime_type, '/' ) ) { |
|
| 192 | - list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
|
| 190 | + if ($attachment) { |
|
| 191 | + if (false !== strpos($attachment->post_mime_type, '/')) { |
|
| 192 | + list($type, $subtype) = explode('/', $attachment->post_mime_type); |
|
| 193 | 193 | } else { |
| 194 | - list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
|
| 194 | + list($type, $subtype) = array($attachment->post_mime_type, ''); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if ( ! empty( $subtype ) ) { |
|
| 197 | + if (!empty($subtype)) { |
|
| 198 | 198 | $views[] = "attachment.{$type}.{$subtype}"; |
| 199 | 199 | $views[] = "attachment.{$subtype}"; |
| 200 | 200 | |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | $views[] = 'attachment.attachment'; |
| 210 | 210 | $views[] = 'attachment'; |
| 211 | 211 | |
| 212 | - elseif ( 'tag' === $type ) : |
|
| 212 | + elseif ('tag' === $type) : |
|
| 213 | 213 | |
| 214 | 214 | $tag = get_queried_object(); |
| 215 | 215 | |
| 216 | - if ( ! empty( $tag->slug ) ) { |
|
| 216 | + if (!empty($tag->slug)) { |
|
| 217 | 217 | $views[] = "post.tag.{$tag->slug}"; |
| 218 | 218 | $views[] = "post.tag.{$tag->term_id}"; |
| 219 | 219 | |
@@ -224,11 +224,11 @@ discard block |
||
| 224 | 224 | $views[] = 'post.tag'; |
| 225 | 225 | $views[] = 'tag'; |
| 226 | 226 | |
| 227 | - elseif ( 'author' === $type ) : |
|
| 227 | + elseif ('author' === $type) : |
|
| 228 | 228 | |
| 229 | 229 | $author = get_queried_object(); |
| 230 | 230 | |
| 231 | - if ( $author instanceof \WP_User ) { |
|
| 231 | + if ($author instanceof \WP_User) { |
|
| 232 | 232 | $views[] = "post.author.{$author->user_nicename}"; |
| 233 | 233 | $views[] = "post.author.{$author->ID}"; |
| 234 | 234 | |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | $views[] = 'post.author'; |
| 240 | 240 | $views[] = 'author'; |
| 241 | 241 | |
| 242 | - elseif ( 'front-page' === $type ) : |
|
| 242 | + elseif ('front-page' === $type) : |
|
| 243 | 243 | |
| 244 | 244 | $template = self::get_classy_template(); |
| 245 | 245 | |
| 246 | - if ( ! empty( $template ) ) { |
|
| 246 | + if (!empty($template)) { |
|
| 247 | 247 | $views[] = $template; |
| 248 | - $views[] = 'page.' . $template; |
|
| 249 | - $views[] = 'template.' . $template; |
|
| 248 | + $views[] = 'page.'.$template; |
|
| 249 | + $views[] = 'template.'.$template; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | $views[] = 'front-page.front-page'; |
@@ -255,37 +255,37 @@ discard block |
||
| 255 | 255 | $views[] = 'home.home'; |
| 256 | 256 | $views[] = 'home'; |
| 257 | 257 | |
| 258 | - $views = array_merge( $views, self::get_request_hierarchy_list( 'post_type_archive' ) ); |
|
| 258 | + $views = array_merge($views, self::get_request_hierarchy_list('post_type_archive')); |
|
| 259 | 259 | |
| 260 | - elseif ( 'classy-template' === $type ) : |
|
| 260 | + elseif ('classy-template' === $type) : |
|
| 261 | 261 | |
| 262 | 262 | $template = self::get_classy_template(); |
| 263 | 263 | |
| 264 | 264 | $views[] = $template; |
| 265 | - $views[] = 'page.' . $template; |
|
| 266 | - $views[] = 'template.' . $template; |
|
| 265 | + $views[] = 'page.'.$template; |
|
| 266 | + $views[] = 'template.'.$template; |
|
| 267 | 267 | $views[] = 'page.page'; |
| 268 | 268 | $views[] = 'page'; |
| 269 | 269 | |
| 270 | - elseif ( 'page' === $type ) : |
|
| 270 | + elseif ('page' === $type) : |
|
| 271 | 271 | |
| 272 | 272 | $id = get_queried_object_id(); |
| 273 | 273 | |
| 274 | - $pagename = get_query_var( 'pagename' ); |
|
| 274 | + $pagename = get_query_var('pagename'); |
|
| 275 | 275 | |
| 276 | - if ( ! $pagename && $id ) { |
|
| 276 | + if (!$pagename && $id) { |
|
| 277 | 277 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object. |
| 278 | - if ( $post = get_queried_object() ) { |
|
| 278 | + if ($post = get_queried_object()) { |
|
| 279 | 279 | $pagename = $post->post_name; |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if ( $pagename ) { |
|
| 284 | - $views[] = 'page.' . $pagename; |
|
| 283 | + if ($pagename) { |
|
| 284 | + $views[] = 'page.'.$pagename; |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - if ( $id ) { |
|
| 288 | - $views[] = 'page.' . $id; |
|
| 287 | + if ($id) { |
|
| 288 | + $views[] = 'page.'.$id; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | $views[] = 'page.page'; |
@@ -317,9 +317,9 @@ discard block |
||
| 317 | 317 | * @return mixed |
| 318 | 318 | */ |
| 319 | 319 | public static function get_classy_template() { |
| 320 | - preg_match( '/classy\-(.*)/', get_page_template_slug(), $matches ); |
|
| 320 | + preg_match('/classy\-(.*)/', get_page_template_slug(), $matches); |
|
| 321 | 321 | |
| 322 | - if ( ! empty( $matches ) && isset( $matches[1] ) ) { |
|
| 322 | + if (!empty($matches) && isset($matches[1])) { |
|
| 323 | 323 | return $matches[1]; |
| 324 | 324 | } |
| 325 | 325 | |
@@ -54,9 +54,11 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | elseif ( is_paged() ) : return 'paged'; |
| 56 | 56 | |
| 57 | - else : |
|
| 57 | + else { |
|
| 58 | + : |
|
| 58 | 59 | |
| 59 | 60 | return 'index'; |
| 61 | + } |
|
| 60 | 62 | |
| 61 | 63 | endif; |
| 62 | 64 | |
@@ -97,7 +99,8 @@ discard block |
||
| 97 | 99 | |
| 98 | 100 | return THEME_PATH . $folder . '/' . $view . '.blade.php'; |
| 99 | 101 | |
| 100 | - } elseif ( 'scope' === $type ) { |
|
| 102 | + } |
|
| 103 | + elseif ( 'scope' === $type ) { |
|
| 101 | 104 | |
| 102 | 105 | $folder = ClassyScope::$folder; |
| 103 | 106 | |
@@ -234,7 +237,8 @@ discard block |
||
| 234 | 237 | |
| 235 | 238 | list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
| 236 | 239 | |
| 237 | - } else { |
|
| 240 | + } |
|
| 241 | + else { |
|
| 238 | 242 | |
| 239 | 243 | list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
| 240 | 244 | |
@@ -347,9 +351,11 @@ discard block |
||
| 347 | 351 | |
| 348 | 352 | // Default |
| 349 | 353 | |
| 350 | - else : |
|
| 354 | + else { |
|
| 355 | + : |
|
| 351 | 356 | |
| 352 | 357 | $views[] = $type; |
| 358 | + } |
|
| 353 | 359 | |
| 354 | 360 | endif; |
| 355 | 361 | |
@@ -186,7 +186,7 @@ |
||
| 186 | 186 | /** |
| 187 | 187 | * Returns first attached image id |
| 188 | 188 | * |
| 189 | - * @return int|boolean |
|
| 189 | + * @return integer|null |
|
| 190 | 190 | */ |
| 191 | 191 | public function get_first_attached_image_id() { |
| 192 | 192 | |
@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @param object|int $post WP_Post or WP_Post.ID. |
| 100 | 100 | */ |
| 101 | - public function __construct( $post = null ) { |
|
| 102 | - if ( is_integer( $post ) ) { |
|
| 101 | + public function __construct($post = null) { |
|
| 102 | + if (is_integer($post)) { |
|
| 103 | 103 | $this->ID = $post; |
| 104 | 104 | $this->init(); |
| 105 | - } elseif ( is_a( $post, '\WP_Post' ) ) { |
|
| 106 | - $this->import( $post ); |
|
| 105 | + } elseif (is_a($post, '\WP_Post')) { |
|
| 106 | + $this->import($post); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | protected function init() { |
| 114 | 114 | $post = $this->get_object(); |
| 115 | 115 | |
| 116 | - if ( is_a( $post, '\WP_Post' ) ) { |
|
| 117 | - $this->import( $post ); |
|
| 116 | + if (is_a($post, '\WP_Post')) { |
|
| 117 | + $this->import($post); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @return \WP_Post |
| 125 | 125 | */ |
| 126 | 126 | public function get_object() { |
| 127 | - return get_post( $this->ID ); |
|
| 127 | + return get_post($this->ID); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | * @return boolean |
| 134 | 134 | */ |
| 135 | 135 | public function can_edit() { |
| 136 | - if ( ! function_exists( 'current_user_can' ) ) { |
|
| 136 | + if (!function_exists('current_user_can')) { |
|
| 137 | 137 | return false; |
| 138 | 138 | } |
| 139 | - if ( current_user_can( 'edit_post', $this->ID ) ) { |
|
| 139 | + if (current_user_can('edit_post', $this->ID)) { |
|
| 140 | 140 | return true; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | * @return string |
| 150 | 150 | */ |
| 151 | 151 | public function get_edit_url() { |
| 152 | - if ( $this->can_edit() ) { |
|
| 153 | - return get_edit_post_link( $this->ID ); |
|
| 152 | + if ($this->can_edit()) { |
|
| 153 | + return get_edit_post_link($this->ID); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | return ''; |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | 'fields' => 'ids', |
| 174 | 174 | ); |
| 175 | 175 | |
| 176 | - $images = get_children( $attrs ); |
|
| 176 | + $images = get_children($attrs); |
|
| 177 | 177 | |
| 178 | - if ( ! count( $images ) ) { |
|
| 178 | + if (!count($images)) { |
|
| 179 | 179 | return false; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -192,11 +192,11 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $images = $this->get_attached_images(); |
| 194 | 194 | |
| 195 | - if ( $images ) { |
|
| 195 | + if ($images) { |
|
| 196 | 196 | |
| 197 | - foreach ( $images as $image_id ) { |
|
| 197 | + foreach ($images as $image_id) { |
|
| 198 | 198 | |
| 199 | - $_return[] = new Image( $image_id ); |
|
| 199 | + $_return[] = new Image($image_id); |
|
| 200 | 200 | |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -222,13 +222,13 @@ discard block |
||
| 222 | 222 | 'fields' => 'ids', |
| 223 | 223 | ); |
| 224 | 224 | |
| 225 | - $images = get_children( $attrs ); |
|
| 225 | + $images = get_children($attrs); |
|
| 226 | 226 | |
| 227 | - if ( ! count( $images ) ) { |
|
| 227 | + if (!count($images)) { |
|
| 228 | 228 | return false; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - $images = array_values( $images ); |
|
| 231 | + $images = array_values($images); |
|
| 232 | 232 | |
| 233 | 233 | return $images[0]; |
| 234 | 234 | } |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | $image_id = $this->get_first_attached_image_id(); |
| 244 | 244 | |
| 245 | - if ( $image_id ) { |
|
| 246 | - return new Image( $image_id ); |
|
| 245 | + if ($image_id) { |
|
| 246 | + return new Image($image_id); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | return new Image(); |
@@ -255,12 +255,12 @@ discard block |
||
| 255 | 255 | * @return Image |
| 256 | 256 | */ |
| 257 | 257 | public function thumbnail() { |
| 258 | - if ( function_exists( 'get_post_thumbnail_id' ) ) { |
|
| 259 | - $image_id = get_post_thumbnail_id( $this->ID ); |
|
| 258 | + if (function_exists('get_post_thumbnail_id')) { |
|
| 259 | + $image_id = get_post_thumbnail_id($this->ID); |
|
| 260 | 260 | |
| 261 | - if ( $image_id ) { |
|
| 261 | + if ($image_id) { |
|
| 262 | 262 | |
| 263 | - return new Image( $image_id ); |
|
| 263 | + return new Image($image_id); |
|
| 264 | 264 | |
| 265 | 265 | } |
| 266 | 266 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * @return string |
| 275 | 275 | */ |
| 276 | 276 | public function get_title() { |
| 277 | - return apply_filters( 'the_title', $this->post_title, $this->ID ); |
|
| 277 | + return apply_filters('the_title', $this->post_title, $this->ID); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -293,24 +293,24 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @return string Post content |
| 295 | 295 | */ |
| 296 | - public function get_content( $page = 0 ) { |
|
| 297 | - if ( 0 === absint( $page ) && $this->post_content ) { |
|
| 298 | - return apply_filters( 'the_content', $this->post_content ); |
|
| 296 | + public function get_content($page = 0) { |
|
| 297 | + if (0 === absint($page) && $this->post_content) { |
|
| 298 | + return apply_filters('the_content', $this->post_content); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | $content = $this->post_content; |
| 302 | 302 | |
| 303 | - if ( $page ) { |
|
| 304 | - $contents = explode( '<!--nextpage-->', $content ); |
|
| 303 | + if ($page) { |
|
| 304 | + $contents = explode('<!--nextpage-->', $content); |
|
| 305 | 305 | |
| 306 | 306 | $page--; |
| 307 | 307 | |
| 308 | - if ( count( $contents ) > $page ) { |
|
| 309 | - $content = $contents[ $page ]; |
|
| 308 | + if (count($contents) > $page) { |
|
| 309 | + $content = $contents[$page]; |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - $content = apply_filters( 'the_content', ($content) ); |
|
| 313 | + $content = apply_filters('the_content', ($content)); |
|
| 314 | 314 | |
| 315 | 315 | return $content; |
| 316 | 316 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @return object |
| 331 | 331 | */ |
| 332 | 332 | public function get_post_type() { |
| 333 | - return get_post_type_object( $this->post_type ); |
|
| 333 | + return get_post_type_object($this->post_type); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | * @return string |
| 340 | 340 | */ |
| 341 | 341 | public function get_permalink() { |
| 342 | - if ( isset( $this->permalink ) ) { |
|
| 342 | + if (isset($this->permalink)) { |
|
| 343 | 343 | return $this->permalink; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - $this->permalink = get_permalink( $this->ID ); |
|
| 346 | + $this->permalink = get_permalink($this->ID); |
|
| 347 | 347 | |
| 348 | 348 | return $this->permalink; |
| 349 | 349 | } |
@@ -369,84 +369,84 @@ discard block |
||
| 369 | 369 | * |
| 370 | 370 | * @return string Post preview. |
| 371 | 371 | */ |
| 372 | - public function get_preview( $len = 50, $force = false, $readmore = 'Read More', $strip = true ) { |
|
| 372 | + public function get_preview($len = 50, $force = false, $readmore = 'Read More', $strip = true) { |
|
| 373 | 373 | $text = ''; |
| 374 | 374 | $trimmed = false; |
| 375 | 375 | |
| 376 | - if ( isset( $this->post_excerpt ) && strlen( $this->post_excerpt ) ) { |
|
| 376 | + if (isset($this->post_excerpt) && strlen($this->post_excerpt)) { |
|
| 377 | 377 | |
| 378 | - if ( $force ) { |
|
| 379 | - $text = Helper::trim_words( $this->post_excerpt, $len, false ); |
|
| 378 | + if ($force) { |
|
| 379 | + $text = Helper::trim_words($this->post_excerpt, $len, false); |
|
| 380 | 380 | $trimmed = true; |
| 381 | 381 | } else { |
| 382 | 382 | $text = $this->post_excerpt; |
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - if ( ! strlen( $text ) && preg_match( '/<!--\s?more(.*?)?-->/', $this->post_content, $readmore_matches ) ) { |
|
| 386 | + if (!strlen($text) && preg_match('/<!--\s?more(.*?)?-->/', $this->post_content, $readmore_matches)) { |
|
| 387 | 387 | |
| 388 | - $pieces = explode( $readmore_matches[0], $this->post_content ); |
|
| 388 | + $pieces = explode($readmore_matches[0], $this->post_content); |
|
| 389 | 389 | $text = $pieces[0]; |
| 390 | 390 | |
| 391 | - if ( $force ) { |
|
| 392 | - $text = Helper::trim_words( $text, $len, false ); |
|
| 391 | + if ($force) { |
|
| 392 | + $text = Helper::trim_words($text, $len, false); |
|
| 393 | 393 | $trimmed = true; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - $text = do_shortcode( $text ); |
|
| 396 | + $text = do_shortcode($text); |
|
| 397 | 397 | |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - if ( ! strlen( $text ) ) { |
|
| 400 | + if (!strlen($text)) { |
|
| 401 | 401 | |
| 402 | - $text = Helper::trim_words( $this->get_content(), $len, false ); |
|
| 402 | + $text = Helper::trim_words($this->get_content(), $len, false); |
|
| 403 | 403 | $trimmed = true; |
| 404 | 404 | |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - if ( ! strlen( trim( $text ) ) ) { |
|
| 407 | + if (!strlen(trim($text))) { |
|
| 408 | 408 | |
| 409 | - return trim( $text ); |
|
| 409 | + return trim($text); |
|
| 410 | 410 | |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if ( $strip ) { |
|
| 413 | + if ($strip) { |
|
| 414 | 414 | |
| 415 | - $text = trim( strip_tags( $text ) ); |
|
| 415 | + $text = trim(strip_tags($text)); |
|
| 416 | 416 | |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( strlen( $text ) ) { |
|
| 419 | + if (strlen($text)) { |
|
| 420 | 420 | |
| 421 | - $text = trim( $text ); |
|
| 422 | - $last = $text[ strlen( $text ) - 1 ]; |
|
| 421 | + $text = trim($text); |
|
| 422 | + $last = $text[strlen($text) - 1]; |
|
| 423 | 423 | |
| 424 | - if ( '.' !== $last && $trimmed ) { |
|
| 424 | + if ('.' !== $last && $trimmed) { |
|
| 425 | 425 | $text .= ' … '; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - if ( ! $strip ) { |
|
| 429 | - $last_p_tag = strrpos( $text, '</p>' ); |
|
| 430 | - if ( false !== $last_p_tag ) { |
|
| 431 | - $text = substr( $text, 0, $last_p_tag ); |
|
| 428 | + if (!$strip) { |
|
| 429 | + $last_p_tag = strrpos($text, '</p>'); |
|
| 430 | + if (false !== $last_p_tag) { |
|
| 431 | + $text = substr($text, 0, $last_p_tag); |
|
| 432 | 432 | } |
| 433 | - if ( '.' !== $last && $trimmed ) { |
|
| 433 | + if ('.' !== $last && $trimmed) { |
|
| 434 | 434 | $text .= ' … '; |
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if ( $readmore && isset( $readmore_matches ) && ! empty( $readmore_matches[1] ) ) { |
|
| 439 | - $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore_matches[1] ) . '</a>'; |
|
| 440 | - } elseif ( $readmore ) { |
|
| 441 | - $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore ) . '</a>'; |
|
| 438 | + if ($readmore && isset($readmore_matches) && !empty($readmore_matches[1])) { |
|
| 439 | + $text .= ' <a href="'.$this->get_permalink().'" class="read-more">'.trim($readmore_matches[1]).'</a>'; |
|
| 440 | + } elseif ($readmore) { |
|
| 441 | + $text .= ' <a href="'.$this->get_permalink().'" class="read-more">'.trim($readmore).'</a>'; |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if ( ! $strip ) { |
|
| 444 | + if (!$strip) { |
|
| 445 | 445 | $text .= '</p>'; |
| 446 | 446 | } |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - return trim( $text ); |
|
| 449 | + return trim($text); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | /** |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | * |
| 458 | 458 | * @return array |
| 459 | 459 | */ |
| 460 | - public function get_comments( $status = 'approve', $order = 'DESC' ) { |
|
| 460 | + public function get_comments($status = 'approve', $order = 'DESC') { |
|
| 461 | 461 | |
| 462 | 462 | $_return = array(); |
| 463 | 463 | |
@@ -467,25 +467,25 @@ discard block |
||
| 467 | 467 | 'order' => $order, |
| 468 | 468 | ); |
| 469 | 469 | |
| 470 | - $comments = get_comments( $args ); |
|
| 470 | + $comments = get_comments($args); |
|
| 471 | 471 | |
| 472 | - foreach ( $comments as $comment ) { |
|
| 472 | + foreach ($comments as $comment) { |
|
| 473 | 473 | |
| 474 | - $_return[ $comment->comment_ID ] = new Comment( $comment ); |
|
| 474 | + $_return[$comment->comment_ID] = new Comment($comment); |
|
| 475 | 475 | |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - foreach ( $_return as $key => $comment ) { |
|
| 478 | + foreach ($_return as $key => $comment) { |
|
| 479 | 479 | |
| 480 | - if ( $comment->has_parent() ) { |
|
| 480 | + if ($comment->has_parent()) { |
|
| 481 | 481 | |
| 482 | - $_return[ $comment->comment_parent ]->add_child( $comment ); |
|
| 482 | + $_return[$comment->comment_parent]->add_child($comment); |
|
| 483 | 483 | |
| 484 | - unset( $_return[ $key ] ); |
|
| 484 | + unset($_return[$key]); |
|
| 485 | 485 | |
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - return array_values( $_return ); |
|
| 489 | + return array_values($_return); |
|
| 490 | 490 | } |
| 491 | 491 | } |
@@ -97,7 +97,8 @@ discard block |
||
| 97 | 97 | if ( is_integer( $post ) ) { |
| 98 | 98 | $this->ID = $post; |
| 99 | 99 | $this->init(); |
| 100 | - } elseif ( is_a( $post, '\WP_Post' ) ) { |
|
| 100 | + } |
|
| 101 | + elseif ( is_a( $post, '\WP_Post' ) ) { |
|
| 101 | 102 | $this->import( $post ); |
| 102 | 103 | } |
| 103 | 104 | } |
@@ -375,7 +376,8 @@ discard block |
||
| 375 | 376 | if ( $force ) { |
| 376 | 377 | $text = Helper::trim_words( $this->post_excerpt, $len, false ); |
| 377 | 378 | $trimmed = true; |
| 378 | - } else { |
|
| 379 | + } |
|
| 380 | + else { |
|
| 379 | 381 | $text = $this->post_excerpt; |
| 380 | 382 | } |
| 381 | 383 | } |
@@ -434,7 +436,8 @@ discard block |
||
| 434 | 436 | |
| 435 | 437 | if ( $readmore && isset( $readmore_matches ) && ! empty( $readmore_matches[1] ) ) { |
| 436 | 438 | $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore_matches[1] ) . '</a>'; |
| 437 | - } elseif ( $readmore ) { |
|
| 439 | + } |
|
| 440 | + elseif ( $readmore ) { |
|
| 438 | 441 | $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore ) . '</a>'; |
| 439 | 442 | } |
| 440 | 443 | |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param int $pid Image attachment ID. |
| 28 | 28 | */ |
| 29 | - public function __construct( $pid = null ) { |
|
| 29 | + public function __construct($pid = null) { |
|
| 30 | 30 | $this->ID = 0; |
| 31 | 31 | |
| 32 | 32 | // Checks if image with this id exists. |
| 33 | - if ( null !== $pid && wp_get_attachment_image_src( $pid ) ) { |
|
| 33 | + if (null !== $pid && wp_get_attachment_image_src($pid)) { |
|
| 34 | 34 | $this->ID = $pid; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public static function get_default_image() { |
| 44 | 44 | // You can put here any url. |
| 45 | - return CLASSY_THEME_DIR . '/assets/noimage.png'; |
|
| 45 | + return CLASSY_THEME_DIR.'/assets/noimage.png'; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | - public function src( $size = 'medium' ) { |
|
| 56 | - if ( $this->ID ) { |
|
| 57 | - $thumb = wp_get_attachment_image_src( $this->ID, $size ); |
|
| 55 | + public function src($size = 'medium') { |
|
| 56 | + if ($this->ID) { |
|
| 57 | + $thumb = wp_get_attachment_image_src($this->ID, $size); |
|
| 58 | 58 | |
| 59 | 59 | return $thumb[0]; |
| 60 | 60 | } |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @param int $uid User id. |
| 68 | 68 | */ |
| 69 | - public function __construct( $uid = null ) { |
|
| 70 | - $this->ID = $this->verify_id( $uid ); |
|
| 69 | + public function __construct($uid = null) { |
|
| 70 | + $this->ID = $this->verify_id($uid); |
|
| 71 | 71 | |
| 72 | 72 | $this->init(); |
| 73 | 73 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return int |
| 81 | 81 | */ |
| 82 | - private function verify_id( $uid ) { |
|
| 82 | + private function verify_id($uid) { |
|
| 83 | 83 | // @todo: Realize this method. |
| 84 | 84 | return $uid; |
| 85 | 85 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | private function init() { |
| 91 | 91 | $this->object = $this->get_object(); |
| 92 | 92 | |
| 93 | - $this->import( $this->object ); |
|
| 93 | + $this->import($this->object); |
|
| 94 | 94 | |
| 95 | 95 | $this->setup_user_name(); |
| 96 | 96 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return object |
| 102 | 102 | */ |
| 103 | 103 | private function get_object() { |
| 104 | - return get_user_by( 'id', $this->ID ); |
|
| 104 | + return get_user_by('id', $this->ID); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | * @return string |
| 156 | 156 | */ |
| 157 | 157 | public function link() { |
| 158 | - if ( ! $this->link ) { |
|
| 159 | - $this->link = get_author_posts_url( $this->ID ); |
|
| 158 | + if (!$this->link) { |
|
| 159 | + $this->link = get_author_posts_url($this->ID); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | return $this->link; |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | private function setup_user_name() { |
| 169 | 169 | $this->name = 'Anonymous'; |
| 170 | - if ( isset( $this->object->first_name ) && isset( $this->object->last_name ) ) { |
|
| 171 | - $this->name = $this->object->first_name . ' ' . $this->object->last_name; |
|
| 170 | + if (isset($this->object->first_name) && isset($this->object->last_name)) { |
|
| 171 | + $this->name = $this->object->first_name.' '.$this->object->last_name; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $this->display_name = $this->object->display_name; |