Download the PHP package rmp-up/wp-twig without Composer

On this page you can find all versions of the php package rmp-up/wp-twig. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-twig

WP Twig

WordPress with Twig on budget.

Before After
  • 404.php
  • search.php
  • single-cpt-foo.php
  • ...
  • 404.html.twig
  • search.html.twig
  • single-cpt-foo.html.twig
  • ...

Installation / Usage

Require via composer:

And add to your "functions.php" or elsewhere:

This function exists when composer's autoload.php is used. From now on WordPress uses ".php" and ".html.twig" templates.

Templating / How Twig works

See given files in this repo like the "index.html.twig" file:

So by default this page shows "Hello world". In other templates we can use the surrounding HTML but replace blocks:

Note: The path to the theme itself is also needed. This way it is possible to access files of other themes.

Using (WordPress-)Functions

Twig is extended in a way that any function can be used as a filter. This means functions like date_i18n('l, d.m.Y') or wp_list_pluck are available as filter and function:

But for the sake of segregation and performance, don't do get_posts('post_type=foo') within a template. Data, lists and other expensive things should be injected as follows.

Data- / Model-Layer

Injecting data via WP_Query

Since WordPress 1.5 you can inject data in templates using $wp_query->query_vars. The load_template function (and locate_template in some cases) extracts the data as variables and so does wp-twig:

This is how you may have injected data in templates until now and it is still available in Twig:

Injecting variables in the Twig-Context

It gives you four filter for injecting data:

  1. wp_twig_template_{type}_block_{name} (e.g. "wp_twig_template_404_block_foo")
  2. wp_twig_block_{name} (e.g. "wp_twig_block_foo")
  3. wp_twig_template_{type} (e.g. "wp_twig_template_index" or "wp_twig_template_search")
  4. wp_twig_context

Those are executed in the given order so you can basically add data to templates:

The order is important to bypass already added data on the more generic levels:

Bypassing the generation of data spares some time which results in a better performance of the theme. We suggest that you encapsulate data in a Generator of other lazy contructs to enhance this even more.


All versions of wp-twig with dependencies

PHP Build Version
Package Version
Requires twig/twig Version ~2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rmp-up/wp-twig contains the following files

Loading the files please wait ....