Conditions | 21 |
Paths | 294 |
Total Lines | 36 |
Lines | 2 |
Ratio | 5.56 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
24 | function pagination($pages = '', $range = 4) |
||
25 | { |
||
26 | $showitems = ($range * 2)+1; |
||
27 | |||
28 | global $paged; |
||
29 | if(empty($paged)) $paged = 1; |
||
30 | |||
31 | if($pages == '') |
||
32 | { |
||
33 | global $wp_query; |
||
34 | $pages = $wp_query->max_num_pages; |
||
35 | if(!$pages) |
||
36 | { |
||
37 | $pages = 1; |
||
38 | } |
||
39 | } |
||
40 | |||
41 | if(1 != $pages) |
||
42 | { |
||
43 | echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>"; |
||
44 | if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>"; |
||
45 | View Code Duplication | if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ Previous</a>"; |
|
46 | |||
47 | for ($i=1; $i <= $pages; $i++) |
||
48 | { |
||
49 | if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) |
||
50 | { |
||
51 | echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>"; |
||
52 | } |
||
53 | } |
||
54 | |||
55 | View Code Duplication | if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next ›</a>"; |
|
56 | if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>"; |
||
57 | echo "</div>\n"; |
||
58 | } |
||
59 | } |
||
60 | |||
96 | add_filter( 'tiny_mce_before_init', 'tinymce_settings' ); |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.