Ipstenu / varnish-http-purge

Proxy Cache Purge
Apache License 2.0
46 stars 48 forks source link

Admin bar 'Purge Cache (This Page)' URL uses filtered the_home_url #70

Closed jnweaver closed 6 years ago

jnweaver commented 6 years ago

Maybe there's another way around this but I don't see it.

I have a Wordpress instance running on two different domains: admin.my.domain and my.domain. Varnish sits in front of my.domain.

I use the the vhp_home_url to filter the_home_url() to my.domain.

However, because varnish_rightnow_adminbar() builds the Purge Cache (This Page) URL using home_url( $wp->request ) that URL ends up being admin.my.domain/$wp->request. This PR does a string replacement using $this->the_home_url(). If no vhp_home_url() is set, the result should be the same as calling home_url( $wp->request ). But if one is set, then the URL to clear the current page will be corrected to the filtered vhp_home_url.

Thanks for considering.

Ipstenu commented 6 years ago

Does changing

$page_url = esc_url( home_url( $wp->request ) );

to this work too for you?

$page_url = esc_url( $this->the_home_url() . $wp->request );

jnweaver commented 6 years ago

Yes, that's better. It does work. I've updated the PR.

I did have to adjust my vhp_home_url filter to pass the trailing slash but I maybe should have done that before anyway.