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_action( 'get_footer'... in 3rd party plugin: the added action is not being called #2420
Comments
I'm not sure I understand your issue.
Do you mean that without calling
Do you mean the Timber Starter Theme? |
Yes, the added action from: add_action( 'get_footer', array( $this, 'styles' ), 100 ); in the 'grid' plugin does not run.
I would expect that the get_footer() was already called by Timber? I guess there will be more plugins that count on add_action( 'get_footer', ... ?
To make this work I had to add get_header(); and get_footer(); in the page.php A big thanks for responding to my question! |
The Timber starter theme does call it from base.twig, here. Is it possible you modified So, to answer your question, you typically won't call @jarednova @gchtr not sure where the best place in the 1.x would be to add this info, but in 2.x I think the Template Inheritance section of the Getting Started guide would make sense. |
Totally agree that this is not clear enough. It’s one of those things that easily get forgotten for us folks who have been using Timber for quite some time. Thanks for calling us out on that, @code-en-design! 👍
Yep, that’s one section where we can add it. It’s currently mentioned in the Functions Guide as an example. We can definitely improve that. I’ll leave this open so I can work on the proper documentation. |
Thanks @acobster, thats exactly what I did in my theme. Thanks also @gchtr , it's great to get detailed feedback! |
To chime in on this: Since I added the following snippets in my timber projects, I never ran into compatibility issues again. The do action hooks fixed some compat issues with the Rank Math SEO plugin for example. {# head.twig in the <head> #}
{% do action('get_header') %}
{{ function('wp_head') }} {# base.twig just before the closing body tag. #}
{% do action('get_footer') %}
{{ function('wp_footer') }} |
@timber/rangers , how have you solved this on a day to day basis? Because I would like to add this to the starter theme/docs. |
@Levdbas I never ran into a situation where I had to add the We also have the footer.php from the starter theme in our themes, but I doubt that this is actually ever used in our websites. I don’t know of any plugin that does this. We could possibly get rid of this and instead add this solution to the documentation somewhere. |
Gotcha, in my case, I never uses the footer.php solution in my 100+ timber projects :D So I think running those two hooks mimics that. I self-assigned this to add this to the docs. Btw, in starter we also have the header.php besides the footer.php. I never used that as well. Shall I create a PR implementing my suggested code and get rid of those two files? |
👍
Yes, I’d be all for that. From comments I have seen in various places, it’s not clear to everyone what these files do. So if we can have a simpler solution, let’s do that. |
In Grids plugin (https://justevolve.it/grids/) this:
add_action( 'get_footer', array( $this, 'styles' ), 100 );
did not work, the added footer action is not called by Timber
My temporary solution, I added:
get_footer();
on the end of the index.php and page.php, and added an empty footer.php
Expected behavior
add_action( 'get_footer', array( $this, 'styles' ), 100 ); in the Grid plugin should output some css in the (Timber) footer
Actual behavior
The css is not being rendered, because the added 'styles' action from the plugin is not being called
Steps to reproduce behavior
Install Grid and try a Timber Theme
What version of WordPress, PHP and Timber are you using?
WordPress 5.6, PHP 7.4.12, Timber 1.18.2
How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)
Installed with Composer
The text was updated successfully, but these errors were encountered: