Skip to content

Commit 3c610ba

Browse files
committed
Fix most PHPCS issues
1 parent 295e94e commit 3c610ba

10 files changed

+287
-236
lines changed

archive.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77
* @package WordPress
88
* @subpackage Fredo
99
*/
10-
get_header(); ?>
1110

12-
<div class="row">
13-
<div class="column">
11+
get_header(); ?>
12+
13+
<div class="row">
14+
<div class="column">
1415
<?php
1516
the_archive_title( '<h1 class="page-title">', '</h1>' );
1617
the_archive_description( '<div class="taxonomy-description">', '</div>' );
1718
?>
1819
</div>
1920
</div>
2021

21-
<?php if ( have_posts() ) :
22+
<?php
23+
if ( have_posts() ) :
2224
get_template_part( 'loop' );
2325
else :
2426
get_template_part( 'content', 'none' );

blog.php

+61-54
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,57 @@
22
/**
33
*
44
* Template Name: Blog
5-
*
5+
*
66
* The main template for displaying all posts.
77
*
88
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
99
*
1010
* @package WordPress
1111
* @subpackage Fredo
1212
*/
13-
get_header(); ?>
1413

15-
<div class="row">
16-
<div class="column">
17-
<h1><?php _e( 'All my posts', 'fredo' ); ?></h1>
14+
get_header(); ?>
15+
16+
<div class="row">
17+
<div class="column">
18+
<h1><?php esc_attr_e( 'All my posts', 'fredo' ); ?></h1>
1819
</div>
1920
</div>
2021

2122
<div class="row home-posts">
2223
<?php
2324

24-
// Create the Query
25+
// Create the Query.
2526
$posts_per_page = 8;
26-
$post_type = 'post';
27-
$orderby = 'date';
28-
$order = 'DESC';
29-
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
30-
31-
$query = new WP_Query( array (
32-
'post_type' => $post_type,
33-
'posts_per_page' => $posts_per_page,
34-
'orderby' => $orderby,
35-
'order' => $order,
36-
'paged' => $paged
37-
)
38-
);
39-
40-
//Get post type count
27+
$post_type = 'post';
28+
$orderby = 'date';
29+
$order = 'DESC';
30+
31+
$query = new WP_Query(
32+
array(
33+
'post_type' => $post_type,
34+
'posts_per_page' => $posts_per_page,
35+
'orderby' => $orderby,
36+
'order' => $order,
37+
)
38+
);
39+
40+
// Get post type count.
4141
$post_count = $query->post_count;
4242

43-
// Displays info
44-
if( $post_count > 0) :
45-
46-
// Loop
47-
while ($query->have_posts()) : $query->the_post();
48-
?>
49-
<div class="column column-50 ">
50-
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
51-
<span class="excerpt"><?php the_excerpt(); ?></span>
52-
<span class="button button-black button-small"><a href="<?php the_permalink(); ?>"><?php _e( 'Read Now', 'fredo' ); ?></a></span>
53-
</div>
54-
<?php
43+
// Displays info.
44+
if ( $post_count > 0 ) :
45+
46+
// Loop.
47+
while ( $query->have_posts() ) :
48+
$query->the_post();
49+
?>
50+
<div class="column column-50 ">
51+
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
52+
<span class="excerpt"><?php the_excerpt(); ?></span>
53+
<span class="button button-black button-small"><a href="<?php the_permalink(); ?>"><?php esc_attr_e( 'Read Now', 'fredo' ); ?></a></span>
54+
</div>
55+
<?php
5556
endwhile;
5657

5758
endif;
@@ -62,33 +63,39 @@
6263
<?php
6364
$total = $query->max_num_pages;
6465
// only bother with the rest if we have more than 1 page!
65-
if ( $total > 1 ) {
66-
// get the current page
67-
if ( !$current_page = get_query_var('paged') )
68-
$current_page = 1;
69-
// structure of "format" depends on whether we're using pretty permalinks
70-
if( empty(get_option('permalink_structure')) ) {
71-
$format = '&paged=%#%';
72-
} else {
73-
$format = 'page/%#%/';
74-
}
75-
echo paginate_links(array(
76-
'base' => get_pagenum_link(1) . '%_%',
77-
'format' => $format,
78-
'current' => $current_page,
79-
'total' => $total,
80-
'mid_size' => 4,
81-
'type' => 'list'
82-
));
66+
if ( $total > 1 ) {
67+
68+
// get the current page.
69+
if ( get_query_var( 'paged' ) !== $current_page ) {
70+
$current_page = 1;
71+
}
72+
73+
// structure of "format" depends on whether we're using pretty permalinks.
74+
if ( empty( get_option( 'permalink_structure' ) ) ) {
75+
$format = '&paged=%#%';
76+
} else {
77+
$format = 'page/%#%/';
78+
}
79+
80+
// Echo pagination.
81+
echo paginate_links(
82+
array(
83+
'base' => get_pagenum_link( 1 ) . '%_%',
84+
'format' => $format,
85+
'current' => $current_page,
86+
'total' => $total,
87+
'mid_size' => 4,
88+
'type' => 'list',
89+
)
90+
);
8391
}
8492
?>
8593

8694
</div>
8795

8896
<?php
89-
90-
// Reset query to prevent conflicts
91-
wp_reset_query();
97+
// Reset query to prevent conflicts.
98+
wp_post_data();
9299
?>
93100
</div>
94101

comments.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
* If the current post is protected by a password and the visitor has not yet
1313
* entered the password we will return early without loading the comments.
1414
*/
15-
if ( post_password_required() )
16-
return;
15+
if ( post_password_required() ) {
16+
return;
17+
}
1718
?>
1819

1920
<div class="row section-title">
20-
<div class="column">
21-
<h2><span><?php printf( _nx( '1 comment', '%1$s comments', get_comments_number(), 'comments title', 'fredo' ),
22-
number_format_i18n( get_comments_number() ) ); ?></span></h2>
23-
</div>
21+
<div class="column">
22+
<h2><span><?php printf( _nx( '1 comment', '%1$s comments', get_comments_number(), 'comments title', 'fredo' ), number_format_i18n( get_comments_number() ) ); ?></span></h2>
23+
</div>
2424
</div>
2525

2626
<div class="row comments">
27-
<div class="column">
27+
<div class="column">
2828

2929
<div id="comments" class="comments-area">
3030

@@ -36,23 +36,23 @@
3636
?>
3737
</ol><!-- .comment-list -->
3838

39-
<?php
39+
<?php
4040
// Are there comments to navigate through?
41-
if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
41+
if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
4242
?>
43-
<nav class="navigation comment-navigation" role="navigation">
44-
<h1 class="screen-reader-text section-heading"><?php _e( 'Comment navigation', 'fredo' ); ?></h1>
45-
<div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'fredo' ) ); ?></div>
46-
<div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', 'fredo' ) ); ?></div>
47-
</nav><!-- .comment-navigation -->
48-
<?php endif; // Check for comment navigation ?>
43+
<nav class="navigation comment-navigation" role="navigation">
44+
<h1 class="screen-reader-text section-heading"><?php esc_attr_e( 'Comment navigation', 'fredo' ); ?></h1>
45+
<div class="nav-previous"><?php previous_comments_link( __( '&larr; Older Comments', 'fredo' ) ); ?></div>
46+
<div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', 'fredo' ) ); ?></div>
47+
</nav>
48+
<?php endif; // Check for comment navigation. ?>
4949

5050
<?php if ( ! comments_open() && get_comments_number() ) : ?>
51-
<p class="no-comments"><?php _e( 'Comments are closed.' , 'fredo' ); ?></p>
51+
<p class="no-comments"><?php esc_attr_e( 'Comments are closed.', 'fredo' ); ?></p>
5252
<?php endif; ?>
5353

54-
<?php endif; // have_comments() ?>
54+
<?php endif; // have_comments(). ?>
5555

56-
<?php comment_form(); ?>
56+
<?php comment_form(); ?>
5757

5858
</div><!-- #comments -->

content.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
* @package WordPress
66
* @subpackage Fredo
77
*/
8+
89
?>
910

1011
<div class="column column-50" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
1112

1213
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
1314
<span class="excerpt"><?php the_excerpt(); ?></span>
14-
<span class="button button-black button-small"><a href="<?php the_permalink(); ?>"><?php _e( 'Read Now', 'fredo' ); ?></a></span>
15+
<span class="button button-black button-small"><a href="<?php the_permalink(); ?>"><?php esc_attr_e( 'Read Now', 'fredo' ); ?></a></span>
1516
<?php
16-
do_action( 'remicorson_loop_post' );
17+
do_action( 'fredo_loop_post' );
1718
?>
1819

1920
</div>

footer.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<!-- FOOTER -->
1111
<div class="row footer">
1212
<div class="column">
13-
Copyright <?php echo date( 'Y' ); ?> @ <?php bloginfo( 'name' ); ?>
13+
Copyright <?php echo date_i18n( 'Y' ); ?> @ <?php bloginfo( 'name' ); ?>
1414
</div>
1515
</div>
1616

@@ -21,13 +21,13 @@
2121

2222
<?php if ( get_theme_mod( 'fredo_tracking_code' ) ) : ?>
2323
<script>
24-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
25-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
26-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
27-
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
24+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
25+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
26+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
27+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
2828

29-
ga('create', '<?php echo get_theme_mod( 'fredo_tracking_code' ); ?>', 'auto');
30-
ga('send', 'pageview');
29+
ga('create', '<?php esc_attr_e( get_theme_mod( 'fredo_tracking_code' ) ); ?>', 'auto');
30+
ga('send', 'pageview');
3131

3232
</script>
3333
<?php endif; ?>

0 commit comments

Comments
 (0)