The tb proxy class

Estimated reading: 1 minute

Although Timber has almost every aspect about WP covered, there is still a small blind spot; sometimes you may still find yourself in the position that you need access to a PHP function. For instance from another plugin like ACF, Meta Box, The Event Calendar or Memberpress. Timber has a method for that, but it isn’t very user friendly.

So, to make it easier and more like the usage in PHP, we’ve added the tb proxy class, which can be used like this:

<h3>{{ post.title }}</h3>
<div class="admin-tools">{{ tb.edit_post_link( 'Edit' , '<span class="edit-link">' , '</span>' ) }}</div>

In this example we use a regular WP function to render an edit link in our Twig template. By typing ‘tb.‘ before a PHP function name we invoke the proxy class, which will try to execute the method.

Non existent methods

To prevent adverse behavior whenever a method is not found because it doesn’t exist, it returns silently.

Share this Doc

The tb proxy class

Or copy link

CONTENTS