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 | * Jetpack Compatibility File. |
||
| 4 | * |
||
| 5 | * @link https://jetpack.me/ |
||
| 6 | * |
||
| 7 | * @package Lighthouse |
||
| 8 | */ |
||
| 9 | |||
| 10 | /** |
||
| 11 | * Jetpack setup function. |
||
| 12 | * |
||
| 13 | * See: https://jetpack.me/support/infinite-scroll/ |
||
| 14 | * See: https://jetpack.me/support/responsive-videos/ |
||
| 15 | */ |
||
| 16 | function lighthouse_jetpack_setup() { |
||
| 17 | // Add theme support for Infinite Scroll. |
||
| 18 | add_theme_support( 'infinite-scroll', array( |
||
| 19 | 'container' => 'main', |
||
| 20 | 'render' => 'lighthouse_infinite_scroll_render', |
||
| 21 | 'footer' => 'page', |
||
| 22 | ) ); |
||
| 23 | |||
| 24 | // Add theme support for Responsive Videos. |
||
| 25 | add_theme_support( 'jetpack-responsive-videos' ); |
||
| 26 | } |
||
| 27 | add_action( 'after_setup_theme', 'lighthouse_jetpack_setup' ); |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Custom render function for Infinite Scroll. |
||
| 31 | */ |
||
| 32 | function lighthouse_infinite_scroll_render() { |
||
| 33 | while ( have_posts() ) { |
||
| 34 | the_post(); |
||
| 35 | if ( is_search() ) : |
||
| 36 | get_template_part( 'template-parts/content', 'search' ); |
||
| 37 | else : |
||
| 38 | get_template_part( 'template-parts/content', get_post_format() ); |
||
| 39 | endif; |
||
| 40 | } |
||
| 41 | } |
||
| 42 |
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.