@@ -54,6 +54,7 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @param string |
| 56 | 56 | * @param string |
| 57 | + * @param string $name |
|
| 57 | 58 | */ |
| 58 | 59 | private function define( $name, $value ) { |
| 59 | 60 | if ( !defined($name) ) { |
@@ -241,7 +242,7 @@ discard block |
||
| 241 | 242 | |
| 242 | 243 | /** |
| 243 | 244 | * @param array $prefs |
| 244 | - * @return array mixed |
|
| 245 | + * @return stdClass mixed |
|
| 245 | 246 | */ |
| 246 | 247 | public static function get_pagination( $prefs = array() ) { |
| 247 | 248 | global $wp_query; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public static function get_instance() { |
| 31 | 31 | |
| 32 | - if ( null === self::$single_instance ) { |
|
| 32 | + if (null === self::$single_instance) { |
|
| 33 | 33 | |
| 34 | 34 | self::$single_instance = new self(); |
| 35 | 35 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $this->init_config(); |
| 58 | 58 | |
| 59 | - add_filter( 'theme_page_templates', array( $this, 'filter_templates' ), 3 ); |
|
| 59 | + add_filter('theme_page_templates', array($this, 'filter_templates'), 3); |
|
| 60 | 60 | |
| 61 | 61 | } |
| 62 | 62 | |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | * @param string |
| 67 | 67 | * @param string |
| 68 | 68 | */ |
| 69 | - private function define( $name, $value ) { |
|
| 69 | + private function define($name, $value) { |
|
| 70 | 70 | |
| 71 | - if ( ! defined( $name ) ) { |
|
| 71 | + if (!defined($name)) { |
|
| 72 | 72 | |
| 73 | - define( $name, $value ); |
|
| 73 | + define($name, $value); |
|
| 74 | 74 | |
| 75 | 75 | } |
| 76 | 76 | |
@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | $theme = wp_get_theme(); |
| 88 | 88 | |
| 89 | - $this->define( 'THEME', $theme->template ); |
|
| 90 | - $this->define( 'THEME_NAME', $theme->get( 'Name' ) ); |
|
| 91 | - $this->define( 'THEME_PATH', get_template_directory() . '/' ); |
|
| 92 | - $this->define( 'THEME_DIR', get_template_directory_uri() . '/' ); |
|
| 93 | - $this->define( 'THEME_VERSION', $theme->get( 'Version' ) ); |
|
| 94 | - $this->define( 'THEME_FRAMEWORK_PATH', THEME_PATH . 'app/' ); |
|
| 95 | - $this->define( 'THEME_FRAMEWORK_DIR', THEME_DIR . 'app/' ); |
|
| 89 | + $this->define('THEME', $theme->template); |
|
| 90 | + $this->define('THEME_NAME', $theme->get('Name')); |
|
| 91 | + $this->define('THEME_PATH', get_template_directory().'/'); |
|
| 92 | + $this->define('THEME_DIR', get_template_directory_uri().'/'); |
|
| 93 | + $this->define('THEME_VERSION', $theme->get('Version')); |
|
| 94 | + $this->define('THEME_FRAMEWORK_PATH', THEME_PATH.'app/'); |
|
| 95 | + $this->define('THEME_FRAMEWORK_DIR', THEME_DIR.'app/'); |
|
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | |
@@ -101,40 +101,40 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | private function include_core_files() { |
| 103 | 103 | |
| 104 | - require_once THEME_PATH . 'vendor/autoload.php'; |
|
| 104 | + require_once THEME_PATH.'vendor/autoload.php'; |
|
| 105 | 105 | |
| 106 | 106 | // Basis Class |
| 107 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-basis.php'; |
|
| 107 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-basis.php'; |
|
| 108 | 108 | |
| 109 | 109 | // Hierarchy |
| 110 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-hierarchy.php'; |
|
| 110 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-hierarchy.php'; |
|
| 111 | 111 | |
| 112 | 112 | // Theme Config |
| 113 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-config.php'; |
|
| 113 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-config.php'; |
|
| 114 | 114 | |
| 115 | 115 | // Scope |
| 116 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-scope.php'; |
|
| 116 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-scope.php'; |
|
| 117 | 117 | |
| 118 | 118 | // View Loader |
| 119 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-view.php'; |
|
| 119 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-view.php'; |
|
| 120 | 120 | |
| 121 | 121 | // Helper functions |
| 122 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-helper.php'; |
|
| 122 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-helper.php'; |
|
| 123 | 123 | |
| 124 | 124 | // Query Helper |
| 125 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-query-helper.php'; |
|
| 125 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-query-helper.php'; |
|
| 126 | 126 | |
| 127 | 127 | // Menu |
| 128 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-menu.php'; |
|
| 128 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-menu.php'; |
|
| 129 | 129 | |
| 130 | 130 | // Menu Item |
| 131 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-menu-item.php'; |
|
| 131 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-menu-item.php'; |
|
| 132 | 132 | |
| 133 | 133 | // Comment |
| 134 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-comment.php'; |
|
| 134 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-comment.php'; |
|
| 135 | 135 | |
| 136 | 136 | // Appearance |
| 137 | - require_once THEME_FRAMEWORK_PATH . 'appearance.php'; |
|
| 137 | + require_once THEME_FRAMEWORK_PATH.'appearance.php'; |
|
| 138 | 138 | |
| 139 | 139 | } |
| 140 | 140 | |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | private function include_models() { |
| 145 | 145 | |
| 146 | - $files = (array) glob( THEME_FRAMEWORK_PATH . '/models/*.php' ); |
|
| 146 | + $files = (array) glob(THEME_FRAMEWORK_PATH.'/models/*.php'); |
|
| 147 | 147 | |
| 148 | - foreach ( $files as $filename ) { |
|
| 148 | + foreach ($files as $filename) { |
|
| 149 | 149 | |
| 150 | - if ( ! empty( $filename ) ) { |
|
| 150 | + if (!empty($filename)) { |
|
| 151 | 151 | |
| 152 | 152 | require_once $filename; |
| 153 | 153 | |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | * @return array |
| 172 | 172 | */ |
| 173 | 173 | |
| 174 | - public function filter_templates( $page_templates = array(), $object = null, $post = null ) { |
|
| 174 | + public function filter_templates($page_templates = array(), $object = null, $post = null) { |
|
| 175 | 175 | |
| 176 | 176 | $custom_templates = ClassyView::get_page_templates_list(); |
| 177 | 177 | |
| 178 | - return array_merge( $page_templates, $custom_templates ); |
|
| 178 | + return array_merge($page_templates, $custom_templates); |
|
| 179 | 179 | |
| 180 | 180 | } |
| 181 | 181 | |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | * @param string $name |
| 186 | 186 | * @return any |
| 187 | 187 | */ |
| 188 | - public static function get_config_var( $name ) { |
|
| 188 | + public static function get_config_var($name) { |
|
| 189 | 189 | |
| 190 | 190 | $vars = ClassyConfig::get_vars(); |
| 191 | 191 | |
| 192 | - if ( isset( $vars[ $name ] ) ) { return $vars[ $name ]; } |
|
| 192 | + if (isset($vars[$name])) { return $vars[$name]; } |
|
| 193 | 193 | |
| 194 | 194 | return false; |
| 195 | 195 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public static function textdomain() { |
| 204 | 204 | |
| 205 | - $textdomain = Classy::get_config_var( 'textdomain' ); |
|
| 205 | + $textdomain = Classy::get_config_var('textdomain'); |
|
| 206 | 206 | |
| 207 | 207 | return $textdomain ? $textdomain : THEME; |
| 208 | 208 | |
@@ -217,17 +217,17 @@ discard block |
||
| 217 | 217 | * @param array|null $data Additional params |
| 218 | 218 | * @return void |
| 219 | 219 | */ |
| 220 | - public static function render( $view = null, $data = null ) { |
|
| 220 | + public static function render($view = null, $data = null) { |
|
| 221 | 221 | |
| 222 | - $views = THEME_PATH . ClassyView::$folder; |
|
| 223 | - $cache = WP_CONTENT_DIR . '/viewcache'; |
|
| 222 | + $views = THEME_PATH.ClassyView::$folder; |
|
| 223 | + $cache = WP_CONTENT_DIR.'/viewcache'; |
|
| 224 | 224 | $common_scope = ClassyScope::get_common_scope(); |
| 225 | 225 | |
| 226 | - if ( null !== $view && is_string( $view ) ) { |
|
| 226 | + if (null !== $view && is_string($view)) { |
|
| 227 | 227 | |
| 228 | - if ( $data && is_array( $data ) ) { |
|
| 228 | + if ($data && is_array($data)) { |
|
| 229 | 229 | |
| 230 | - $scope = array_merge( $common_scope, $data ); |
|
| 230 | + $scope = array_merge($common_scope, $data); |
|
| 231 | 231 | |
| 232 | 232 | } else { |
| 233 | 233 | |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - $renderer = new BladeRenderer( $views, array( 'cache_path' => $cache ) ); |
|
| 245 | + $renderer = new BladeRenderer($views, array('cache_path' => $cache)); |
|
| 246 | 246 | |
| 247 | - echo $renderer->render( $view, $scope ); |
|
| 247 | + echo $renderer->render($view, $scope); |
|
| 248 | 248 | |
| 249 | 249 | } |
| 250 | 250 | |
@@ -269,27 +269,27 @@ discard block |
||
| 269 | 269 | * @param string $return object/id/ClassyPost |
| 270 | 270 | * @return mixed |
| 271 | 271 | */ |
| 272 | - public static function get_posts( $args = false, $return = 'ClassyPost' ) { |
|
| 272 | + public static function get_posts($args = false, $return = 'ClassyPost') { |
|
| 273 | 273 | |
| 274 | 274 | $_return = array(); |
| 275 | 275 | |
| 276 | - $query = ClassyQueryHelper::find_query( $args ); |
|
| 276 | + $query = ClassyQueryHelper::find_query($args); |
|
| 277 | 277 | |
| 278 | - if ( isset( $query->posts ) ) { |
|
| 278 | + if (isset($query->posts)) { |
|
| 279 | 279 | |
| 280 | - foreach ( $query->posts as $post ) { |
|
| 280 | + foreach ($query->posts as $post) { |
|
| 281 | 281 | |
| 282 | - if ( 'id' == $return ) { |
|
| 282 | + if ('id' == $return) { |
|
| 283 | 283 | |
| 284 | 284 | $_return[] = $post->id; |
| 285 | 285 | |
| 286 | - } elseif ( 'object' == $return ) { |
|
| 286 | + } elseif ('object' == $return) { |
|
| 287 | 287 | |
| 288 | 288 | $_return[] = $post; |
| 289 | 289 | |
| 290 | - } elseif ( class_exists( $return ) ) { |
|
| 290 | + } elseif (class_exists($return)) { |
|
| 291 | 291 | |
| 292 | - $_return[] = new $return( $post ); |
|
| 292 | + $_return[] = new $return($post); |
|
| 293 | 293 | |
| 294 | 294 | } |
| 295 | 295 | } |
@@ -306,11 +306,11 @@ discard block |
||
| 306 | 306 | * @param string $return_type ClassyPost/object/id |
| 307 | 307 | * @return mixed |
| 308 | 308 | */ |
| 309 | - public static function get_post( $args = false, $return_type = 'ClassyPost' ) { |
|
| 309 | + public static function get_post($args = false, $return_type = 'ClassyPost') { |
|
| 310 | 310 | |
| 311 | - $posts = self::get_posts( $args, $return_type ); |
|
| 311 | + $posts = self::get_posts($args, $return_type); |
|
| 312 | 312 | |
| 313 | - if ( $post = reset( $posts ) ) { |
|
| 313 | + if ($post = reset($posts)) { |
|
| 314 | 314 | return $post; |
| 315 | 315 | } |
| 316 | 316 | |
@@ -320,62 +320,62 @@ discard block |
||
| 320 | 320 | * @param array $prefs |
| 321 | 321 | * @return array mixed |
| 322 | 322 | */ |
| 323 | - public static function get_pagination( $prefs = array() ) { |
|
| 323 | + public static function get_pagination($prefs = array()) { |
|
| 324 | 324 | |
| 325 | 325 | global $wp_query; |
| 326 | 326 | global $paged; |
| 327 | 327 | global $wp_rewrite; |
| 328 | 328 | |
| 329 | 329 | $args = array(); |
| 330 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
| 330 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
| 331 | 331 | |
| 332 | - if ( $wp_rewrite->using_permalinks() ) { |
|
| 332 | + if ($wp_rewrite->using_permalinks()) { |
|
| 333 | 333 | |
| 334 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
| 334 | + $url = explode('?', get_pagenum_link(0)); |
|
| 335 | 335 | |
| 336 | - if ( isset( $url[1] ) ) { |
|
| 337 | - parse_str( $url[1], $query ); |
|
| 336 | + if (isset($url[1])) { |
|
| 337 | + parse_str($url[1], $query); |
|
| 338 | 338 | $args['add_args'] = $query; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | $args['format'] = 'page/%#%'; |
| 342 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
| 342 | + $args['base'] = trailingslashit($url[0]).'%_%'; |
|
| 343 | 343 | |
| 344 | 344 | } else { |
| 345 | 345 | $big = 999999999; |
| 346 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
| 346 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | $args['type'] = 'array'; |
| 350 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
| 351 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
| 350 | + $args['current'] = max(1, get_query_var('paged')); |
|
| 351 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
| 352 | 352 | $args['prev_next'] = false; |
| 353 | 353 | |
| 354 | - if ( is_int( $prefs ) ) { |
|
| 354 | + if (is_int($prefs)) { |
|
| 355 | 355 | $args['mid_size'] = $prefs - 2; |
| 356 | 356 | } else { |
| 357 | - $args = array_merge( $args, $prefs ); |
|
| 357 | + $args = array_merge($args, $prefs); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | $data = array(); |
| 361 | - $data['pages'] = ClassyHelper::paginate_links( $args ); |
|
| 362 | - $next = get_next_posts_page_link( $args['total'] ); |
|
| 361 | + $data['pages'] = ClassyHelper::paginate_links($args); |
|
| 362 | + $next = get_next_posts_page_link($args['total']); |
|
| 363 | 363 | |
| 364 | - if ( $next ) { |
|
| 365 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
| 364 | + if ($next) { |
|
| 365 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $prev = previous_posts( false ); |
|
| 368 | + $prev = previous_posts(false); |
|
| 369 | 369 | |
| 370 | - if ( $prev ) { |
|
| 371 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
| 370 | + if ($prev) { |
|
| 371 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if ( $paged < 2 ) { |
|
| 374 | + if ($paged < 2) { |
|
| 375 | 375 | $data['prev'] = null; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - return ClassyHelper::array_to_object( $data ); |
|
| 378 | + return ClassyHelper::array_to_object($data); |
|
| 379 | 379 | |
| 380 | 380 | } |
| 381 | 381 | } |
@@ -61,6 +61,9 @@ |
||
| 61 | 61 | $this->init(); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | + /** |
|
| 65 | + * @param integer|null $uid |
|
| 66 | + */ |
|
| 64 | 67 | private function verify_id($uid) { |
| 65 | 68 | return $uid; |
| 66 | 69 | } |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | * Main constructor function. Requires user id |
| 61 | 61 | * @param int $uid |
| 62 | 62 | */ |
| 63 | - public function __construct( $uid = null ) { |
|
| 64 | - $this->ID = $this->verify_id( $uid ); |
|
| 63 | + public function __construct($uid = null) { |
|
| 64 | + $this->ID = $this->verify_id($uid); |
|
| 65 | 65 | |
| 66 | 66 | $this->init(); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - private function verify_id( $uid ) { |
|
| 69 | + private function verify_id($uid) { |
|
| 70 | 70 | return $uid; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -76,10 +76,10 @@ discard block |
||
| 76 | 76 | private function init() { |
| 77 | 77 | $object = (array) $this->get_object(); |
| 78 | 78 | |
| 79 | - $this->import( $object ); |
|
| 79 | + $this->import($object); |
|
| 80 | 80 | |
| 81 | - if ( isset( $this->first_name ) && isset( $this->last_name ) ) { |
|
| 82 | - $this->name = $this->first_name . ' ' . $this->last_name; |
|
| 81 | + if (isset($this->first_name) && isset($this->last_name)) { |
|
| 82 | + $this->name = $this->first_name.' '.$this->last_name; |
|
| 83 | 83 | } else { |
| 84 | 84 | $this->name = 'Anonymous'; |
| 85 | 85 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @return object |
| 93 | 93 | */ |
| 94 | 94 | private function get_object() { |
| 95 | - return get_userdata( $this->ID ); |
|
| 95 | + return get_userdata($this->ID); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | * @return string |
| 157 | 157 | */ |
| 158 | 158 | public function link() { |
| 159 | - if ( ! $this->link ) { |
|
| 160 | - $this->link = get_author_posts_url( $this->ID ); |
|
| 159 | + if (!$this->link) { |
|
| 160 | + $this->link = get_author_posts_url($this->ID); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | return $this->link; |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | /** |
| 63 | 63 | * Returns ClassyUser object of comment author |
| 64 | 64 | * |
| 65 | - * @return object ClassyUser |
|
| 65 | + * @return ClassyUser ClassyUser |
|
| 66 | 66 | */ |
| 67 | 67 | public function author() { |
| 68 | 68 | |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param WP_Comment $item |
| 51 | 51 | */ |
| 52 | - public function __construct( $item ) { |
|
| 52 | + public function __construct($item) { |
|
| 53 | 53 | |
| 54 | - if ( is_a( $item, 'WP_Comment' ) ) { |
|
| 54 | + if (is_a($item, 'WP_Comment')) { |
|
| 55 | 55 | |
| 56 | - $this->import( $item ); |
|
| 56 | + $this->import($item); |
|
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function author() { |
| 68 | 68 | |
| 69 | - if ( $this->user_id ) { |
|
| 69 | + if ($this->user_id) { |
|
| 70 | 70 | |
| 71 | - return new ClassyUser( $this->user_id ); |
|
| 71 | + return new ClassyUser($this->user_id); |
|
| 72 | 72 | |
| 73 | 73 | } else { |
| 74 | 74 | |
| 75 | - $author = new ClassyUser( 0 ); |
|
| 75 | + $author = new ClassyUser(0); |
|
| 76 | 76 | |
| 77 | - if ( isset( $this->comment_author ) && $this->comment_author ) { |
|
| 77 | + if (isset($this->comment_author) && $this->comment_author) { |
|
| 78 | 78 | |
| 79 | 79 | $author->name = $this->comment_author; |
| 80 | 80 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @return string |
| 92 | 92 | */ |
| 93 | 93 | public function content() { |
| 94 | - return apply_filters( 'get_comment_text ', $this->comment_content ); |
|
| 94 | + return apply_filters('get_comment_text ', $this->comment_content); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | * @param string $date_format |
| 110 | 110 | * @return string |
| 111 | 111 | */ |
| 112 | - public function date( $date_format = '' ) { |
|
| 113 | - $df = $date_format ? $date_format : get_option( 'date_format' ); |
|
| 114 | - $the_date = (string) mysql2date( $df, $this->comment_date ); |
|
| 112 | + public function date($date_format = '') { |
|
| 113 | + $df = $date_format ? $date_format : get_option('date_format'); |
|
| 114 | + $the_date = (string) mysql2date($df, $this->comment_date); |
|
| 115 | 115 | |
| 116 | - return apply_filters( 'get_comment_date ', $the_date, $df ); |
|
| 116 | + return apply_filters('get_comment_date ', $the_date, $df); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -132,26 +132,26 @@ discard block |
||
| 132 | 132 | * @param string $default |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public function avatar( $size = 92, $default = '' ) { |
|
| 135 | + public function avatar($size = 92, $default = '') { |
|
| 136 | 136 | |
| 137 | - if ( ! get_option( 'show_avatars' ) ) { |
|
| 137 | + if (!get_option('show_avatars')) { |
|
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( ! is_numeric( $size ) ) { $size = '92'; } |
|
| 141 | + if (!is_numeric($size)) { $size = '92'; } |
|
| 142 | 142 | |
| 143 | 143 | $email = $this->get_avatar_email(); |
| 144 | 144 | $email_hash = ''; |
| 145 | 145 | |
| 146 | - if ( ! empty( $email ) ) { |
|
| 147 | - $email_hash = md5( strtolower( trim( $email ) ) ); |
|
| 146 | + if (!empty($email)) { |
|
| 147 | + $email_hash = md5(strtolower(trim($email))); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $host = $this->get_avatar_host( $email_hash ); |
|
| 151 | - $default = $this->get_default_avatar( $default, $email, $size, $host ); |
|
| 150 | + $host = $this->get_avatar_host($email_hash); |
|
| 151 | + $default = $this->get_default_avatar($default, $email, $size, $host); |
|
| 152 | 152 | |
| 153 | - if ( ! empty( $email ) ) { |
|
| 154 | - $avatar = $this->get_avatar_url( $default, $host, $email_hash, $size ); |
|
| 153 | + if (!empty($email)) { |
|
| 154 | + $avatar = $this->get_avatar_url($default, $host, $email_hash, $size); |
|
| 155 | 155 | } else { |
| 156 | 156 | $avatar = $default; |
| 157 | 157 | } |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | protected function get_avatar_email() { |
| 169 | 169 | |
| 170 | 170 | $id = (int) $this->user_id; |
| 171 | - $user = get_userdata( $id ); |
|
| 171 | + $user = get_userdata($id); |
|
| 172 | 172 | |
| 173 | - if ( $user ) { |
|
| 173 | + if ($user) { |
|
| 174 | 174 | $email = $user->user_email; |
| 175 | 175 | } else { |
| 176 | 176 | $email = $this->comment_author_email; |
@@ -189,32 +189,32 @@ discard block |
||
| 189 | 189 | * @param string $host |
| 190 | 190 | * @return string |
| 191 | 191 | */ |
| 192 | - protected function get_default_avatar( $default, $email, $size, $host ) { |
|
| 192 | + protected function get_default_avatar($default, $email, $size, $host) { |
|
| 193 | 193 | |
| 194 | - if ( substr( $default, 0, 1 ) == '/' ) { |
|
| 195 | - $default = home_url() . $default; |
|
| 194 | + if (substr($default, 0, 1) == '/') { |
|
| 195 | + $default = home_url().$default; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if ( empty( $default ) ) { |
|
| 199 | - $avatar_default = get_option( 'avatar_default' ); |
|
| 200 | - if ( empty( $avatar_default ) ) { |
|
| 198 | + if (empty($default)) { |
|
| 199 | + $avatar_default = get_option('avatar_default'); |
|
| 200 | + if (empty($avatar_default)) { |
|
| 201 | 201 | $default = 'mystery'; |
| 202 | 202 | } else { |
| 203 | 203 | $default = $avatar_default; |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( 'mystery' == $default ) { |
|
| 208 | - $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
|
| 207 | + if ('mystery' == $default) { |
|
| 208 | + $default = $host.'/avatar/ad516503a11cd5ca435acc9bb6523536?s='.$size; |
|
| 209 | 209 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
| 210 | - } else if ( 'blank' == $default ) { |
|
| 211 | - $default = $email ? 'blank' : includes_url( 'images/blank.gif' ); |
|
| 212 | - } else if ( ! empty( $email ) && 'gravatar_default' == $default ) { |
|
| 210 | + } else if ('blank' == $default) { |
|
| 211 | + $default = $email ? 'blank' : includes_url('images/blank.gif'); |
|
| 212 | + } else if (!empty($email) && 'gravatar_default' == $default) { |
|
| 213 | 213 | $default = ''; |
| 214 | - } else if ( 'gravatar_default' == $default ) { |
|
| 215 | - $default = $host . '/avatar/?s=' . $size; |
|
| 216 | - } else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
| 217 | - $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
|
| 214 | + } else if ('gravatar_default' == $default) { |
|
| 215 | + $default = $host.'/avatar/?s='.$size; |
|
| 216 | + } else if (empty($email) && !strstr($default, 'http://')) { |
|
| 217 | + $default = $host.'/avatar/?d='.$default.'&s='.$size; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | return $default; |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | * @param string $email_hash |
| 228 | 228 | * @return string |
| 229 | 229 | */ |
| 230 | - protected function get_avatar_host( $email_hash ) { |
|
| 230 | + protected function get_avatar_host($email_hash) { |
|
| 231 | 231 | |
| 232 | - if ( is_ssl() ) { |
|
| 232 | + if (is_ssl()) { |
|
| 233 | 233 | $host = 'https://secure.gravatar.com'; |
| 234 | 234 | } else { |
| 235 | - if ( ! empty( $email_hash ) ) { |
|
| 236 | - $host = sprintf( 'http://%d.gravatar.com', (hexdec( $email_hash[0] ) % 2) ); |
|
| 235 | + if (!empty($email_hash)) { |
|
| 236 | + $host = sprintf('http://%d.gravatar.com', (hexdec($email_hash[0]) % 2)); |
|
| 237 | 237 | } else { |
| 238 | 238 | $host = 'http://0.gravatar.com'; |
| 239 | 239 | } |
@@ -252,16 +252,16 @@ discard block |
||
| 252 | 252 | * @param int $size |
| 253 | 253 | * @return string |
| 254 | 254 | */ |
| 255 | - protected function get_avatar_url( $default, $host, $email_hash, $size ) { |
|
| 255 | + protected function get_avatar_url($default, $host, $email_hash, $size) { |
|
| 256 | 256 | |
| 257 | - $_return = $host . '/avatar/' . $email_hash . '?s=' . $size . '&d=' . urlencode( $default ); |
|
| 258 | - $rating = get_option( 'avatar_rating' ); |
|
| 257 | + $_return = $host.'/avatar/'.$email_hash.'?s='.$size.'&d='.urlencode($default); |
|
| 258 | + $rating = get_option('avatar_rating'); |
|
| 259 | 259 | |
| 260 | - if ( ! empty( $rating ) ) { |
|
| 261 | - $_return .= '&r=' . $rating; |
|
| 260 | + if (!empty($rating)) { |
|
| 261 | + $_return .= '&r='.$rating; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - return str_replace( '&', '&', esc_url( $_return ) ); |
|
| 264 | + return str_replace('&', '&', esc_url($_return)); |
|
| 265 | 265 | |
| 266 | 266 | } |
| 267 | 267 | |
@@ -270,12 +270,12 @@ discard block |
||
| 270 | 270 | * |
| 271 | 271 | * @param ClassyComment $comment |
| 272 | 272 | */ |
| 273 | - public function add_child( $comment ) { |
|
| 273 | + public function add_child($comment) { |
|
| 274 | 274 | |
| 275 | 275 | $this->children[] = $item; |
| 276 | 276 | $item->level = $this->level + 1; |
| 277 | 277 | |
| 278 | - if ( $item->children ) { |
|
| 278 | + if ($item->children) { |
|
| 279 | 279 | $this->update_child_levels(); |
| 280 | 280 | } |
| 281 | 281 | |
@@ -289,9 +289,9 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | protected function update_child_levels() { |
| 291 | 291 | |
| 292 | - if ( is_array( $this->children ) ) { |
|
| 292 | + if (is_array($this->children)) { |
|
| 293 | 293 | |
| 294 | - foreach ( $this->children as $child ) { |
|
| 294 | + foreach ($this->children as $child) { |
|
| 295 | 295 | $child->level = $this->level + 1; |
| 296 | 296 | $child->update_child_levels(); |
| 297 | 297 | } |
@@ -43,6 +43,7 @@ |
||
| 43 | 43 | /** |
| 44 | 44 | * Extends Scope with scope that is defined in theme_name/scope folder |
| 45 | 45 | * |
| 46 | + * @param string|false $view_name |
|
| 46 | 47 | * @return array |
| 47 | 48 | */ |
| 48 | 49 | public static function extend_scope($scope, $view_name) { |
@@ -16,21 +16,21 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @return array |
| 18 | 18 | */ |
| 19 | - public static function get_scope( $view_name = null ) { |
|
| 19 | + public static function get_scope($view_name = null) { |
|
| 20 | 20 | |
| 21 | 21 | $scope = self::get_common_scope(); |
| 22 | 22 | |
| 23 | - if ( is_string( $view_name ) ) { |
|
| 23 | + if (is_string($view_name)) { |
|
| 24 | 24 | |
| 25 | - $scope = self::extend_scope( $scope, $view_name ); |
|
| 25 | + $scope = self::extend_scope($scope, $view_name); |
|
| 26 | 26 | |
| 27 | 27 | } else { |
| 28 | 28 | |
| 29 | 29 | $request = ClassyHierarchy::get_current_request(); |
| 30 | 30 | |
| 31 | - $file = ClassyHierarchy::get_available_file( 'scope', $request ); |
|
| 31 | + $file = ClassyHierarchy::get_available_file('scope', $request); |
|
| 32 | 32 | |
| 33 | - $scope = self::extend_scope( $scope, $file ); |
|
| 33 | + $scope = self::extend_scope($scope, $file); |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return array |
| 46 | 46 | */ |
| 47 | - public static function extend_scope( $scope, $view_name ) { |
|
| 47 | + public static function extend_scope($scope, $view_name) { |
|
| 48 | 48 | |
| 49 | - $scope = array_merge( $scope, self::require_scope( $view_name ) ); |
|
| 49 | + $scope = array_merge($scope, self::require_scope($view_name)); |
|
| 50 | 50 | |
| 51 | 51 | return $scope; |
| 52 | 52 | |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public static function get_common_scope() { |
| 62 | 62 | |
| 63 | - if ( null === self::$common ) { |
|
| 63 | + if (null === self::$common) { |
|
| 64 | 64 | |
| 65 | - self::$common = self::require_scope( 'common' ); |
|
| 65 | + self::$common = self::require_scope('common'); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
@@ -76,19 +76,19 @@ discard block |
||
| 76 | 76 | * @param string $filename |
| 77 | 77 | * @return array |
| 78 | 78 | */ |
| 79 | - public static function require_scope( $filename ) { |
|
| 79 | + public static function require_scope($filename) { |
|
| 80 | 80 | |
| 81 | 81 | $_return = array(); |
| 82 | 82 | |
| 83 | - $file = ClassyHierarchy::get_file_path( 'scope', $filename ); |
|
| 83 | + $file = ClassyHierarchy::get_file_path('scope', $filename); |
|
| 84 | 84 | |
| 85 | - if ( file_exists( $file ) ) { |
|
| 85 | + if (file_exists($file)) { |
|
| 86 | 86 | |
| 87 | 87 | require $file; |
| 88 | 88 | |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if ( isset( $data ) ) { |
|
| 91 | + if (isset($data)) { |
|
| 92 | 92 | |
| 93 | 93 | $_return = $data; |
| 94 | 94 | |
@@ -1,1 +1,1 @@ |
||
| 1 | -<?php Classy::render( 'layout.footer' ); ?> |
|
| 2 | 1 | \ No newline at end of file |
| 2 | +<?php Classy::render('layout.footer'); ?> |
|
| 3 | 3 | \ No newline at end of file |
@@ -8,23 +8,23 @@ discard block |
||
| 8 | 8 | * @param array/boolean $args |
| 9 | 9 | * @return object WP_Query |
| 10 | 10 | */ |
| 11 | - public static function find_query( $args = false ) { |
|
| 11 | + public static function find_query($args = false) { |
|
| 12 | 12 | |
| 13 | 13 | $default_args = array(); |
| 14 | 14 | |
| 15 | - if ( ! $args ) { |
|
| 15 | + if (!$args) { |
|
| 16 | 16 | |
| 17 | 17 | return self::get_current_query(); |
| 18 | 18 | |
| 19 | - } elseif ( is_array( $args ) ) { |
|
| 19 | + } elseif (is_array($args)) { |
|
| 20 | 20 | |
| 21 | - $args = array_merge( $default_args, $args ); |
|
| 21 | + $args = array_merge($default_args, $args); |
|
| 22 | 22 | |
| 23 | - return new WP_Query( $args ); |
|
| 23 | + return new WP_Query($args); |
|
| 24 | 24 | |
| 25 | 25 | } else { |
| 26 | 26 | |
| 27 | - return new WP_Query( $default_args ); |
|
| 27 | + return new WP_Query($default_args); |
|
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | global $wp_query; |
| 40 | 40 | |
| 41 | - $query =& $wp_query; |
|
| 41 | + $query = & $wp_query; |
|
| 42 | 42 | |
| 43 | - $query = self::handle_maybe_custom_posts_page( $query ); |
|
| 43 | + $query = self::handle_maybe_custom_posts_page($query); |
|
| 44 | 44 | |
| 45 | 45 | return $query; |
| 46 | 46 | |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | * @param object $query WP_Query |
| 53 | 53 | * @return object WP_Query |
| 54 | 54 | */ |
| 55 | - private static function handle_maybe_custom_posts_page( $query ) { |
|
| 55 | + private static function handle_maybe_custom_posts_page($query) { |
|
| 56 | 56 | |
| 57 | - if ( $custom_posts_page = get_option( 'page_for_posts' ) ) { |
|
| 57 | + if ($custom_posts_page = get_option('page_for_posts')) { |
|
| 58 | 58 | |
| 59 | - if ( isset( $query->query['p'] ) && $query->query['p'] == $custom_posts_page ) { |
|
| 59 | + if (isset($query->query['p']) && $query->query['p'] == $custom_posts_page) { |
|
| 60 | 60 | |
| 61 | - return new WP_Query( array( 'post_type' => 'post' ) ); |
|
| 61 | + return new WP_Query(array('post_type' => 'post')); |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -15,44 +15,44 @@ discard block |
||
| 15 | 15 | * @param string $allowed_tags |
| 16 | 16 | * @return string |
| 17 | 17 | */ |
| 18 | - public static function trim_words( $text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote' ) { |
|
| 19 | - if ( null === $more ) { |
|
| 20 | - $more = __( '…' ); |
|
| 18 | + public static function trim_words($text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote') { |
|
| 19 | + if (null === $more) { |
|
| 20 | + $more = __('…'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | $original_text = $text; |
| 24 | 24 | $allowed_tag_string = ''; |
| 25 | 25 | |
| 26 | - foreach ( explode( ' ', $allowed_tags ) as $tag ) { |
|
| 27 | - $allowed_tag_string .= '<' . $tag . '>'; |
|
| 26 | + foreach (explode(' ', $allowed_tags) as $tag) { |
|
| 27 | + $allowed_tag_string .= '<'.$tag.'>'; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - $text = strip_tags( $text, $allowed_tag_string ); |
|
| 30 | + $text = strip_tags($text, $allowed_tag_string); |
|
| 31 | 31 | |
| 32 | 32 | /* translators: If your word count is based on single characters (East Asian characters), |
| 33 | 33 | enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */ |
| 34 | 34 | |
| 35 | - if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { |
|
| 36 | - $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); |
|
| 37 | - preg_match_all( '/./u', $text, $words_array ); |
|
| 38 | - $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
|
| 35 | + if ('characters' == _x('words', 'word count: words or characters?') && preg_match('/^utf\-?8$/i', get_option('blog_charset'))) { |
|
| 36 | + $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); |
|
| 37 | + preg_match_all('/./u', $text, $words_array); |
|
| 38 | + $words_array = array_slice($words_array[0], 0, $num_words + 1); |
|
| 39 | 39 | $sep = ''; |
| 40 | 40 | } else { |
| 41 | - $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|
| 41 | + $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); |
|
| 42 | 42 | $sep = ' '; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if ( count( $words_array ) > $num_words ) { |
|
| 46 | - array_pop( $words_array ); |
|
| 47 | - $text = implode( $sep, $words_array ); |
|
| 48 | - $text = $text . $more; |
|
| 45 | + if (count($words_array) > $num_words) { |
|
| 46 | + array_pop($words_array); |
|
| 47 | + $text = implode($sep, $words_array); |
|
| 48 | + $text = $text.$more; |
|
| 49 | 49 | } else { |
| 50 | - $text = implode( $sep, $words_array ); |
|
| 50 | + $text = implode($sep, $words_array); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $text = self::close_tags( $text ); |
|
| 53 | + $text = self::close_tags($text); |
|
| 54 | 54 | |
| 55 | - return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); |
|
| 55 | + return apply_filters('wp_trim_words', $text, $num_words, $more, $original_text); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | |
@@ -62,36 +62,36 @@ discard block |
||
| 62 | 62 | * @param string $html |
| 63 | 63 | * @return string |
| 64 | 64 | */ |
| 65 | - public static function close_tags( $html ) { |
|
| 65 | + public static function close_tags($html) { |
|
| 66 | 66 | //put all opened tags into an array |
| 67 | - preg_match_all( '#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result ); |
|
| 67 | + preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result); |
|
| 68 | 68 | |
| 69 | 69 | $openedtags = $result[1]; |
| 70 | 70 | |
| 71 | 71 | //put all closed tags into an array |
| 72 | - preg_match_all( '#</([a-z]+)>#iU', $html, $result ); |
|
| 72 | + preg_match_all('#</([a-z]+)>#iU', $html, $result); |
|
| 73 | 73 | |
| 74 | 74 | $closedtags = $result[1]; |
| 75 | - $len_opened = count( $openedtags ); |
|
| 75 | + $len_opened = count($openedtags); |
|
| 76 | 76 | |
| 77 | 77 | // all tags are closed |
| 78 | - if ( count( $closedtags ) == $len_opened ) { |
|
| 78 | + if (count($closedtags) == $len_opened) { |
|
| 79 | 79 | return $html; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $openedtags = array_reverse( $openedtags ); |
|
| 82 | + $openedtags = array_reverse($openedtags); |
|
| 83 | 83 | |
| 84 | 84 | // close tags |
| 85 | - for ( $i = 0; $i < $len_opened; $i++ ) { |
|
| 86 | - if ( ! in_array( $openedtags[ $i ], $closedtags ) ) { |
|
| 87 | - $html .= '</' . $openedtags[ $i ] . '>'; |
|
| 85 | + for ($i = 0; $i < $len_opened; $i++) { |
|
| 86 | + if (!in_array($openedtags[$i], $closedtags)) { |
|
| 87 | + $html .= '</'.$openedtags[$i].'>'; |
|
| 88 | 88 | } else { |
| 89 | - unset( $closedtags[ array_search( $openedtags[ $i ], $closedtags ) ] ); |
|
| 89 | + unset($closedtags[array_search($openedtags[$i], $closedtags)]); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $html = str_replace( array( '</br>', '</hr>', '</wbr>' ), '', $html ); |
|
| 94 | - $html = str_replace( array( '<br>', '<hr>', '<wbr>' ), array( '<br />', '<hr />', '<wbr />' ), $html ); |
|
| 93 | + $html = str_replace(array('</br>', '</hr>', '</wbr>'), '', $html); |
|
| 94 | + $html = str_replace(array('<br>', '<hr>', '<wbr>'), array('<br />', '<hr />', '<wbr />'), $html); |
|
| 95 | 95 | |
| 96 | 96 | return $html; |
| 97 | 97 | } |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @param mixed $arg |
| 103 | 103 | */ |
| 104 | - public static function error_log( $arg ) { |
|
| 105 | - if ( ! WP_DEBUG ) { |
|
| 104 | + public static function error_log($arg) { |
|
| 105 | + if (!WP_DEBUG) { |
|
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | - if ( is_object( $arg ) || is_array( $arg ) ) { |
|
| 109 | - $arg = print_r( $arg, true ); |
|
| 108 | + if (is_object($arg) || is_array($arg)) { |
|
| 109 | + $arg = print_r($arg, true); |
|
| 110 | 110 | } |
| 111 | - return error_log( $arg ); |
|
| 111 | + return error_log($arg); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @param string $args |
| 118 | 118 | * @return array |
| 119 | 119 | */ |
| 120 | - public static function paginate_links( $args = '' ) { |
|
| 120 | + public static function paginate_links($args = '') { |
|
| 121 | 121 | $defaults = array( |
| 122 | 122 | 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below) |
| 123 | 123 | 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number |
@@ -125,43 +125,43 @@ discard block |
||
| 125 | 125 | 'current' => 0, |
| 126 | 126 | 'show_all' => false, |
| 127 | 127 | 'prev_next' => true, |
| 128 | - 'prev_text' => __( '« Previous' ), |
|
| 129 | - 'next_text' => __( 'Next »' ), |
|
| 128 | + 'prev_text' => __('« Previous'), |
|
| 129 | + 'next_text' => __('Next »'), |
|
| 130 | 130 | 'end_size' => 1, |
| 131 | 131 | 'mid_size' => 2, |
| 132 | 132 | 'type' => 'array', |
| 133 | 133 | 'add_args' => false, // array of query args to add |
| 134 | 134 | 'add_fragment' => '', |
| 135 | 135 | ); |
| 136 | - $args = wp_parse_args( $args, $defaults ); |
|
| 136 | + $args = wp_parse_args($args, $defaults); |
|
| 137 | 137 | // Who knows what else people pass in $args |
| 138 | - $args['total'] = intval( (int) $args['total'] ); |
|
| 139 | - if ( $args['total'] < 2 ) { |
|
| 138 | + $args['total'] = intval((int) $args['total']); |
|
| 139 | + if ($args['total'] < 2) { |
|
| 140 | 140 | return array(); |
| 141 | 141 | } |
| 142 | 142 | $args['current'] = (int) $args['current']; |
| 143 | 143 | $args['end_size'] = 0 < (int) $args['end_size'] ? (int) $args['end_size'] : 1; // Out of bounds? Make it the default. |
| 144 | 144 | $args['mid_size'] = 0 <= (int) $args['mid_size'] ? (int) $args['mid_size'] : 2; |
| 145 | - $args['add_args'] = is_array( $args['add_args'] ) ? $args['add_args'] : false; |
|
| 145 | + $args['add_args'] = is_array($args['add_args']) ? $args['add_args'] : false; |
|
| 146 | 146 | $page_links = array(); |
| 147 | 147 | $dots = false; |
| 148 | - if ( $args['prev_next'] && $args['current'] && 1 < $args['current'] ) { |
|
| 149 | - $link = str_replace( '%_%', 2 == $args['current'] ? '' : $args['format'], $args['base'] ); |
|
| 150 | - $link = str_replace( '%#%', $args['current'] - 1, $link ); |
|
| 151 | - if ( $args['add_args'] ) { |
|
| 152 | - $link = add_query_arg( $args['add_args'], $link ); |
|
| 148 | + if ($args['prev_next'] && $args['current'] && 1 < $args['current']) { |
|
| 149 | + $link = str_replace('%_%', 2 == $args['current'] ? '' : $args['format'], $args['base']); |
|
| 150 | + $link = str_replace('%#%', $args['current'] - 1, $link); |
|
| 151 | + if ($args['add_args']) { |
|
| 152 | + $link = add_query_arg($args['add_args'], $link); |
|
| 153 | 153 | } |
| 154 | 154 | $link .= $args['add_fragment']; |
| 155 | - $link = untrailingslashit( $link ); |
|
| 155 | + $link = untrailingslashit($link); |
|
| 156 | 156 | $page_links[] = array( |
| 157 | 157 | 'class' => 'prev page-numbers', |
| 158 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
| 158 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
| 159 | 159 | 'title' => $args['prev_text'], |
| 160 | 160 | ); |
| 161 | 161 | } |
| 162 | - for ( $n = 1; $n <= $args['total']; $n++ ) { |
|
| 163 | - $n_display = number_format_i18n( $n ); |
|
| 164 | - if ( $n == $args['current'] ) { |
|
| 162 | + for ($n = 1; $n <= $args['total']; $n++) { |
|
| 163 | + $n_display = number_format_i18n($n); |
|
| 164 | + if ($n == $args['current']) { |
|
| 165 | 165 | $page_links[] = array( |
| 166 | 166 | 'class' => 'page-number page-numbers current', |
| 167 | 167 | 'title' => $n_display, |
@@ -171,42 +171,42 @@ discard block |
||
| 171 | 171 | ); |
| 172 | 172 | $dots = true; |
| 173 | 173 | } else { |
| 174 | - if ( $args['show_all'] || ( $n <= $args['end_size'] || ( $args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size'] ) || $n > $args['total'] - $args['end_size'] ) ) { |
|
| 175 | - $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] ); |
|
| 176 | - $link = str_replace( '%#%', $n, $link ); |
|
| 177 | - $link = trailingslashit( $link ) . ltrim( $args['add_fragment'], '/' ); |
|
| 178 | - if ( $args['add_args'] ) { |
|
| 179 | - $link = rtrim( add_query_arg( $args['add_args'], $link ), '/' ); |
|
| 174 | + if ($args['show_all'] || ($n <= $args['end_size'] || ($args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size']) || $n > $args['total'] - $args['end_size'])) { |
|
| 175 | + $link = str_replace('%_%', 1 == $n ? '' : $args['format'], $args['base']); |
|
| 176 | + $link = str_replace('%#%', $n, $link); |
|
| 177 | + $link = trailingslashit($link).ltrim($args['add_fragment'], '/'); |
|
| 178 | + if ($args['add_args']) { |
|
| 179 | + $link = rtrim(add_query_arg($args['add_args'], $link), '/'); |
|
| 180 | 180 | } |
| 181 | - $link = str_replace( ' ', '+', $link ); |
|
| 182 | - $link = untrailingslashit( $link ); |
|
| 181 | + $link = str_replace(' ', '+', $link); |
|
| 182 | + $link = untrailingslashit($link); |
|
| 183 | 183 | $page_links[] = array( |
| 184 | 184 | 'class' => 'page-number page-numbers', |
| 185 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
| 185 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
| 186 | 186 | 'title' => $n_display, |
| 187 | 187 | 'name' => $n_display, |
| 188 | 188 | 'current' => $args['current'] == $n, |
| 189 | 189 | ); |
| 190 | 190 | $dots = true; |
| 191 | - } elseif ( $dots && ! $args['show_all'] ) { |
|
| 191 | + } elseif ($dots && !$args['show_all']) { |
|
| 192 | 192 | $page_links[] = array( |
| 193 | 193 | 'class' => 'dots', |
| 194 | - 'title' => __( '…' ), |
|
| 194 | + 'title' => __('…'), |
|
| 195 | 195 | ); |
| 196 | 196 | $dots = false; |
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | - if ( $args['prev_next'] && $args['current'] && ( $args['current'] < $args['total'] || -1 == $args['total'] ) ) { |
|
| 201 | - $link = str_replace( '%_%', $args['format'], $args['base'] ); |
|
| 202 | - $link = str_replace( '%#%', $args['current'] + 1, $link ); |
|
| 203 | - if ( $args['add_args'] ) { |
|
| 204 | - $link = add_query_arg( $args['add_args'], $link ); |
|
| 200 | + if ($args['prev_next'] && $args['current'] && ($args['current'] < $args['total'] || -1 == $args['total'])) { |
|
| 201 | + $link = str_replace('%_%', $args['format'], $args['base']); |
|
| 202 | + $link = str_replace('%#%', $args['current'] + 1, $link); |
|
| 203 | + if ($args['add_args']) { |
|
| 204 | + $link = add_query_arg($args['add_args'], $link); |
|
| 205 | 205 | } |
| 206 | - $link = untrailingslashit( trailingslashit( $link ) . $args['add_fragment'] ); |
|
| 206 | + $link = untrailingslashit(trailingslashit($link).$args['add_fragment']); |
|
| 207 | 207 | $page_links[] = array( |
| 208 | 208 | 'class' => 'next page-numbers', |
| 209 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
| 209 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
| 210 | 210 | 'title' => $args['next_text'], |
| 211 | 211 | ); |
| 212 | 212 | } |
@@ -220,13 +220,13 @@ discard block |
||
| 220 | 220 | * @param array $array |
| 221 | 221 | * @return object |
| 222 | 222 | */ |
| 223 | - public static function array_to_object( $array ) { |
|
| 223 | + public static function array_to_object($array) { |
|
| 224 | 224 | $obj = new stdClass; |
| 225 | 225 | |
| 226 | - foreach ( $array as $k => $v ) { |
|
| 227 | - if ( strlen( $k ) ) { |
|
| 228 | - if ( is_array( $v ) ) { |
|
| 229 | - $obj->{$k} = self::array_to_object( $v ); //RECURSION |
|
| 226 | + foreach ($array as $k => $v) { |
|
| 227 | + if (strlen($k)) { |
|
| 228 | + if (is_array($v)) { |
|
| 229 | + $obj->{$k} = self::array_to_object($v); //RECURSION |
|
| 230 | 230 | } else { |
| 231 | 231 | $obj->{$k} = $v; |
| 232 | 232 | } |
@@ -249,42 +249,42 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | $archives_title = ''; |
| 251 | 251 | |
| 252 | - if ( is_category() ) { |
|
| 252 | + if (is_category()) { |
|
| 253 | 253 | |
| 254 | - $archives_title = single_cat_title( '', false ); |
|
| 254 | + $archives_title = single_cat_title('', false); |
|
| 255 | 255 | |
| 256 | - } else if ( is_tag() ) { |
|
| 256 | + } else if (is_tag()) { |
|
| 257 | 257 | |
| 258 | - $archives_title = 'Tag: ' . single_tag_title( '', false ); |
|
| 258 | + $archives_title = 'Tag: '.single_tag_title('', false); |
|
| 259 | 259 | |
| 260 | - } else if ( is_author() ) { |
|
| 260 | + } else if (is_author()) { |
|
| 261 | 261 | |
| 262 | - if ( have_posts() ) { |
|
| 262 | + if (have_posts()) { |
|
| 263 | 263 | |
| 264 | 264 | the_post(); |
| 265 | - $archives_title = 'Author: ' . get_the_author(); |
|
| 265 | + $archives_title = 'Author: '.get_the_author(); |
|
| 266 | 266 | |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | rewind_posts(); |
| 270 | 270 | |
| 271 | - } else if ( is_search() ) { |
|
| 271 | + } else if (is_search()) { |
|
| 272 | 272 | |
| 273 | - $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
|
| 273 | + $archives_title = sprintf(__('Search Results for: %s', $textdomain), '<span>'.get_search_query().'</span>'); |
|
| 274 | 274 | |
| 275 | - } else if ( is_archive() ) { |
|
| 275 | + } else if (is_archive()) { |
|
| 276 | 276 | |
| 277 | - if ( is_day() ) { |
|
| 277 | + if (is_day()) { |
|
| 278 | 278 | |
| 279 | 279 | $archives_title = get_the_date(); |
| 280 | 280 | |
| 281 | - } elseif ( is_month() ) { |
|
| 281 | + } elseif (is_month()) { |
|
| 282 | 282 | |
| 283 | - $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
|
| 283 | + $archives_title = get_the_date(_x('F Y', 'monthly archives date format', $textdomain)); |
|
| 284 | 284 | |
| 285 | - } elseif ( is_year() ) { |
|
| 285 | + } elseif (is_year()) { |
|
| 286 | 286 | |
| 287 | - $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
|
| 287 | + $archives_title = get_the_date(_x('Y', 'yearly archives date format', $textdomain)); |
|
| 288 | 288 | |
| 289 | 289 | } else { |
| 290 | 290 | |
@@ -12,23 +12,23 @@ |
||
| 12 | 12 | * @param object/array $data |
| 13 | 13 | * @return void |
| 14 | 14 | */ |
| 15 | - protected function import( $data ) { |
|
| 15 | + protected function import($data) { |
|
| 16 | 16 | |
| 17 | - if ( is_object( $data ) ) { |
|
| 17 | + if (is_object($data)) { |
|
| 18 | 18 | |
| 19 | - $data = get_object_vars( $data ); |
|
| 19 | + $data = get_object_vars($data); |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if ( is_array( $data ) ) { |
|
| 23 | + if (is_array($data)) { |
|
| 24 | 24 | |
| 25 | - foreach ( $data as $key => $value ) { |
|
| 25 | + foreach ($data as $key => $value) { |
|
| 26 | 26 | |
| 27 | - if ( ! empty( $key ) ) { |
|
| 27 | + if (!empty($key)) { |
|
| 28 | 28 | |
| 29 | 29 | $this->$key = $value; |
| 30 | 30 | |
| 31 | - } else if ( ! empty( $key ) && ! method_exists( $this, $key ) ) { |
|
| 31 | + } else if (!empty($key) && !method_exists($this, $key)) { |
|
| 32 | 32 | |
| 33 | 33 | $this->$key = $value; |
| 34 | 34 | |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | $request = ClassyHierarchy::get_current_request(); |
| 25 | 25 | |
| 26 | - $file = ClassyHierarchy::get_available_file( 'view', $request ); |
|
| 26 | + $file = ClassyHierarchy::get_available_file('view', $request); |
|
| 27 | 27 | |
| 28 | - $view = self::get_blade_view( $file ); |
|
| 28 | + $view = self::get_blade_view($file); |
|
| 29 | 29 | |
| 30 | 30 | return $view; |
| 31 | 31 | |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | * @param string $view |
| 39 | 39 | * @return string |
| 40 | 40 | */ |
| 41 | - public static function get_blade_view( $view ) { |
|
| 41 | + public static function get_blade_view($view) { |
|
| 42 | 42 | |
| 43 | - return str_replace( '/', '.', $view ); |
|
| 43 | + return str_replace('/', '.', $view); |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
@@ -54,21 +54,21 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $templates = array(); |
| 56 | 56 | |
| 57 | - $files = (array) glob( THEME_PATH . '/' . self::$folder . '/*/*.blade.php' ); |
|
| 57 | + $files = (array) glob(THEME_PATH.'/'.self::$folder.'/*/*.blade.php'); |
|
| 58 | 58 | |
| 59 | - foreach ( $files as $filename ) { |
|
| 59 | + foreach ($files as $filename) { |
|
| 60 | 60 | |
| 61 | - if ( ! empty( $filename ) ) { |
|
| 61 | + if (!empty($filename)) { |
|
| 62 | 62 | |
| 63 | - if ( ! preg_match( '/\{\{\-\-\s*Template Name:(.*)\s*\-\-\}\}/mi', file_get_contents( $filename ), $header ) ) { continue; } |
|
| 63 | + if (!preg_match('/\{\{\-\-\s*Template Name:(.*)\s*\-\-\}\}/mi', file_get_contents($filename), $header)) { continue; } |
|
| 64 | 64 | |
| 65 | - $template_name = trim( $header[1] ); |
|
| 65 | + $template_name = trim($header[1]); |
|
| 66 | 66 | |
| 67 | - preg_match( '/\/([^\/]*)\.blade.php$/is', $filename, $filename_match ); |
|
| 67 | + preg_match('/\/([^\/]*)\.blade.php$/is', $filename, $filename_match); |
|
| 68 | 68 | |
| 69 | - $template_file = 'classy-' . $filename_match[1]; |
|
| 69 | + $template_file = 'classy-'.$filename_match[1]; |
|
| 70 | 70 | |
| 71 | - $templates[ $template_file ] = $template_name; |
|
| 71 | + $templates[$template_file] = $template_name; |
|
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | } |