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

Deprecate the pre_amp_render_post action (when AMP theme support is present) #1129

Closed
westonruter opened this issue May 7, 2018 · 2 comments
Labels
Milestone

Comments

@westonruter
Copy link
Member

In v0.7 we've added amp theme support where you can have the entire theme be served as AMP, not just the post templates. For example, you could have your blog index template be served as AMP now (see example site: https://ampdemo.xwp.io/). In that case, there is no $post_id to be passed as the arg for the pre_amp_render_post action. But you can see from the source that the pre_amp_render_post action actually runs at template_redirect (priority 10) anyway:

https://github.com/Automattic/amp-wp/blob/7439d2ab5eebd0ee071749a849fda946a2eff4be/amp.php#L326-L383

As such, we should deprecate the pre_amp_render_post action entirely in favor of themes and plugins doing:

add_action( 'template_redirect', function() {
    if ( is_amp_endpoint() ) {
        // ...
    }
}, 9 );

The pre_amp_render_post action should only emit a deprecation warning when amp theme support is present.

We could also consider adding a new action that gets triggered here instead, like pre_amp_render_template which does not pass any $post_id arg.

See #1125.

@westonruter westonruter added this to the v1.0 milestone May 7, 2018
@oscarssanchez
Copy link
Contributor

oscarssanchez commented May 11, 2018

Hi @westonruter,

Would _deprecated_hook() work for this? https://developer.wordpress.org/reference/functions/_deprecated_hook/

Since it's not intented to be used by plugin developers and a similar one ( _deprecated_function() ) was replaced in this commit #1141, i'm not sure if it would be fine to use it to output a warning.

Any comments are gladly appreciated.

@westonruter
Copy link
Member Author

@oscarssanchez hi, I think actually what you're looking for is do_action_deprecated(). That should do it.

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

No branches or pull requests

4 participants