Skip to content

Add new actions before and after loading the located template#2462

Closed
remyperona wants to merge 4 commits intoWordPress:trunkfrom
wp-media:54541
Closed

Add new actions before and after loading the located template#2462
remyperona wants to merge 4 commits intoWordPress:trunkfrom
wp-media:54541

Conversation

@remyperona
Copy link
Copy Markdown

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
Copy Markdown
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.

@martinkrcho
Copy link
Copy Markdown

@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.

Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
@remyperona
Copy link
Copy Markdown
Author

@martinkrcho Done!

Copy link
Copy Markdown
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
Copy Markdown
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.

@remyperona remyperona requested a review from johnbillion June 21, 2022 17:01
@johnbillion
Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants