Create WordPress themes with beautiful OOP code and the Twig Template Engine

Overview

By Jared Novack (@jarednova), Lukas Gächter (@lgaechter), Pascal Knecht (@pascalknecht), Maciej Palmowski (@palmiak_fp), Coby Tamayo (@cobytamayo), Upstatement and hundreds of other GitHub contributors

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version WordPress Download Count WordPress Rating

Because WordPress is awesome, but the_loop isn't

Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the Twig Template Engine separate from your PHP files.

This cleans up your theme code so, for example, your PHP file can focus on being the data/logic, while your Twig file can focus 100% on the HTML and display.

This is what Timber's .twig files look like (from this Hello World example)

{{ foo }}

{{ post.title }}

{{ post.content }}
{% endblock %} ">
{% extends "base.twig" %}
{% block content %}
  <h1 class="big-title">{{ foo }}h1>
  <h2 class="post-title">{{ post.title }}h2>
  <img src="{{ post.thumbnail.src }}" />
  <div class="body">
	{{ post.content }}
  div>
{% endblock %}

Once Timber is installed and activated in your plugins directory, it gives any WordPress theme the ability to take advantage of the power of Twig and other Timber features.

Looking for docs?


Installation

The GitHub version of Timber requires Composer and is setup for inclusion within a theme or plugin. If you'd prefer one-click installation for your site, you should use the WordPress.org version.

cd ~/wp-content/themes/my-theme
composer require timber/timber

If your theme/plugin is not setup to pull in Composer's autoload file, you will need to

/* functions.php */
require_once(__DIR__ . '/vendor/autoload.php');

After this line, initialize Timber with

$timber = new \Timber\Timber();

What Now?

Setup the Timber Starter Theme. Once you have that installed in your WordPress setup, continue reading the Getting Started guide to Themeing.


Mission Statement

Timber is a tool for developers who want to translate their HTML into high-quality WordPress themes through an intuitive, consistent and fully-accessible interface.

  • Intuitive: The API is written to be user-centric around a programmer's expectations.
  • Consistent: WordPress objects can be accessed through common polymorphic properties like slug, ID and name.
  • Accessible: No black boxes. Every effort is made so the developer has access to 100% of their HTML.

What does it look like?

Nothing. Timber is meant for you to build a theme on. Like _s it comes style-free, because you're the style expert. Instead, Timber handles the logic you need to make a kick-ass looking site.

Who is it good for?

Timber is great for any WordPress developer who cares about writing good, maintainable code. It helps teams of designers and developers working together. At Upstatement we made Timber because while our entire team needs to participate in building WordPress sites, not everyone knows the ins-and-outs of the_loop(), codex and PHP (nor should they). With Timber your best WordPress engineer can focus on building the .php files with requests from WordPress and pass the data into .twig files. Once there, designers can easily mark-up data and build out a site's look-and-feel.

Related & Official Projects

  • Twig The template language used by Timber.
  • Timber Starter Theme The "_s" of Timber to give you an easy start to the most basic theme you can build upon and customize.
  • Timber Debug Bar Adds a debug bar panel that will show you which template is in-use and the data sent to your twig file.

Related Timber Projects

Projects that use Timber

  • Branch Bootstrap 3 + Timber = Branch starter theme!
  • Flynt a component based WordPress starter theme built on Timber and ACF Pro
  • Gantry5 a framework for theme development
  • Hozokit a component based starter theme
  • Seedling a starter theme using Bootstrap 4

Helpful Links

Support

Please post on StackOverflow under the "Timber" tag. Please use GitHub issues only for specific bugs, feature requests and other types of issues.

Should I use it?

It's MIT-licensed, so please use in personal or commercial work. Just don't re-sell it. Timber is used on tens of thousands of sites (and tons more we don't know about)

Contributing & Community

We love PRs! Read the Contributor Guidelines for more info. Say hello, share your tips/work, and spread the love on Twitter at @TimberWP.

Documentation

The Official Documentation for Timber is generated from the contents of this repository:

Comments
  • 2.x Documentation for API

    2.x Documentation for API

    Tickets: #1219, #1793.

    @pascalknecht and I thought about what would be the most consistent way to go forward with Object Factories and the changes that come to the API. Here’s our proposal. As discussed in #1219, we’re starting with the documentation first.

    How to navigate this proposal

    1. Read the new documentation for Posts, Terms, Class Maps and the updated documentation for the Context (see commit for changes).
    2. Read the updates to the Upgrade Guide (see commit for changes).
    3. Continue reading this pull request.

    The API

    We’ve found that the new API could evolve around Class Maps. Class Maps define what objects will be used for getting single objects as well as collections of objects. We already have them in Timber, but we don’t use them in all the places yet.

    When we only have Class Maps, we can use them as a central hub to set what classes are used in Timber. A single source of truth, so to say. We could remove the existing possibilities that we currently have in certain functions to pass in the class that should be used, like for Timber::get_posts() and Timber\PostQuery().

    @aj-dl proposed to always be explicit when instantiating new posts in https://github.com/timber/timber/pull/1219#issuecomment-503400807. We think that is a good idea in general, at least better than always getting something from a Post class, which then might not necessarily be a Post, but a child class of Post.

    However, by being explicit, we could only be explicit with objects that can be instantiated directly. But for all other functionality like $post->thumbnail() where the instantiation is hidden in a function, we would still have to rely on the Class Map. It still wouldn’t be clear when exactly the classes we defined in the Class Map would be used.

    I myself have recently found that when I had to define the class that should be used in several places, I ran into a couple of cases where I was confused why something didn’t work, until I realized that I didn’t pass the class to be used in a function parameter. If we’d have Class Maps only, we wouldn’t have to think about instantiating objects with the proper class all the time.

    Because of @aj-dl’s comments, we explored the different options we had for the API and thought about the following possibilities:

    • PostFactory::get() and PostQueryFactory::get() – Like I commented in other issues before, I would find it great if we wouldn’t introduce the concept of factories into the API, but keep it hidden behind the scenes. Developers should be able to start with Timber without having to understand the concept of factories.
    • Post::get() and PostQuery::get() – Here we would clearly state what we get, but there could be confusion about the naming. And we would probably have to rename the Timber\Post class to something like Timber\BasePost and make get() the only method in Post.
    • Timber::post() or Timber::posts() – Here it might not be clear enough that you get something. It could also be understood as posting something.

    Which leads us to the proposed API. We think we should use the functions we already have:

    • Timber::get_post()
    • Timber::get_posts()
    • Timber::get_term()
    • Timber::get_terms()

    This is basically what @acobster already proposed in https://github.com/timber/timber/pull/1219#issuecomment-435624322. All of these functions could rely on Class Maps. The benefits of this API would be:

    • 👍 Developers can mostly use the API they already know. It’s really close to how WordPress works. We will make usage stricter though, with some deprecations.
    • 👍 By using Class Maps, you define what custom classes are used and when in a single place. If you want to use a new method in Twig and extend Timber with a new class, you only need to update the Class Map and update your Twig file, but not every instantiation of where you need to use that class.
    • 👍 By defining all public functions in the Timber class, developers get a nice overview of the API when looking at the code or the online documentation.
    • 👍 Automatic template contexts become even easier. There’s no need to manually call setup() when using a custom class, because the context also uses a Class Map.

    The drawbacks:

    • 😔 With Class Maps, you don’t see right in the code what class you’re dealing with and you can’t make use of navigating to that class in your IDE. Syntax highlighting might not work properly without adding custom DocBlocks with @var definitions.

    Do you see any other benefits or drawbacks? We’d be pleased to hear them.

    Factories

    For the factories implementation, I think we’re still on track in https://github.com/timber/timber/pull/1793 and can continue discussing and working out the details about the factories themselves there.

    This pull request can be used for the changes to the documentation (without documentation in DocBlocks).

    Proposed Changes

    When we stay with the proposed API, we can target to release Timber 2.0 sooner, because the only thing that’s holding us back is how the public API will look like. There are changes that need to be made for 2.0 and then there are changes that we can make later, in 2.x.

    Changes for 2.0

    For 2.0, we could implement updates to the API for post objects only.

    • [x] Add option to use callback functions in Class Maps. #2093
    • [x] Add Class Maps for Terms, Users and Comments. #2093
    • [x] Always use an array instead of a string as the default argument passed to the timber/post/classmap filter. #2093
    • [x] Deprecate Update the API to prohibit passing in the class to use for instantation in all post functions and use the Post Class Map as the single source of truth. #2090
    • [x] Deprecate Update the API to prohibit passing in query strings to Timber::get_posts(), like here: Timber::get_posts( 'post_type=article' ); #2090
    • [x] Deprecate Update the API to prohibit passing in the class to use for instantation in all functions and use the new Class Maps as the single source of truth. #2090
    • [x] Implement Timber::get_menu(), Timber::get_user(), and Timber::get_comment() methods. #2089, #2197
    • [x] Replace all direct instantiations in core and tests with the corresponding Timber::get_* calls. #2094
    • [x] Throw a doing-it-wrong exception when a Post [Term, Menu, Comment or User ] or PostQuery object is instantiated directly. (Is that even possible?) Make Post, Term, Comment, and User constructors protected. #2088 ( Menu and MenuItem constructors will be made protected in #2292)
    • [x] Add to_array() to Collection classes so that we can use something like Timber::get_posts( $query )->to_array().
    • [x] Add a new User Guide.
    • [x] Deprecate Timber\PostClassMap filter and rename it to timber/post/classmap. Currently, it’s called timber/post/post_class in the 2.x branch. #2293
    • [ ] Determine what happens when a timber/*/classmap filter callback returns something other than a CoreInterface. (Probably should throw an exception rather than just letting it TypeError.) - also #2293
    • [ ] Finalize type declarations #1863
    • [ ] Implement the new PagesMenu API. #2292
    • [x] Implement ::get_image() and ::get_attachment() top-level methods and corresponding Twig functions. #2333

    Backwards compatibility

    With the proposed API, we would replace the existing API for Timber::get_post() and Timber::get_posts(). We will have to consider what happens with the differences between get_posts() and WP_Query as discussed in https://github.com/timber/timber/issues/1957.

    Open Questions/Discussion

    @jarednova, @pascalknecht, @acobster, @palmiak, @aj-adl: I’d be happy to get your opinions on this pull request. Some more questions came up while working on this pull request:

    • ~~I know Inheritance is not always the best option for Object Oriented Programming. Does anybody see any problems with class conflicts?~~
    • ~~Are callback functions in the Class Maps enough to have advanced control over what class is used when?~~
    • For the API in Twig, we still have Post, PostQuery, etc. For consistency, should we consider renaming these functions to get_post(), get_posts(), etc?
    • ~~Should we use Timber::get_posts() or Timber::query_posts()? Would it be more clear that query_posts() returns a query/collection of posts, and not an array of posts?~~

    Todo

    • [x] Update Context Guide with new function signatures.
    • [x] Document no_found_rows, see https://github.com/timber/timber/pull/2073#issuecomment-535720949. → Documented in https://github.com/timber/timber/blob/2.x-docs-api/docs/v2/guides/posts.md#count-rows-only-if-needed
    • [x] Document Timber::get_posts( $query )->to_array(), see https://github.com/timber/timber/pull/2073#issuecomment-571375271.
    • [x] Document difference between post arrays and PostCollections. → Documented in https://github.com/timber/timber/pull/2073/commits/508aa9efee730798288592a7d67becec20b84c0d
    • [x] Optimize API for Menu Class Maps #2247.
    • [x] Document JSON serialization of posts #2311. (#2335)
    • [x] Update Upgrade Guide with updates added in #2311. Done in https://github.com/timber/timber/pull/2073/commits/82b6a6abb40f614e6821714f10b82d75042a6185.
    • [x] Update Upgrade Guide with changes from THE PURGE in #2354, including the removal of the timber/get_posts/mirror_wp_get_posts filter. Done in #2367.
    2.0 
    opened by gchtr 51
  • Using Timber library with Bedrock

    Using Timber library with Bedrock

    I've been using Timber with Bedrock.

    Until RC3, there were no major issues. Now Timber calls is_admin() and uses WordPress hooks on being loaded. Because Bedrock loads Composer dependencies before WordPress this will cause a fatal error.

    Is the only solution to switch to the plugin version of Timber?

    confirm-and-close needs-investigation has-patch 
    opened by chrisgherbert 40
  • 2.x improve meta field handling

    2.x improve meta field handling

    Hi there,

    Happy new year to the Timber team!

    Issue

    ACF and Timber have different ways of representing some common values like image, dates, etc.

    For example, native WordPress images (e.g. post thumbnails) are Timber\Image objects whereas ACF images are arrays. More importantly, they don't share the same keys for holding the same values (url ≠ src, mime_type ≠ post_mime_type, etc.).

    I find this a bit annoying and confusing to switch between those two representations. It can also be error prone.

    Solution

    Convert fields that can be converted (like Timber does for post objects) to Timber/standard objects and have a unified API when working with data in templates.

    I'm thinking about those fields:

    • image -> Timber\Image
    • gallery -> array of Timber\Image
    • date picker -> DateTime object
    • date time picker -> DateTime object

    I'm already using it in my own projects and I think it would be great if those features were implemented in Timber core.

    Impact

    This will cause some breaking changes because {{ post.meta('my_key') }} will not return the same values anymore but hey, that's what major version are made for 😁

    I chose to not honor the "return format" value in ACF which is almost (not to say always) useless, at least to me. Let me know if you see some use case where it could be legitimately used. This is a draft opened for discussion.

    Usage Changes

    Most notable changes:

    • no "return format" anymore, images fields will always return Timber\Image, dates will always return DateTime objects, etc.
    • key/values changes

    Considerations

    Nothing comes to mind.

    Testing

    This PR only contains image test right now as it's a draft.

    2.0 
    opened by nlemoine 39
  • 2.x posts api

    2.x posts api

    Work in progress final port of the Posts API to use Factories under the hood.

    • [x] Switch ::get_post[s]() API to use Factories
    • [x] Replace a bunch of direct instantiations in the tests
    • [x] Fix Term::posts()
    • [x] Post::build() method
    • [x] Attachment/Image class map callback
    • [x] Update Twig functions (@gchtr doing on #2178)
    • [x] Simplify PostQuery::__construct() to only accepting a WP_Query instance (with no wrapping it in an array)
    • [x] Fix #2178 and merge in to this feature branch
    • [x] Make Post::__construct() protected, annotate WP_Post arg
    • [x] Timber::get_attachment_by()
    • [x] Close the loop on whether we need to pass an array as a second arg to wp_check_filetype()
    • [x] Attachment::__construct() has an option to pass an array like ['ID' => 123] ~...are we good to drop support for this? Otherwise we would need to handle this special case in ::get_post().~ we need to support this for ACF integration, so add a special case for this in ::get_post() (or PostFactory?)
    • [x] @expectedIncorrectUsage is failing randomly on those two tests...y tho.
    • [x] deprecate Attachment::get_pathinfo() and Image::get_pathinfo() and use Attachment::pathinfo() only to be in line with other post method names.
    • [x] Support the merge_default option in ::get_post[s]()
    opened by acobster 36
  • TimberImage: Incorrect URL returned when image is stored off-server

    TimberImage: Incorrect URL returned when image is stored off-server

    When calling get_src (either directly or through typecasting a TimberImage instance to a string), the method doesn't take into account any of the standard WP methods for retrieving the image's URL (e.g. wp_get_attachment_url or wp_get_attachement_image_src) and instead goes off and does it's own thing for deriving the URL.

    This works fine in what I would expect to be the majority of use-cases, however where other plugins are used to modify the location of files (in my case, moving uploaded files to an S3 bucket and then removing them from the server), this no longer works.

    I suppose this is partially an issue with the other plugin, however they correctly apply a filter to the result of the above core method calls that would otherwise allow it to play nicely with other plugins. i.e. Calling wp_get_attachment_url($id) shows the Amazon S3 URL, not the (incorrect) location on the server.

    Is there a reason why you went with a custom implementation over using a core method?

    As a workaround for my case (and would work for anyone else affected by this issue), I just sub-classed TimberImage and overrode the get_src method:

    <?php
    
    namespace MyProject\PostType;
    
    
    class Image extends \TimberImage {
        /**
         * @var int
         */
        private $iid;
    
        /**
         * @param int $iid
         */
        public function __construct($iid) {
            $this->iid = $iid;
    
            parent::__construct($iid);
        }
    
        /**
         * @param string|array $size - See http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
         * @return array|bool|string
         */
        public function get_src($size = 'full') {
            return wp_get_attachment_image_src($this->iid, $size)[0];
        }
    } 
    
    

    I'm happy to put a PR up to correct this, but as I don't fully understand the reasoning behind the current implementation I'm reluctant to do so without hearing from you first.

    Thanks (and thanks for the library, it's awesome!) :)

    confirm-and-close has-patch CDN 
    opened by TomSeldon 35
  • Add support for path namespaces.

    Add support for path namespaces.

    Issue

    When looking into timber for a project I'm currently working on, I was looking to make use of path namespaces (e.g. https://symfony.com/doc/current/templating/namespaced_paths.html#registering-your-own-namespaces) but it seems that Timber doesn't currently support this.

    Solution

    This patch introduces support for path namespace, at time of writing only as part of user defined locations, however this could easily be added to to support namespace in theme dirs as well if you wanted.

    Impact

    It should be backwards compatible, so it shouldn't have any negative impact on existing users.

    Update This will have an affect on users of some filters, see https://github.com/timber/timber/pull/1791#issuecomment-423122266

    Usage Changes

    Users who wish to make use of path namespaces can now do so, e.g. with a styleguide namespace

    Timber::$locations = array(
        '/Users/jared/Sandbox/templates',
        '~/Sites/timber-templates/',
        ABSPATH.'/wp-content/templates',
        ABSPATCH.'/wp-content/styleguide' => 'styleguide'
    );
    

    Considerations

    I've not spent too much time on this patch, I'm hoping for some guidance/advice if there are any edge cases I may not have considered as I am very new to this library.

    ~It's also worth noting that I've just checked for a namespace presence and ignored if none there, but we could easily change to give each location the default namespace (__MAIN__) if none is configured, to cut down on an if statement.~

    Update This now does indeed set the default namespace.

    Testing

    ~I included one basic unit test, but would be happy to add more if you think this patch is worth including.~

    Update Have included several useful tests.

    opened by jenkoian 31
  • Resize filter not returning new path

    Resize filter not returning new path

    Expected behavior

    Resize filter should return new path I'm experiencing a similar issue to #237. Resize filter was working, but now it is not. The image is still being created (it is in the content/uploads directory), but the original upload URL is being included instead. Oddly, it is working just fine on my staging site and local server with the same codebase and Timber / WP versions. I've had this happen recently with another site too, but the error occurred on the staging site rather than production.

    I noticed the issue after upgrading to Timber 1.2.1, but I am using the same version of Timber across all of my installs and not experiencing the problem everywhere.

    Questions from Issue #237:

    Are you running WP from a subdirectory?

    No

    Do you have "normal" setup with /wp-content/uploads/ etc.?

    Yes

    Do all images fail?

    Yes

    Actual behavior

    Resize filter creating cropped image but not returning the path

    Steps to reproduce behavior

    {% for accessory in post.get_field('featured_accessory') %}
      <img alt=""
        src="{{ TimberImage(accessory.image).src | resize(400, 266) }}"
        sizes="(max-width: 47.9375em) 100vw, (max-width: 59.9375em) 50vw, 33vw"
        srcset="{{ TimberImage(accessory.image).src | resize(400,266) }} 400w, {{ TimberImage(accessory.image).src | resize(750,500) }} 750w">
    {% endfor %}
    

    What version of WordPress, PHP and Timber are you using?

    WordPress 4.7.1, Timber 1.2.1

    How did you install Timber?

    Upgraded to newest version via plugin updater in WordPress dashboard.

    bug has-patch CDN 
    opened by saralohr 31
  • Custom Routes Usage

    Custom Routes Usage

    Hello, I have added the following to my functions.php:

    Timber::add_route('blog/:name', function($params){
          $context = Timber::get_context();
          $args = 'category_name='.$params['name'];
          $posts = Timber::get_posts($args);
          $context['posts'] = $posts;
          Timber::render('index.twig', $context);
    });
    

    If I now call eg: localhost/blog/food It will display all Posts with the category food, but also the 404 Page content is shown.

    What am I missing?


    I also tried :

    Timber::add_route('blog/:name', function($params){
    
        $query = $params['name'];
        Timber::load_template('index.php', $query);
    });
    

    but I get :

    
    Strict Standards: Non-static method Timber::load_template() should not be called statically in /Applications/MAMP/htdocs/wordpress/wp-content/themes/timber-starter-theme/functions.php on line 57
    
    Warning: array_keys() expects parameter 1 to be array, string given in /Applications/MAMP/htdocs/wordpress/wp-includes/class-wp.php on line 420
    
    Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/wordpress/wp-content/themes/timber-starter-theme/functions.php:57) in /Applications/MAMP/htdocs/wordpress/wp-includes/pluggable.php on line 875
    
    opened by daslicht 30
  • Override Timber templating sytem

    Override Timber templating sytem

    I am new to Timber and I have inherited a site that is using Timber and Twig. I need to know if there is a way to overide or skip over the Timber system for one template. I have a very complicated custom template I need to create and I want to bypass the system for this one template. I have tried in both the functions, index file to check for if the template is being used to not load all of the Timber files but not having success.

    Thanks in advanced for any help.

    opened by redsoxfan2499 26
  • Repeater within Relationship returning String instead of Array

    Repeater within Relationship returning String instead of Array

    Expected behavior

    I have a relationship field pulling in a repeater of images and expect them to display.

    Actual behavior

    If I print_r I only get the count of how many images there are printed. A dump returns:

    string(1) "4"

    I tried setting the repeater field to return Array, URL and ID on the image field and they all produce the same result. I know I've done this in past versions of Timber, so I'm wondering if something has shifted in how I need to get these field values?

    Steps to reproduce behavior

    PHP file:

    $context['featured_case_studies'] = get_field('featured_case_studies');

    Twig file:

    {% for study in featured_case_studies %} {% set study = TimberPost(study) %} <div class="case-study-entry" id="study-0{{loop.index}}"> <div class="study-title"> <span>Case Study</span> <h4>{{study.title}}</h4> <h3 class="location">{{study.location}}</h3> <a href="" class="view-photos"><img src="{{site.theme.link}}/assets/img/view-photos.gif" alt=""></a> <div id="" class="project-photos"> {{ dump(study.project_photos) }} {% for photo in study.project_photos %} <a href="" rel="study-0{{loop.index}}" class="fancybox"><img src="{{TimberImage(photo.project_image).src|resize(1200,9999,'center')}}" alt=""></a> {% endfor %} </div> </div> </div> {% endfor %}

    (Not sure why my code won't format properly, sorry for that. Spacing it out only made it worse).

    What version of WordPress, PHP and Timber are you using?

    WP 4.5.2 and Timber 10.0.1

    How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)

    Downloaded from wp.org

    UPDATE

    I did roll back Timber and got the same behavior.

    question 
    opened by cheestudio 25
  • Namespacing

    Namespacing

    Ticket: #869 Reviewer: @jarednova

    Issue

    Modernising Timber to use namespaces

    Solution

    A lot of code changes...

    Impact

    Is fully backwards compatible, I was thinking of using a trait, but as the list of classes that needed backwards compatibility is atomic, it was easier just to create a function.

    Usage

    Yes, too much to list here. See considerations.

    Considerations

    We need to update all the docs to represent this new change.

    Testing

    Tests need updating with this.

    For now to test you can do the following composer require timber/timber:dev-dev-namespacing

    opened by connorjburton 25
  • Timber::get_post do not work after updating WP from 5.8.5 to 6.11

    Timber::get_post do not work after updating WP from 5.8.5 to 6.11

    After updating WP from 5.8.5 to 6.1.1 Timber::get_post and Timber::get_posts return null on posts, categories, and tags.

    Expected behavior

    return non empty WP_Query with actual post / taxonomy

    Actual behavior

    global $wp_query; also returns null

    object(WP_Query)[7856]
      public 'query' => null
      ...
    

    get_the_ID() return false or 0

    Steps to reproduce behavior

    just update WP from 5.8.5 to 6.1.1

    What version of WordPress, PHP, and Timber are you using?

    Example: WordPress 6.1.1, PHP 7.4, Timber 1.3.4

    How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)

    Timber installed as a lib inside the project

    needs-info 
    opened by taurus-git 4
  • Fix User entity

    Fix User entity

    Issue

    Setting public properties for user meta fields results in {{ user.first_name }} to return null. Because those properties are not WP_User properties and thus not imported.

    Since those properties are declared, Twig will not retrieve them either: https://twig.symfony.com/doc/3.x/templates.html#variables

    Solution

    Remove public properties matching user meta so __call in Timber\Core is actually called.

    Impact

    None.

    Usage Changes

    You can now do {{ user.first_name }}, {{ user.last_name }}, etc.

    Testing

    Just changed the test with description to ensure this works fine.

    2.0 
    opened by nlemoine 2
  • Pagination with custom query doesn't seem to work

    Pagination with custom query doesn't seem to work

    Expected behavior

    I want to display pagination under a list of posts on a custom page template. I'd expect to see the pagination based on the values in $context['posts']

    Actual behavior

    I don't get any pagination at all. The pagination.pages var is empty.

    Steps to reproduce behavior

    I used the following code, based on https://timber.github.io/docs/v2/guides/pagination/#what-if-im-not-using-the-default-query?

    use Timber\Timber;
    use Timber\Pagination;
    if (!isset($paged) || !$paged) {
    	$paged = 1;
    }
    $context = Timber::context();
    
    $context['posts'] = Timber::get_posts( [
    	'post_type' => 'post',
    	'paged' => $paged,
    ] );
    
    // Set pagination to show 2 pages before and 2 after the current selected page.
    $context['pagination'] = Pagination::get_pagination( [
    	'mid_size' => 2,
    	'end_size' => 1,
    	'show_all' => false,
    ] );
    
    echo Timber::compile( [ 'partials/post-list/list.twig' ], $context );
    

    It looks like the $wp_query var is not passed to the Pagination class which caused it to use the $wp_query of the current page, which (logically) has no pagination.

    What version of WordPress, PHP and Timber are you using?

    WordPress: 6.1.1 PHP: 7.4.21 TImber: 2.0.0-beta.1

    How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)

    Timber is installed via composer.

    opened by YourMark 3
  •  PHP Fatal error after PHP upgrade (8.0 or higher)

    PHP Fatal error after PHP upgrade (8.0 or higher)

    Hi, I am upgrading PHP on this website since we are using PHP 7.4, however, once I go to PHP 8.0+ I get a Fatal error and I see this on the error log:

    PHP Fatal error:  Uncaught Error: Undefined constant "ENV" in /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Extension/CoreExtension.php:1661
    Stack trace:
    #0 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Extension/CoreExtension.php(1661): constant('ENV')
    #1 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php(497) : eval()'d code(30): twig_constant('ENV')
    #2 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(453): __TwigTemplate_53e9d8e1532f224322e40f11d9628ced0ef859351326ec40020691e39bf7212b->doDisplay(Array, Array)
    #3 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(420): Twig\Template->displayWithErrorHandling(Array, Array)
    #4 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php(497) : eval()'d code(84): Twig\Template->display(Array)
    #5 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(453): __TwigTemplate_463bbf3a9ad038b5ee00f4f934eb82c973c950e04f16fdf7b490be87ad3d210b->doDisplay(Array, Array)
    #6 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(420): Twig\Template->displayWithErrorHandling(Array, Array)
    #7 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php(497) : eval()'d code(35): Twig\Template->display(Array, Array)
    #8 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(453): __TwigTemplate_6117eef2967e4024a8ddd13d22f98637553697006029f77f64e8511beda77b5b->doDisplay(Array, Array)
    #9 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(420): Twig\Template->displayWithErrorHandling(Array, Array)
    #10 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php(497) : eval()'d code(31): Twig\Template->display(Array)
    #11 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(453): __TwigTemplate_1412182097d0a23bc5f170f22c3537c40d9efcdedeb01625fc6e0e9929b2a5d5->doDisplay(Array, Array)
    #12 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(420): Twig\Template->displayWithErrorHandling(Array, Array)
    #13 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(432): Twig\Template->display(Array)
    #14 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/TemplateWrapper.php(47): Twig\Template->render(Array, Array)
    #15 /dom42117/wp-content/plugins/timber-library/lib/Loader.php(79): Twig\TemplateWrapper->render(Array)
    #16 /dom42117/wp-content/plugins/timber-library/lib/Timber.php(334): Timber\Loader->render('page.twig', Array, false, 'default')
    #17 /dom42117/wp-content/plugins/timber-library/lib/Timber.php(383): Timber\Timber::compile(Array, Array, false, 'default', true)
    #18 /dom42117/wp-content/plugins/timber-library/lib/Timber.php(410): Timber\Timber::fetch(Array, Array, false, 'default')
    #19 /dom42117/wp-content/themes/accedian/page.php(70): Timber\Timber::render(Array, Array)
    #20 /wordpress-versions/6.1.1/wp-includes/template-loader.php(106): include('/dom42117/wp-co...')
    #21 /wordpress-versions/6.1.1/wp-blog-header.php(19): require_once('/wordpress-vers...')
    #22 /wordpress-versions/6.1.1/index.php(17): require('/wordpress-vers...')
    #23 {main}
      thrown in /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Extension/CoreExtension.php on line 1661
    

    WordPress 6.1.1, PHP 8.0, Timber 1.22.1

    Thanks!

    opened by Castiblanco 3
  • Using meta_query with custom query vars leads to 404 on pagination

    Using meta_query with custom query vars leads to 404 on pagination

    I have a CPT that I'm filtering with custom query vars associated with ACF fields. Pagination pages lead to 404 whenever the meta_query is active. I've tried every possible solution I can find in the docs and on Stackoverflow. Any assistance would be appreciated.

    On search.php:

    if ( $post_type == 'funded_grants' ) {
    
      $program_type = get_query_var('program_type');
      $contributor = get_query_var('contributor');
      $researchers = get_query_var('researchers');
      $area_of_research = get_query_var('area_of_research');
      $disease_areas = get_query_var('disease_areas');
      $province = get_query_var('province');
      $start_date = get_query_var('start_date');
      $end_date = get_query_var('end_date');
    
      $meta_query = bc_create_meta_query();
    
      $args = [
        's' => $text_query,
        'meta_query' => $meta_query,
      ];
    
      $context['posts'] = new Timber\PostQuery($args);
    
      Timber::render(['archive-funded_grants.twig'], $context);
    
    }
    

    In functions.php

    function filterFundedGrantsSearch($query) {
        if ($query->is_search && $query->get('post_type') == 'funded_grants' && !is_admin() ) {
          $query->set( 'posts_per_page', 5 );
          $query->set( 'paged', (get_query_var('paged')) ? get_query_var('paged') : 1 );
        }
        return $query;
      }
    
      add_filter('pre_get_posts','filterFundedGrantsSearch');
    
    function bc_create_meta_query()
    {
        $program_type = get_query_var('program_type');
        $contributor = get_query_var('contributor');
        $researchers = get_query_var('researchers');
        $area_of_research = get_query_var('area_of_research');
        $disease_areas = get_query_var('disease_areas');
        $province = get_query_var('province');
        $start_date = get_query_var('start_date');
        $end_date = get_query_var('end_date');
    
        $meta_query = array();
    
        if (isset($program_type) && $program_type > 0) {
            $meta_query[] = array(
                'key' => 'fg_program_type',
                'value' => array($program_type),
                'compare' => 'IN',
            );
        }
    
        if (isset($contributor) && $contributor == 'on') {
            $meta_query[] = array(
                'key' => 'fg_contributor',
                'value' =>  3500,
                'compare' => 'LIKE',
            );
        }
    
        if (isset($researchers) && $researchers > 0) {
            $meta_query[] = array(
                'relation' => 'OR',
                array(
                    'key' => 'fg_principal_investigator',
                    'value' =>  $researchers,
                    'compare' => 'LIKE',
                ),
                array(
                    'key' => 'fg_team_members',
                    'value' => $researchers,
                    'compare' => 'LIKE',
                )
            );
        }
    
        if (isset($disease_areas) && $disease_areas > 0) {
            $meta_query[] = array(
                'key' => 'fg_disease_areas',
                'value' => $disease_areas,
                'compare' => 'IN',
            );
        }
    
        if (isset($area_of_research) && $area_of_research > 0) {
            $meta_query[] = array(
                'key' => 'fg_area_of_research',
                'value' => array($area_of_research),
                'compare' => 'IN',
            );
        }
    
        if (isset($province) && $province > 0) {
            $meta_query[] = array(
                'key' => 'fg_province',
                'value' => array($province),
                'compare' => 'IN',
            );
        }
    
        if (isset($start_date) && $start_date > 1) {
            $meta_query[] = array(
                'key'     => 'fg_start_date',
                'value'   => $start_date,
                'compare' => '>=',
            );
        }
    
        if (isset($end_date) && $end_date > 1) {
            $meta_query[] = array(
                'key'     => 'fg_end_date',
                'value'   => $end_date,
                'compare' => '<=',
            );
        }
    
        if (count($meta_query) > 1) {
            array_unshift($meta_query, array('relation' => 'AND'));
        }
    
        return $meta_query;
    }
    

    Timber is installed with Composer. Wordpress 6.1.1. PHP 8.1.9.

    opened by Mikewalker24 0
Releases(1.22.1)
  • 1.22.1(Nov 24, 2022)

    What's Changed

    • Fixed a bug when Twig version 3 was accidentally installed when installing Timber through Composer, by @rmens in https://github.com/timber/timber/pull/2679.

    Full Changelog: https://github.com/timber/timber/compare/1.22.0...1.22.1

    Source code(tar.gz)
    Source code(zip)
  • 1.22.0(Nov 8, 2022)

    This resolves issues with a prior deploy of 1.21.0 to WP.org by correctly targeting the versions of Twig and PHP.

    What's Changed

    • Fix bugs with latest plugin release 1.21.0 by @gchtr in https://github.com/timber/timber/pull/2658

    Full Changelog: https://github.com/timber/timber/compare/1.21.0...1.22.0

    Source code(tar.gz)
    Source code(zip)
  • 1.21.0(Oct 12, 2022)

    This release comes with compatibility for PHP 8.0 and 8.1. To support this, we updated the minimum required PHP version from 5.3 to 7.2.

    (Please be aware that WordPress itself is still in beta support for PHP 8.0 and 8.1, which means it’s not completely completely compatible yet (see Trac tickets). You might see deprecation warnings for some functionality in WordPress.)

    What’s changed

    • Fixed support for PHP 8.0 and PHP 8.1 by @nlemoine in https://github.com/timber/timber/pull/2638
    • Updated minimum required PHP version to 7.2 to make the included Twig version (1.44) support PHP 8.0 and 8.1, by @gchtr in https://github.com/timber/timber/pull/2640
    • Added release checklist by @jarednova in https://github.com/timber/timber/pull/2597
    • Deleted deprecated ISSUE_TEMPLATE.md by @szepeviktor in https://github.com/timber/timber/pull/2598

    Full Changelog: https://github.com/timber/timber/compare/1.20.0...1.21.0

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-beta.1(Aug 5, 2022)

    This is the first beta version of the long awaited Version 2 of Timber. We consider this beta feature-complete. We will concentrate on fixing bugs to be able to soon release a first release candidate.

    You can try it out by following the Installation Guide. When installing Timber through Composer, you need to quire the 2.0.0-beta.1 version:

    composer require timber/timber:2.0.0-beta.1
    

    There are quite a few breaking changes in Version 2 of Timber. Refer to the Upgrade Guide for more information.

    The overall goals of Timber 2.0 include:

    • Making Timber more consistent.
    • Making Timber easier to handle and extend.
    • Refactoring how Timber Core works under the hood to improve compatibility with WordPress Core and be ready for future challenges.
    • Making Timber more compatible with other plugins.

    High-level changes include:

    We’re happy if you want to test out the first Timber beta. In case you find errors, please open an issue (and label with 2.x and bug) or create a discussion in case you have questions.

    We want to thank so so so many people for being a part of Timber and helping us achieve this milestone. We're so proud of the work and the evolution to a stable and widely-used part of so many developer's tools.


    If you've been using the alpha versions, here's what's changed in this version of 1.0.0-beta.1:

    What's Changed

    • Add a .git-blame-ignore-revs file by @gchtr in https://github.com/timber/timber/pull/2606
    • 2.x Add missing query() method to Timber\PostQuery by @gchtr in https://github.com/timber/timber/pull/2613
    • 2.x Reintroduce Timber’s WP-CLI integration by @gchtr in https://github.com/timber/timber/pull/2611
    • 2.x Remove unused WPML integration class by @gchtr in https://github.com/timber/timber/pull/2616
    • 2.x Remove Attachment::$caption property in favor of Attachment::caption() method by @gchtr in https://github.com/timber/timber/pull/2612
    • Make snippets CS compliant by @nlemoine in https://github.com/timber/timber/pull/2620
    • 2.x update tests fix indentation by @nlemoine in https://github.com/timber/timber/pull/2622
    • 2.x Fix tests in #2614 by @gchtr in https://github.com/timber/timber/pull/2621
    • Use yoast/wp-test-utils by @nlemoine in https://github.com/timber/timber/pull/2614
    • 2.x Document the timber/menuitem/classmap filter by @gchtr in https://github.com/timber/timber/pull/2618
    • 2.x Add wp_object() method and $wp_object property for Core objects by @gchtr in https://github.com/timber/timber/pull/2615
    • 2.x Update Upgrade Guide by @gchtr in https://github.com/timber/timber/pull/2617
    • 2x Update CONTRIBUTING.md by @gchtr in https://github.com/timber/timber/pull/2619

    Full Changelog: https://github.com/timber/timber/compare/2.0.0-alpha.5...2.0.0-beta.1

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha.6(Jul 5, 2022)

    What's Changed

    • Improve #2592 by @szepeviktor in https://github.com/timber/timber/pull/2593
    • Add lint-composer script by @nlemoine in https://github.com/timber/timber/pull/2594
    • Add QA tooling by @nlemoine in https://github.com/timber/timber/pull/2592
    • add correct title to "Extending Twig" guide in v2 docs by @stefenphelps in https://github.com/timber/timber/pull/2602

    Full Changelog: https://github.com/timber/timber/compare/2.0.0-alpha.5...2.0.0-alpha.6

    Source code(tar.gz)
    Source code(zip)
  • 1.20.0(Jun 22, 2022)

    What's Changed

    • Use newest version of Upstatement/routes by @jarednova in https://github.com/timber/timber/pull/2595

    Full Changelog: https://github.com/timber/timber/compare/1.19.2...1.20.0

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha.5(Jun 22, 2022)

    What's Changed

    • Bump version of Upstatement/Routes to 0.8.1 by @jarednova in https://github.com/timber/timber/pull/2512
    • Add a timber/{object}/class to all objects types by @nlemoine in https://github.com/timber/timber/pull/2513
    • Handle for duplicate term names in difft taxes by @jarednova in https://github.com/timber/timber/pull/2390
    • Fix typo in resize error message. by @Web-Assembler in https://github.com/timber/timber/pull/2523
    • Add webp support to letterbox filter by @ThomasBerends in https://github.com/timber/timber/pull/2528
    • 2.x Fix tests by @gchtr in https://github.com/timber/timber/pull/2547
    • Update composer/installers from v1 to v2 by @adamtomat in https://github.com/timber/timber/pull/2543
    • Update composer/installers from v1 to v2 by @adamtomat in https://github.com/timber/timber/pull/2544
    • Introduce Timber::init() as official way to initialize Timber by @gchtr in https://github.com/timber/timber/pull/2549
    • Test against Latest WP Version instead of Trunk by @jarednova in https://github.com/timber/timber/pull/2563
    • Improve composer version ranges by @gchtr in https://github.com/timber/timber/pull/2550
    • 2.x Remove twig/cache-extension, add support for twig/cache-extra by @gchtr in https://github.com/timber/timber/pull/2546
    • Menu API enhancements by @nlemoine in https://github.com/timber/timber/pull/2517
    • 2.0 Use null instead of false as return type in factories by @gchtr in https://github.com/timber/timber/pull/2566
    • 2.x Clean up Timber\PostCollection by @gchtr in https://github.com/timber/timber/pull/2579
    • 2.x Don’t overwrite post global by @gchtr in https://github.com/timber/timber/pull/2545
    • 2.x Use assertTrue() and get_class() instead of assertInstanceOf() in certain tests by @gchtr in https://github.com/timber/timber/pull/2591
    • 2.x Implement new PagesMenu API by @gchtr in https://github.com/timber/timber/pull/2562
    • 2.x Update Upgrade Guide with Twig deprecations by @gchtr in https://github.com/timber/timber/pull/2565

    New Contributors

    • @Web-Assembler made their first contribution in https://github.com/timber/timber/pull/2523
    • @ThomasBerends made their first contribution in https://github.com/timber/timber/pull/2528

    Full Changelog: https://github.com/timber/timber/compare/2.0.0-alpha.4...2.0.0-alpha.5

    Source code(tar.gz)
    Source code(zip)
  • 1.19.2(Apr 21, 2022)

    What's Changed

    • Handle for duplicate term names in difft taxes by @jarednova in https://github.com/timber/timber/pull/2390
    • Fix typo in resize error message. by @Web-Assembler in https://github.com/timber/timber/pull/2523
    • Add webp support to letterbox filter by @ThomasBerends in https://github.com/timber/timber/pull/2528
    • Update composer/installers from v1 to v2 by @adamtomat in https://github.com/timber/timber/pull/2543
    • Improve composer version ranges by @gchtr in https://github.com/timber/timber/pull/2550

    New Contributors

    • @Web-Assembler made their first contribution in https://github.com/timber/timber/pull/2523
    • @ThomasBerends made their first contribution in https://github.com/timber/timber/pull/2528

    Full Changelog: https://github.com/timber/timber/compare/1.19.1...1.19.2

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha.4(Oct 22, 2021)

    What's Changed

    • #2445 Fix documentation inconsistencies around minimum requirements by @gchtr in https://github.com/timber/timber/pull/2506
    • 2.x Fix invalid type in DocBlock by @gchtr in https://github.com/timber/timber/pull/2511
    • 2.x: Nav menus improvements by @nlemoine in https://github.com/timber/timber/pull/2504
    • Make cache extension optional and let users choose their own implemen… by @nlemoine in https://github.com/timber/timber/pull/2486
    • 2.x Improve Date/Time Guide by @gchtr in https://github.com/timber/timber/pull/2424
    • Update the readme with new link to Twig by @AlexVWeb in https://github.com/timber/timber/pull/2465
    • #2417 Add GitHub Actions for 2.x and update version requirements by @gchtr in https://github.com/timber/timber/pull/2480
    • Github Actions tests (2.x) by @nlemoine in https://github.com/timber/timber/pull/2417
    • Don't prefer lowest for WebP tests by @jarednova in https://github.com/timber/timber/pull/2481
    • Fix bug when using switch_to_blog() in combination with Timber images by @gchtr in https://github.com/timber/timber/pull/2478
    • Fix the thumbnail() method return type by @titouanmathis in https://github.com/timber/timber/pull/2463
    • 2.x Improve routing docs by @gchtr in https://github.com/timber/timber/pull/2469
    • 2.x Add hint about checking for Timber’s version by @gchtr in https://github.com/timber/timber/pull/2479
    • #2192 - Allow users to filter Timber default Twig functions by @nlemoine in https://github.com/timber/timber/pull/2408
    • 2.x Improve documentation for terms by @gchtr in https://github.com/timber/timber/pull/2379
    • Fix a test failing with 2.x + Multisite by @jarednova in https://github.com/timber/timber/pull/2485
    • Merge in 2.x GH Actions changes by @jarednova in https://github.com/timber/timber/pull/2484
    • 2.x Update Twig documentation by @gchtr in https://github.com/timber/timber/pull/2471
    • 2.x Deprecate Timber\PostClassMap filter and rename it to timber/post/classmap by @gchtr in https://github.com/timber/timber/pull/2293
    • 2.x Update timber/twig/… filters by @gchtr in https://github.com/timber/timber/pull/2419
    • Adds @nlemoine to the contribs list! by @jarednova in https://github.com/timber/timber/pull/2488
    • 2.x improve meta field handling by @nlemoine in https://github.com/timber/timber/pull/2397
    • 2.x Fix bug when page_on_front is not set in some cases by @gchtr in https://github.com/timber/timber/pull/2490
    • Update compatibility checks by @nlemoine in https://github.com/timber/timber/pull/2500
    • Use Timber full path by @nlemoine in https://github.com/timber/timber/pull/2497
    • Integrations API by @acobster in https://github.com/timber/timber/pull/2405
    • Fix transforms on file and image by @nlemoine in https://github.com/timber/timber/pull/2498
    • Update integration tests: by @nlemoine in https://github.com/timber/timber/pull/2503

    New Contributors

    • @AlexVWeb made their first contribution in https://github.com/timber/timber/pull/2465
    • @titouanmathis made their first contribution in https://github.com/timber/timber/pull/2463

    Full Changelog: https://github.com/timber/timber/compare/2.0.0-alpha.2...2.0.0-alpha.4

    Source code(tar.gz)
    Source code(zip)
  • 1.19.1(Oct 18, 2021)

    What's Changed

    • Fix bug when using switch_to_blog() in combination with Timber images by @gchtr in https://github.com/timber/timber/pull/2478
    • Fix the thumbnail() method return type by @titouanmathis in https://github.com/timber/timber/pull/2463
    • Merge in 2.x GH Actions changes by @jarednova in https://github.com/timber/timber/pull/2484
    • Adds @nlemoine to the contribs list! by @jarednova in https://github.com/timber/timber/pull/2488
    • Bump version of Upstatement/Routes to 0.8.1 by @jarednova in https://github.com/timber/timber/pull/2512

    New Contributors

    • @titouanmathis made their first contribution in https://github.com/timber/timber/pull/2463

    Full Changelog: https://github.com/timber/timber/compare/1.19.0...1.19.1

    Source code(tar.gz)
    Source code(zip)
  • 1.19.0(Sep 15, 2021)

    = 1.19.0 =

    Changes for Theme Developers

    • You can now get dimensions of SVG images #2421 #2432 (thanks @vyskoczilova)
    • You can pass additional variables to the timber/loader/loader filter #2324 (thanks @neojp)

    Fixes and improvements

    • Fix for double quotes that might appear in a "Read More" in Gutenberg #2337 #2343 (thanks @Keysaw)
    • Fix implementation of WP's get_the_date and get_the_time filters #2350 (thanks @shvlv)
    • Fix for how the wp:more tag works with noteaser #2348 #2351 (thanks @jhhazelaar)
    • Fix for two cases of where home_url() should be used instead of site_url() #2356 #2357 (thanks @Levdbas)
    • Fix for where Timber::get_sites returned the same locale for all sites #1908 #2369 (thanks @highbelt)
    • Use the latest release of Upstatement/Routes (0.5 => 0.8) #2373 (thanks @jverneaut)
    • Fix for sidebar retrieval in PHP 8 #2385 (thanks @marciojc)
    • Fix for proper ignoring of the Cache directory on case-insensitive file systems #342 #2416 (thanks @toonvandeputte)
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha.2(Apr 18, 2021)

    We've been at it pretty hard getting this ready for 2.0. There are just a few issues and PRs remaining before this will become the default branch. Here's a GitHub view to compare what's new in this alpha:

    https://github.com/timber/timber/compare/2.0.0-alpha.1...2.0.0-alpha.2

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha.1(Dec 9, 2020)

    This is the first version of the long awaited Timber version 2.0.0 that you can try out. It’s not stable yet. We still have some smaller tasks to finish and test it out.

    It’s a version 2, because there are quite a few breaking changes. Refer to the Upgrade Guide for more information.

    The overall goals of Timber 2.0 include:

    • Making Timber more consistent.
    • Making Timber easier to handle and extend.
    • Making Timber more compatible with plugins.

    High-level changes include:

    • A newer, streamlined Posts API.
    • Class Maps for a more loosely coupled way of creating Post, Term, User, Menu, MenuItem, and Comment objects.
    • No more direct instantiation of the classes mentioned above. Use Class Maps instead.
    • New PostCollectionInterface for a unified way to deal with various lists of posts.
    • An upgraded Context.
    • A big update for how fetching meta values works.

    We’re happy if you want to test it out. In case you find errors, please open an issue.

    Source code(tar.gz)
    Source code(zip)
  • 1.18.2(Oct 11, 2020)

  • 1.18.1(Aug 26, 2020)

    Fixes and improvements

    • Corrects an issue where #2305 tested for arrays but not other Iterables (like Timber\PostCollections) #2314 (thanks @nlemoine)
    Source code(tar.gz)
    Source code(zip)
  • 1.18.0(Aug 16, 2020)

    Changes for Theme Developers

    • Improves control over pagination stops #2302 (thanks @IJMacD)

    Fixes and improvements

    • Fixes an error with array_filter and later versions of Twig #2305
    Source code(tar.gz)
    Source code(zip)
  • 1.17.0(Jul 19, 2020)

    Changes for Theme Developers

    • Adds new filter: timber/allow_fs_write to ensure compatibility with WordPress VIP and other hosts with filewrite restrictions. #2250 (thanks @mjangda)

    Fixes and improvements

    • Add a catch so that {{ dump() }} when WP_DEBUG = FALSE doesn't cause a fatal error #2217, #2282
    • Performance improvement for the deletion of transients #2281 (thanks @opengeekv2)
    • Fix for "More" block issue with Gutenberg #2256
    Source code(tar.gz)
    Source code(zip)
  • 1.16.0(May 18, 2020)

    Changes for Theme Developers

    • Allows for translation of time_ago Twig filter #2214 #2215 (thanks @gchtr)

    Fixes and improvements

    • Fixed an issue where an excessive amount of DELETEs could hit the DB #1834 #2243 (thanks @chads2000 @dennisjac)
    • Fix an issue with blank user names #2232 (thanks @flip111)
    Source code(tar.gz)
    Source code(zip)
  • 1.15.2(Mar 24, 2020)

  • 1.15.1(Feb 27, 2020)

    Fixes and improvements

    • Fixed an issue where null results from PostGetter::get_posts could trigger a fatal error #2199 (thanks @jhhazelaar)
    • Removed a useless and confusing error_log message when a post_type isn't found in a class map #2202 (thanks @gchtr)
    • Fixed a documentation issue that gave phpStorm a bad time with query_post #2205 (thanks @mweimerskirch)
    Source code(tar.gz)
    Source code(zip)
  • 1.15.0(Feb 10, 2020)

    Fixes and improvements

    • Fixed an issue where a custom field named "content" could conflict with {{ post.content }}
    • Fixed an issue where Timber/User::$id was returned as a string instead of an integer (thanks @rubas)

    Changes for Theme Developers

    • Timber's data to Apache/Nginx error logs (via error_log()) is now prefixed with [ Timber ]
    Source code(tar.gz)
    Source code(zip)
  • 1.14.0(Jan 7, 2020)

    Fixes and improvements

    • {{ post.date }} and {{ post.time }} now use date_i18n under the hood instead of mysql2date #2104 #2126 (thanks @palmiak)
    • WordPress 4.9.8 is the new min supported version.

    Changes for Theme Developers

    • We're now using minimum versions of Twig 1.41 and 2.10

    The filter filter

    Twig introduced a filter filter (you read that right, a filter named filter — like {{ sizes | filter(v => v > 38) }}. This wrecked havoc on our own pre-existing Timber filter filter {{ posts | filter({post_title:"Cheese", post_content:"Yum!"}, "AND") }}.

    In #2124 we gave Twig's filter the preferred treatment. However, if the arguments look like you intend to use the old filter (which is a wrapper for WordPress's WP_List_Util class) we use what's there. Want to keep using the class Timber filter filter? Switch it to wp_list_filter as in {{ posts | wp_list_filter({post_title:"Cheese", post_content:"Yum!"}, "AND") }} (thanks @palmiak @gchtr @nlemoine @aj-adl @rubas @xdevelx and others)

    Source code(tar.gz)
    Source code(zip)
  • 1.13.0(Nov 19, 2019)

  • 1.12.1(Oct 20, 2019)

  • 1.12.0(Oct 18, 2019)

    Fixes and improvements

    • Fix resizing for images with UTF-8 characters in their filename #2072
    • Added tests to cover RTL languages and special characters in image file names #2072
    • Fixed MenuItem menu recursion #2071 #2083

    Changes for Theme Developers

    • Added new found_posts property for Timber\PostQuery. Now you can check how many posts were found in a query. #2074
    Source code(tar.gz)
    Source code(zip)
  • 1.11.0(Sep 14, 2019)

    General Note

    • If you use WPML with Timber, please upgrade to WPML 4.2.8. The WPML team has removed their included Twig version which means no more conflicts!

    Fixes and improvements

    • Fix to menu items getting incorrect classes in WPML and others #1974
    • Fixed issue with Timber not respecting comment order #1731 #2015

    Changes for Theme Developers

    • Theme methods (theme.get and theme.display) for headers are now exposed by Timber\Theme #2051 (thanks @dtvn)
    Source code(tar.gz)
    Source code(zip)
  • 1.10.1(Jun 17, 2019)

  • 1.10.0(Jun 10, 2019)

    Important Note If you use WPML, please do not upgrade to 1.10.* yet. Because WPML also uses Twig, there is a conflict with loading Twig versions. They will release an update soon to keep things in sync. Until then, please use version 1.9.2

    Fixes and improvements

    • You can now skip the eager loading of meta vars through a filter #2014 (thanks @aj-adl @gchtr)
    • Use Twig 1.38 to prevent compatibility issues with WPML and other plug-ins
    • This restores the prior behavior before #1813 / 1.9.3 when using Timber::get_posts. This is now controllable by devs
    • Add support for non-cookied comment awaiting moderation message #1954 (thanks @codeclarified)
    • Avoids a potential WSOD when incorrectly specifying template filenames #1984 (thanks @aj-adl)
    • Fixes a bug introduced in #1813 that was watching for the query param of supress_filters (instead of the correct spelling: suppress_filters)
    • Fixes a bug where the last menu item received incorrect CSS classes #2009 #1974 (thanks @strategio)

    Changes for Theme Developers

    • You can use WordPress's behavior of get_posts (versus WP_Query) via a filter. By default, Timber uses the behaviors of WP_Query in Timber's queries #1989 (thanks @palmiak)
    • If you run into problems with unknown Twig_SimpleFilter or unknown Twig_Filter classes, you can use Timber\Twig_Filter instead.
    • Fixed Timber::get_posts so that its default query parameters mirror WordPress's get_posts #1812 (thanks @bartvanraaij)
    • You can now more easily work with menu locations and filters #1959 #2018 (thanks @gchtr)
    Source code(tar.gz)
    Source code(zip)
  • 1.9.5(May 30, 2019)

    Fixes and improvements

    • Updated to most current version of Twig.
    • This restores the prior behavior before #1813 / 1.9.3 when using Timber::get_posts(). This is now controllable by devs.
    • Add support for non-cookied comment awaiting moderation message #1954 (thanks @codeclarified).
    • Avoids a potential WSOD when incorrectly specifying template filenames #1984 (thanks @aj-adl).

    Changes for Theme Developers

    • If you run into problems with unknown Twig_SimpleFilter or unknown Twig_Filter classes, you can use Timber\Twig_Filter instead #1963.
    • You can use WordPress's behavior of get_posts() (versus WP_Query) via a filter. By default, Timber uses the behaviors of WP_Query in Timber’s queries #1989 (thanks @palmiak).
    // Turn on WordPress’s behavior of get_posts when using Timber::get_posts()
    add_filter( 'timber/get_posts/mirror_wp_get_posts', '__return_true' );
    
    Source code(tar.gz)
    Source code(zip)
  • 1.9.4(Apr 1, 2019)

    Fixes a bug introduced in #1813 that was watching for the query param of supress_filters (instead of the correct spelling: suppress_filters)

    Source code(tar.gz)
    Source code(zip)
Provides Twig template IDE autocomplete of Craft CMS & plugin variables

Autocomplete for Craft CMS 3.x Provides Twig template IDE autocompletion for Craft CMS and plugin/module variables and element types. Works with PhpSt

nystudio107 35 Dec 21, 2022
A Simple and Lightweight WordPress Option Framework for Themes and Plugins

A Simple and Lightweight WordPress Option Framework for Themes and Plugins. Built in Object Oriented Programming paradigm with high number of custom fields and tons of options. Allows you to bring custom admin, metabox, taxonomy and customize settings to all of your pages, posts and categories. It's highly modern and advanced framework.

Codestar 241 Dec 23, 2022
Add subtitles into your WordPress posts, pages, custom post types, and themes. No coding required.

Add subtitles into your WordPress posts, pages, custom post types, and themes. No coding required. Simply activate Subtitles and you're ready to go.

We Cobble 117 Dec 31, 2022
Boilerplate used to build nearly-headless WordPress themes

Boilerplate for Nearly Headless WordPress Themes This is a plugin boilerplate built using Underpin ,Nicholas, and AlpineJS. It will allow you to build

Nicholas 103 Dec 22, 2022
Manage your photos with Piwigo, a full featured open source photo gallery application for the web. Star us on Github! More than 200 plugins and themes available. Join us and contribute!

Manage your photo library. Piwigo is open source photo gallery software for the web. Designed for organisations, teams and individuals. The piwigo.org

Piwigo 2.3k Jan 1, 2023
YesWiki is a wiki system written in PHP, including extensions making collaboration more simple (databases, maps, easy editing, bootstrap themes,...).

YesWiki YesWiki is a Free Software under the AGPL licence, made for creating and managing your website, in a collaborative way. YesWiki allows any web

YesWiki 84 Dec 26, 2022
Typecho Themes,bestgril

bestgirl Typecho Themes,bestgirl主题 主题简介 bestgirl主题是一款简约风格的响应式轻主题,基于鹅厂熊大的出租本人创意域名展示页。 此主题适合日志、轻言、诗词、语录、格言、名句、条目、菜谱、记事本、大事记、回忆录等各种轻简短文字类网站。 主题预览 链接:http

null 38 Nov 14, 2022
True Multisite, Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony

True Multisite, Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony

null 4 Oct 28, 2022
Provides autocompletion for Craft CMS and plugins in Twig templates.

Autocomplete for Craft CMS Provides autocompletion for Craft CMS and plugins in Twig templates. Currently works with PhpStorm only, as VSCode does not

PutYourLightsOn 12 Nov 23, 2021
Statamic 3 - the flat-first, Laravel + Git powered CMS designed for building beautiful, easy to manage websites

Statamic 3 - the flat-first, Laravel + Git powered CMS designed for building beautiful, easy to manage websites

Statamic 600 Jan 4, 2023
(Hard) Fork of WordPress Plugin Boilerplate, actively taking PRs and actively maintained. Following WordPress Coding Standards. With more features than the original.

Better WordPress Plugin Boilerplate This is a Hard Fork of the original WordPress Plugin Boilerplate. The Better WordPress Plugin Boilerplate actively

Beda Schmid 46 Dec 7, 2022
PressDoWiki - Fast & Light PHP Wiki Engine

PressDoWiki - Fast & Light PHP Wiki Engine 이 위키는 현재 제작 중입니다. Currently in development. the seed와 최대한 유사하게 구현하는 것을 목표로 하고 있는 PHP 위키 엔진입니다. 요구 사항 (Requi

PressDo 18 Nov 25, 2022
FlatPress is a lightweight, easy-to-set-up flat-file blogging engine.

[flatpress.org] [Support forum] [Wiki] [GitHub] [Mastodon] [Twitter] [Changelog] [Contributors] Welcome to FlatPress! FlatPress is a lightweight, easy

FlatPress 143 Dec 22, 2022
Batteries include Drupal project template with Redis and object storage for assets.

Mojo An opinionated Drupal build designed to run in a cloud native environment. This is a work in progress, see the TODO.md for initial tracking of it

Bluehorn Digital 12 Apr 4, 2022
A module allowing you to write your Processwire template using MJML and get a converted HTML output using MJML API.

PageMjmlToHtml A module allowing you to write your Processwire template using MJML and get a converted HTML output using MJML API. This is considered

Romain Cazier 7 Oct 5, 2022
Project template for starting a project based on the Rabble admin system.

Note: this is an experimental project and heavily under development. If you do come across this repository, and you would like to support development,

Rabble 12 Oct 26, 2022
Bismuth CMS is a ready-made Website CMS based on Yii 2 Advance Template

Bismuth CMS is a ready-made Website CMS based on Yii 2 Advance Template, it's the simplest and easy to set up CMS you may come across.

Hamadas Telebrain 1 Feb 11, 2022
A template package of package development for Concrete CMS Version 9.

A boilerplate to develop a package on Concrete CMS Version 9.

株式会社マカルーデジタル 11 Nov 27, 2022
Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. /// Chat with us and others on Spectrum: https://spectrum.chat/twill

About Twill Twill is an open source Laravel package that helps developers rapidly create a custom CMS that is beautiful, powerful, and flexible. By st

AREA 17 3k Jan 6, 2023