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 | * Shortcode: Recent Post Slider |
||
| 5 | */ |
||
| 6 | function recent_post_slider($atts, $content = null){
|
||
|
0 ignored issues
–
show
|
|||
| 7 | |||
| 8 | ob_start(); |
||
| 9 | |||
| 10 | echo '<div class="post-slider row"><div id="recent-posts" class="owl-carousel">'; |
||
| 11 | |||
| 12 | global $post; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 13 | $post_query = new WP_Query( array( |
||
| 14 | 'post_type' => 'post', |
||
| 15 | 'posts_per_page' => 12, |
||
| 16 | 'order'=>'DESC', |
||
| 17 | 'orderby' => 'date', |
||
| 18 | ) |
||
| 19 | ); |
||
| 20 | |||
| 21 | if( $post_query->have_posts() ) : while( $post_query->have_posts() ) : $post_query->the_post(); |
||
| 22 | $thumb_post = wp_get_attachment_image_src( get_post_thumbnail_id(), 'lighthouse_related_post'); |
||
| 23 | $url_post = $thumb_post[0]; |
||
| 24 | $content = get_the_content(); |
||
| 25 | |||
| 26 | echo '<div class="col-xs-12"><div class="thumbnail thumbnail-hover">'; |
||
| 27 | echo '<img class="img-responsive" src=" ' . $url_post . '">'; |
||
| 28 | echo '<a href=" ' . get_permalink() .' " " title=" ' . get_the_title() .' " class="overlay"></a>'; |
||
| 29 | echo '</div>'; |
||
| 30 | echo '<div class="entry">'; |
||
| 31 | echo '<h3><a href=" ' . get_permalink() . ' "> ' . get_the_title() . '</a></h3>'; |
||
| 32 | echo '<span class="date"> <i class="fa fa-clock-o"></i> ' . get_the_time(get_option('date_format')) .'</span>';
|
||
| 33 | echo '<div class="entry-content">' . wp_trim_words( $content , '27' ) . '</div>'; |
||
| 34 | echo '<div class="read-more">'; |
||
| 35 | echo '<a href="' . get_permalink() . ' " class="btn read-more-btn">View Article</a>'; |
||
| 36 | echo '</div>'; |
||
| 37 | echo '</div></div>'; |
||
| 38 | |||
| 39 | endwhile; |
||
| 40 | wp_reset_postdata(); |
||
| 41 | endif; |
||
| 42 | |||
| 43 | echo '</div></div>'; |
||
| 44 | |||
| 45 | $output = ob_get_clean(); |
||
| 46 | return $output; |
||
| 47 | } |
||
| 48 | |||
| 49 | add_shortcode('recent_posts','recent_post_slider');
|
||
| 50 | |||
| 51 | |||
| 52 | /** |
||
| 53 | * Shortcode: Recent Post Slider |
||
| 54 | */ |
||
| 55 | function member_logo_slider($atts, $content = null){
|
||
|
0 ignored issues
–
show
|
|||
| 56 | |||
| 57 | ob_start(); |
||
| 58 | |||
| 59 | echo '<div class="members-logo row"> <div id="logo-slider" class="owl-carousel">'; |
||
| 60 | |||
| 61 | if( have_rows('members_logo', 'option') ):
|
||
|
0 ignored issues
–
show
'option' is of type string, but the function expects a boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 62 | while ( have_rows('members_logo', 'option') ) : the_row();
|
||
|
0 ignored issues
–
show
'option' is of type string, but the function expects a boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 63 | $logo_url = get_sub_field('logo');
|
||
| 64 | $company_link = get_sub_field('link');
|
||
| 65 | |||
| 66 | echo '<div class="thumbnail thumbnail-hover">'; |
||
| 67 | echo '<img class="img-responsive" src=" ' . $logo_url . '">'; |
||
| 68 | echo '<a href=" ' . $company_link .' " " title=" ' . $company_link .' " class="link-full"></a>'; |
||
| 69 | echo '</div>'; |
||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | endwhile; |
||
| 74 | else : |
||
| 75 | echo '<div class="col-xs-12">Members Logo Slider not found! <be> please add some logo in theme setting page</div>'; |
||
| 76 | endif; |
||
| 77 | echo '</div></div>'; |
||
| 78 | |||
| 79 | $output = ob_get_clean(); |
||
| 80 | |||
| 81 | return $output; |
||
| 82 | |||
| 83 | } |
||
| 84 | |||
| 85 | add_shortcode('members_logo','member_logo_slider'); |
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.