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

Reorder twig files #162

Merged
merged 11 commits into from
May 21, 2024
3 changes: 2 additions & 1 deletion 404.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* The template for displaying 404 pages (Not Found)
*
Expand All @@ -10,4 +11,4 @@
*/

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

/**
* The template for displaying Archive pages.
*
Expand All @@ -14,27 +15,27 @@
* @since Timber 0.2
*/

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

$context = Timber::context();

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

$context['posts'] = Timber::get_posts();

Timber::render( $templates, $context );
Timber::render($templates, $context);
2 changes: 1 addition & 1 deletion author.php
Levdbas marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
$context['author'] = $author;
$context['title'] = 'Author Archives: ' . $author->name();
}
Timber::render( array( 'author.twig', 'archive.twig' ), $context );
Timber::render( array( 'templates/author.twig', 'templates/archive.twig' ), $context );
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
$context = Timber::context();
$context['posts'] = Timber::get_posts();
$context['foo'] = 'bar';
$templates = array( 'index.twig' );
$templates = array( 'templates/index.twig' );
if ( is_home() ) {
array_unshift( $templates, 'front-page.twig', 'home.twig' );
array_unshift( $templates, 'templates/front-page.twig', 'templates/home.twig' );
}
Timber::render( $templates, $context );
2 changes: 1 addition & 1 deletion page.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@

$timber_post = Timber::get_post();
$context['post'] = $timber_post;
Timber::render( array( 'page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );
Timber::render(array('templates/page-' . $timber_post->post_name . '.twig', 'templates/page.twig'), $context);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$timber_post is not defined here, right?

2 changes: 1 addition & 1 deletion search.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @since Timber 0.1
*/

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

$context = Timber::context();
$context['title'] = 'Search results for ' . get_search_query();
Expand Down
7 changes: 4 additions & 3 deletions single.php
Levdbas marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* The Template for displaying all single posts
*
Expand All @@ -13,8 +14,8 @@
$timber_post = Timber::get_post();
$context['post'] = $timber_post;

if ( post_password_required( $timber_post->ID ) ) {
Timber::render( 'single-password.twig', $context );
if (post_password_required($timber_post->ID)) {
Timber::render('single-password.twig', $context);
} else {
Timber::render( array( 'single-' . $timber_post->ID . '.twig', 'single-' . $timber_post->post_type . '.twig', 'single-' . $timber_post->slug . '.twig', 'single.twig' ), $context );
Timber::render(array('templates/single-' . $timber_post->ID . '.twig', 'templates/single-' . $timber_post->post_type . '.twig', 'templates/single-' . $timber_post->slug . '.twig', 'templates/single.twig'), $context);
}
5 changes: 0 additions & 5 deletions views/404.twig

This file was deleted.

7 changes: 0 additions & 7 deletions views/author.twig

This file was deleted.

38 changes: 0 additions & 38 deletions views/base.twig

This file was deleted.

21 changes: 0 additions & 21 deletions views/comment.twig

This file was deleted.

3 changes: 0 additions & 3 deletions views/footer.twig

This file was deleted.

13 changes: 0 additions & 13 deletions views/head.twig

This file was deleted.

11 changes: 0 additions & 11 deletions views/index.twig

This file was deleted.

43 changes: 43 additions & 0 deletions views/layouts/base.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html {{ site.language_attributes }}>
{% block head %}
{% include 'partials/head.twig' %}
{% endblock %}

<body class="{{ body_class }}">
{{ function('wp_body_open') }}
<a class="skip-link screen-reader-text" href="#content">{{ _e('Skip to content') }}</a>
<header class="header">
{% block header %}
<div class="wrapper">
<h1 class="hdr-logo">
<a class="hdr-logo-link" href="{{ site.url }}">{{ site.name }}</a>
</h1>
<nav id="nav-main" class="nav-main">
{% include 'partials/menu.twig' with {
items: menu.get_items
} %}
</nav>
<!-- #nav -->
</div>
{% endblock %}
</header>

<section id="content" class="content-wrapper">
{% if title %}
<h1>{{ title }}</h1>
{% endif %}
<div class="wrapper">
{% block content %}
Sorry, no content
{% endblock %}
</div>
</section>

{% block footer %}
{% include 'partials/footer.twig' %}
{% endblock %}
{{ function('wp_footer') }}
{% do action('get_footer') %}
</body>
</html>
10 changes: 0 additions & 10 deletions views/menu.twig

This file was deleted.

14 changes: 0 additions & 14 deletions views/page.twig

This file was deleted.

64 changes: 0 additions & 64 deletions views/partial/pagination.twig

This file was deleted.

Loading
Loading