diff --git a/README.md b/README.md index 4bd95c20e..806263719 100644 --- a/README.md +++ b/README.md @@ -3,27 +3,26 @@ [![Build Status](https://travis-ci.com/timber/starter-theme.svg?branch=master)](https://travis-ci.com/github/timber/starter-theme) [![Packagist Version](https://img.shields.io/packagist/v/upstatement/timber-starter-theme?include_prereleases)](https://packagist.org/packages/upstatement/timber-starter-theme) -The "_s" for Timber: a dead-simple theme that you can build from. The primary purpose of this theme is to provide a file structure rather than a framework for markup or styles. Configure your Sass, scripts, and task runners however you would like! +The "_s" for Timber: a dead-simple theme that you can build from. The primary purpose of this theme is to provide a file structure rather than a framework for markup or styles. Configure your SASS files, scripts, and task runners however you would like! -## Installing the Theme +## Installing the theme -Install this theme as you would any other, and be sure the Timber plugin is activated. But hey, let's break it down into some bullets: +Follow the guide on [how to Install Timber using the Starter Theme](https://timber.github.io/docs/v2/installation/#use-the-starter-theme). -1. Make sure you have installed the plugin for the [Timber Library](https://wordpress.org/plugins/timber-library/) (and Advanced Custom Fields - they [play quite nicely](https://timber.github.io/docs/guides/acf-cookbook/#nav) together). -2. Download the zip for this theme (or clone it) and move it to `wp-content/themes` in your WordPress installation. -3. Rename the folder to something that makes sense for your website (generally no spaces and all lowercase). You could keep the name `timber-starter-theme` but the point of a starter theme is to make it your own! -4. Activate the theme in Appearance > Themes. -5. Do your thing! And read [the docs](https://timber.github.io/docs/). +Then, -## What's here? +1. Rename the theme folder to something that makes sense for your website. You could keep the name `timber-starter-theme` but the point of a starter theme is to make it your own! +2. Activate the theme in the WordPress Dashboard under **Appearance → Themes**. +3. Do your thing! And read [the docs](https://timber.github.io/docs/). -`static/` is where you can keep your static front-end scripts, styles, or images. In other words, your Sass files, JS files, fonts, and SVGs would live here. +Small tip: You can make use of Composer’s [autoloading functionality](https://getcomposer.org/doc/04-schema.md#psr-4) to automatically load your PHP classes when they are requested instead of requiring the one by one in **functions.php**. -`theme/` contains all of the PHP and other files needed by WordPress. When using the Timber Starter Theme as a parent theme, you need to include the theme directory in your child theme’s `style.css` docblock like so: `Template: timber-starter-theme/theme` +## What’s here? -`views/` contains all of your Twig templates. These pretty much correspond 1 to 1 with the PHP files that respond to the WordPress template hierarchy. At the end of each PHP template, you’ll notice a `Timber::render()` function whose first parameter is the Twig file where that data (or `$context`) will be used. Just an FYI. - -`bin/` and `tests/` ... basically don't worry about (or remove) these unless you know what they are and want to. +- `static/` is where you can keep your static front-end scripts, styles, or images. In other words, your Sass files, JS files, fonts, and SVGs would live here. +- `theme/` contains all of the PHP and other files needed by WordPress. When using the Timber Starter Theme as a parent theme, you need to include the theme directory in your child theme’s `style.css` docblock like so: `Template: timber-starter-theme/theme` +- `views/` contains all of your Twig templates. These pretty much correspond 1 to 1 with the PHP files that respond to the WordPress template hierarchy. At the end of each PHP template, you’ll notice a `Timber::render()` function whose first parameter is the Twig file where that data (or `$context`) will be used. Just an FYI. +- `tests/` ... basically don’t worry about (or remove) these unless you know what they are and want to. ## Other Resources @@ -32,4 +31,3 @@ Install this theme as you would any other, and be sure the Timber plugin is acti * [Timber and Twig Reignited My Love for WordPress](https://css-tricks.com/timber-and-twig-reignited-my-love-for-wordpress/) on CSS-Tricks * [A real live Timber theme](https://github.com/laras126/yuling-theme). * [Timber Video Tutorials](http://timber.github.io/timber/#video-tutorials) and [an incomplete set of screencasts](https://www.youtube.com/playlist?list=PLuIlodXmVQ6pkqWyR6mtQ5gQZ6BrnuFx-) for building a Timber theme from scratch. - diff --git a/composer.json b/composer.json index 3dfec0959..8309e1c83 100644 --- a/composer.json +++ b/composer.json @@ -9,11 +9,6 @@ "name": "jarednova" } ], - "autoload": { - "psr-4": { - "": "src/" - } - }, "repositories": [ { "type": "composer", diff --git a/functions.php b/functions.php index e20892f19..43cddcbec 100644 --- a/functions.php +++ b/functions.php @@ -7,11 +7,11 @@ // 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 - */ +// Sets the directories (inside your theme) to find .twig files. Timber::$dirname = [ 'templates', 'views' ]; new StarterSite(); diff --git a/src/StarterSite.php b/src/StarterSite.php index 9b563fa68..7f6c3ac86 100644 --- a/src/StarterSite.php +++ b/src/StarterSite.php @@ -1,9 +1,11 @@