-
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: rework of PHP files. * chore: update namespace * fix: don't provide post again * Remove $dirname since we only use the default location now. * chore: remove unneeded get_post(s) calls
- Loading branch information
Showing
9 changed files
with
136 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
<?php | ||
|
||
/** | ||
* The template for displaying 404 pages (Not Found) | ||
* | ||
* Methods for TimberHelper can be found in the /functions sub-directory | ||
* | ||
* @package WordPress | ||
* @subpackage Timber | ||
* @since Timber 0.1 | ||
* The template for the 404 page | ||
*/ | ||
|
||
namespace App; | ||
|
||
use Timber\Timber; | ||
|
||
$context = Timber::context(); | ||
Timber::render( '404.twig', $context ); | ||
Timber::render('404.twig', $context); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
<?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: http://codex.wordpress.org/Template_Hierarchy | ||
* | ||
* Methods for TimberHelper can be found in the /lib sub-directory | ||
* Learn more: https://developer.wordpress.org/themes/basics/template-hierarchy/ | ||
* | ||
* @package WordPress | ||
* @subpackage Timber | ||
* @since Timber 0.2 | ||
*/ | ||
|
||
$templates = array( 'archive.twig', 'index.twig' ); | ||
namespace App; | ||
|
||
use Timber\Timber; | ||
|
||
$context = Timber::context(); | ||
$templates = array('archive.twig', 'index.twig'); | ||
|
||
$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' ); | ||
$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); | ||
array_unshift($templates, 'archive-' . get_query_var('cat') . '.twig'); | ||
} elseif (is_post_type_archive()) { | ||
$title = post_type_archive_title('', false); | ||
array_unshift($templates, 'archive-' . get_post_type() . '.twig'); | ||
} | ||
|
||
$context['posts'] = Timber::get_posts(); | ||
$context = Timber::context([ | ||
'title' => $title, | ||
]); | ||
|
||
Timber::render( $templates, $context ); | ||
Timber::render($templates, $context); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
<?php | ||
|
||
/** | ||
* The template for displaying Author Archive pages | ||
* | ||
* Methods for TimberHelper can be found in the /lib sub-directory | ||
* | ||
* @package WordPress | ||
* @subpackage Timber | ||
* @since Timber 0.1 | ||
*/ | ||
|
||
namespace App; | ||
|
||
use Timber\Timber; | ||
|
||
global $wp_query; | ||
|
||
$context = Timber::context(); | ||
$context['posts'] = Timber::get_posts(); | ||
if ( isset( $wp_query->query_vars['author'] ) ) { | ||
$author = Timber::get_user( $wp_query->query_vars['author'] ); | ||
$context['author'] = $author; | ||
$context['title'] = 'Author Archives: ' . $author->name(); | ||
$title = false; | ||
if (isset($wp_query->query_vars['author'])) { | ||
$author = Timber::get_user($wp_query->query_vars['author']); | ||
$title = 'Author Archives: ' . $author->name(); | ||
} | ||
Timber::render( array( 'author.twig', 'archive.twig' ), $context ); | ||
|
||
$context = Timber::context([ | ||
'title' => $title, | ||
'author' => $author, | ||
]); | ||
|
||
Timber::render(array('author.twig', 'archive.twig'), $context); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* Timber starter-theme | ||
* https://github.com/timber/starter-theme | ||
* Functions and definitions | ||
* | ||
* @link https://developer.wordpress.org/themes/basics/theme-functions/ | ||
* @link https://github.com/timber/starter-theme | ||
*/ | ||
|
||
namespace App; | ||
|
||
use Timber\Timber; | ||
|
||
// Load Composer dependencies. | ||
require_once __DIR__ . '/vendor/autoload.php'; | ||
|
||
require_once __DIR__ . '/src/StarterSite.php'; | ||
|
||
Timber\Timber::init(); | ||
|
||
// Sets the directories (inside your theme) to find .twig files. | ||
Timber::$dirname = [ 'templates', 'views' ]; | ||
Timber::init(); | ||
|
||
new StarterSite(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
<?php | ||
|
||
/** | ||
* The main template file | ||
* | ||
* This is the most generic template file in a WordPress theme | ||
* and one of the two required files for a theme (the other being style.css). | ||
* It is used to display a page when nothing more specific matches a query. | ||
* E.g., it puts together the home page when no home.php file exists | ||
* E.g., it puts together the home page when no home.php file exists. | ||
* | ||
* Methods for TimberHelper can be found in the /lib sub-directory | ||
* | ||
* @package WordPress | ||
* @subpackage Timber | ||
* @since Timber 0.1 | ||
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/ | ||
*/ | ||
|
||
$context = Timber::context(); | ||
$context['posts'] = Timber::get_posts(); | ||
$context['foo'] = 'bar'; | ||
$templates = array( 'index.twig' ); | ||
if ( is_home() ) { | ||
array_unshift( $templates, 'front-page.twig', 'home.twig' ); | ||
use Timber\Timber; | ||
|
||
$templates = array('index.twig'); | ||
|
||
if (is_home()) { | ||
array_unshift($templates, 'front-page.twig', 'home.twig'); | ||
} | ||
Timber::render( $templates, $context ); | ||
|
||
$context = Timber::context([ | ||
'foo' => 'bar', | ||
]); | ||
|
||
Timber::render($templates, $context); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
<?php | ||
|
||
/** | ||
* Search results page | ||
* | ||
* Methods for TimberHelper can be found in the /lib sub-directory | ||
* | ||
* @package WordPress | ||
* @subpackage Timber | ||
* @since Timber 0.1 | ||
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/ | ||
*/ | ||
|
||
$templates = array( 'search.twig', 'archive.twig', 'index.twig' ); | ||
use Timber\Timber; | ||
|
||
$templates = array('search.twig', 'archive.twig', 'index.twig'); | ||
|
||
$context = Timber::context(); | ||
$context['title'] = 'Search results for ' . get_search_query(); | ||
$context['posts'] = Timber::get_posts(); | ||
$context = Timber::context([ | ||
'title' => 'Search results for ' . get_search_query(), | ||
]); | ||
|
||
Timber::render( $templates, $context ); | ||
Timber::render($templates, $context); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
<?php | ||
|
||
/** | ||
* The Template for displaying all single posts | ||
* | ||
* Methods for TimberHelper can be found in the /lib sub-directory | ||
* | ||
* @package WordPress | ||
* @subpackage Timber | ||
* @since Timber 0.1 | ||
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/ | ||
*/ | ||
|
||
$context = Timber::context(); | ||
$timber_post = Timber::get_post(); | ||
$context['post'] = $timber_post; | ||
namespace App; | ||
|
||
use Timber\Timber; | ||
|
||
$context = Timber::context(); | ||
$post = $context['post']; | ||
|
||
if ( post_password_required( $timber_post->ID ) ) { | ||
Timber::render( 'single-password.twig', $context ); | ||
if (post_password_required($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('single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single-' . $post->slug . '.twig', 'single.twig'), $context); | ||
} |
Oops, something went wrong.