@@ -1,41 +1,41 @@ |
||
1 | -<?php if ( have_posts() ): ?> |
|
1 | +<?php if (have_posts()): ?> |
|
2 | 2 | <div class="wrap"> |
3 | - <?php while ( have_posts() ) : the_post(); ?> |
|
4 | - <article <?php post_class( 'article' ); ?>> |
|
5 | - <?php if ( has_post_thumbnail() ) : ?> |
|
3 | + <?php while (have_posts()) : the_post(); ?> |
|
4 | + <article <?php post_class('article'); ?>> |
|
5 | + <?php if (has_post_thumbnail()) : ?> |
|
6 | 6 | <figure class="post--thumbnail"> |
7 | - <?php the_post_thumbnail( 'large' ); $background_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ); ?> |
|
7 | + <?php the_post_thumbnail('large'); $background_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); ?> |
|
8 | 8 | <style> |
9 | 9 | @media screen and (max-width: 48em) { |
10 | 10 | body { |
11 | - background: url(<?php echo array_shift( $background_image ); ?>) no-repeat; |
|
11 | + background: url(<?php echo array_shift($background_image); ?>) no-repeat; |
|
12 | 12 | background-size: contain; |
13 | 13 | } |
14 | 14 | } |
15 | 15 | </style> |
16 | 16 | <?php |
17 | - $attachment = get_post( get_post_thumbnail_id() ); |
|
18 | - echo apply_filters( 'the_content', $attachment->post_excerpt ); |
|
17 | + $attachment = get_post(get_post_thumbnail_id()); |
|
18 | + echo apply_filters('the_content', $attachment->post_excerpt); |
|
19 | 19 | ?> |
20 | 20 | </figure> |
21 | 21 | <?php endif ?> |
22 | 22 | <header> |
23 | 23 | <h1 class="page--title"><?php the_title(); ?></h1> |
24 | - <time datetime="<?php echo get_the_date( 'c' ); ?>"><?php the_date(); ?></time><?php edit_post_link( 'Edit' ); ?> |
|
24 | + <time datetime="<?php echo get_the_date('c'); ?>"><?php the_date(); ?></time><?php edit_post_link('Edit'); ?> |
|
25 | 25 | </header> |
26 | 26 | <?php the_content() ?> |
27 | 27 | |
28 | 28 | <footer> |
29 | 29 | <?php |
30 | 30 | // If comments are open or we have at least one comment, load up the comment template. |
31 | - if ( comments_open() || get_comments_number() ) : |
|
31 | + if (comments_open() || get_comments_number()) : |
|
32 | 32 | comments_template(); |
33 | 33 | endif; ?> |
34 | 34 | </footer> |
35 | 35 | </article> |
36 | 36 | <?php endwhile ?> |
37 | 37 | <div class="widgets"> |
38 | - <?php dynamic_sidebar( 'slms_single_post' ); ?> |
|
38 | + <?php dynamic_sidebar('slms_single_post'); ?> |
|
39 | 39 | </div> |
40 | 40 | </div> |
41 | 41 | <?php endif; ?> |
@@ -2,19 +2,19 @@ discard block |
||
2 | 2 | |
3 | 3 | class slms_blog extends WP_Widget { |
4 | 4 | public function __construct() { |
5 | - parent::__construct( 'slms_blog', 'Blog', array( 'classname' => 'multi' ) ); |
|
5 | + parent::__construct('slms_blog', 'Blog', array('classname' => 'multi')); |
|
6 | 6 | $this->widget_options['before_widget'] = 'test'; |
7 | 7 | } |
8 | 8 | |
9 | - public function widget( $args, $instance ) { |
|
9 | + public function widget($args, $instance) { |
|
10 | 10 | |
11 | - $number_of_posts = isset( $instance['posts'] ) && is_numeric( intval( $instance['posts'] ) ) ? intval( $instance['posts'] ) : 3; |
|
11 | + $number_of_posts = isset($instance['posts']) && is_numeric(intval($instance['posts'])) ? intval($instance['posts']) : 3; |
|
12 | 12 | |
13 | - $query = new WP_Query( array( |
|
14 | - 'posts_per_page' => is_single( get_queried_object_id() ) ? $number_of_posts + 1 : $number_of_posts, |
|
15 | - 'ignore_sticky_posts'=> is_sticky( get_queried_object_ID() ), |
|
16 | - 'post_not_in' => array( get_queried_object_id() ) |
|
17 | - ) ); |
|
13 | + $query = new WP_Query(array( |
|
14 | + 'posts_per_page' => is_single(get_queried_object_id()) ? $number_of_posts + 1 : $number_of_posts, |
|
15 | + 'ignore_sticky_posts'=> is_sticky(get_queried_object_ID()), |
|
16 | + 'post_not_in' => array(get_queried_object_id()) |
|
17 | + )); |
|
18 | 18 | |
19 | 19 | ?> |
20 | 20 | <section class="widget widget__large"> |
@@ -22,24 +22,24 @@ discard block |
||
22 | 22 | <?php echo sprintf( |
23 | 23 | '%s<a href="%s">%s</a>%s', |
24 | 24 | $args['before_title'], |
25 | - get_permalink( get_option( 'page_for_posts' ) ), |
|
26 | - apply_filters( 'widget_title', 'Blog' ), |
|
25 | + get_permalink(get_option('page_for_posts')), |
|
26 | + apply_filters('widget_title', 'Blog'), |
|
27 | 27 | $args['after_title'] |
28 | 28 | ); ?> |
29 | - <?php if ( ! empty( $instance['text'] ) ): ?> |
|
30 | - <p><?php echo nl2br( $instance['text'] ); ?></p> |
|
29 | + <?php if ( ! empty($instance['text'])): ?> |
|
30 | + <p><?php echo nl2br($instance['text']); ?></p> |
|
31 | 31 | <?php endif ?> |
32 | 32 | </header> |
33 | 33 | <div class="posts"> |
34 | - <?php while ( $query->have_posts() ) : |
|
34 | + <?php while ($query->have_posts()) : |
|
35 | 35 | $query->the_post(); |
36 | 36 | |
37 | - if ( $query->current_post < $number_of_posts ) : ?><!-- |
|
37 | + if ($query->current_post < $number_of_posts) : ?><!-- |
|
38 | 38 | |
39 | 39 | --><article <?php post_class(); ?>> |
40 | 40 | <header> |
41 | 41 | <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> |
42 | - <time datetime="<?php echo get_the_date( 'c' ); ?>"><?php echo get_the_date(); ?></time><?php edit_post_link( 'Edit' ); ?> |
|
42 | + <time datetime="<?php echo get_the_date('c'); ?>"><?php echo get_the_date(); ?></time><?php edit_post_link('Edit'); ?> |
|
43 | 43 | </header> |
44 | 44 | <?php the_excerpt(); ?> |
45 | 45 | <a href="<?php the_permalink(); ?>">Read more</a> |
@@ -51,26 +51,26 @@ discard block |
||
51 | 51 | wp_reset_postdata(); |
52 | 52 | } |
53 | 53 | |
54 | - public function form( $instance ) { |
|
54 | + public function form($instance) { |
|
55 | 55 | |
56 | 56 | ?><p> |
57 | - <label for="<?php echo $this->get_field_id( 'posts' ); ?>">Posts:</label> |
|
58 | - <input type="number" min="1" max="12" id="<?php echo $this->get_field_id( 'posts' ); ?>" name="<?php echo $this->get_field_name( 'posts' ); ?>" value="<?php echo $instance['posts'] ?>"> |
|
57 | + <label for="<?php echo $this->get_field_id('posts'); ?>">Posts:</label> |
|
58 | + <input type="number" min="1" max="12" id="<?php echo $this->get_field_id('posts'); ?>" name="<?php echo $this->get_field_name('posts'); ?>" value="<?php echo $instance['posts'] ?>"> |
|
59 | 59 | </p> |
60 | 60 | <p> |
61 | - <label for="<?php echo $this->get_field_id( 'text' ); ?>">Text:</label><br /> |
|
62 | - <textarea id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>"><?php echo esc_attr( $instance['text'] ); ?></textarea> |
|
61 | + <label for="<?php echo $this->get_field_id('text'); ?>">Text:</label><br /> |
|
62 | + <textarea id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo esc_attr($instance['text']); ?></textarea> |
|
63 | 63 | </p> |
64 | 64 | <?php |
65 | 65 | } |
66 | 66 | |
67 | - public function update( $new_instance, $old_instance ) { |
|
67 | + public function update($new_instance, $old_instance) { |
|
68 | 68 | $instance = array(); |
69 | - $instance['text'] = ( ! empty( $new_instance['text'] ) ) ? strip_tags( $new_instance['text'] ) : ''; |
|
69 | + $instance['text'] = ( ! empty($new_instance['text'])) ? strip_tags($new_instance['text']) : ''; |
|
70 | 70 | |
71 | 71 | $instance['posts'] = 3; |
72 | 72 | |
73 | - if ( ! empty( $new_instance['posts'] ) && is_numeric( $new_instance['posts'] ) && $new_instance['posts'] >= 1 && $new_instance['posts'] <= 12 ) |
|
73 | + if ( ! empty($new_instance['posts']) && is_numeric($new_instance['posts']) && $new_instance['posts'] >= 1 && $new_instance['posts'] <= 12) |
|
74 | 74 | $instance['posts'] = $new_instance['posts']; |
75 | 75 | |
76 | 76 | return $instance; |