rousnay /
lighthouse
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 2 | |||
| 3 | /** |
||
| 4 | * Read More button in excerpt |
||
| 5 | */ |
||
| 6 | function new_excerpt_more( $more ) {
|
||
| 7 | return '... <a class="readmore" href="' . get_permalink() . ' ">Read more <i class="fa fa-external-link"></i></a>'; |
||
| 8 | } |
||
| 9 | |||
| 10 | add_filter( 'excerpt_more', 'new_excerpt_more' ); |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Custome Lenght of excerpt |
||
| 14 | */ |
||
| 15 | // function custom_excerpt_length( $length ) {
|
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
49% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 16 | // return 50; |
||
| 17 | // } |
||
| 18 | // add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); |
||
| 19 | |||
| 20 | |||
| 21 | /** |
||
| 22 | * Numbered Pagination |
||
| 23 | */ |
||
| 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>"; |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 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>"; |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 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 | |||
| 61 | |||
| 62 | /** |
||
| 63 | * stop wp removing div tags |
||
| 64 | */ |
||
| 65 | function tinymce_settings( $settings ) {
|
||
| 66 | |||
| 67 | // html elements being stripped |
||
| 68 | $settings['extended_valid_elements'] = 'div[*],article[*]'; |
||
| 69 | |||
| 70 | // only html elements to keep |
||
| 71 | //$settings['valid_elements'] = 'a,strong/b,div,h1,h2,h3,section'; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 72 | |||
| 73 | // paste elements to keep |
||
| 74 | //$opts = '*[*]'; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 75 | //$settings['paste_word_valid_elements'] = $opts; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 76 | |||
| 77 | // don't remove line breaks |
||
| 78 | $settings['remove_linebreaks'] = false; |
||
| 79 | |||
| 80 | $settings['allow_html_in_named_anchor'] = true; |
||
| 81 | |||
| 82 | // convert newline characters to BR |
||
| 83 | $settings['convert_newlines_to_brs'] = true; |
||
| 84 | |||
| 85 | // don't remove redundant BR |
||
| 86 | $settings['remove_redundant_brs'] = false; |
||
| 87 | |||
| 88 | // only html elements to keep |
||
| 89 | //$settings['wpautop'] = false; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 90 | |||
| 91 | // pass back to wordpress |
||
| 92 | |||
| 93 | return $settings; |
||
| 94 | } |
||
| 95 | |||
| 96 | add_filter( 'tiny_mce_before_init', 'tinymce_settings' ); |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.