Plugin Directory

Changeset 3068975

Timestamp:
04/11/2024 12:23:16 PM (4 months ago)
Author:
jarednova
Message:

Update to 1.23.1

Location:
timber-library/trunk/timber-starter-theme
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • timber-library/trunk/timber-starter-theme/.gitignore

    r2175400 r3068975  
    1 vendor
    2 wp-content
    3 composer.lock
     1/composer.lock
     2/vendor/
     3/wordpress/
  • timber-library/trunk/timber-starter-theme/README.md

    r2603908 r3068975  
    1 
    21# The Timber Starter Theme
    32
    4 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!
     3[![Build Status](https://travis-ci.com/timber/starter-theme.svg?branch=master)](https://travis-ci.com/github/timber/starter-theme)
     4[![Packagist Version](https://img.shields.io/packagist/v/upstatement/timber-starter-theme?include_prereleases)](https://packagist.org/packages/upstatement/timber-starter-theme)
    55
    6 [![Build Status](https://travis-ci.com/timber/starter-theme.svg?branch=master)](https://travis-ci.com/github/timber/starter-theme)
     6The "_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!
    77
    8 ## Installing the Theme
     8## Installing the heme
    99
    10 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:
     10Follow the guide on [how to Install Timber using the Starter Theme](https://timber.github.io/docs/v2/installation/installation/#use-the-starter-theme).
    1111
    12 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).
    13 2. Download the zip for this theme (or clone it) and move it to `wp-content/themes` in your WordPress installation.
    14 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!
    15 4. Activate the theme in Appearance >  Themes.
    16 5. Do your thing! And read [the docs](https://timber.github.io/docs/).
     12Then,
    1713
    18 ## What's here?
     141. 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!
     152. Activate the theme in the WordPress Dashboard under **Appearance → Themes**.
     163. Do your thing! And read [the docs](https://timber.github.io/docs/).
    1917
    20 `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.
     18## The `StarterSite` class
    2119
    22 `templates/` 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.
     20.
    2321
    24 `bin/` and `tests/` ... basically don't worry about (or remove) these unless you know what they are and want to.
     22The **src** folder would be the right place to put your classes that [extend Timber’s functionality](https://timber.github.io/docs/v2/guides/extending-timber/).
     23
     24Small 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 one by one in **functions.php**.
     25
     26## What else is there?
     27
     28- `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.
     29- `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.
     30- `tests/` ... basically don’t worry about (or remove) this unless you know what it is and want to.
    2531
    2632## Other Resources
     
    3137* [A real live Timber theme](https://github.com/laras126/yuling-theme).
    3238* [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.
    33 
  • timber-library/trunk/timber-starter-theme/archive.php

    r2397504 r3068975  
    3636}
    3737
    38 $context['posts'] = new Timber\PostQuery();
     38$context['posts'] = ();
    3939
    4040Timber::render( $templates, $context );
  • timber-library/trunk/timber-starter-theme/author.php

    r2397504 r3068975  
    1313
    1414$context          = Timber::context();
    15 $context['posts'] = new Timber\PostQuery();
     15$context['posts'] = ();
    1616if ( isset( $wp_query->query_vars['author'] ) ) {
    17     $author            = new Timber\User( $wp_query->query_vars['author'] );
     17    $author            = ser( $wp_query->query_vars['author'] );
    1818    $context['author'] = $author;
    1919    $context['title']  = 'Author Archives: ' . $author->name();
  • timber-library/trunk/timber-starter-theme/functions.php

    r2397504 r3068975  
    33 * Timber starter-theme
    44 * https://github.com/timber/starter-theme
    5  *
    6  * @package  WordPress
    7  * @subpackage  Timber
    8  * @since   Timber 0.1
    95 */
    106
    11 /**
    12  * If you are installing Timber as a Composer dependency in your theme, you'll need this block
    13  * to load your dependencies and initialize Timber. If you are using Timber via the WordPress.org
    14  * plug-in, you can safely delete this block.
    15  */
    16 $composer_autoload = __DIR__ . '/vendor/autoload.php';
    17 if ( file_exists( $composer_autoload ) ) {
    18     require_once $composer_autoload;
    19     $timber = new Timber\Timber();
    20 }
     7// Load Composer dependencies.
     8require_once __DIR__ . '/vendor/autoload.php';
    219
    22 /**
    23  * This ensures that Timber is loaded and available as a PHP class.
    24  * If not, it gives an error message to help direct developers on where to activate
    25  */
    26 if ( ! class_exists( 'Timber' ) ) {
     10require_once __DIR__ . '/src/StarterSite.php';
    2711
    28     add_action(
    29         'admin_notices',
    30         function() {
    31             echo '<div class="error"><p>Timber not activated. Make sure you activate the plugin in <a href="' . esc_url( admin_url( 'plugins.php#timber' ) ) . '">' . esc_url( admin_url( 'plugins.php' ) ) . '</a></p></div>';
    32         }
    33     );
     12Timber\Timber::init();
    3413
    35     add_filter(
    36         'template_include',
    37         function( $template ) {
    38             return get_stylesheet_directory() . '/static/no-timber.html';
    39         }
    40     );
    41     return;
    42 }
    43 
    44 /**
    45  * Sets the directories (inside your theme) to find .twig files
    46  */
    47 Timber::$dirname = array( 'templates', 'views' );
    48 
    49 /**
    50  * By default, Timber does NOT autoescape values. Want to enable Twig's autoescape?
    51  * No prob! Just set this value to true
    52  */
    53 Timber::$autoescape = false;
    54 
    55 
    56 /**
    57  * We're going to configure our theme inside of a subclass of Timber\Site
    58  * You can move this to its own file and include here via php's include("MySite.php")
    59  */
    60 class StarterSite extends Timber\Site {
    61     /** Add timber support. */
    62     public function __construct() {
    63         add_action( 'after_setup_theme', array( $this, 'theme_supports' ) );
    64         add_filter( 'timber/context', array( $this, 'add_to_context' ) );
    65         add_filter( 'timber/twig', array( $this, 'add_to_twig' ) );
    66         add_action( 'init', array( $this, 'register_post_types' ) );
    67         add_action( 'init', array( $this, 'register_taxonomies' ) );
    68         parent::__construct();
    69     }
    70     /** This is where you can register custom post types. */
    71     public function register_post_types() {
    72 
    73     }
    74     /** This is where you can register custom taxonomies. */
    75     public function register_taxonomies() {
    76 
    77     }
    78 
    79     /** This is where you add some context
    80      *
    81      * @param string $context context['this'] Being the Twig's {{ this }}.
    82      */
    83     public function add_to_context( $context ) {
    84         $context['foo']   = 'bar';
    85         $context['stuff'] = 'I am a value set in your functions.php file';
    86         $context['notes'] = 'These values are available everytime you call Timber::context();';
    87         $context['menu']  = new Timber\Menu();
    88         $context['site']  = $this;
    89         return $context;
    90     }
    91 
    92     public function theme_supports() {
    93         // Add default posts and comments RSS feed links to head.
    94         add_theme_support( 'automatic-feed-links' );
    95 
    96         /*
    97          * Let WordPress manage the document title.
    98          * By adding theme support, we declare that this theme does not use a
    99          * hard-coded <title> tag in the document head, and expect WordPress to
    100          * provide it for us.
    101          */
    102         add_theme_support( 'title-tag' );
    103 
    104         /*
    105          * Enable support for Post Thumbnails on posts and pages.
    106          *
    107          * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
    108          */
    109         add_theme_support( 'post-thumbnails' );
    110 
    111         /*
    112          * Switch default core markup for search form, comment form, and comments
    113          * to output valid HTML5.
    114          */
    115         add_theme_support(
    116             'html5',
    117             array(
    118                 'comment-form',
    119                 'comment-list',
    120                 'gallery',
    121                 'caption',
    122             )
    123         );
    124 
    125         /*
    126          * Enable support for Post Formats.
    127          *
    128          * See: https://codex.wordpress.org/Post_Formats
    129          */
    130         add_theme_support(
    131             'post-formats',
    132             array(
    133                 'aside',
    134                 'image',
    135                 'video',
    136                 'quote',
    137                 'link',
    138                 'gallery',
    139                 'audio',
    140             )
    141         );
    142 
    143         add_theme_support( 'menus' );
    144     }
    145 
    146     /** This Would return 'foo bar!'.
    147      *
    148      * @param string $text being 'foo', then returned 'foo bar!'.
    149      */
    150     public function myfoo( $text ) {
    151         $text .= ' bar!';
    152         return $text;
    153     }
    154 
    155     /** This is where you can add your own functions to twig.
    156      *
    157      * @param string $twig get extension.
    158      */
    159     public function add_to_twig( $twig ) {
    160         $twig->addExtension( new Twig\Extension\StringLoaderExtension() );
    161         $twig->addFilter( new Twig\TwigFilter( 'myfoo', array( $this, 'myfoo' ) ) );
    162         return $twig;
    163     }
    164 
    165 }
     14// Sets the directories (inside your theme) to find .twig files.
     15Timber::$dirname = [ 'templates', 'views' ];
    16616
    16717new StarterSite();
  • timber-library/trunk/timber-starter-theme/humans.txt

    r1736508 r3068975  
    22
    33Your name or company
    4 http://yoursite.org
    5 @you_on_twitter
     4http
     5@you
    66
    77
    88## Site
    99
    10 Software: Built with [Timber](http://upstatement.com/timber) by Upstatement
     10Software: Built with [Timber](http) by Upstatement
  • timber-library/trunk/timber-starter-theme/index.php

    r2397504 r3068975  
    1515
    1616$context          = Timber::context();
    17 $context['posts'] = new Timber\PostQuery();
     17$context['posts'] = ();
    1818$context['foo']   = 'bar';
    1919$templates        = array( 'index.twig' );
  • timber-library/trunk/timber-starter-theme/page.php

    r2397504 r3068975  
    2424$context = Timber::context();
    2525
    26 $timber_post     = new Timber\Post();
     26$timber_post     = ost();
    2727$context['post'] = $timber_post;
    2828Timber::render( array( 'page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );
  • timber-library/trunk/timber-starter-theme/phpunit.xml

    r1274158 r3068975  
    88    >
    99    <testsuites>
    10         <testsuite>
     10        <testsuite>
    1111            <directory prefix="test-" suffix=".php">./tests/</directory>
    12         </testsuite>
    13         <!-- The suite below HAS to be last to run,
    14         as it includes a test that sets some const and would contaminate
    15         the other tests as well. -->
    16         <testsuite>
    17             <directory prefix="testX-" suffix=".php">./tests/</directory>
    1812        </testsuite>
    1913    </testsuites>
  • timber-library/trunk/timber-starter-theme/search.php

    r2397504 r3068975  
    1414$context          = Timber::context();
    1515$context['title'] = 'Search results for ' . get_search_query();
    16 $context['posts'] = new Timber\PostQuery();
     16$context['posts'] = ();
    1717
    1818Timber::render( $templates, $context );
  • timber-library/trunk/timber-starter-theme/style.css

    r2397504 r3068975  
    11/*
    2  * Theme Name: My Timber Starter Theme
     2 * Theme Name: My Timber Starter Theme
    33 * Description: Starter Theme to use with Timber
    44 * Author: Upstatement and YOU!
  • timber-library/trunk/timber-starter-theme/tests/bootstrap.php

    r2175400 r3068975  
    11<?php
    22
    3 $_tests_dir = getenv('WP_TESTS_DIR');
    4 if ( !$_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
     3use WorDBless\Load;
    54
    6 require_once $_tests_dir . '/includes/functions.php';
    7 
    8 function _manually_load_plugin() {
    9     $plugins_dir = dirname( __FILE__ ).'/../../../plugins';
    10     $timber =  $plugins_dir.'/timber/timber.php';
    11     if ( file_exists($timber) ) {
    12         require_once($timber);
    13     } else {
    14         $timber_library = $plugins_dir.'/timber-library/timber.php';
    15         if ( file_exists($timber_library) ) {
    16             require_once($timber_library);
    17         }
    18     }
     5if (! file_exists( dirname(__DIR__) . '/wordpress/wp-content')) {
     6    mkdir(dirname(__DIR__) . '/wordpress/wp-content');
    197}
    208
    21 tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
    22 require $_tests_dir . '/includes/bootstrap.php';
     9if (! file_exists(dirname(__DIR__) . '/wordpress/wp-content/themes')) {
     10    mkdir(dirname(__DIR__) . '/wordpress/wp-content/themes');
     11}
     12
     13copy(
     14    dirname( __DIR__ ) . '/vendor/automattic/wordbless/src/dbless-wpdb.php',
     15    dirname( __DIR__ ) . '/wordpress/wp-content/db.php'
     16);
     17
     18$theme_base_name = basename( dirname( __DIR__ ) );
     19$src = realpath( dirname( dirname( __DIR__ ) ) . '/' . $theme_base_name );
     20$dest = dirname( __DIR__ ) . '/wordpress/wp-content/themes/' . $theme_base_name;
     21
     22if ( is_dir($src) && ! file_exists($dest) ) {
     23    symlink($src, $dest);
     24}
     25
     26require_once dirname( __DIR__ ) . '/vendor/autoload.php';
     27
     28Load::load();
Note: See TracChangeset for help on using the changeset viewer.