Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix codestyles and better phpcs file #164

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions 404.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* The template for the 404 page
*/
Expand All @@ -9,4 +8,4 @@
use Timber\Timber;

$context = Timber::context();
Timber::render('templates/404.twig', $context);
Timber::render( 'templates/404.twig', $context );
40 changes: 20 additions & 20 deletions archive.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
<?php

/**
* The template for displaying Archive pages.
*
* Used to display archive-type pages if nothing more specific matches a query.
* For example, puts together date-based pages if no date.php file exists.
*
* Learn more: https://developer.wordpress.org/themes/basics/template-hierarchy/
*
*/

namespace App;

use Timber\Timber;

$templates = array('templates/archive.twig', 'templates/index.twig');
$templates = [ 'templates/archive.twig', 'templates/index.twig' ];

$title = 'Archive';
if (is_day()) {
$title = 'Archive: ' . get_the_date('D M Y');
} elseif (is_month()) {
$title = 'Archive: ' . get_the_date('M Y');
} elseif (is_year()) {
$title = 'Archive: ' . get_the_date('Y');
} elseif (is_tag()) {
$title = single_tag_title('', false);
} elseif (is_category()) {
$title = single_cat_title('', false);
} elseif (is_post_type_archive()) {
$title = post_type_archive_title('', false);
array_unshift($templates, 'templates/archive-' . get_post_type() . '.twig');
if ( is_day() ) {
$title = 'Archive: ' . get_the_date( 'D M Y' );
} elseif ( is_month() ) {
$title = 'Archive: ' . get_the_date( 'M Y' );
} elseif ( is_year() ) {
$title = 'Archive: ' . get_the_date( 'Y' );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
array_unshift( $templates, 'templates/archive-' . get_post_type() . '.twig' );
}

$context = Timber::context([
'title' => $title,
]);
$context = Timber::context(
[
'title' => $title,
]
);

Timber::render($templates, $context);
Timber::render( $templates, $context );
8 changes: 3 additions & 5 deletions author.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php

/**
* The template for displaying Author Archive pages
*
* Methods for TimberHelper can be found in the /lib sub-directory
*
*/

namespace App;
Expand All @@ -13,8 +11,8 @@

$context = Timber::context();

if (isset($context['author'])) {
$context['title'] = sprintf(__('Archive of %s', 'timber-starter'), $context['author']->name());
if ( isset( $context['author'] ) ) {
$context['title'] = sprintf( __( 'Archive of %s', 'timber-starter' ), $context['author']->name() );
}

Timber::render(array('templates/author.twig', 'templates/archive.twig'), $context);
Timber::render( [ 'templates/author.twig', 'templates/archive.twig' ], $context );
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
}
},
"scripts": {
"test": "phpunit",
"cs": "@php ./vendor/bin/phpcs",
"cs:fix": "@php ./vendor/bin/phpcbf",
"test": "phpunit",
"cs": "@php ./vendor/bin/phpcs --colors -s -p -v ./",
"cs:fix": "@php ./vendor/bin/phpcbf --colors -s -p -v ./",
"phpstan": "@php ./vendor/bin/phpstan analyse"
}
}
1 change: 0 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* Functions and definitions
*
Expand Down
15 changes: 8 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* The main template file
*
Expand All @@ -13,14 +12,16 @@

use Timber\Timber;

$templates = array('templates/index.twig');
$templates = [ 'templates/index.twig' ];

if (is_home()) {
if ( is_home() ) {
array_unshift( $templates, 'templates/front-page.twig', 'templates/home.twig' );
}

$context = Timber::context([
'foo' => 'bar',
]);
$context = Timber::context(
[
'foo' => 'bar',
]
);

Timber::render($templates, $context);
Timber::render( $templates, $context );
4 changes: 1 addition & 3 deletions page.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
*/

namespace App;
Expand All @@ -16,4 +14,4 @@

$context = Timber::context();

Timber::render('templates/page.twig', $context);
Timber::render( 'templates/page.twig', $context );
12 changes: 6 additions & 6 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<!-- Set a minimum PHP version for PHPCompatibility -->
<config name="testVersion" value="8.1-" />

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

<!-- Set the text domain to timber-starter -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="timber-starter"/>
Expand Down
14 changes: 8 additions & 6 deletions search.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php

/**
* Search results page
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*/

use Timber\Timber;

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

$context = Timber::context([
'title' => 'Search results for ' . get_search_query(),
]);
$context = Timber::context(
[
'title' => 'Search results for ' . get_search_query(),
]
);

Timber::render($templates, $context);
Timber::render( $templates, $context );
14 changes: 7 additions & 7 deletions single.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php

/**
* The Template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*/

namespace App;

use Timber\Timber;

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

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

Timber::render($templates, $context);
Timber::render( $templates, $context );
Loading