T
T
thehighhomie2018-03-15 19:15:25
Twig
thehighhomie, 2018-03-15 19:15:25

Wordpress & Timber (twig): admin side usage and usage doubts?

I’ve been working with Timber for 2 days now and I’m quite satisfied, I don’t want to write pages as before, but there are a few things:
1) I don’t quite understand how to use timber on the admin side, for example, display the template in some custom section. I did not find any docks for this case, so I myself came up with this option:
function.php, code for adding a field in the user profile

add_action( "show_user_profile", "add_worker_profile_section" );
add_action( "edit_user_profile", "add_worker_profile_section" );
add_action( 'user_new_form', 'add_worker_profile_section' );

function add_worker_profile_section( $user ) {
    $context['edit_user'] = new TimberUser( $user );
    Timber::render('admin.twig', $context);
}

admin.twig template code
<h1>{{ edit_user.name }}</h1>

<input type="text" name="city" value="{{ user.get_field('_city') }}" placeholder="Город">

So, I'm not sure if Timber::get_context() should be pulled to the context, since this is done on the front side, for example, in page.php. And in general, I doubt that this is at least a little bit correct code for the admin panel.
2) Performance. I have a project now that I'm going to redo from scratch, just to ensure better performance, the current project is slow + it's already difficult to maintain, since it's not webpack, not gulp, it's not there, and the whole front is written in static files. And I'm worried that the new project will become even slower than the old one because of the timber, ironically of course, but not cool at all, since some pages use several WP_Query cycles, and + to this, Timber's work ... in general, this fact too makes you doubt and does not allow you to start the project yet.
3) Plugins: I looked for Wordpress + Timber starter themes, everything seems to be fine, everything is clear, except for the moments in the starter template from Timber itself footer.php and in header.php . The fact is that these files can be deleted if you do not use any Woocommerce, as I understand they refer to these files, but I could not find such things in the docks themselves. The lack of information on the docks has brought me here, and I hope there are people with experience who have worked with Timber.
4) Versioning. I am no less worried that when the project is done and one fine day, the next WordPress update will appear, and if the client updates it and the version of the timber that is installed through composer does not work correctly with the new version of WordPress, then everything will fly.
In general, I first wanted to install a blade from laravel for the template engine, but for me the installation turned out to be very difficult, so I installed Timber + it is sharpened specifically for WP and has its own api for working with WP. I really liked it, but those moments that I described above do not allow me to calmly start doing the project.
I really hope for those who have worked with Timber and are experienced in WP development in their own right, that is, they are competent in this matter, tell me what to do?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question