Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation and plugin notice about the end of the plugin version #2800

Merged
merged 16 commits into from
Oct 17, 2023
Merged
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ By
[![WordPress Rating](https://img.shields.io/wordpress/plugin/r/timber-library.svg?style=flat-square)](https://wordpress.org/support/plugin/timber-library/reviews/)
[![!Financial Contributors](https://opencollective.com/timber/tiers/badge.svg)](https://opencollective.com/timber/)

> ⚠️ **Important information about the Timber plugin**
> With the upcoming release of Timber 2.0, we will stop releasing Timber as a plugin. We advise everyone to **[switch to the Composer based install of Timber 1 as a first step](https://timber.github.io/docs/getting-started/switch-to-composer/)** as soon as possible. If you need PHP 8.2 support you will have to switch to Timber 2.0.


Underneath this text you will find an extensive list with guides and the reasons why we are not going to release Timber 2 in plugin version anymore.
* Announcement: [Dropping support for the plugin version of Timber](https://github.com/timber/timber/discussions/2804)
* Guide: [How do I switch over from the plugin version to the Composer based version of Timber?](https://timber.github.io/docs/getting-started/switch-to-composer/)
* Backstory: [Why we are dropping support for the plugin in the first place](https://github.com/timber/timber/pull/2005)
* Github issue: [Roadmap for Timber 2.0](https://github.com/timber/timber/issues/2741)

### 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](https://twig.symfony.com/) separate from your PHP files.

Expand Down
16 changes: 12 additions & 4 deletions docs/getting-started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ menu:
---

## Installation
> ⚠️ **Important information about the Timber plugin**
> With the upcoming release of Timber 2.0, we will stop releasing Timber as a plugin. We advise everyone to **[switch to the Composer based install of Timber 1 as a first step](https://timber.github.io/docs/getting-started/switch-to-composer/)** as soon as possible. If you need PHP 8.2 support you will have to switch to Timber 2.0.

### Via WordPress.org (easy)
Underneath this text you will find an extensive list with guides and the reasons why we are not going to release Timber 2 in plugin version anymore.

You can grab the all-things-included plugin at [WordPress.org](http://wordpress.org/plugins/timber-library/) either through the WordPress site or through the Plugins menu in the backend. Then skip ahead to [using the starter theme](#use-the-starter-theme).
* Guide: [How do I switch over from the plugin version to the Composer based version of Timber?](https://timber.github.io/docs/getting-started/switch-to-composer/)
* Backstory: [Why are we dropping support for the plugin in the first place](https://github.com/timber/timber/pull/2005)
* Github issue: [Road to Timber 2.0](https://github.com/timber/timber/issues/2741)

### Via GitHub (for developers)
### ~~Via WordPress.org (easy)~~

The GitHub version of Timber requires [Composer](https://getcomposer.org/download/). If you'd prefer one-click installation, you should use the [WordPress.org](https://wordpress.org/plugins/timber-library/) version.
~~You can grab the all-things-included plugin at [WordPress.org](http://wordpress.org/plugins/timber-library/) either through the WordPress site or through the Plugins menu in the backend. Then skip ahead to [using the starter theme](#use-the-starter-theme).~~

### Via Composer (recommended)

The GitHub version of Timber requires [Composer](https://getcomposer.org/download/).

Run the following Composer command from within your theme's root directory:

Expand Down
76 changes: 76 additions & 0 deletions docs/getting-started/switch-to-composer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: "Switch to Composer"
description: "How to switch your plugin based Timber theme over to the Composer based version."
menu:
main:
parent: "getting-started"
---

With the upcoming release of Timber 2, we will stop releasing Timber as a plugin. We advise everyone to switch to the Composer based install of Timber 1 as soon as possible as a first step towards upgrading to Timber 2.

## Recommended upgrade path

1. Get a local development version of your website up and running.
2. Check if you are running the latest version of the Timber plugin. If not, update it and check if your website still runs as expected.

Levdbas marked this conversation as resolved.
Show resolved Hide resolved
4. Install the latest 1.x version of Timber via Composer
5. Load the Composer autoloader and initialize Timber
5. Load the composer autoloader and initialize Timber
Levdbas marked this conversation as resolved.
Show resolved Hide resolved
Levdbas marked this conversation as resolved.
Show resolved Hide resolved
6. Check if your website still runs as expected
7. Deploy your changes to your live website

We highly recommend doing these steps on a local development version of your website. If you don’t have one yet, you could use [Local by Flywheel](https://localbyflywheel.com/) to get one up and running in a few minutes.
Levdbas marked this conversation as resolved.
Show resolved Hide resolved

#### 1.1 How to install Composer
If you don’t have Composer installed yet, you can follow the [official installation guide](https://getcomposer.org/doc/00-intro.md).


### 2. Check if you are running the latest version of the Timber plugin
We want to make sure that you are running the latest version of the Timber plugin before we start the upgrade process. This way we can be sure that any issues that might occur are not caused by an outdated version of the plugin.

### 3. Disable the Timber plugin
Once you are sure that you are running the latest version of the Timber plugin, you can disable it. This will make sure that the plugin is not loaded anymore and does not interfere with the Composer based version of Timber.

Levdbas marked this conversation as resolved.
Show resolved Hide resolved
### 4. Install the latest 1.x version of Timber via Composer
Now that the plugin is disabled, you can install the latest 1.x version of Timber via Composer. You can do this by navigating to your site's active theme folder inside your terminal and then running the following command:

```shell
composer require timber/timber:^1.0
```

If Composer gives you the following notice:

```shell
composer/installers contains a Composer plugin [...] (writes "allow-plugins" to composer.json)
```
it is safe to answer `y` to this question and press enter.


### 5. Load the Composer autoloader and initialize Timber
Now that we have Timber installed via Composer, we need to load the Composer autoloader and initialize Timber. You can do this by adding the following code at the top of your **functions.php** file:

```php
/**
* If you are installing Timber as a Composer dependency in your theme, you'll need this block
Levdbas marked this conversation as resolved.
Show resolved Hide resolved
* to load your dependencies and initialize Timber.
Levdbas marked this conversation as resolved.
Show resolved Hide resolved
*/
$composer_autoload = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $composer_autoload ) ) {
require_once $composer_autoload;
$timber = new Timber\Timber();
}
```

### 6. Check if your website still runs as expected
Now that you have Timber installed via Composer, you can check if your website still runs as expected. If you run into any issues, please try to solve them yourself by activating [WordPress debugging](https://wordpress.org/documentation/article/debugging-in-wordpress/) and checking the error logs.

### 7. Deploy your changes to your live website
When you are 100% sure that you have successfully upgraded your theme in the development website to the Composer based version of Timber, you can deploy your theme changes to your live website.

Make sure that the new **vendor** folder inside your theme gets deployed as well. If you are using a deployment pipeline, you can commit your changes and push to your live website.

If you are not using a version control system, you can use FTP or SCP to upload your changes to your theme.

As a last step, you should disable and then remove the Timber v1 plugin from your live website.

Congrats - you successfully moved to the Composer-based install and are prepared to later [upgrade to Timber v2](https://timber.github.io/docs/v2/upgrade-guides/2.0/).
12 changes: 12 additions & 0 deletions lib/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ class Admin {

public static function init() {
$filter = add_filter('plugin_row_meta', array(__CLASS__, 'meta_links'), 10, 2);
$action = add_action('after_plugin_row_timber-library/timber.php', array(__CLASS__, 'show_deprecation_warning'), 10, 3);
Levdbas marked this conversation as resolved.
Show resolved Hide resolved
$action = add_action('in_plugin_update_message-timber-library/timber.php', array(__CLASS__, 'in_plugin_update_message'), 10, 2);
$action = add_action('in_plugin_update_message-timber/timber.php', array(__CLASS__, 'in_plugin_update_message'), 10, 2);
if ( $filter && $action ) {
return true;
}
}

/**
* show additional information about the plugin deprecation.
*
* @param string $file
* @param array $plugin
*/
public static function show_deprecation_warning($file, $plugin, $status)
{
echo '<td colspan="3" class="plugin-update colspanchange"><div class="update-message notice-error notice inline notice-warning notice-alt"><p>We recommend <a target="_blank" href="https://timber.github.io/docs/getting-started/switch-to-composer/">switching to the Composer based version</a> of Timber. <a href="https://github.com/timber/timber/discussions/2804" target="_blank">Why you need to switch.</a></p></div></td>';
}

/**
* @param array $links
* @param string $file
Expand Down
9 changes: 9 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
Helps you create themes faster with sustainable code. With Timber, you write HTML using Twig Templates http://www.upstatement.com/timber/

== Description ==
With the upcoming release of Timber 2.0, we will not release a 2.0 version and beyond as a plugin, but only as a Composer package. We advise everyone to switch to the Composer based install as soon as possible.
You will find an extensive list with guides and the reasons why we are not going to release Timber 2.0 as a plugin anymore.

### Switching to the Composer based version
* Announcement: [Dropping support for the plugin version of Timber](https://github.com/timber/timber/discussions/2804)
* Guide: [How do I switch over from the plugin version to the Composer based version of Timber?](https://timber.github.io/docs/getting-started/switch-to-composer/)
* Backstory: [Why are we dropping support for the plugin in the first place](https://github.com/timber/timber/pull/2005)
* GitHub issue: [Roadmap for Timber 2.0](https://github.com/timber/timber/issues/2741)

Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the [Twig Template Engine](http://twig.sensiolabs.org/) 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.

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