Skip to content

Commit c1353f2

Browse files
authored
feat: fix codestyles and better phpcs file (#164)
1 parent c116aea commit c1353f2

11 files changed

+95
-102
lines changed

404.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/**
43
* The template for the 404 page
54
*/
@@ -9,4 +8,4 @@
98
use Timber\Timber;
109

1110
$context = Timber::context();
12-
Timber::render('templates/404.twig', $context);
11+
Timber::render( 'templates/404.twig', $context );

archive.php

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
<?php
2-
32
/**
43
* The template for displaying Archive pages.
54
*
65
* Used to display archive-type pages if nothing more specific matches a query.
76
* For example, puts together date-based pages if no date.php file exists.
87
*
98
* Learn more: https://developer.wordpress.org/themes/basics/template-hierarchy/
10-
*
119
*/
1210

1311
namespace App;
1412

1513
use Timber\Timber;
1614

17-
$templates = array('templates/archive.twig', 'templates/index.twig');
15+
$templates = [ 'templates/archive.twig', 'templates/index.twig' ];
1816

1917
$title = 'Archive';
20-
if (is_day()) {
21-
$title = 'Archive: ' . get_the_date('D M Y');
22-
} elseif (is_month()) {
23-
$title = 'Archive: ' . get_the_date('M Y');
24-
} elseif (is_year()) {
25-
$title = 'Archive: ' . get_the_date('Y');
26-
} elseif (is_tag()) {
27-
$title = single_tag_title('', false);
28-
} elseif (is_category()) {
29-
$title = single_cat_title('', false);
30-
} elseif (is_post_type_archive()) {
31-
$title = post_type_archive_title('', false);
32-
array_unshift($templates, 'templates/archive-' . get_post_type() . '.twig');
18+
if ( is_day() ) {
19+
$title = 'Archive: ' . get_the_date( 'D M Y' );
20+
} elseif ( is_month() ) {
21+
$title = 'Archive: ' . get_the_date( 'M Y' );
22+
} elseif ( is_year() ) {
23+
$title = 'Archive: ' . get_the_date( 'Y' );
24+
} elseif ( is_tag() ) {
25+
$title = single_tag_title( '', false );
26+
} elseif ( is_category() ) {
27+
$title = single_cat_title( '', false );
28+
} elseif ( is_post_type_archive() ) {
29+
$title = post_type_archive_title( '', false );
30+
array_unshift( $templates, 'templates/archive-' . get_post_type() . '.twig' );
3331
}
3432

35-
$context = Timber::context([
36-
'title' => $title,
37-
]);
33+
$context = Timber::context(
34+
[
35+
'title' => $title,
36+
]
37+
);
3838

39-
Timber::render($templates, $context);
39+
Timber::render( $templates, $context );

author.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
2-
32
/**
43
* The template for displaying Author Archive pages
54
*
65
* Methods for TimberHelper can be found in the /lib sub-directory
7-
*
86
*/
97

108
namespace App;
@@ -13,8 +11,8 @@
1311

1412
$context = Timber::context();
1513

16-
if (isset($context['author'])) {
17-
$context['title'] = sprintf(__('Archive of %s', 'timber-starter'), $context['author']->name());
14+
if ( isset( $context['author'] ) ) {
15+
$context['title'] = sprintf( __( 'Archive of %s', 'timber-starter' ), $context['author']->name() );
1816
}
1917

20-
Timber::render(array('templates/author.twig', 'templates/archive.twig'), $context);
18+
Timber::render( [ 'templates/author.twig', 'templates/archive.twig' ], $context );

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
}
6363
},
6464
"scripts": {
65-
"test": "phpunit",
66-
"cs": "@php ./vendor/bin/phpcs",
67-
"cs:fix": "@php ./vendor/bin/phpcbf",
65+
"test": "phpunit",
66+
"cs": "@php ./vendor/bin/phpcs --colors -s -p -v ./",
67+
"cs:fix": "@php ./vendor/bin/phpcbf --colors -s -p -v ./",
6868
"phpstan": "@php ./vendor/bin/phpstan analyse"
6969
}
7070
}

functions.php

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/**
43
* Functions and definitions
54
*

index.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/**
43
* The main template file
54
*
@@ -13,14 +12,16 @@
1312

1413
use Timber\Timber;
1514

16-
$templates = array('templates/index.twig');
15+
$templates = [ 'templates/index.twig' ];
1716

18-
if (is_home()) {
17+
if ( is_home() ) {
1918
array_unshift( $templates, 'templates/front-page.twig', 'templates/home.twig' );
2019
}
2120

22-
$context = Timber::context([
23-
'foo' => 'bar',
24-
]);
21+
$context = Timber::context(
22+
[
23+
'foo' => 'bar',
24+
]
25+
);
2526

26-
Timber::render($templates, $context);
27+
Timber::render( $templates, $context );

page.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<?php
2-
32
/**
43
* The template for displaying all pages.
54
*
65
* This is the template that displays all pages by default.
76
* Please note that this is the WordPress construct of pages
87
* and that other 'pages' on your WordPress site will use a
98
* different template.
10-
*
119
*/
1210

1311
namespace App;
@@ -16,4 +14,4 @@
1614

1715
$context = Timber::context();
1816

19-
Timber::render('templates/page.twig', $context);
17+
Timber::render( 'templates/page.twig', $context );

phpcs.xml.dist

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
<!-- Set a minimum PHP version for PHPCompatibility -->
1717
<config name="testVersion" value="8.1-" />
1818

19-
<rule ref="10up-Default" />
20-
<rule ref="WordPress-Core" />
21-
<rule ref="WordPress-Docs" />
22-
<rule ref="WordPress-Extra" />
23-
<!-- Add VIP-specific rules -->
24-
<config name="minimum_supported_wp_version" value="6.1"/>
19+
<!-- Use 10up's phpcs ruleset -->
20+
<rule ref="10up-Default">
21+
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag"/>
22+
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment"/>
23+
</rule>
2524

25+
<!-- Set the text domain to timber-starter -->
2626
<rule ref="WordPress.WP.I18n">
2727
<properties>
2828
<property name="text_domain" type="array" value="timber-starter"/>

search.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<?php
2-
32
/**
43
* Search results page
4+
*
55
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
66
*/
77

88
use Timber\Timber;
99

10-
$templates = array( 'templates/search.twig', 'templates/archive.twig', 'templates/index.twig' );
10+
$templates = [ 'templates/search.twig', 'templates/archive.twig', 'templates/index.twig' ];
1111

12-
$context = Timber::context([
13-
'title' => 'Search results for ' . get_search_query(),
14-
]);
12+
$context = Timber::context(
13+
[
14+
'title' => 'Search results for ' . get_search_query(),
15+
]
16+
);
1517

16-
Timber::render($templates, $context);
18+
Timber::render( $templates, $context );

single.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?php
2-
32
/**
43
* The Template for displaying all single posts
4+
*
55
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
66
*/
77

88
namespace App;
99

1010
use Timber\Timber;
1111

12-
$context = Timber::context();
13-
$post = $context['post'];
14-
$templates = array('templates/single-' . $post->post_type . '.twig', 'templates/single.twig');
12+
$context = Timber::context();
13+
$post = $context['post'];
14+
$templates = [ 'templates/single-' . $post->post_type . '.twig', 'templates/single.twig' ];
1515

16-
if (post_password_required($post->ID)) {
16+
if ( post_password_required( $post->ID ) ) {
1717
$templates = 'templates/single-password.twig';
18-
}
18+
}
1919

20-
Timber::render($templates, $context);
20+
Timber::render( $templates, $context );

0 commit comments

Comments
 (0)