@@ -22,41 +22,41 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @return string Trimmed text. |
| 24 | 24 | */ |
| 25 | - public static function trim_words( $text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote' ) { |
|
| 26 | - if ( null === $more ) { |
|
| 27 | - $more = __( '…' ); |
|
| 25 | + public static function trim_words($text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote') { |
|
| 26 | + if (null === $more) { |
|
| 27 | + $more = __('…'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $original_text = $text; |
| 31 | 31 | $allowed_tag_string = ''; |
| 32 | 32 | |
| 33 | - foreach ( explode( ' ', $allowed_tags ) as $tag ) { |
|
| 34 | - $allowed_tag_string .= '<' . $tag . '>'; |
|
| 33 | + foreach (explode(' ', $allowed_tags) as $tag) { |
|
| 34 | + $allowed_tag_string .= '<'.$tag.'>'; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $text = strip_tags( $text, $allowed_tag_string ); |
|
| 37 | + $text = strip_tags($text, $allowed_tag_string); |
|
| 38 | 38 | |
| 39 | - if ( 'characters' === _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { |
|
| 40 | - $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); |
|
| 41 | - preg_match_all( '/./u', $text, $words_array ); |
|
| 42 | - $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
|
| 39 | + if ('characters' === _x('words', 'word count: words or characters?') && preg_match('/^utf\-?8$/i', get_option('blog_charset'))) { |
|
| 40 | + $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); |
|
| 41 | + preg_match_all('/./u', $text, $words_array); |
|
| 42 | + $words_array = array_slice($words_array[0], 0, $num_words + 1); |
|
| 43 | 43 | $sep = ''; |
| 44 | 44 | } else { |
| 45 | - $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|
| 45 | + $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); |
|
| 46 | 46 | $sep = ' '; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if ( count( $words_array ) > $num_words ) { |
|
| 50 | - array_pop( $words_array ); |
|
| 51 | - $text = implode( $sep, $words_array ); |
|
| 52 | - $text = $text . $more; |
|
| 49 | + if (count($words_array) > $num_words) { |
|
| 50 | + array_pop($words_array); |
|
| 51 | + $text = implode($sep, $words_array); |
|
| 52 | + $text = $text.$more; |
|
| 53 | 53 | } else { |
| 54 | - $text = implode( $sep, $words_array ); |
|
| 54 | + $text = implode($sep, $words_array); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $text = self::close_tags( $text ); |
|
| 57 | + $text = self::close_tags($text); |
|
| 58 | 58 | |
| 59 | - return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); |
|
| 59 | + return apply_filters('wp_trim_words', $text, $num_words, $more, $original_text); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -66,36 +66,36 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return string |
| 68 | 68 | */ |
| 69 | - public static function close_tags( $html ) { |
|
| 69 | + public static function close_tags($html) { |
|
| 70 | 70 | // Put all opened tags into an array. |
| 71 | - preg_match_all( '#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result ); |
|
| 71 | + preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result); |
|
| 72 | 72 | |
| 73 | 73 | $openedtags = $result[1]; |
| 74 | 74 | |
| 75 | 75 | // Put all closed tags into an array. |
| 76 | - preg_match_all( '#</([a-z]+)>#iU', $html, $result ); |
|
| 76 | + preg_match_all('#</([a-z]+)>#iU', $html, $result); |
|
| 77 | 77 | |
| 78 | 78 | $closedtags = $result[1]; |
| 79 | - $len_opened = count( $openedtags ); |
|
| 79 | + $len_opened = count($openedtags); |
|
| 80 | 80 | |
| 81 | 81 | // All tags are closed. |
| 82 | - if ( count( $closedtags ) === $len_opened ) { |
|
| 82 | + if (count($closedtags) === $len_opened) { |
|
| 83 | 83 | return $html; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $openedtags = array_reverse( $openedtags ); |
|
| 86 | + $openedtags = array_reverse($openedtags); |
|
| 87 | 87 | |
| 88 | 88 | // Close tags. |
| 89 | - for ( $i = 0; $i < $len_opened; $i++ ) { |
|
| 90 | - if ( ! in_array( $openedtags[ $i ], $closedtags, true ) ) { |
|
| 91 | - $html .= '</' . $openedtags[ $i ] . '>'; |
|
| 89 | + for ($i = 0; $i < $len_opened; $i++) { |
|
| 90 | + if (!in_array($openedtags[$i], $closedtags, true)) { |
|
| 91 | + $html .= '</'.$openedtags[$i].'>'; |
|
| 92 | 92 | } else { |
| 93 | - unset( $closedtags[ array_search( $openedtags[ $i ], $closedtags ) ] ); |
|
| 93 | + unset($closedtags[array_search($openedtags[$i], $closedtags)]); |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $html = str_replace( array( '</br>', '</hr>', '</wbr>' ), '', $html ); |
|
| 98 | - $html = str_replace( array( '<br>', '<hr>', '<wbr>' ), array( '<br />', '<hr />', '<wbr />' ), $html ); |
|
| 97 | + $html = str_replace(array('</br>', '</hr>', '</wbr>'), '', $html); |
|
| 98 | + $html = str_replace(array('<br>', '<hr>', '<wbr>'), array('<br />', '<hr />', '<wbr />'), $html); |
|
| 99 | 99 | |
| 100 | 100 | return $html; |
| 101 | 101 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return array |
| 109 | 109 | */ |
| 110 | - public static function paginate_links( $args = '' ) { |
|
| 110 | + public static function paginate_links($args = '') { |
|
| 111 | 111 | $defaults = array( |
| 112 | 112 | 'base' => '%_%', // Example http://example.com/all_posts.php%_% : %_% is replaced by format (below). |
| 113 | 113 | 'format' => '?page=%#%', // Example ?page=%#% : %#% is replaced by the page number. |
@@ -115,44 +115,44 @@ discard block |
||
| 115 | 115 | 'current' => 0, |
| 116 | 116 | 'show_all' => false, |
| 117 | 117 | 'prev_next' => true, |
| 118 | - 'prev_text' => __( '« Previous' ), |
|
| 119 | - 'next_text' => __( 'Next »' ), |
|
| 118 | + 'prev_text' => __('« Previous'), |
|
| 119 | + 'next_text' => __('Next »'), |
|
| 120 | 120 | 'end_size' => 1, |
| 121 | 121 | 'mid_size' => 2, |
| 122 | 122 | 'type' => 'array', |
| 123 | 123 | 'add_args' => false, // Array of query args to add. |
| 124 | 124 | 'add_fragment' => '', |
| 125 | 125 | ); |
| 126 | - $args = wp_parse_args( $args, $defaults ); |
|
| 126 | + $args = wp_parse_args($args, $defaults); |
|
| 127 | 127 | |
| 128 | 128 | // Who knows what else people pass in $args. |
| 129 | - $args['total'] = intval( (int) $args['total'] ); |
|
| 130 | - if ( $args['total'] < 2 ) { |
|
| 129 | + $args['total'] = intval((int) $args['total']); |
|
| 130 | + if ($args['total'] < 2) { |
|
| 131 | 131 | return array(); |
| 132 | 132 | } |
| 133 | 133 | $args['current'] = (int) $args['current']; |
| 134 | 134 | $args['end_size'] = 0 < (int) $args['end_size'] ? (int) $args['end_size'] : 1; // Out of bounds? Make it the default. |
| 135 | 135 | $args['mid_size'] = 0 <= (int) $args['mid_size'] ? (int) $args['mid_size'] : 2; |
| 136 | - $args['add_args'] = is_array( $args['add_args'] ) ? $args['add_args'] : false; |
|
| 136 | + $args['add_args'] = is_array($args['add_args']) ? $args['add_args'] : false; |
|
| 137 | 137 | $page_links = array(); |
| 138 | 138 | $dots = false; |
| 139 | - if ( $args['prev_next'] && $args['current'] && 1 < $args['current'] ) { |
|
| 140 | - $link = str_replace( '%_%', 2 === absint( $args['current'] ) ? '' : $args['format'], $args['base'] ); |
|
| 141 | - $link = str_replace( '%#%', $args['current'] - 1, $link ); |
|
| 142 | - if ( $args['add_args'] ) { |
|
| 143 | - $link = add_query_arg( $args['add_args'], $link ); |
|
| 139 | + if ($args['prev_next'] && $args['current'] && 1 < $args['current']) { |
|
| 140 | + $link = str_replace('%_%', 2 === absint($args['current']) ? '' : $args['format'], $args['base']); |
|
| 141 | + $link = str_replace('%#%', $args['current'] - 1, $link); |
|
| 142 | + if ($args['add_args']) { |
|
| 143 | + $link = add_query_arg($args['add_args'], $link); |
|
| 144 | 144 | } |
| 145 | 145 | $link .= $args['add_fragment']; |
| 146 | - $link = untrailingslashit( $link ); |
|
| 146 | + $link = untrailingslashit($link); |
|
| 147 | 147 | $page_links[] = array( |
| 148 | 148 | 'class' => 'prev page-numbers', |
| 149 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
| 149 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
| 150 | 150 | 'title' => $args['prev_text'], |
| 151 | 151 | ); |
| 152 | 152 | } |
| 153 | - for ( $n = 1; $n <= $args['total']; $n++ ) { |
|
| 154 | - $n_display = number_format_i18n( $n ); |
|
| 155 | - if ( absint( $args['current'] ) === $n ) { |
|
| 153 | + for ($n = 1; $n <= $args['total']; $n++) { |
|
| 154 | + $n_display = number_format_i18n($n); |
|
| 155 | + if (absint($args['current']) === $n) { |
|
| 156 | 156 | $page_links[] = array( |
| 157 | 157 | 'class' => 'page-number page-numbers current', |
| 158 | 158 | 'title' => $n_display, |
@@ -162,42 +162,42 @@ discard block |
||
| 162 | 162 | ); |
| 163 | 163 | $dots = true; |
| 164 | 164 | } else { |
| 165 | - 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'] ) ) { |
|
| 166 | - $link = str_replace( '%_%', 1 === absint( $n ) ? '' : $args['format'], $args['base'] ); |
|
| 167 | - $link = str_replace( '%#%', $n, $link ); |
|
| 168 | - $link = trailingslashit( $link ) . ltrim( $args['add_fragment'], '/' ); |
|
| 169 | - if ( $args['add_args'] ) { |
|
| 170 | - $link = rtrim( add_query_arg( $args['add_args'], $link ), '/' ); |
|
| 165 | + 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'])) { |
|
| 166 | + $link = str_replace('%_%', 1 === absint($n) ? '' : $args['format'], $args['base']); |
|
| 167 | + $link = str_replace('%#%', $n, $link); |
|
| 168 | + $link = trailingslashit($link).ltrim($args['add_fragment'], '/'); |
|
| 169 | + if ($args['add_args']) { |
|
| 170 | + $link = rtrim(add_query_arg($args['add_args'], $link), '/'); |
|
| 171 | 171 | } |
| 172 | - $link = str_replace( ' ', '+', $link ); |
|
| 173 | - $link = untrailingslashit( $link ); |
|
| 172 | + $link = str_replace(' ', '+', $link); |
|
| 173 | + $link = untrailingslashit($link); |
|
| 174 | 174 | $page_links[] = array( |
| 175 | 175 | 'class' => 'page-number page-numbers', |
| 176 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
| 176 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
| 177 | 177 | 'title' => $n_display, |
| 178 | 178 | 'name' => $n_display, |
| 179 | - 'current' => absint( $args['current'] ) === $n, |
|
| 179 | + 'current' => absint($args['current']) === $n, |
|
| 180 | 180 | ); |
| 181 | 181 | $dots = true; |
| 182 | - } elseif ( $dots && ! $args['show_all'] ) { |
|
| 182 | + } elseif ($dots && !$args['show_all']) { |
|
| 183 | 183 | $page_links[] = array( |
| 184 | 184 | 'class' => 'dots', |
| 185 | - 'title' => __( '…' ), |
|
| 185 | + 'title' => __('…'), |
|
| 186 | 186 | ); |
| 187 | 187 | $dots = false; |
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | - if ( $args['prev_next'] && $args['current'] && ( $args['current'] < $args['total'] || -1 === intval( $args['total'] ) ) ) { |
|
| 192 | - $link = str_replace( '%_%', $args['format'], $args['base'] ); |
|
| 193 | - $link = str_replace( '%#%', $args['current'] + 1, $link ); |
|
| 194 | - if ( $args['add_args'] ) { |
|
| 195 | - $link = add_query_arg( $args['add_args'], $link ); |
|
| 191 | + if ($args['prev_next'] && $args['current'] && ($args['current'] < $args['total'] || -1 === intval($args['total']))) { |
|
| 192 | + $link = str_replace('%_%', $args['format'], $args['base']); |
|
| 193 | + $link = str_replace('%#%', $args['current'] + 1, $link); |
|
| 194 | + if ($args['add_args']) { |
|
| 195 | + $link = add_query_arg($args['add_args'], $link); |
|
| 196 | 196 | } |
| 197 | - $link = untrailingslashit( trailingslashit( $link ) . $args['add_fragment'] ); |
|
| 197 | + $link = untrailingslashit(trailingslashit($link).$args['add_fragment']); |
|
| 198 | 198 | $page_links[] = array( |
| 199 | 199 | 'class' => 'next page-numbers', |
| 200 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
| 200 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
| 201 | 201 | 'title' => $args['next_text'], |
| 202 | 202 | ); |
| 203 | 203 | } |
@@ -211,13 +211,13 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @return object |
| 213 | 213 | */ |
| 214 | - public static function array_to_object( $array ) { |
|
| 214 | + public static function array_to_object($array) { |
|
| 215 | 215 | $obj = new \stdClass; |
| 216 | 216 | |
| 217 | - foreach ( $array as $k => $v ) { |
|
| 218 | - if ( strlen( $k ) ) { |
|
| 219 | - if ( is_array( $v ) ) { |
|
| 220 | - $obj->{$k} = self::array_to_object( $v ); // Recursion. |
|
| 217 | + foreach ($array as $k => $v) { |
|
| 218 | + if (strlen($k)) { |
|
| 219 | + if (is_array($v)) { |
|
| 220 | + $obj->{$k} = self::array_to_object($v); // Recursion. |
|
| 221 | 221 | } else { |
| 222 | 222 | $obj->{$k} = $v; |
| 223 | 223 | } |
@@ -236,26 +236,26 @@ discard block |
||
| 236 | 236 | $textdomain = Classy::textdomain(); |
| 237 | 237 | $archives_title = ''; |
| 238 | 238 | |
| 239 | - if ( is_category() ) { |
|
| 240 | - $archives_title = single_cat_title( '', false ); |
|
| 241 | - } else if ( is_tag() ) { |
|
| 242 | - $archives_title = 'Tag: ' . single_tag_title( '', false ); |
|
| 243 | - } else if ( is_author() ) { |
|
| 244 | - if ( have_posts() ) { |
|
| 239 | + if (is_category()) { |
|
| 240 | + $archives_title = single_cat_title('', false); |
|
| 241 | + } else if (is_tag()) { |
|
| 242 | + $archives_title = 'Tag: '.single_tag_title('', false); |
|
| 243 | + } else if (is_author()) { |
|
| 244 | + if (have_posts()) { |
|
| 245 | 245 | the_post(); |
| 246 | - $archives_title = 'Author: ' . get_the_author(); |
|
| 246 | + $archives_title = 'Author: '.get_the_author(); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | rewind_posts(); |
| 250 | - } else if ( is_search() ) { |
|
| 251 | - $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
|
| 252 | - } else if ( is_archive() ) { |
|
| 253 | - if ( is_day() ) { |
|
| 250 | + } else if (is_search()) { |
|
| 251 | + $archives_title = sprintf(__('Search Results for: %s', $textdomain), '<span>'.get_search_query().'</span>'); |
|
| 252 | + } else if (is_archive()) { |
|
| 253 | + if (is_day()) { |
|
| 254 | 254 | $archives_title = get_the_date(); |
| 255 | - } elseif ( is_month() ) { |
|
| 256 | - $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
|
| 257 | - } elseif ( is_year() ) { |
|
| 258 | - $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
|
| 255 | + } elseif (is_month()) { |
|
| 256 | + $archives_title = get_the_date(_x('F Y', 'monthly archives date format', $textdomain)); |
|
| 257 | + } elseif (is_year()) { |
|
| 258 | + $archives_title = get_the_date(_x('Y', 'yearly archives date format', $textdomain)); |
|
| 259 | 259 | } else { |
| 260 | 260 | $archives_title = 'Archives'; |
| 261 | 261 | } |
@@ -236,29 +236,29 @@ |
||
| 236 | 236 | $textdomain = Classy::textdomain(); |
| 237 | 237 | $archives_title = 'Archives'; |
| 238 | 238 | |
| 239 | - if ( is_category() ) { |
|
| 240 | - $archives_title = single_cat_title( '', false ); |
|
| 241 | - } else if ( is_tag() ) { |
|
| 242 | - $archives_title = 'Tag: ' . single_tag_title( '', false ); |
|
| 243 | - } else if ( is_author() ) { |
|
| 244 | - if ( have_posts() ) { |
|
| 245 | - the_post(); |
|
| 246 | - $archives_title = 'Author: ' . get_the_author(); |
|
| 247 | - } |
|
| 239 | + if ( is_category() ) { |
|
| 240 | + $archives_title = single_cat_title( '', false ); |
|
| 241 | + } else if ( is_tag() ) { |
|
| 242 | + $archives_title = 'Tag: ' . single_tag_title( '', false ); |
|
| 243 | + } else if ( is_author() ) { |
|
| 244 | + if ( have_posts() ) { |
|
| 245 | + the_post(); |
|
| 246 | + $archives_title = 'Author: ' . get_the_author(); |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - rewind_posts(); |
|
| 250 | - } else if ( is_search() ) { |
|
| 251 | - $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
|
| 252 | - } else if ( is_archive() ) { |
|
| 253 | - if ( is_day() ) { |
|
| 254 | - $archives_title = get_the_date(); |
|
| 255 | - } elseif ( is_month() ) { |
|
| 256 | - $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
|
| 257 | - } elseif ( is_year() ) { |
|
| 258 | - $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
|
| 259 | - } |
|
| 249 | + rewind_posts(); |
|
| 250 | + } else if ( is_search() ) { |
|
| 251 | + $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
|
| 252 | + } else if ( is_archive() ) { |
|
| 253 | + if ( is_day() ) { |
|
| 254 | + $archives_title = get_the_date(); |
|
| 255 | + } elseif ( is_month() ) { |
|
| 256 | + $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
|
| 257 | + } elseif ( is_year() ) { |
|
| 258 | + $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
|
| 259 | + } |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - return $archives_title; |
|
| 262 | + return $archives_title; |
|
| 263 | 263 | } |
| 264 | 264 | } |
@@ -41,7 +41,8 @@ discard block |
||
| 41 | 41 | preg_match_all( '/./u', $text, $words_array ); |
| 42 | 42 | $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
| 43 | 43 | $sep = ''; |
| 44 | - } else { |
|
| 44 | + } |
|
| 45 | + else { |
|
| 45 | 46 | $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
| 46 | 47 | $sep = ' '; |
| 47 | 48 | } |
@@ -50,7 +51,8 @@ discard block |
||
| 50 | 51 | array_pop( $words_array ); |
| 51 | 52 | $text = implode( $sep, $words_array ); |
| 52 | 53 | $text = $text . $more; |
| 53 | - } else { |
|
| 54 | + } |
|
| 55 | + else { |
|
| 54 | 56 | $text = implode( $sep, $words_array ); |
| 55 | 57 | } |
| 56 | 58 | |
@@ -89,7 +91,8 @@ discard block |
||
| 89 | 91 | for ( $i = 0; $i < $len_opened; $i++ ) { |
| 90 | 92 | if ( ! in_array( $openedtags[ $i ], $closedtags, true ) ) { |
| 91 | 93 | $html .= '</' . $openedtags[ $i ] . '>'; |
| 92 | - } else { |
|
| 94 | + } |
|
| 95 | + else { |
|
| 93 | 96 | unset( $closedtags[ array_search( $openedtags[ $i ], $closedtags ) ] ); |
| 94 | 97 | } |
| 95 | 98 | } |
@@ -161,7 +164,8 @@ discard block |
||
| 161 | 164 | 'current' => true, |
| 162 | 165 | ); |
| 163 | 166 | $dots = true; |
| 164 | - } else { |
|
| 167 | + } |
|
| 168 | + else { |
|
| 165 | 169 | 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'] ) ) { |
| 166 | 170 | $link = str_replace( '%_%', 1 === absint( $n ) ? '' : $args['format'], $args['base'] ); |
| 167 | 171 | $link = str_replace( '%#%', $n, $link ); |
@@ -179,7 +183,8 @@ discard block |
||
| 179 | 183 | 'current' => absint( $args['current'] ) === $n, |
| 180 | 184 | ); |
| 181 | 185 | $dots = true; |
| 182 | - } elseif ( $dots && ! $args['show_all'] ) { |
|
| 186 | + } |
|
| 187 | + elseif ( $dots && ! $args['show_all'] ) { |
|
| 183 | 188 | $page_links[] = array( |
| 184 | 189 | 'class' => 'dots', |
| 185 | 190 | 'title' => __( '…' ), |
@@ -218,7 +223,8 @@ discard block |
||
| 218 | 223 | if ( strlen( $k ) ) { |
| 219 | 224 | if ( is_array( $v ) ) { |
| 220 | 225 | $obj->{$k} = self::array_to_object( $v ); // Recursion. |
| 221 | - } else { |
|
| 226 | + } |
|
| 227 | + else { |
|
| 222 | 228 | $obj->{$k} = $v; |
| 223 | 229 | } |
| 224 | 230 | } |
@@ -238,23 +244,29 @@ discard block |
||
| 238 | 244 | |
| 239 | 245 | if ( is_category() ) { |
| 240 | 246 | $archives_title = single_cat_title( '', false ); |
| 241 | - } else if ( is_tag() ) { |
|
| 247 | + } |
|
| 248 | + else if ( is_tag() ) { |
|
| 242 | 249 | $archives_title = 'Tag: ' . single_tag_title( '', false ); |
| 243 | - } else if ( is_author() ) { |
|
| 250 | + } |
|
| 251 | + else if ( is_author() ) { |
|
| 244 | 252 | if ( have_posts() ) { |
| 245 | 253 | the_post(); |
| 246 | 254 | $archives_title = 'Author: ' . get_the_author(); |
| 247 | 255 | } |
| 248 | 256 | |
| 249 | 257 | rewind_posts(); |
| 250 | - } else if ( is_search() ) { |
|
| 258 | + } |
|
| 259 | + else if ( is_search() ) { |
|
| 251 | 260 | $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
| 252 | - } else if ( is_archive() ) { |
|
| 261 | + } |
|
| 262 | + else if ( is_archive() ) { |
|
| 253 | 263 | if ( is_day() ) { |
| 254 | 264 | $archives_title = get_the_date(); |
| 255 | - } elseif ( is_month() ) { |
|
| 265 | + } |
|
| 266 | + elseif ( is_month() ) { |
|
| 256 | 267 | $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
| 257 | - } elseif ( is_year() ) { |
|
| 268 | + } |
|
| 269 | + elseif ( is_year() ) { |
|
| 258 | 270 | $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
| 259 | 271 | } |
| 260 | 272 | } |
@@ -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 | } |
@@ -19,18 +19,18 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @return \WP_Query |
| 21 | 21 | */ |
| 22 | - public static function find_query( $args = false ) { |
|
| 22 | + public static function find_query($args = false) { |
|
| 23 | 23 | $default_args = array(); |
| 24 | 24 | |
| 25 | - if ( ! $args ) { |
|
| 25 | + if (!$args) { |
|
| 26 | 26 | return self::get_current_query(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if ( is_array( $args ) ) { |
|
| 30 | - return new \WP_Query( array_merge( $default_args, $args ) ); |
|
| 29 | + if (is_array($args)) { |
|
| 30 | + return new \WP_Query(array_merge($default_args, $args)); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - return new \WP_Query( $default_args ); |
|
| 33 | + return new \WP_Query($default_args); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public static function get_current_query() { |
| 42 | 42 | global $wp_query; |
| 43 | - $query =& $wp_query; |
|
| 44 | - $query = self::handle_maybe_custom_posts_page( $query ); |
|
| 43 | + $query = & $wp_query; |
|
| 44 | + $query = self::handle_maybe_custom_posts_page($query); |
|
| 45 | 45 | |
| 46 | 46 | return $query; |
| 47 | 47 | } |
@@ -53,13 +53,13 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return \WP_Query |
| 55 | 55 | */ |
| 56 | - private static function handle_maybe_custom_posts_page( $query ) { |
|
| 57 | - if ( $custom_posts_page = get_option( 'page_for_posts' ) ) { |
|
| 56 | + private static function handle_maybe_custom_posts_page($query) { |
|
| 57 | + if ($custom_posts_page = get_option('page_for_posts')) { |
|
| 58 | 58 | if ( |
| 59 | - isset( $query->query['p'] ) && |
|
| 60 | - absint( $query->query['p'] ) === absint( $custom_posts_page ) |
|
| 59 | + isset($query->query['p']) && |
|
| 60 | + absint($query->query['p']) === absint($custom_posts_page) |
|
| 61 | 61 | ) { |
| 62 | - return new \WP_Query( array( 'post_type' => 'post' ) ); |
|
| 62 | + return new \WP_Query(array('post_type' => 'post')); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -43,25 +43,25 @@ discard block |
||
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | 45 | public static function get_vars() { |
| 46 | - if ( is_null( self::$vars ) ) { |
|
| 46 | + if (is_null(self::$vars)) { |
|
| 47 | 47 | // Check for a theme config. |
| 48 | - $config_file = CLASSY_THEME_FRAMEWORK_PATH . 'config.php'; |
|
| 48 | + $config_file = CLASSY_THEME_FRAMEWORK_PATH.'config.php'; |
|
| 49 | 49 | |
| 50 | - if ( ! file_exists( $config_file ) ) { |
|
| 51 | - wp_die( sprintf( |
|
| 50 | + if (!file_exists($config_file)) { |
|
| 51 | + wp_die(sprintf( |
|
| 52 | 52 | 'There is no config file in %s custom/config.php', |
| 53 | - esc_html( CLASSY_THEME ) |
|
| 54 | - ) ); |
|
| 53 | + esc_html(CLASSY_THEME) |
|
| 54 | + )); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - require_once( CLASSY_THEME_FRAMEWORK_PATH . 'config.php' ); |
|
| 57 | + require_once(CLASSY_THEME_FRAMEWORK_PATH.'config.php'); |
|
| 58 | 58 | $vars = self::get_allowed_variables(); |
| 59 | 59 | |
| 60 | - foreach ( $vars as $var ) { |
|
| 61 | - if ( isset( $$var ) ) { |
|
| 62 | - self::$vars[ $var ] = $$var; |
|
| 60 | + foreach ($vars as $var) { |
|
| 61 | + if (isset($$var)) { |
|
| 62 | + self::$vars[$var] = $$var; |
|
| 63 | 63 | |
| 64 | - unset( $$var ); // We don't require it anymore. |
|
| 64 | + unset($$var); // We don't require it anymore. |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -76,23 +76,23 @@ discard block |
||
| 76 | 76 | $vars = self::get_vars(); |
| 77 | 77 | |
| 78 | 78 | // Init Post Types. |
| 79 | - if ( isset( $vars['post_types'] ) ) { |
|
| 80 | - self::init_post_types( $vars['post_types'] ); |
|
| 79 | + if (isset($vars['post_types'])) { |
|
| 80 | + self::init_post_types($vars['post_types']); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Init Taxonomies. |
| 84 | - if ( isset( $vars['taxonomies'] ) ) { |
|
| 85 | - self::init_taxonomies( $vars['taxonomies'] ); |
|
| 84 | + if (isset($vars['taxonomies'])) { |
|
| 85 | + self::init_taxonomies($vars['taxonomies']); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // Init Post Formats. |
| 89 | - if ( isset( $vars['post_formats'] ) ) { |
|
| 90 | - self::init_post_formats( $vars['post_formats'] ); |
|
| 89 | + if (isset($vars['post_formats'])) { |
|
| 90 | + self::init_post_formats($vars['post_formats']); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Init Sidebars. |
| 94 | - if ( isset( $vars['sidebars'] ) ) { |
|
| 95 | - self::init_sidebars( $vars['sidebars'] ); |
|
| 94 | + if (isset($vars['sidebars'])) { |
|
| 95 | + self::init_sidebars($vars['sidebars']); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @param array $post_types Custom post types to be registered. |
| 103 | 103 | */ |
| 104 | - private static function init_post_types( $post_types ) { |
|
| 105 | - if ( is_array( $post_types ) ) { |
|
| 106 | - foreach ( $post_types as $type => $options ) { |
|
| 104 | + private static function init_post_types($post_types) { |
|
| 105 | + if (is_array($post_types)) { |
|
| 106 | + foreach ($post_types as $type => $options) { |
|
| 107 | 107 | self::add_post_type( |
| 108 | 108 | $type, |
| 109 | 109 | $options['config'], |
@@ -122,25 +122,25 @@ discard block |
||
| 122 | 122 | * @param string $singular Optional. Default singular name. |
| 123 | 123 | * @param string $multiple Optional. Default multiple name. |
| 124 | 124 | */ |
| 125 | - private static function add_post_type( $name, $config, $singular = 'Entry', $multiple = 'Entries' ) { |
|
| 125 | + private static function add_post_type($name, $config, $singular = 'Entry', $multiple = 'Entries') { |
|
| 126 | 126 | $domain = Classy::textdomain(); |
| 127 | 127 | |
| 128 | - if ( ! isset( $config['labels'] ) ) { |
|
| 128 | + if (!isset($config['labels'])) { |
|
| 129 | 129 | $config['labels'] = array( |
| 130 | - 'name' => __( $multiple, $domain ), |
|
| 131 | - 'singular_name' => __( $singular, $domain ), |
|
| 132 | - 'not_found' => __( 'No ' . $multiple . ' Found', $domain ), |
|
| 133 | - 'not_found_in_trash' => __( 'No ' . $multiple . ' found in Trash', $domain ), |
|
| 134 | - 'edit_item' => __( 'Edit ', $singular, $domain ), |
|
| 135 | - 'search_items' => __( 'Search ' . $multiple, $domain ), |
|
| 136 | - 'view_item' => __( 'View ', $singular, $domain ), |
|
| 137 | - 'new_item' => __( 'New ' . $singular, $domain ), |
|
| 138 | - 'add_new' => __( 'Add New', $domain ), |
|
| 139 | - 'add_new_item' => __( 'Add New ' . $singular, $domain ), |
|
| 130 | + 'name' => __($multiple, $domain), |
|
| 131 | + 'singular_name' => __($singular, $domain), |
|
| 132 | + 'not_found' => __('No '.$multiple.' Found', $domain), |
|
| 133 | + 'not_found_in_trash' => __('No '.$multiple.' found in Trash', $domain), |
|
| 134 | + 'edit_item' => __('Edit ', $singular, $domain), |
|
| 135 | + 'search_items' => __('Search '.$multiple, $domain), |
|
| 136 | + 'view_item' => __('View ', $singular, $domain), |
|
| 137 | + 'new_item' => __('New '.$singular, $domain), |
|
| 138 | + 'add_new' => __('Add New', $domain), |
|
| 139 | + 'add_new_item' => __('Add New '.$singular, $domain), |
|
| 140 | 140 | ); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - register_post_type( $name, $config ); |
|
| 143 | + register_post_type($name, $config); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @param array $taxonomies Taxonomies to be registered. |
| 150 | 150 | */ |
| 151 | - private static function init_taxonomies( $taxonomies ) { |
|
| 152 | - if ( is_array( $taxonomies ) ) { |
|
| 153 | - foreach ( $taxonomies as $type => $options ) { |
|
| 151 | + private static function init_taxonomies($taxonomies) { |
|
| 152 | + if (is_array($taxonomies)) { |
|
| 153 | + foreach ($taxonomies as $type => $options) { |
|
| 154 | 154 | self::add_taxonomy( |
| 155 | 155 | $type, |
| 156 | 156 | $options['for'], |
@@ -171,26 +171,26 @@ discard block |
||
| 171 | 171 | * @param string $singular Optional. Default singular name. |
| 172 | 172 | * @param string $multiple Optional. Default multiple name. |
| 173 | 173 | */ |
| 174 | - private static function add_taxonomy( $name, $object_type, $config, $singular = 'Entry', $multiple = 'Entries' ) { |
|
| 174 | + private static function add_taxonomy($name, $object_type, $config, $singular = 'Entry', $multiple = 'Entries') { |
|
| 175 | 175 | $domain = Classy::textdomain(); |
| 176 | 176 | |
| 177 | - if ( ! isset( $config['labels'] ) ) { |
|
| 177 | + if (!isset($config['labels'])) { |
|
| 178 | 178 | $config['labels'] = array( |
| 179 | - 'name' => __( $multiple, $domain ), |
|
| 180 | - 'singular_name' => __( $singular, $domain ), |
|
| 181 | - 'search_items' => __( 'Search ' . $multiple, $domain ), |
|
| 182 | - 'all_items' => __( 'All ' . $multiple, $domain ), |
|
| 183 | - 'parent_item' => __( 'Parent ' . $singular, $domain ), |
|
| 184 | - 'parent_item_colon' => __( 'Parent ' . $singular . ':', $domain ), |
|
| 185 | - 'edit_item' => __( 'Edit ' . $singular, $domain ), |
|
| 186 | - 'update_item' => __( 'Update ' . $singular, $domain ), |
|
| 187 | - 'add_new_item' => __( 'Add New ' . $singular, $domain ), |
|
| 188 | - 'new_item_name' => __( 'New ' . $singular . ' Name', $domain ), |
|
| 189 | - 'menu_name' => __( $singular, $domain ), |
|
| 179 | + 'name' => __($multiple, $domain), |
|
| 180 | + 'singular_name' => __($singular, $domain), |
|
| 181 | + 'search_items' => __('Search '.$multiple, $domain), |
|
| 182 | + 'all_items' => __('All '.$multiple, $domain), |
|
| 183 | + 'parent_item' => __('Parent '.$singular, $domain), |
|
| 184 | + 'parent_item_colon' => __('Parent '.$singular.':', $domain), |
|
| 185 | + 'edit_item' => __('Edit '.$singular, $domain), |
|
| 186 | + 'update_item' => __('Update '.$singular, $domain), |
|
| 187 | + 'add_new_item' => __('Add New '.$singular, $domain), |
|
| 188 | + 'new_item_name' => __('New '.$singular.' Name', $domain), |
|
| 189 | + 'menu_name' => __($singular, $domain), |
|
| 190 | 190 | ); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - register_taxonomy( $name, $object_type, $config ); |
|
| 193 | + register_taxonomy($name, $object_type, $config); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @param array $post_formats Array with available post formats. |
| 200 | 200 | */ |
| 201 | - private static function init_post_formats( $post_formats ) { |
|
| 202 | - if ( is_array( $post_formats ) ) { |
|
| 203 | - add_theme_support( 'post-formats', $post_formats ); |
|
| 201 | + private static function init_post_formats($post_formats) { |
|
| 202 | + if (is_array($post_formats)) { |
|
| 203 | + add_theme_support('post-formats', $post_formats); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
@@ -209,16 +209,16 @@ discard block |
||
| 209 | 209 | * |
| 210 | 210 | * @param array $sidebars Sidebars to be registered. |
| 211 | 211 | */ |
| 212 | - private static function init_sidebars( $sidebars ) { |
|
| 212 | + private static function init_sidebars($sidebars) { |
|
| 213 | 213 | $domain = Classy::textdomain(); |
| 214 | 214 | |
| 215 | - if ( is_array( $sidebars ) ) { |
|
| 216 | - foreach ( $sidebars as $id => $title ) { |
|
| 215 | + if (is_array($sidebars)) { |
|
| 216 | + foreach ($sidebars as $id => $title) { |
|
| 217 | 217 | register_sidebar( |
| 218 | 218 | array( |
| 219 | 219 | 'id' => $id, |
| 220 | - 'name' => __( $title, $domain ), |
|
| 221 | - 'description' => __( $title, $domain ), |
|
| 220 | + 'name' => __($title, $domain), |
|
| 221 | + 'description' => __($title, $domain), |
|
| 222 | 222 | 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-inner">', |
| 223 | 223 | 'after_widget' => '</div></div>', |
| 224 | 224 | 'before_title' => '<h3>', |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @param \WP_Post $item WP_Post object. |
| 54 | 54 | */ |
| 55 | - public function __construct( $item ) { |
|
| 56 | - if ( is_a( $item, '\WP_Post' ) ) { |
|
| 57 | - $this->import( $item ); |
|
| 55 | + public function __construct($item) { |
|
| 56 | + if (is_a($item, '\WP_Post')) { |
|
| 57 | + $this->import($item); |
|
| 58 | 58 | $this->filter_classes(); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return string |
| 102 | 102 | */ |
| 103 | 103 | public function get_classes() { |
| 104 | - return implode( ' ', $this->classes ); |
|
| 104 | + return implode(' ', $this->classes); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @param string $class_name CSS class name. |
| 111 | 111 | */ |
| 112 | - public function add_class( $class_name ) { |
|
| 112 | + public function add_class($class_name) { |
|
| 113 | 113 | $this->classes[] = $class_name; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -118,16 +118,16 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | * @param Menu_Item $item Menu_Item object. |
| 120 | 120 | */ |
| 121 | - public function add_child( $item ) { |
|
| 122 | - if ( ! $this->has_child ) { |
|
| 123 | - $this->add_class( 'menu-item-has-children' ); |
|
| 121 | + public function add_child($item) { |
|
| 122 | + if (!$this->has_child) { |
|
| 123 | + $this->add_class('menu-item-has-children'); |
|
| 124 | 124 | $this->has_child = true; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $this->children[] = $item; |
| 128 | 128 | $item->level = $this->level + 1; |
| 129 | 129 | |
| 130 | - if ( $item->children ) { |
|
| 130 | + if ($item->children) { |
|
| 131 | 131 | $this->update_child_levels(); |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * Applies filters for item classes. |
| 137 | 137 | */ |
| 138 | 138 | protected function filter_classes() { |
| 139 | - $this->classes = apply_filters( 'nav_menu_css_class', $this->classes, $this ); |
|
| 139 | + $this->classes = apply_filters('nav_menu_css_class', $this->classes, $this); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | * @return boolean |
| 146 | 146 | */ |
| 147 | 147 | protected function update_child_levels() { |
| 148 | - if ( is_array( $this->children ) ) { |
|
| 149 | - foreach ( $this->children as $child ) { |
|
| 148 | + if (is_array($this->children)) { |
|
| 149 | + foreach ($this->children as $child) { |
|
| 150 | 150 | $child->level = $this->level + 1; |
| 151 | 151 | $child->update_child_levels(); |
| 152 | 152 | } |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @param \WP_Comment $item WP_Comment object. |
| 103 | 103 | */ |
| 104 | - public function __construct( $item ) { |
|
| 105 | - if ( is_a( $item, '\WP_Comment' ) ) { |
|
| 106 | - $this->import( $item ); |
|
| 104 | + public function __construct($item) { |
|
| 105 | + if (is_a($item, '\WP_Comment')) { |
|
| 106 | + $this->import($item); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -113,18 +113,18 @@ discard block |
||
| 113 | 113 | * @return \Classy\Models\User |
| 114 | 114 | */ |
| 115 | 115 | public function author() { |
| 116 | - if ( ! $this->user_id ) { |
|
| 116 | + if (!$this->user_id) { |
|
| 117 | 117 | |
| 118 | - $author = new Models\User( 0 ); |
|
| 118 | + $author = new Models\User(0); |
|
| 119 | 119 | |
| 120 | - if ( isset( $this->comment_author ) && $this->comment_author ) { |
|
| 120 | + if (isset($this->comment_author) && $this->comment_author) { |
|
| 121 | 121 | $author->name = $this->comment_author; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return $author; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - return new Models\User( $this->user_id ); |
|
| 127 | + return new Models\User($this->user_id); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | 135 | public function content() { |
| 136 | - return apply_filters( 'get_comment_text ', $this->comment_content ); |
|
| 136 | + return apply_filters('get_comment_text ', $this->comment_content); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return string |
| 154 | 154 | */ |
| 155 | - public function date( $date_format = '' ) { |
|
| 156 | - $df = $date_format ? $date_format : get_option( 'date_format' ); |
|
| 157 | - $the_date = (string) mysql2date( $df, $this->comment_date ); |
|
| 155 | + public function date($date_format = '') { |
|
| 156 | + $df = $date_format ? $date_format : get_option('date_format'); |
|
| 157 | + $the_date = (string) mysql2date($df, $this->comment_date); |
|
| 158 | 158 | |
| 159 | - return apply_filters( 'get_comment_date ', $the_date, $df ); |
|
| 159 | + return apply_filters('get_comment_date ', $the_date, $df); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -176,25 +176,25 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return string |
| 178 | 178 | */ |
| 179 | - public function avatar( $size = 92, $default = '' ) { |
|
| 180 | - if ( ! get_option( 'show_avatars' ) ) { |
|
| 179 | + public function avatar($size = 92, $default = '') { |
|
| 180 | + if (!get_option('show_avatars')) { |
|
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( ! is_numeric( $size ) ) { $size = '92'; } |
|
| 184 | + if (!is_numeric($size)) { $size = '92'; } |
|
| 185 | 185 | |
| 186 | 186 | $email = $this->get_avatar_email(); |
| 187 | 187 | $email_hash = ''; |
| 188 | 188 | |
| 189 | - if ( ! empty( $email ) ) { |
|
| 190 | - $email_hash = md5( strtolower( trim( $email ) ) ); |
|
| 189 | + if (!empty($email)) { |
|
| 190 | + $email_hash = md5(strtolower(trim($email))); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - $host = $this->get_avatar_host( $email_hash ); |
|
| 194 | - $default = $this->get_default_avatar( $default, $email, $size, $host ); |
|
| 193 | + $host = $this->get_avatar_host($email_hash); |
|
| 194 | + $default = $this->get_default_avatar($default, $email, $size, $host); |
|
| 195 | 195 | |
| 196 | - if ( ! empty( $email ) ) { |
|
| 197 | - $avatar = $this->get_avatar_url( $default, $host, $email_hash, $size ); |
|
| 196 | + if (!empty($email)) { |
|
| 197 | + $avatar = $this->get_avatar_url($default, $host, $email_hash, $size); |
|
| 198 | 198 | } else { |
| 199 | 199 | $avatar = $default; |
| 200 | 200 | } |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | protected function get_avatar_email() { |
| 211 | 211 | $id = (int) $this->user_id; |
| 212 | - $user = get_userdata( $id ); |
|
| 212 | + $user = get_userdata($id); |
|
| 213 | 213 | |
| 214 | - if ( $user ) { |
|
| 214 | + if ($user) { |
|
| 215 | 215 | $email = $user->user_email; |
| 216 | 216 | } else { |
| 217 | 217 | $email = $this->comment_author_email; |
@@ -229,31 +229,31 @@ discard block |
||
| 229 | 229 | * @param string $host |
| 230 | 230 | * @return string |
| 231 | 231 | */ |
| 232 | - protected function get_default_avatar( $default, $email, $size, $host ) { |
|
| 233 | - if ( '/' === substr( $default, 0, 1 ) ) { |
|
| 234 | - $default = home_url() . $default; |
|
| 232 | + protected function get_default_avatar($default, $email, $size, $host) { |
|
| 233 | + if ('/' === substr($default, 0, 1)) { |
|
| 234 | + $default = home_url().$default; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - if ( empty( $default ) ) { |
|
| 238 | - $avatar_default = get_option( 'avatar_default' ); |
|
| 239 | - if ( empty( $avatar_default ) ) { |
|
| 237 | + if (empty($default)) { |
|
| 238 | + $avatar_default = get_option('avatar_default'); |
|
| 239 | + if (empty($avatar_default)) { |
|
| 240 | 240 | $default = 'mystery'; |
| 241 | 241 | } else { |
| 242 | 242 | $default = $avatar_default; |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ( 'mystery' === $default ) { |
|
| 247 | - $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
|
| 246 | + if ('mystery' === $default) { |
|
| 247 | + $default = $host.'/avatar/ad516503a11cd5ca435acc9bb6523536?s='.$size; |
|
| 248 | 248 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
| 249 | - } else if ( 'blank' === $default ) { |
|
| 250 | - $default = $email ? 'blank' : includes_url( 'images/blank.gif' ); |
|
| 251 | - } else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
| 249 | + } else if ('blank' === $default) { |
|
| 250 | + $default = $email ? 'blank' : includes_url('images/blank.gif'); |
|
| 251 | + } else if (!empty($email) && 'gravatar_default' === $default) { |
|
| 252 | 252 | $default = ''; |
| 253 | - } else if ( 'gravatar_default' === $default ) { |
|
| 254 | - $default = $host . '/avatar/?s=' . $size; |
|
| 255 | - } else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
| 256 | - $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
|
| 253 | + } else if ('gravatar_default' === $default) { |
|
| 254 | + $default = $host.'/avatar/?s='.$size; |
|
| 255 | + } else if (empty($email) && !strstr($default, 'http://')) { |
|
| 256 | + $default = $host.'/avatar/?d='.$default.'&s='.$size; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | return $default; |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | * @param string $email_hash |
| 266 | 266 | * @return string |
| 267 | 267 | */ |
| 268 | - protected function get_avatar_host( $email_hash ) { |
|
| 268 | + protected function get_avatar_host($email_hash) { |
|
| 269 | 269 | |
| 270 | - if ( is_ssl() ) { |
|
| 270 | + if (is_ssl()) { |
|
| 271 | 271 | $host = 'https://secure.gravatar.com'; |
| 272 | 272 | } else { |
| 273 | - if ( ! empty( $email_hash ) ) { |
|
| 274 | - $host = sprintf( 'http://%d.gravatar.com', (hexdec( $email_hash[0] ) % 2) ); |
|
| 273 | + if (!empty($email_hash)) { |
|
| 274 | + $host = sprintf('http://%d.gravatar.com', (hexdec($email_hash[0]) % 2)); |
|
| 275 | 275 | } else { |
| 276 | 276 | $host = 'http://0.gravatar.com'; |
| 277 | 277 | } |
@@ -289,15 +289,15 @@ discard block |
||
| 289 | 289 | * @param int $size |
| 290 | 290 | * @return string |
| 291 | 291 | */ |
| 292 | - protected function get_avatar_url( $default, $host, $email_hash, $size ) { |
|
| 293 | - $_return = $host . '/avatar/' . $email_hash . '?s=' . $size . '&d=' . urlencode( $default ); |
|
| 294 | - $rating = get_option( 'avatar_rating' ); |
|
| 292 | + protected function get_avatar_url($default, $host, $email_hash, $size) { |
|
| 293 | + $_return = $host.'/avatar/'.$email_hash.'?s='.$size.'&d='.urlencode($default); |
|
| 294 | + $rating = get_option('avatar_rating'); |
|
| 295 | 295 | |
| 296 | - if ( ! empty( $rating ) ) { |
|
| 297 | - $_return .= '&r=' . $rating; |
|
| 296 | + if (!empty($rating)) { |
|
| 297 | + $_return .= '&r='.$rating; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - return str_replace( '&', '&', esc_url( $_return ) ); |
|
| 300 | + return str_replace('&', '&', esc_url($_return)); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -305,11 +305,11 @@ discard block |
||
| 305 | 305 | * |
| 306 | 306 | * @param Comment $comment |
| 307 | 307 | */ |
| 308 | - public function add_child( $comment ) { |
|
| 308 | + public function add_child($comment) { |
|
| 309 | 309 | $this->children[] = $comment; |
| 310 | 310 | $item->level = $this->level + 1; |
| 311 | 311 | |
| 312 | - if ( $item->children ) { |
|
| 312 | + if ($item->children) { |
|
| 313 | 313 | $this->update_child_levels(); |
| 314 | 314 | } |
| 315 | 315 | } |
@@ -320,8 +320,8 @@ discard block |
||
| 320 | 320 | * @return boolean |
| 321 | 321 | */ |
| 322 | 322 | protected function update_child_levels() { |
| 323 | - if ( is_array( $this->children ) ) { |
|
| 324 | - foreach ( $this->children as $child ) { |
|
| 323 | + if (is_array($this->children)) { |
|
| 324 | + foreach ($this->children as $child) { |
|
| 325 | 325 | $child->level = $this->level + 1; |
| 326 | 326 | $child->update_child_levels(); |
| 327 | 327 | } |
@@ -195,7 +195,8 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | if ( ! empty( $email ) ) { |
| 197 | 197 | $avatar = $this->get_avatar_url( $default, $host, $email_hash, $size ); |
| 198 | - } else { |
|
| 198 | + } |
|
| 199 | + else { |
|
| 199 | 200 | $avatar = $default; |
| 200 | 201 | } |
| 201 | 202 | |
@@ -213,7 +214,8 @@ discard block |
||
| 213 | 214 | |
| 214 | 215 | if ( $user ) { |
| 215 | 216 | $email = $user->user_email; |
| 216 | - } else { |
|
| 217 | + } |
|
| 218 | + else { |
|
| 217 | 219 | $email = $this->comment_author_email; |
| 218 | 220 | } |
| 219 | 221 | |
@@ -238,7 +240,8 @@ discard block |
||
| 238 | 240 | $avatar_default = get_option( 'avatar_default' ); |
| 239 | 241 | if ( empty( $avatar_default ) ) { |
| 240 | 242 | $default = 'mystery'; |
| 241 | - } else { |
|
| 243 | + } |
|
| 244 | + else { |
|
| 242 | 245 | $default = $avatar_default; |
| 243 | 246 | } |
| 244 | 247 | } |
@@ -246,13 +249,17 @@ discard block |
||
| 246 | 249 | if ( 'mystery' === $default ) { |
| 247 | 250 | $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
| 248 | 251 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
| 249 | - } else if ( 'blank' === $default ) { |
|
| 252 | + } |
|
| 253 | + else if ( 'blank' === $default ) { |
|
| 250 | 254 | $default = $email ? 'blank' : includes_url( 'images/blank.gif' ); |
| 251 | - } else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
| 255 | + } |
|
| 256 | + else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
| 252 | 257 | $default = ''; |
| 253 | - } else if ( 'gravatar_default' === $default ) { |
|
| 258 | + } |
|
| 259 | + else if ( 'gravatar_default' === $default ) { |
|
| 254 | 260 | $default = $host . '/avatar/?s=' . $size; |
| 255 | - } else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
| 261 | + } |
|
| 262 | + else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
| 256 | 263 | $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
| 257 | 264 | } |
| 258 | 265 | |
@@ -269,10 +276,12 @@ discard block |
||
| 269 | 276 | |
| 270 | 277 | if ( is_ssl() ) { |
| 271 | 278 | $host = 'https://secure.gravatar.com'; |
| 272 | - } else { |
|
| 279 | + } |
|
| 280 | + else { |
|
| 273 | 281 | if ( ! empty( $email_hash ) ) { |
| 274 | 282 | $host = sprintf( 'http://%d.gravatar.com', (hexdec( $email_hash[0] ) % 2) ); |
| 275 | - } else { |
|
| 283 | + } |
|
| 284 | + else { |
|
| 276 | 285 | $host = 'http://0.gravatar.com'; |
| 277 | 286 | } |
| 278 | 287 | } |
@@ -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'); |
|
@@ -36,9 +36,11 @@ |
||
| 36 | 36 | |
| 37 | 37 | if ( is_numeric( $arg ) && 0 !== absint( $arg ) ) { |
| 38 | 38 | $menu_id = $this->check_menu_id( $arg ); |
| 39 | - } elseif ( is_array( $locations ) && count( $locations ) ) { |
|
| 39 | + } |
|
| 40 | + elseif ( is_array( $locations ) && count( $locations ) ) { |
|
| 40 | 41 | $menu_id = $this->get_locations_menu_id( $locations, $arg ); |
| 41 | - } elseif ( is_string( $arg ) ) { |
|
| 42 | + } |
|
| 43 | + elseif ( is_string( $arg ) ) { |
|
| 42 | 44 | $menu_id = $this->get_menu_id_by_name( $arg ); |
| 43 | 45 | } |
| 44 | 46 | |
@@ -38,22 +38,22 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param string $arg It can be menu id, slug or full name. |
| 40 | 40 | */ |
| 41 | - public function __construct( $arg = null ) { |
|
| 41 | + public function __construct($arg = null) { |
|
| 42 | 42 | $locations = get_nav_menu_locations(); |
| 43 | 43 | |
| 44 | - if ( is_numeric( $arg ) && 0 !== absint( $arg ) ) { |
|
| 45 | - $menu_id = $this->check_menu_id( $arg ); |
|
| 46 | - } elseif ( is_array( $locations ) && count( $locations ) ) { |
|
| 47 | - $menu_id = $this->get_locations_menu_id( $locations, $arg ); |
|
| 48 | - } elseif ( is_string( $arg ) ) { |
|
| 49 | - $menu_id = $this->get_menu_id_by_name( $arg ); |
|
| 44 | + if (is_numeric($arg) && 0 !== absint($arg)) { |
|
| 45 | + $menu_id = $this->check_menu_id($arg); |
|
| 46 | + } elseif (is_array($locations) && count($locations)) { |
|
| 47 | + $menu_id = $this->get_locations_menu_id($locations, $arg); |
|
| 48 | + } elseif (is_string($arg)) { |
|
| 49 | + $menu_id = $this->get_menu_id_by_name($arg); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if ( ! isset( $menu_id ) ) { |
|
| 52 | + if (!isset($menu_id)) { |
|
| 53 | 53 | $menu_id = $this->get_first_menu_id(); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ( $menu_id ) { |
|
| 56 | + if ($menu_id) { |
|
| 57 | 57 | $this->ID = $menu_id; |
| 58 | 58 | $this->title = $this->get_menu_name_by_id(); |
| 59 | 59 | $this->init(); |
@@ -65,21 +65,21 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | protected function init() { |
| 67 | 67 | $_return = array(); |
| 68 | - $items = wp_get_nav_menu_items( $this->ID ); |
|
| 68 | + $items = wp_get_nav_menu_items($this->ID); |
|
| 69 | 69 | |
| 70 | - foreach ( $items as $item ) { |
|
| 71 | - $_return[ $item->ID ] = new Menu_Item( $item ); |
|
| 70 | + foreach ($items as $item) { |
|
| 71 | + $_return[$item->ID] = new Menu_Item($item); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Apply nesting. |
| 75 | - foreach ( $_return as $item_id => $item ) { |
|
| 75 | + foreach ($_return as $item_id => $item) { |
|
| 76 | 76 | if ( |
| 77 | - isset( $item->menu_item_parent ) && |
|
| 77 | + isset($item->menu_item_parent) && |
|
| 78 | 78 | $item->menu_item_parent && |
| 79 | - isset( $_return[ $item->menu_item_parent ] ) |
|
| 79 | + isset($_return[$item->menu_item_parent]) |
|
| 80 | 80 | ) { |
| 81 | - $_return[ $item->menu_item_parent ]->add_child( $item ); |
|
| 82 | - unset( $_return[ $item_id ] ); |
|
| 81 | + $_return[$item->menu_item_parent]->add_child($item); |
|
| 82 | + unset($_return[$item_id]); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | * @return int|bool |
| 93 | 93 | */ |
| 94 | 94 | protected function get_first_menu_id() { |
| 95 | - $menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) ); |
|
| 95 | + $menus = get_terms('nav_menu', array('hide_empty' => true)); |
|
| 96 | 96 | |
| 97 | - if ( is_array( $menus ) && count( $menus ) ) { |
|
| 98 | - if ( isset( $menus[0]->term_id ) ) { |
|
| 97 | + if (is_array($menus) && count($menus)) { |
|
| 98 | + if (isset($menus[0]->term_id)) { |
|
| 99 | 99 | return $menus[0]->term_id; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | * @param int|string $arg navigation id. |
| 111 | 111 | * @return int |
| 112 | 112 | */ |
| 113 | - protected function get_locations_menu_id( $locations, $arg ) { |
|
| 114 | - if ( is_numeric( $arg ) ) { |
|
| 115 | - $arg = array_search( $arg, $locations ); |
|
| 113 | + protected function get_locations_menu_id($locations, $arg) { |
|
| 114 | + if (is_numeric($arg)) { |
|
| 115 | + $arg = array_search($arg, $locations); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( isset( $locations[ $arg ] ) ) { |
|
| 119 | - $menu_id = $locations[ $arg ]; |
|
| 118 | + if (isset($locations[$arg])) { |
|
| 119 | + $menu_id = $locations[$arg]; |
|
| 120 | 120 | |
| 121 | 121 | return $menu_id; |
| 122 | 122 | } |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return int|boolean |
| 131 | 131 | */ |
| 132 | - protected function check_menu_id( $menu_id ) { |
|
| 133 | - $menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) ); |
|
| 132 | + protected function check_menu_id($menu_id) { |
|
| 133 | + $menus = get_terms('nav_menu', array('hide_empty' => true)); |
|
| 134 | 134 | |
| 135 | - if ( is_array( $menus ) && count( $menus ) ) { |
|
| 136 | - foreach ( $menus as $menu ) { |
|
| 137 | - if ( absint( $menu->term_id ) === absint( $menu_id ) ) { |
|
| 135 | + if (is_array($menus) && count($menus)) { |
|
| 136 | + foreach ($menus as $menu) { |
|
| 137 | + if (absint($menu->term_id) === absint($menu_id)) { |
|
| 138 | 138 | return $menu_id; |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @return int|bool |
| 152 | 152 | */ |
| 153 | - protected function get_menu_id_by_name( $slug = null ) { |
|
| 154 | - if ( $slug && is_string( $slug ) ) { |
|
| 155 | - if ( $menu_id = get_term_by( 'slug', $slug, 'nav_menu' ) ) { |
|
| 153 | + protected function get_menu_id_by_name($slug = null) { |
|
| 154 | + if ($slug && is_string($slug)) { |
|
| 155 | + if ($menu_id = get_term_by('slug', $slug, 'nav_menu')) { |
|
| 156 | 156 | return $menu_id; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( $menu_id = get_term_by( 'name', $slug, 'nav_menu' ) ) { |
|
| 159 | + if ($menu_id = get_term_by('name', $slug, 'nav_menu')) { |
|
| 160 | 160 | return $menu_id; |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | * @return int|bool |
| 171 | 171 | */ |
| 172 | 172 | protected function get_menu_name_by_id() { |
| 173 | - $menu_obj = wp_get_nav_menu_object( $this->ID ); |
|
| 173 | + $menu_obj = wp_get_nav_menu_object($this->ID); |
|
| 174 | 174 | |
| 175 | - if ( $menu_obj ) { |
|
| 175 | + if ($menu_obj) { |
|
| 176 | 176 | return $menu_obj->name; |
| 177 | 177 | } |
| 178 | 178 | |