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 new actions before and after loading the located template #2462

Closed
wants to merge 4 commits into from

Conversation

Tabrisrp
Copy link

This patch adds new actions before and after loading the located template in locate_template().

The template filename is passed as an additional parameter to the action, as that can be useful for callbacks on these hooks.

The hooks name and the @since value are suggestions, I couldn't find if there is a standard for hooks names in core, as there is some prefixed with wp_, and others that are not.

Trac ticket: https://core.trac.wordpress.org/ticket/54541


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a couple of minor notes inline, nothing to big.

I think @johnbillion wanted to review this too so maybe wait until you hear from John before taking any action. John's been around longer than me so may have additional advice.

src/wp-includes/template.php Outdated Show resolved Hide resolved
src/wp-includes/template.php Outdated Show resolved Hide resolved
@martinkrcho
Copy link

@Tabrisrp , would you be able to apply the changes suggested by @peterwilsoncc? Then we could get @johnbillion to review and I would be more than happy to contribute with some unit tests.

src/wp-includes/template.php Outdated Show resolved Hide resolved
src/wp-includes/template.php Outdated Show resolved Hide resolved
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
@Tabrisrp
Copy link
Author

Tabrisrp commented Jun 3, 2022

@martinkrcho Done!

src/wp-includes/template.php Outdated Show resolved Hide resolved
src/wp-includes/template.php Outdated Show resolved Hide resolved
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. This code looks good to me.

I think John has limited availability at the moment, so let's give him a week or two to add any thougths to this ticket.

Copy link
Member

@johnbillion johnbillion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good but it would be good to pass some additional contextual parameters to the actions. I think the $template_names, $require_once, and $args parameters are all potentially useful to these hooks, so let's pass them in please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants